@enigmatry/entry-components 15.0.0-preview.2 → 15.0.0-preview.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/common/README.md +19 -0
- package/common/common.module.d.ts +8 -0
- package/common/constants.d.ts +2 -0
- package/common/directives/index.d.ts +1 -0
- package/common/directives/scroll-to-invalid-control.directive.d.ts +18 -0
- package/common/public-api.d.ts +2 -0
- package/esm2020/common/common.module.mjs +27 -0
- package/esm2020/common/constants.mjs +3 -0
- package/esm2020/common/directives/index.mjs +2 -0
- package/esm2020/common/directives/scroll-to-invalid-control.directive.mjs +51 -0
- package/esm2020/common/public-api.mjs +3 -1
- package/fesm2015/enigmatry-entry-components-common.mjs +79 -2
- package/fesm2015/enigmatry-entry-components-common.mjs.map +1 -1
- package/fesm2020/enigmatry-entry-components-common.mjs +77 -2
- package/fesm2020/enigmatry-entry-components-common.mjs.map +1 -1
- package/package.json +1 -1
package/common/README.md
ADDED
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
# Entry common
|
|
2
|
+
|
|
3
|
+
EntryCommonModule includes a set of commonly used directives, pipes, services and utilities.
|
|
4
|
+
|
|
5
|
+
`import { EntryCommonModule } from '@enigmatry/entry-components/common';`
|
|
6
|
+
|
|
7
|
+
## Directives
|
|
8
|
+
|
|
9
|
+
### `ScrollToInvalidControlDirective`
|
|
10
|
+
|
|
11
|
+
Scrolls to first invalid form control when form is submitted.
|
|
12
|
+
|
|
13
|
+
Selector: `form[formGroup],form[ngForm]`
|
|
14
|
+
|
|
15
|
+
Directive is applied to reactive or template driven forms, no additional selectors are required. Directive will listen to form submit event and scroll to first invalid form control when form is invalid. For this to work, submit button should be enabled so users always get feedback of what is wrong.
|
|
16
|
+
|
|
17
|
+
## Pipes
|
|
18
|
+
|
|
19
|
+
## Services
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import * as i0 from "@angular/core";
|
|
2
|
+
import * as i1 from "@angular/common";
|
|
3
|
+
import * as i2 from "./directives/scroll-to-invalid-control.directive";
|
|
4
|
+
export declare class EntryCommonModule {
|
|
5
|
+
static ɵfac: i0.ɵɵFactoryDeclaration<EntryCommonModule, never>;
|
|
6
|
+
static ɵmod: i0.ɵɵNgModuleDeclaration<EntryCommonModule, never, [typeof i1.CommonModule, typeof i2.ScrollToInvalidControlDirective], [typeof i2.ScrollToInvalidControlDirective]>;
|
|
7
|
+
static ɵinj: i0.ɵɵInjectorDeclaration<EntryCommonModule>;
|
|
8
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './scroll-to-invalid-control.directive';
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { ElementRef, OnDestroy, OnInit } from '@angular/core';
|
|
2
|
+
import { ControlContainer } from '@angular/forms';
|
|
3
|
+
import * as i0 from "@angular/core";
|
|
4
|
+
/**
|
|
5
|
+
* Scroll to first invalid control when form is submitted.
|
|
6
|
+
* Directive is applied to 'form[formGroup],form[ngForm]' (reactive or template driven forms)
|
|
7
|
+
*/
|
|
8
|
+
export declare class ScrollToInvalidControlDirective implements OnInit, OnDestroy {
|
|
9
|
+
private form;
|
|
10
|
+
private elementRef;
|
|
11
|
+
private destroy$;
|
|
12
|
+
constructor(form: ControlContainer, elementRef: ElementRef<HTMLFormElement>);
|
|
13
|
+
ngOnInit(): void;
|
|
14
|
+
ngOnDestroy(): void;
|
|
15
|
+
private scrollToInvalidControl;
|
|
16
|
+
static ɵfac: i0.ɵɵFactoryDeclaration<ScrollToInvalidControlDirective, [{ self: true; }, null]>;
|
|
17
|
+
static ɵdir: i0.ɵɵDirectiveDeclaration<ScrollToInvalidControlDirective, "form[formGroup],form[ngForm]", never, {}, {}, never, never, true, never>;
|
|
18
|
+
}
|
package/common/public-api.d.ts
CHANGED
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { NgModule } from '@angular/core';
|
|
2
|
+
import { CommonModule } from '@angular/common';
|
|
3
|
+
/** Directives */
|
|
4
|
+
import { ScrollToInvalidControlDirective } from './directives/scroll-to-invalid-control.directive';
|
|
5
|
+
import * as i0 from "@angular/core";
|
|
6
|
+
const DIRECTIVES = [
|
|
7
|
+
ScrollToInvalidControlDirective
|
|
8
|
+
];
|
|
9
|
+
export class EntryCommonModule {
|
|
10
|
+
}
|
|
11
|
+
EntryCommonModule.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: EntryCommonModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule });
|
|
12
|
+
EntryCommonModule.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "14.0.0", version: "15.2.9", ngImport: i0, type: EntryCommonModule, imports: [CommonModule, ScrollToInvalidControlDirective], exports: [ScrollToInvalidControlDirective] });
|
|
13
|
+
EntryCommonModule.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: EntryCommonModule, imports: [CommonModule] });
|
|
14
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: EntryCommonModule, decorators: [{
|
|
15
|
+
type: NgModule,
|
|
16
|
+
args: [{
|
|
17
|
+
declarations: [],
|
|
18
|
+
imports: [
|
|
19
|
+
CommonModule,
|
|
20
|
+
...DIRECTIVES
|
|
21
|
+
],
|
|
22
|
+
exports: [
|
|
23
|
+
...DIRECTIVES
|
|
24
|
+
]
|
|
25
|
+
}]
|
|
26
|
+
}] });
|
|
27
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiY29tbW9uLm1vZHVsZS5qcyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uLy4uLy4uLy4uLy4uL2xpYnMvZW50cnktY29tcG9uZW50cy9jb21tb24vY29tbW9uLm1vZHVsZS50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiQUFBQSxPQUFPLEVBQUUsUUFBUSxFQUFFLE1BQU0sZUFBZSx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ICAgQ29tbW9uTW9kdWxlLFxyXG4gICAgLi4uRElSRUNUSVZFU1xyXG4gIF0sXHJcbiAgZXhwb3J0czogW1xyXG4gICAgLi4uRElSRUNUSVZFU1xyXG4gIF1cclxufSlcclxuZXhwb3J0IGNsYXNzIEVudHJ5Q29tbW9uTW9kdWxlIHtcclxufVxyXG4iXX0=
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
export const NG_VALID_CLASS = '.ng-valid';
|
|
2
|
+
export const NG_INVALID_CLASS = '.ng-invalid';
|
|
3
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiY29uc3RhbnRzLmpzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiLi4vLi4vLi4vLi4vLi4vbGlicy9lbnRyeS1jb21wb25lbnRzL2NvbW1vbi9jb25zdGFudHMudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IkFBQUEsTUFBTSxDQUFDLE1BQU0sY0FBYyxHQUFHLFdBQVcsQ0FBQztBQUMxQyxNQUFNLENBQUMsTUFBTSxnQkFBZ0IsR0FBRyxhQUFhLENBQUMiLCJzb3VyY2VzQ29udGVudCI6WyJleHBvcnQgY29uc3QgTkdfVkFMSURfQ0xBU1MgPSAnLm5nLXZhbGlkJztcclxuZXhwb3J0IGNvbnN0IE5HX0lOVkFMSURfQ0xBU1MgPSAnLm5nLWludmFsaWQnO1xyXG4iXX0=
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
export * from './scroll-to-invalid-control.directive';
|
|
2
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiaW5kZXguanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi8uLi8uLi8uLi8uLi8uLi9saWJzL2VudHJ5LWNvbXBvbmVudHMvY29tbW9uL2RpcmVjdGl2ZXMvaW5kZXgudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IkFBQUEsY0FBYyx1Q0FBdUMsQ0FBQyIsInNvdXJjZXNDb250ZW50IjpbImV4cG9ydCAqIGZyb20gJy4vc2Nyb2xsLXRvLWludmFsaWQtY29udHJvbC5kaXJlY3RpdmUnO1xyXG4iXX0=
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import { Directive, Self } from '@angular/core';
|
|
2
|
+
import { Subject, fromEvent } from 'rxjs';
|
|
3
|
+
import { takeUntil } from 'rxjs/operators';
|
|
4
|
+
import { NG_INVALID_CLASS } from '../constants';
|
|
5
|
+
import * as i0 from "@angular/core";
|
|
6
|
+
import * as i1 from "@angular/forms";
|
|
7
|
+
/**
|
|
8
|
+
* Scroll to first invalid control when form is submitted.
|
|
9
|
+
* Directive is applied to 'form[formGroup],form[ngForm]' (reactive or template driven forms)
|
|
10
|
+
*/
|
|
11
|
+
export class ScrollToInvalidControlDirective {
|
|
12
|
+
constructor(form, elementRef) {
|
|
13
|
+
this.form = form;
|
|
14
|
+
this.elementRef = elementRef;
|
|
15
|
+
this.destroy$ = new Subject();
|
|
16
|
+
}
|
|
17
|
+
ngOnInit() {
|
|
18
|
+
fromEvent(this.elementRef.nativeElement, 'submit')
|
|
19
|
+
.pipe(takeUntil(this.destroy$))
|
|
20
|
+
.subscribe(_ => {
|
|
21
|
+
if (this.form.invalid) {
|
|
22
|
+
this.scrollToInvalidControl();
|
|
23
|
+
}
|
|
24
|
+
});
|
|
25
|
+
}
|
|
26
|
+
ngOnDestroy() {
|
|
27
|
+
this.destroy$.next();
|
|
28
|
+
this.destroy$.complete();
|
|
29
|
+
}
|
|
30
|
+
scrollToInvalidControl() {
|
|
31
|
+
const firstInvalidControl = this.elementRef.nativeElement.querySelector(NG_INVALID_CLASS);
|
|
32
|
+
if (firstInvalidControl) {
|
|
33
|
+
firstInvalidControl.scrollIntoView({
|
|
34
|
+
behavior: 'smooth',
|
|
35
|
+
block: 'center' // vertical alignment
|
|
36
|
+
});
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
ScrollToInvalidControlDirective.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: ScrollToInvalidControlDirective, deps: [{ token: i1.ControlContainer, self: true }, { token: i0.ElementRef }], target: i0.ɵɵFactoryTarget.Directive });
|
|
41
|
+
ScrollToInvalidControlDirective.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "15.2.9", type: ScrollToInvalidControlDirective, isStandalone: true, selector: "form[formGroup],form[ngForm]", ngImport: i0 });
|
|
42
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: ScrollToInvalidControlDirective, decorators: [{
|
|
43
|
+
type: Directive,
|
|
44
|
+
args: [{
|
|
45
|
+
standalone: true,
|
|
46
|
+
selector: 'form[formGroup],form[ngForm]'
|
|
47
|
+
}]
|
|
48
|
+
}], ctorParameters: function () { return [{ type: i1.ControlContainer, decorators: [{
|
|
49
|
+
type: Self
|
|
50
|
+
}] }, { type: i0.ElementRef }]; } });
|
|
51
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoic2Nyb2xsLXRvLWludmFsaWQtY29udHJvbC5kaXJlY3RpdmUuanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi8uLi8uLi8uLi8uLi8uLi9saWJzL2VudHJ5LWNvbXBvbmVudHMvY29tbW9uL2RpcmVjdGl2ZXMvc2Nyb2xsLXRvLWludmFsaWQtY29udHJvbC5kaXJlY3RpdmUudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IkFBQUEsT0FBTyxFQUFFLFNBQVMsRUFBaUMsSUFBSSxFQUFFLE1BQU0sZUFBZSxDQUFDO0FBRS9FLE9BQU8sRUFBRSxPQUFPLEVBQUUsU0FBUyxFQUFFLE1BQU0sTUFBTSxDQUFDO0FBQzFDLE9BQU8sRUFBRSxTQUFTLEVBQUUsTUFBTSxn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XHJcbiAgICAgICAgYmxvY2s6ICdjZW50ZXInICAvLyB2ZXJ0aWNhbCBhbGlnbm1lbnRcclxuICAgICAgfSk7XHJcbiAgICB9XHJcbiAgfVxyXG59XHJcbiJdfQ==
|
|
@@ -1,2 +1,4 @@
|
|
|
1
|
+
export { EntryCommonModule } from './common.module';
|
|
1
2
|
export * from './utils';
|
|
2
|
-
|
|
3
|
+
export * from './directives';
|
|
4
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoicHVibGljLWFwaS5qcyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uLy4uLy4uLy4uLy4uL2xpYnMvZW50cnktY29tcG9uZW50cy9jb21tb24vcHVibGljLWFwaS50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiQUFBQSxPQUFPLEVBQUUsaUJBQWlCLEVBQUUsTUFBTSxpQkFBaUIsQ0FBQztBQUVwRCxjQUFjLFNBQVMsQ0FBQztBQUN4QixjQUFjLGNBQWMsQ0FBQyIsInNvdXJjZXNDb250ZW50IjpbImV4cG9ydCB7IEVudHJ5Q29tbW9uTW9kdWxlIH0gZnJvbSAnLi9jb21tb24ubW9kdWxlJztcblxuZXhwb3J0ICogZnJvbSAnLi91dGlscyc7XG5leHBvcnQgKiBmcm9tICcuL2RpcmVjdGl2ZXMnO1xuIl19
|
|
@@ -1,4 +1,81 @@
|
|
|
1
|
-
import
|
|
1
|
+
import * as i0 from '@angular/core';
|
|
2
|
+
import { Directive, Self, NgModule, InjectionToken } from '@angular/core';
|
|
3
|
+
import { CommonModule } from '@angular/common';
|
|
4
|
+
import { Subject, fromEvent } from 'rxjs';
|
|
5
|
+
import { takeUntil } from 'rxjs/operators';
|
|
6
|
+
import * as i1 from '@angular/forms';
|
|
7
|
+
|
|
8
|
+
const NG_VALID_CLASS = '.ng-valid';
|
|
9
|
+
const NG_INVALID_CLASS = '.ng-invalid';
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* Scroll to first invalid control when form is submitted.
|
|
13
|
+
* Directive is applied to 'form[formGroup],form[ngForm]' (reactive or template driven forms)
|
|
14
|
+
*/
|
|
15
|
+
class ScrollToInvalidControlDirective {
|
|
16
|
+
constructor(form, elementRef) {
|
|
17
|
+
this.form = form;
|
|
18
|
+
this.elementRef = elementRef;
|
|
19
|
+
this.destroy$ = new Subject();
|
|
20
|
+
}
|
|
21
|
+
ngOnInit() {
|
|
22
|
+
fromEvent(this.elementRef.nativeElement, 'submit')
|
|
23
|
+
.pipe(takeUntil(this.destroy$))
|
|
24
|
+
.subscribe(_ => {
|
|
25
|
+
if (this.form.invalid) {
|
|
26
|
+
this.scrollToInvalidControl();
|
|
27
|
+
}
|
|
28
|
+
});
|
|
29
|
+
}
|
|
30
|
+
ngOnDestroy() {
|
|
31
|
+
this.destroy$.next();
|
|
32
|
+
this.destroy$.complete();
|
|
33
|
+
}
|
|
34
|
+
scrollToInvalidControl() {
|
|
35
|
+
const firstInvalidControl = this.elementRef.nativeElement.querySelector(NG_INVALID_CLASS);
|
|
36
|
+
if (firstInvalidControl) {
|
|
37
|
+
firstInvalidControl.scrollIntoView({
|
|
38
|
+
behavior: 'smooth',
|
|
39
|
+
block: 'center' // vertical alignment
|
|
40
|
+
});
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
ScrollToInvalidControlDirective.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: ScrollToInvalidControlDirective, deps: [{ token: i1.ControlContainer, self: true }, { token: i0.ElementRef }], target: i0.ɵɵFactoryTarget.Directive });
|
|
45
|
+
ScrollToInvalidControlDirective.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "15.2.9", type: ScrollToInvalidControlDirective, isStandalone: true, selector: "form[formGroup],form[ngForm]", ngImport: i0 });
|
|
46
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: ScrollToInvalidControlDirective, decorators: [{
|
|
47
|
+
type: Directive,
|
|
48
|
+
args: [{
|
|
49
|
+
standalone: true,
|
|
50
|
+
selector: 'form[formGroup],form[ngForm]'
|
|
51
|
+
}]
|
|
52
|
+
}], ctorParameters: function () {
|
|
53
|
+
return [{ type: i1.ControlContainer, decorators: [{
|
|
54
|
+
type: Self
|
|
55
|
+
}] }, { type: i0.ElementRef }];
|
|
56
|
+
} });
|
|
57
|
+
|
|
58
|
+
const DIRECTIVES = [
|
|
59
|
+
ScrollToInvalidControlDirective
|
|
60
|
+
];
|
|
61
|
+
class EntryCommonModule {
|
|
62
|
+
}
|
|
63
|
+
EntryCommonModule.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: EntryCommonModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule });
|
|
64
|
+
EntryCommonModule.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "14.0.0", version: "15.2.9", ngImport: i0, type: EntryCommonModule, imports: [CommonModule, ScrollToInvalidControlDirective], exports: [ScrollToInvalidControlDirective] });
|
|
65
|
+
EntryCommonModule.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: EntryCommonModule, imports: [CommonModule] });
|
|
66
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: EntryCommonModule, decorators: [{
|
|
67
|
+
type: NgModule,
|
|
68
|
+
args: [{
|
|
69
|
+
declarations: [],
|
|
70
|
+
imports: [
|
|
71
|
+
CommonModule,
|
|
72
|
+
...DIRECTIVES
|
|
73
|
+
],
|
|
74
|
+
exports: [
|
|
75
|
+
...DIRECTIVES
|
|
76
|
+
]
|
|
77
|
+
}]
|
|
78
|
+
}] });
|
|
2
79
|
|
|
3
80
|
function createInjectionToken(defaultValue) {
|
|
4
81
|
return new InjectionToken(defaultValue.constructor.name, {
|
|
@@ -17,5 +94,5 @@ function provideConfig(token, factory) {
|
|
|
17
94
|
* Generated bundle index. Do not edit.
|
|
18
95
|
*/
|
|
19
96
|
|
|
20
|
-
export { createInjectionToken, provideConfig };
|
|
97
|
+
export { EntryCommonModule, ScrollToInvalidControlDirective, createInjectionToken, provideConfig };
|
|
21
98
|
//# sourceMappingURL=enigmatry-entry-components-common.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"enigmatry-entry-components-common.mjs","sources":["../../../../libs/entry-components/common/utils/provide-config.ts","../../../../libs/entry-components/common/enigmatry-entry-components-common.ts"],"sourcesContent":["import { InjectionToken, Provider } from '@angular/core';\r\n\r\nexport function createInjectionToken<T>(defaultValue: T): InjectionToken<T> {\r\n return new InjectionToken<T>(defaultValue.constructor.name,\r\n {\r\n providedIn: 'root',\r\n factory: () => defaultValue\r\n }\r\n );\r\n}\r\n\r\nexport function provideConfig<T>(token: InjectionToken<T>, factory: () => T): Provider {\r\n return {\r\n provide: token,\r\n useFactory: factory\r\n };\r\n}\r\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './public-api';\n"],"names":[],"mappings":";;
|
|
1
|
+
{"version":3,"file":"enigmatry-entry-components-common.mjs","sources":["../../../../libs/entry-components/common/constants.ts","../../../../libs/entry-components/common/directives/scroll-to-invalid-control.directive.ts","../../../../libs/entry-components/common/common.module.ts","../../../../libs/entry-components/common/utils/provide-config.ts","../../../../libs/entry-components/common/enigmatry-entry-components-common.ts"],"sourcesContent":["export const NG_VALID_CLASS = '.ng-valid';\r\nexport const NG_INVALID_CLASS = '.ng-invalid';\r\n","import { Directive, ElementRef, OnDestroy, OnInit, Self } from '@angular/core';\r\nimport { ControlContainer } from '@angular/forms';\r\nimport { Subject, fromEvent } from 'rxjs';\r\nimport { takeUntil } from 'rxjs/operators';\r\nimport { NG_INVALID_CLASS } from '../constants';\r\n\r\n/**\r\n * Scroll to first invalid control when form is submitted.\r\n * Directive is applied to 'form[formGroup],form[ngForm]' (reactive or template driven forms)\r\n */\r\n@Directive({\r\n standalone: true,\r\n selector: 'form[formGroup],form[ngForm]'\r\n})\r\nexport class ScrollToInvalidControlDirective implements OnInit, OnDestroy {\r\n\r\n private destroy$ = new Subject<void>();\r\n\r\n constructor(\r\n @Self() private form: ControlContainer,\r\n private elementRef: ElementRef<HTMLFormElement>) { }\r\n\r\n ngOnInit(): void {\r\n fromEvent(this.elementRef.nativeElement, 'submit')\r\n .pipe(takeUntil(this.destroy$))\r\n .subscribe(_ => {\r\n if (this.form.invalid) {\r\n this.scrollToInvalidControl();\r\n }\r\n });\r\n }\r\n\r\n ngOnDestroy(): void {\r\n this.destroy$.next();\r\n this.destroy$.complete();\r\n }\r\n\r\n private scrollToInvalidControl() {\r\n const firstInvalidControl: HTMLElement =\r\n this.elementRef.nativeElement.querySelector(NG_INVALID_CLASS);\r\n\r\n if (firstInvalidControl) {\r\n firstInvalidControl.scrollIntoView({\r\n behavior: 'smooth',\r\n block: 'center' // vertical alignment\r\n });\r\n }\r\n }\r\n}\r\n","import { NgModule } from '@angular/core';\r\nimport { CommonModule } from '@angular/common';\r\n\r\n/** Directives */\r\n\r\nimport { ScrollToInvalidControlDirective } from './directives/scroll-to-invalid-control.directive';\r\n\r\nconst DIRECTIVES = [\r\n ScrollToInvalidControlDirective\r\n];\r\n\r\n@NgModule({\r\n declarations: [\r\n ],\r\n imports: [\r\n CommonModule,\r\n ...DIRECTIVES\r\n ],\r\n exports: [\r\n ...DIRECTIVES\r\n ]\r\n})\r\nexport class EntryCommonModule {\r\n}\r\n","import { InjectionToken, Provider } from '@angular/core';\r\n\r\nexport function createInjectionToken<T>(defaultValue: T): InjectionToken<T> {\r\n return new InjectionToken<T>(defaultValue.constructor.name,\r\n {\r\n providedIn: 'root',\r\n factory: () => defaultValue\r\n }\r\n );\r\n}\r\n\r\nexport function provideConfig<T>(token: InjectionToken<T>, factory: () => T): Provider {\r\n return {\r\n provide: token,\r\n useFactory: factory\r\n };\r\n}\r\n","/**\n * Generated bund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AO,EAAE;AACP,wBAAA,GAAG,UAAU;AACd,qBAAA;iBACF,CAAA;;;ACnBK,SAAU,oBAAoB,CAAI,YAAe,EAAA;IACrD,OAAO,IAAI,cAAc,CAAI,YAAY,CAAC,WAAW,CAAC,IAAI,EACxD;AACE,QAAA,UAAU,EAAE,MAAM;AAClB,QAAA,OAAO,EAAE,MAAM,YAAY;AAC5B,KAAA,CACF,CAAC;AACJ,CAAC;AAEe,SAAA,aAAa,CAAI,KAAwB,EAAE,OAAgB,EAAA;IACzE,OAAO;AACL,QAAA,OAAO,EAAE,KAAK;AACd,QAAA,UAAU,EAAE,OAAO;KACpB,CAAC;AACJ;;AChBA;;AAEG;;;;"}
|
|
@@ -1,4 +1,79 @@
|
|
|
1
|
-
import
|
|
1
|
+
import * as i0 from '@angular/core';
|
|
2
|
+
import { Directive, Self, NgModule, InjectionToken } from '@angular/core';
|
|
3
|
+
import { CommonModule } from '@angular/common';
|
|
4
|
+
import { Subject, fromEvent } from 'rxjs';
|
|
5
|
+
import { takeUntil } from 'rxjs/operators';
|
|
6
|
+
import * as i1 from '@angular/forms';
|
|
7
|
+
|
|
8
|
+
const NG_VALID_CLASS = '.ng-valid';
|
|
9
|
+
const NG_INVALID_CLASS = '.ng-invalid';
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* Scroll to first invalid control when form is submitted.
|
|
13
|
+
* Directive is applied to 'form[formGroup],form[ngForm]' (reactive or template driven forms)
|
|
14
|
+
*/
|
|
15
|
+
class ScrollToInvalidControlDirective {
|
|
16
|
+
constructor(form, elementRef) {
|
|
17
|
+
this.form = form;
|
|
18
|
+
this.elementRef = elementRef;
|
|
19
|
+
this.destroy$ = new Subject();
|
|
20
|
+
}
|
|
21
|
+
ngOnInit() {
|
|
22
|
+
fromEvent(this.elementRef.nativeElement, 'submit')
|
|
23
|
+
.pipe(takeUntil(this.destroy$))
|
|
24
|
+
.subscribe(_ => {
|
|
25
|
+
if (this.form.invalid) {
|
|
26
|
+
this.scrollToInvalidControl();
|
|
27
|
+
}
|
|
28
|
+
});
|
|
29
|
+
}
|
|
30
|
+
ngOnDestroy() {
|
|
31
|
+
this.destroy$.next();
|
|
32
|
+
this.destroy$.complete();
|
|
33
|
+
}
|
|
34
|
+
scrollToInvalidControl() {
|
|
35
|
+
const firstInvalidControl = this.elementRef.nativeElement.querySelector(NG_INVALID_CLASS);
|
|
36
|
+
if (firstInvalidControl) {
|
|
37
|
+
firstInvalidControl.scrollIntoView({
|
|
38
|
+
behavior: 'smooth',
|
|
39
|
+
block: 'center' // vertical alignment
|
|
40
|
+
});
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
ScrollToInvalidControlDirective.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: ScrollToInvalidControlDirective, deps: [{ token: i1.ControlContainer, self: true }, { token: i0.ElementRef }], target: i0.ɵɵFactoryTarget.Directive });
|
|
45
|
+
ScrollToInvalidControlDirective.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "15.2.9", type: ScrollToInvalidControlDirective, isStandalone: true, selector: "form[formGroup],form[ngForm]", ngImport: i0 });
|
|
46
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: ScrollToInvalidControlDirective, decorators: [{
|
|
47
|
+
type: Directive,
|
|
48
|
+
args: [{
|
|
49
|
+
standalone: true,
|
|
50
|
+
selector: 'form[formGroup],form[ngForm]'
|
|
51
|
+
}]
|
|
52
|
+
}], ctorParameters: function () { return [{ type: i1.ControlContainer, decorators: [{
|
|
53
|
+
type: Self
|
|
54
|
+
}] }, { type: i0.ElementRef }]; } });
|
|
55
|
+
|
|
56
|
+
const DIRECTIVES = [
|
|
57
|
+
ScrollToInvalidControlDirective
|
|
58
|
+
];
|
|
59
|
+
class EntryCommonModule {
|
|
60
|
+
}
|
|
61
|
+
EntryCommonModule.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: EntryCommonModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule });
|
|
62
|
+
EntryCommonModule.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "14.0.0", version: "15.2.9", ngImport: i0, type: EntryCommonModule, imports: [CommonModule, ScrollToInvalidControlDirective], exports: [ScrollToInvalidControlDirective] });
|
|
63
|
+
EntryCommonModule.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: EntryCommonModule, imports: [CommonModule] });
|
|
64
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: EntryCommonModule, decorators: [{
|
|
65
|
+
type: NgModule,
|
|
66
|
+
args: [{
|
|
67
|
+
declarations: [],
|
|
68
|
+
imports: [
|
|
69
|
+
CommonModule,
|
|
70
|
+
...DIRECTIVES
|
|
71
|
+
],
|
|
72
|
+
exports: [
|
|
73
|
+
...DIRECTIVES
|
|
74
|
+
]
|
|
75
|
+
}]
|
|
76
|
+
}] });
|
|
2
77
|
|
|
3
78
|
function createInjectionToken(defaultValue) {
|
|
4
79
|
return new InjectionToken(defaultValue.constructor.name, {
|
|
@@ -17,5 +92,5 @@ function provideConfig(token, factory) {
|
|
|
17
92
|
* Generated bundle index. Do not edit.
|
|
18
93
|
*/
|
|
19
94
|
|
|
20
|
-
export { createInjectionToken, provideConfig };
|
|
95
|
+
export { EntryCommonModule, ScrollToInvalidControlDirective, createInjectionToken, provideConfig };
|
|
21
96
|
//# sourceMappingURL=enigmatry-entry-components-common.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"enigmatry-entry-components-common.mjs","sources":["../../../../libs/entry-components/common/utils/provide-config.ts","../../../../libs/entry-components/common/enigmatry-entry-components-common.ts"],"sourcesContent":["import { InjectionToken, Provider } from '@angular/core';\r\n\r\nexport function createInjectionToken<T>(defaultValue: T): InjectionToken<T> {\r\n return new InjectionToken<T>(defaultValue.constructor.name,\r\n {\r\n providedIn: 'root',\r\n factory: () => defaultValue\r\n }\r\n );\r\n}\r\n\r\nexport function provideConfig<T>(token: InjectionToken<T>, factory: () => T): Provider {\r\n return {\r\n provide: token,\r\n useFactory: factory\r\n };\r\n}\r\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './public-api';\n"],"names":[],"mappings":";;
|
|
1
|
+
{"version":3,"file":"enigmatry-entry-components-common.mjs","sources":["../../../../libs/entry-components/common/constants.ts","../../../../libs/entry-components/common/directives/scroll-to-invalid-control.directive.ts","../../../../libs/entry-components/common/common.module.ts","../../../../libs/entry-components/common/utils/provide-config.ts","../../../../libs/entry-components/common/enigmatry-entry-components-common.ts"],"sourcesContent":["export const NG_VALID_CLASS = '.ng-valid';\r\nexport const NG_INVALID_CLASS = '.ng-invalid';\r\n","import { Directive, ElementRef, OnDestroy, OnInit, Self } from '@angular/core';\r\nimport { ControlContainer } from '@angular/forms';\r\nimport { Subject, fromEvent } from 'rxjs';\r\nimport { takeUntil } from 'rxjs/operators';\r\nimport { NG_INVALID_CLASS } from '../constants';\r\n\r\n/**\r\n * Scroll to first invalid control when form is submitted.\r\n * Directive is applied to 'form[formGroup],form[ngForm]' (reactive or template driven forms)\r\n */\r\n@Directive({\r\n standalone: true,\r\n selector: 'form[formGroup],form[ngForm]'\r\n})\r\nexport class ScrollToInvalidControlDirective implements OnInit, OnDestroy {\r\n\r\n private destroy$ = new Subject<void>();\r\n\r\n constructor(\r\n @Self() private form: ControlContainer,\r\n private elementRef: ElementRef<HTMLFormElement>) { }\r\n\r\n ngOnInit(): void {\r\n fromEvent(this.elementRef.nativeElement, 'submit')\r\n .pipe(takeUntil(this.destroy$))\r\n .subscribe(_ => {\r\n if (this.form.invalid) {\r\n this.scrollToInvalidControl();\r\n }\r\n });\r\n }\r\n\r\n ngOnDestroy(): void {\r\n this.destroy$.next();\r\n this.destroy$.complete();\r\n }\r\n\r\n private scrollToInvalidControl() {\r\n const firstInvalidControl: HTMLElement =\r\n this.elementRef.nativeElement.querySelector(NG_INVALID_CLASS);\r\n\r\n if (firstInvalidControl) {\r\n firstInvalidControl.scrollIntoView({\r\n behavior: 'smooth',\r\n block: 'center' // vertical alignment\r\n });\r\n }\r\n }\r\n}\r\n","import { NgModule } from '@angular/core';\r\nimport { CommonModule } from '@angular/common';\r\n\r\n/** Directives */\r\n\r\nimport { ScrollToInvalidControlDirective } from './directives/scroll-to-invalid-control.directive';\r\n\r\nconst DIRECTIVES = [\r\n ScrollToInvalidControlDirective\r\n];\r\n\r\n@NgModule({\r\n declarations: [\r\n ],\r\n imports: [\r\n CommonModule,\r\n ...DIRECTIVES\r\n ],\r\n exports: [\r\n ...DIRECTIVES\r\n ]\r\n})\r\nexport class EntryCommonModule {\r\n}\r\n","import { InjectionToken, Provider } from '@angular/core';\r\n\r\nexport function createInjectionToken<T>(defaultValue: T): InjectionToken<T> {\r\n return new InjectionToken<T>(defaultValue.constructor.name,\r\n {\r\n providedIn: 'root',\r\n factory: () => defaultValue\r\n }\r\n );\r\n}\r\n\r\nexport function provideConfig<T>(token: InjectionToken<T>, factory: () => T): Provider {\r\n return {\r\n provide: token,\r\n useFactory: factory\r\n };\r\n}\r\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './public-api';\n"],"names":[],"mappings":";;;;;;;AAAO,MAAM,cAAc,GAAG,WAAW,CAAC;AACnC,MAAM,gBAAgB,GAAG,aAAa;;ACK7C;;;AAGG;MAKU,+BAA+B,CAAA;IAI1C,WACkB,CAAA,IAAsB,EAC9B,UAAuC,EAAA;QAD/B,IAAI,CAAA,IAAA,GAAJ,IAAI,CAAkB;QAC9B,IAAU,CAAA,UAAA,GAAV,UAAU,CAA6B;AAJzC,QAAA,IAAA,CAAA,QAAQ,GAAG,IAAI,OAAO,EAAQ,CAAC;KAIe;IAEtD,QAAQ,GAAA;QACN,SAAS,CAAC,IAAI,CAAC,UAAU,CAAC,aAAa,EAAE,QAAQ,CAAC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+1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@enigmatry/entry-components",
|
|
3
|
-
"version": "15.0.0-preview.
|
|
3
|
+
"version": "15.0.0-preview.3",
|
|
4
4
|
"author": "Enigmatry",
|
|
5
5
|
"description": "Enigmatry entry angular material components",
|
|
6
6
|
"homepage": "https://github.com/enigmatry/entry-angular-building-blocks/tree/master/libs/entry-components#readme",
|