@ng-vagabond-lab/ng-dsv 0.1.52 → 0.1.54
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/assets/global.scss +82 -0
- package/assets/style.scss +144 -0
- package/fesm2022/ng-vagabond-lab-ng-dsv-ds-form-signal.mjs +226 -0
- package/fesm2022/ng-vagabond-lab-ng-dsv-ds-form-signal.mjs.map +1 -0
- package/fesm2022/ng-vagabond-lab-ng-dsv-modules-auth.mjs +167 -0
- package/fesm2022/ng-vagabond-lab-ng-dsv-modules-auth.mjs.map +1 -0
- package/package.json +1 -1
- package/types/ng-vagabond-lab-ng-dsv-ds-form-signal.d.ts +105 -0
- package/types/ng-vagabond-lab-ng-dsv-modules-auth.d.ts +70 -0
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
html,
|
|
2
|
+
body {
|
|
3
|
+
padding: 0px !important;
|
|
4
|
+
margin: 0px !important;
|
|
5
|
+
width: 100% !important;
|
|
6
|
+
height: 100% !important;
|
|
7
|
+
font-family: Roboto, Helvetica, Arial, sans-serif;
|
|
8
|
+
font-size: 14px;
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
body {
|
|
12
|
+
overflow-x: hidden;
|
|
13
|
+
scrollbar-color: rgb(117, 117, 117) rgb(245, 245, 245);
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
body.dark {
|
|
17
|
+
scrollbar-color: rgb(169, 169, 169) rgb(56, 56, 56);
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
app-root {
|
|
21
|
+
height: 100%;
|
|
22
|
+
display: flex;
|
|
23
|
+
flex-direction: column;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
button {
|
|
27
|
+
cursor: pointer;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
p {
|
|
31
|
+
line-height: 1.5rem;
|
|
32
|
+
margin: 0;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
.flex,
|
|
36
|
+
.flex-column {
|
|
37
|
+
display: flex;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
.flex-column {
|
|
41
|
+
flex-direction: column;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
.gap10 {
|
|
45
|
+
gap: 10px;
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
.flex1 {
|
|
49
|
+
flex: 1;
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
.hidden {
|
|
53
|
+
display: none;
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
a {
|
|
57
|
+
text-decoration: none;
|
|
58
|
+
color: inherit;
|
|
59
|
+
font-weight: 500;
|
|
60
|
+
cursor: pointer;
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
h1 {
|
|
64
|
+
font-size: 1.5rem;
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
h2 {
|
|
68
|
+
font-size: 1.2rem;
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
form {
|
|
72
|
+
width: 100%;
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
|
|
76
|
+
.card-container .subtitle {
|
|
77
|
+
color: rgb(91, 90, 90);
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
.dark .card-container .subtitle {
|
|
81
|
+
color: rgba(255, 255, 255, 0.7);
|
|
82
|
+
}
|
|
@@ -0,0 +1,144 @@
|
|
|
1
|
+
.inherit {
|
|
2
|
+
background-color: inherit;
|
|
3
|
+
color: inherit;
|
|
4
|
+
}
|
|
5
|
+
|
|
6
|
+
.default {
|
|
7
|
+
background-color: var(--text);
|
|
8
|
+
color: var(--text-dark);
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
.primary {
|
|
12
|
+
background-color: var(--primary);
|
|
13
|
+
color: var(--text-dark);
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
.secondary {
|
|
17
|
+
background-color: var(--secondary);
|
|
18
|
+
color: var(--text-dark);
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
.success {
|
|
22
|
+
background-color: var(--success);
|
|
23
|
+
color: var(--text-dark);
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
.info {
|
|
27
|
+
background-color: var(--info);
|
|
28
|
+
color: var(--text-dark);
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
.warning {
|
|
32
|
+
background-color: var(--warning);
|
|
33
|
+
color: var(--text-dark);
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
.error {
|
|
37
|
+
background-color: var(--error);
|
|
38
|
+
color: var(--text-dark);
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
.text,
|
|
42
|
+
.outlined {
|
|
43
|
+
background-color: transparent;
|
|
44
|
+
box-shadow: none;
|
|
45
|
+
|
|
46
|
+
&.default {
|
|
47
|
+
color: var(--text);
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
&.primary {
|
|
51
|
+
color: var(--primary);
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
&.success {
|
|
55
|
+
color: var(--success);
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
&.info {
|
|
59
|
+
color: var(--info);
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
&.warning {
|
|
63
|
+
color: var(--warning);
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
&.error {
|
|
67
|
+
color: var(--error);
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
&.outlined.default {
|
|
71
|
+
border: 1px solid var(--text);
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
&.outlined.primary {
|
|
75
|
+
border: 1px solid var(--primary);
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
&.outlined.success {
|
|
79
|
+
border: 1px solid var(--success);
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
&.outlined.info {
|
|
83
|
+
border: 1px solid var(--info);
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
&.outlined.warning {
|
|
87
|
+
border: 1px solid var(--warning);
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
&.outlined.error {
|
|
91
|
+
border: 1px solid var(--error);
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
.dark {
|
|
96
|
+
|
|
97
|
+
.default {
|
|
98
|
+
background-color: var(--text-dark);
|
|
99
|
+
color: var(--text);
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
.inherit {
|
|
103
|
+
filter: hue-rotate(5deg);
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
.text,
|
|
107
|
+
.outlined {
|
|
108
|
+
.default {
|
|
109
|
+
color: var(--text-dark);
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
.outlined.default {
|
|
114
|
+
border: 1px solid var(--text-dark);
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
|
|
119
|
+
|
|
120
|
+
.small,
|
|
121
|
+
.small>i {
|
|
122
|
+
font-size: 1rem;
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
.medium,
|
|
126
|
+
.medium>i {
|
|
127
|
+
font-size: 1.25rem;
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
.large,
|
|
131
|
+
.large>i {
|
|
132
|
+
font-size: 1.5rem;
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
.fullwidth {
|
|
136
|
+
width: 100%;
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
dsv-tooltip>*:not(.dsv-tooltip) {
|
|
140
|
+
cursor: context-menu;
|
|
141
|
+
white-space: nowrap;
|
|
142
|
+
overflow: hidden;
|
|
143
|
+
text-overflow: ellipsis;
|
|
144
|
+
}
|
|
@@ -0,0 +1,226 @@
|
|
|
1
|
+
import * as i0 from '@angular/core';
|
|
2
|
+
import { input, signal, output, effect, Component, HostBinding, inject, computed } from '@angular/core';
|
|
3
|
+
import { FormField, submit, form } from '@angular/forms/signals';
|
|
4
|
+
import { TranslatePipe } from '@ngx-translate/core';
|
|
5
|
+
import { RouterLink } from '@angular/router';
|
|
6
|
+
import { isCallback } from '@ng-vagabond-lab/ng-dsv/base';
|
|
7
|
+
import { DsvButtonComponent } from '@ng-vagabond-lab/ng-dsv/ds/button';
|
|
8
|
+
import { ToastService } from '@ng-vagabond-lab/ng-dsv/ds/toast';
|
|
9
|
+
|
|
10
|
+
class FormSignalInputBase {
|
|
11
|
+
form = input.required(...(ngDevMode ? [{ debugName: "form" }] : /* istanbul ignore next */ []));
|
|
12
|
+
fieldName = input.required(...(ngDevMode ? [{ debugName: "fieldName" }] : /* istanbul ignore next */ []));
|
|
13
|
+
label = input(...(ngDevMode ? [undefined, { debugName: "label" }] : /* istanbul ignore next */ []));
|
|
14
|
+
withLabel = input(true, ...(ngDevMode ? [{ debugName: "withLabel" }] : /* istanbul ignore next */ []));
|
|
15
|
+
placeholder = input('', ...(ngDevMode ? [{ debugName: "placeholder" }] : /* istanbul ignore next */ []));
|
|
16
|
+
required = input(false, ...(ngDevMode ? [{ debugName: "required" }] : /* istanbul ignore next */ []));
|
|
17
|
+
debug = input(false, ...(ngDevMode ? [{ debugName: "debug" }] : /* istanbul ignore next */ []));
|
|
18
|
+
isError = signal(false, ...(ngDevMode ? [{ debugName: "isError" }] : /* istanbul ignore next */ []));
|
|
19
|
+
onSend = output();
|
|
20
|
+
callbackChange = output();
|
|
21
|
+
constructor() {
|
|
22
|
+
effect(() => {
|
|
23
|
+
this.isError.set(this.getSignal()?.().touched() && this.getSignal()?.().errors().length > 0);
|
|
24
|
+
});
|
|
25
|
+
}
|
|
26
|
+
isTouched() {
|
|
27
|
+
return this.getSignal()().touched();
|
|
28
|
+
}
|
|
29
|
+
getSignal() {
|
|
30
|
+
return this.form()?.[this.fieldName()];
|
|
31
|
+
}
|
|
32
|
+
doOnSend() {
|
|
33
|
+
this.getValue() && this.onSend.emit(this.getValue());
|
|
34
|
+
}
|
|
35
|
+
doChange() {
|
|
36
|
+
this.getValue() && this.callbackChange.emit(this.getValue());
|
|
37
|
+
}
|
|
38
|
+
getValue() {
|
|
39
|
+
const signal = this.getSignal();
|
|
40
|
+
if (signal) {
|
|
41
|
+
const value = signal().value();
|
|
42
|
+
this.debug() && console.log(signal, signal().errors(), value);
|
|
43
|
+
return value;
|
|
44
|
+
}
|
|
45
|
+
return "";
|
|
46
|
+
}
|
|
47
|
+
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.7", ngImport: i0, type: FormSignalInputBase, deps: [], target: i0.ɵɵFactoryTarget.Component });
|
|
48
|
+
static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.1.0", version: "21.2.7", type: FormSignalInputBase, isStandalone: true, selector: "ng-component", inputs: { form: { classPropertyName: "form", publicName: "form", isSignal: true, isRequired: true, transformFunction: null }, fieldName: { classPropertyName: "fieldName", publicName: "fieldName", isSignal: true, isRequired: true, transformFunction: null }, label: { classPropertyName: "label", publicName: "label", isSignal: true, isRequired: false, transformFunction: null }, withLabel: { classPropertyName: "withLabel", publicName: "withLabel", isSignal: true, isRequired: false, transformFunction: null }, placeholder: { classPropertyName: "placeholder", publicName: "placeholder", isSignal: true, isRequired: false, transformFunction: null }, required: { classPropertyName: "required", publicName: "required", isSignal: true, isRequired: false, transformFunction: null }, debug: { classPropertyName: "debug", publicName: "debug", isSignal: true, isRequired: false, transformFunction: null } }, outputs: { onSend: "onSend", callbackChange: "callbackChange" }, ngImport: i0, template: ``, isInline: true });
|
|
49
|
+
}
|
|
50
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.7", ngImport: i0, type: FormSignalInputBase, decorators: [{
|
|
51
|
+
type: Component,
|
|
52
|
+
args: [{
|
|
53
|
+
template: ``
|
|
54
|
+
}]
|
|
55
|
+
}], ctorParameters: () => [], propDecorators: { form: [{ type: i0.Input, args: [{ isSignal: true, alias: "form", required: true }] }], fieldName: [{ type: i0.Input, args: [{ isSignal: true, alias: "fieldName", required: true }] }], label: [{ type: i0.Input, args: [{ isSignal: true, alias: "label", required: false }] }], withLabel: [{ type: i0.Input, args: [{ isSignal: true, alias: "withLabel", required: false }] }], placeholder: [{ type: i0.Input, args: [{ isSignal: true, alias: "placeholder", required: false }] }], required: [{ type: i0.Input, args: [{ isSignal: true, alias: "required", required: false }] }], debug: [{ type: i0.Input, args: [{ isSignal: true, alias: "debug", required: false }] }], onSend: [{ type: i0.Output, args: ["onSend"] }], callbackChange: [{ type: i0.Output, args: ["callbackChange"] }] } });
|
|
56
|
+
|
|
57
|
+
class FormSignalLabelComponent {
|
|
58
|
+
label = input.required(...(ngDevMode ? [{ debugName: "label" }] : /* istanbul ignore next */ []));
|
|
59
|
+
name = input.required(...(ngDevMode ? [{ debugName: "name" }] : /* istanbul ignore next */ []));
|
|
60
|
+
signal = input.required(...(ngDevMode ? [{ debugName: "signal" }] : /* istanbul ignore next */ []));
|
|
61
|
+
show = input(true, ...(ngDevMode ? [{ debugName: "show" }] : /* istanbul ignore next */ []));
|
|
62
|
+
isRequired = signal(false, ...(ngDevMode ? [{ debugName: "isRequired" }] : /* istanbul ignore next */ []));
|
|
63
|
+
constructor() {
|
|
64
|
+
effect(() => {
|
|
65
|
+
this.isRequired.set(this.signal().required());
|
|
66
|
+
});
|
|
67
|
+
}
|
|
68
|
+
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.7", ngImport: i0, type: FormSignalLabelComponent, deps: [], target: i0.ɵɵFactoryTarget.Component });
|
|
69
|
+
static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "21.2.7", type: FormSignalLabelComponent, isStandalone: true, selector: "dsv-form-signal-label", inputs: { label: { classPropertyName: "label", publicName: "label", isSignal: true, isRequired: true, transformFunction: null }, name: { classPropertyName: "name", publicName: "name", isSignal: true, isRequired: true, transformFunction: null }, signal: { classPropertyName: "signal", publicName: "signal", isSignal: true, isRequired: true, transformFunction: null }, show: { classPropertyName: "show", publicName: "show", isSignal: true, isRequired: false, transformFunction: null } }, ngImport: i0, template: "@if (show()) {\n <label\n [for]=\"name()\"\n class=\"text\"\n [class.error]=\"signal().touched() && signal().errors().length! > 0\"\n >\n {{ label() }} {{ isRequired() ? \"*\" : \"\" }}\n </label>\n}\n", styles: [":host{margin-bottom:.5rem;display:flex;align-content:center;opacity:.65;-webkit-user-select:none;user-select:none}:host label{width:100%}\n"] });
|
|
70
|
+
}
|
|
71
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.7", ngImport: i0, type: FormSignalLabelComponent, decorators: [{
|
|
72
|
+
type: Component,
|
|
73
|
+
args: [{ selector: 'dsv-form-signal-label', template: "@if (show()) {\n <label\n [for]=\"name()\"\n class=\"text\"\n [class.error]=\"signal().touched() && signal().errors().length! > 0\"\n >\n {{ label() }} {{ isRequired() ? \"*\" : \"\" }}\n </label>\n}\n", styles: [":host{margin-bottom:.5rem;display:flex;align-content:center;opacity:.65;-webkit-user-select:none;user-select:none}:host label{width:100%}\n"] }]
|
|
74
|
+
}], ctorParameters: () => [], propDecorators: { label: [{ type: i0.Input, args: [{ isSignal: true, alias: "label", required: true }] }], name: [{ type: i0.Input, args: [{ isSignal: true, alias: "name", required: true }] }], signal: [{ type: i0.Input, args: [{ isSignal: true, alias: "signal", required: true }] }], show: [{ type: i0.Input, args: [{ isSignal: true, alias: "show", required: false }] }] } });
|
|
75
|
+
|
|
76
|
+
class FormSignalCheckboxComponent extends FormSignalInputBase {
|
|
77
|
+
getBooleanSignal() {
|
|
78
|
+
return this.form()?.[this.fieldName()];
|
|
79
|
+
}
|
|
80
|
+
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.7", ngImport: i0, type: FormSignalCheckboxComponent, deps: null, target: i0.ɵɵFactoryTarget.Component });
|
|
81
|
+
static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "21.2.7", type: FormSignalCheckboxComponent, isStandalone: true, selector: "dsv-form-signal-checkbox", usesInheritance: true, ngImport: i0, template: "<div>\n @if (getSignal()) {\n <dsv-form-signal-label\n [name]=\"fieldName()\"\n [label]=\"label() ?? fieldName()\"\n [signal]=\"getSignal()()\"\n [show]=\"withLabel()\"\n />\n <div>\n <input\n type=\"checkbox\"\n [id]=\"fieldName()\"\n class=\"form-control\"\n [class.error]=\"isError()\"\n [formField]=\"getBooleanSignal()\"\n (change)=\"doChange()\"\n />\n </div>\n }\n</div>\n", styles: [":host{width:100%}:host>div{display:flex;flex-direction:column;position:relative}:host>div .form-control{font-family:inherit;display:block;width:calc(100% - 20px);margin:0;padding:6px 6px 6px 10px;font-size:1rem;line-height:1.5;color:#495057;background-color:#fff;background-clip:padding-box;border:1px solid #ced4da;border-radius:5px;transition:border-color .15s ease-in-out,box-shadow .15s ease-in-out;outline-color:#0000004d}:host>div .form-control.icon{padding-left:25px}:host>div .form-control.error{border:1px solid var(--error)}:host>div .form-control:disabled{opacity:.6}:host>div i{position:absolute;z-index:1000;top:10px;left:7px}:host>div textarea{overflow:auto;scrollbar-width:thin;resize:vertical}:host>div textarea.form-control{height:auto;min-height:90px}::ng-deep .dark .form-control{color-scheme:dark;background-color:var(--background-dark)!important;color:var(--text-dark)!important}\n", ":host{display:flex;flex:1;width:100%}:host>div{align-items:center;flex-direction:row;flex:1}:host>div dsv-form-label,:host>div dsv-form-reactive-label,:host>div dsv-form-signal-label{flex:1}:host>div input{accent-color:var(--primary);width:20px!important;height:20px!important}\n"], dependencies: [{ kind: "directive", type: FormField, selector: "[formField]", inputs: ["formField"], exportAs: ["formField"] }, { kind: "component", type: FormSignalLabelComponent, selector: "dsv-form-signal-label", inputs: ["label", "name", "signal", "show"] }] });
|
|
82
|
+
}
|
|
83
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.7", ngImport: i0, type: FormSignalCheckboxComponent, decorators: [{
|
|
84
|
+
type: Component,
|
|
85
|
+
args: [{ selector: 'dsv-form-signal-checkbox', imports: [FormField, FormSignalLabelComponent], template: "<div>\n @if (getSignal()) {\n <dsv-form-signal-label\n [name]=\"fieldName()\"\n [label]=\"label() ?? fieldName()\"\n [signal]=\"getSignal()()\"\n [show]=\"withLabel()\"\n />\n <div>\n <input\n type=\"checkbox\"\n [id]=\"fieldName()\"\n class=\"form-control\"\n [class.error]=\"isError()\"\n [formField]=\"getBooleanSignal()\"\n (change)=\"doChange()\"\n />\n </div>\n }\n</div>\n", styles: [":host{width:100%}:host>div{display:flex;flex-direction:column;position:relative}:host>div .form-control{font-family:inherit;display:block;width:calc(100% - 20px);margin:0;padding:6px 6px 6px 10px;font-size:1rem;line-height:1.5;color:#495057;background-color:#fff;background-clip:padding-box;border:1px solid #ced4da;border-radius:5px;transition:border-color .15s ease-in-out,box-shadow .15s ease-in-out;outline-color:#0000004d}:host>div .form-control.icon{padding-left:25px}:host>div .form-control.error{border:1px solid var(--error)}:host>div .form-control:disabled{opacity:.6}:host>div i{position:absolute;z-index:1000;top:10px;left:7px}:host>div textarea{overflow:auto;scrollbar-width:thin;resize:vertical}:host>div textarea.form-control{height:auto;min-height:90px}::ng-deep .dark .form-control{color-scheme:dark;background-color:var(--background-dark)!important;color:var(--text-dark)!important}\n", ":host{display:flex;flex:1;width:100%}:host>div{align-items:center;flex-direction:row;flex:1}:host>div dsv-form-label,:host>div dsv-form-reactive-label,:host>div dsv-form-signal-label{flex:1}:host>div input{accent-color:var(--primary);width:20px!important;height:20px!important}\n"] }]
|
|
86
|
+
}] });
|
|
87
|
+
|
|
88
|
+
class FormSignalErrorComponent {
|
|
89
|
+
errors = input.required(...(ngDevMode ? [{ debugName: "errors" }] : /* istanbul ignore next */ []));
|
|
90
|
+
error = signal('', ...(ngDevMode ? [{ debugName: "error" }] : /* istanbul ignore next */ []));
|
|
91
|
+
get hostClasses() {
|
|
92
|
+
const classes = ['text', 'error'];
|
|
93
|
+
return classes.join(' ');
|
|
94
|
+
}
|
|
95
|
+
constructor() {
|
|
96
|
+
effect(() => {
|
|
97
|
+
let errorMessage = "";
|
|
98
|
+
this.errors().forEach(error => {
|
|
99
|
+
switch (error.kind) {
|
|
100
|
+
case "required":
|
|
101
|
+
errorMessage = "Le champ est obligatoire.";
|
|
102
|
+
break;
|
|
103
|
+
case "minLength":
|
|
104
|
+
errorMessage = "La taille minimum est de " + error['minLength'] + ".";
|
|
105
|
+
break;
|
|
106
|
+
case "maxLength":
|
|
107
|
+
errorMessage = "La taille maximum est de " + error['maxLength'] + ".";
|
|
108
|
+
break;
|
|
109
|
+
case "email":
|
|
110
|
+
errorMessage = "Le format n'est pas celui d'un email.";
|
|
111
|
+
break;
|
|
112
|
+
default:
|
|
113
|
+
errorMessage = error.message ?? "Erreur inconnue.";
|
|
114
|
+
break;
|
|
115
|
+
}
|
|
116
|
+
});
|
|
117
|
+
this.error.set(errorMessage);
|
|
118
|
+
});
|
|
119
|
+
}
|
|
120
|
+
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.7", ngImport: i0, type: FormSignalErrorComponent, deps: [], target: i0.ɵɵFactoryTarget.Component });
|
|
121
|
+
static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "21.2.7", type: FormSignalErrorComponent, isStandalone: true, selector: "dsv-signal-form-error", inputs: { errors: { classPropertyName: "errors", publicName: "errors", isSignal: true, isRequired: true, transformFunction: null } }, host: { properties: { "class": "this.hostClasses" } }, ngImport: i0, template: "@if (errors().length > 0) {\n @if (error() !== \"\") {\n <div>{{ error() | translate }}</div>\n }\n}\n", styles: [":host{margin:5px}\n"], dependencies: [{ kind: "pipe", type: TranslatePipe, name: "translate" }] });
|
|
122
|
+
}
|
|
123
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.7", ngImport: i0, type: FormSignalErrorComponent, decorators: [{
|
|
124
|
+
type: Component,
|
|
125
|
+
args: [{ selector: 'dsv-signal-form-error', imports: [TranslatePipe], template: "@if (errors().length > 0) {\n @if (error() !== \"\") {\n <div>{{ error() | translate }}</div>\n }\n}\n", styles: [":host{margin:5px}\n"] }]
|
|
126
|
+
}], ctorParameters: () => [], propDecorators: { errors: [{ type: i0.Input, args: [{ isSignal: true, alias: "errors", required: true }] }], hostClasses: [{
|
|
127
|
+
type: HostBinding,
|
|
128
|
+
args: ['class']
|
|
129
|
+
}] } });
|
|
130
|
+
|
|
131
|
+
class FormSignalComponent {
|
|
132
|
+
toastService = inject(ToastService);
|
|
133
|
+
form = input.required(...(ngDevMode ? [{ debugName: "form" }] : /* istanbul ignore next */ []));
|
|
134
|
+
urlBack = input(...(ngDevMode ? [undefined, { debugName: "urlBack" }] : /* istanbul ignore next */ []));
|
|
135
|
+
textValid = input('ENREGISTRER', ...(ngDevMode ? [{ debugName: "textValid" }] : /* istanbul ignore next */ []));
|
|
136
|
+
formValid = input('Formulaire envoyé !', ...(ngDevMode ? [{ debugName: "formValid" }] : /* istanbul ignore next */ []));
|
|
137
|
+
callbackBack = output();
|
|
138
|
+
callback = output();
|
|
139
|
+
isCallbackBack = computed(() => isCallback(this.callbackBack), ...(ngDevMode ? [{ debugName: "isCallbackBack" }] : /* istanbul ignore next */ []));
|
|
140
|
+
goBack() {
|
|
141
|
+
this.callbackBack.emit();
|
|
142
|
+
}
|
|
143
|
+
onSubmit(event) {
|
|
144
|
+
event.preventDefault();
|
|
145
|
+
submit(this.form(), async (form) => {
|
|
146
|
+
if (form().valid()) {
|
|
147
|
+
this.callback.emit(form().value());
|
|
148
|
+
this.toastService.showToast({
|
|
149
|
+
text: this.formValid(),
|
|
150
|
+
});
|
|
151
|
+
}
|
|
152
|
+
else {
|
|
153
|
+
this.toastService.showToast({
|
|
154
|
+
text: 'Erreur dans le formulaire !',
|
|
155
|
+
type: 'error',
|
|
156
|
+
});
|
|
157
|
+
}
|
|
158
|
+
});
|
|
159
|
+
}
|
|
160
|
+
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.7", ngImport: i0, type: FormSignalComponent, deps: [], target: i0.ɵɵFactoryTarget.Component });
|
|
161
|
+
static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "21.2.7", type: FormSignalComponent, isStandalone: true, selector: "app-form-signal", inputs: { form: { classPropertyName: "form", publicName: "form", isSignal: true, isRequired: true, transformFunction: null }, urlBack: { classPropertyName: "urlBack", publicName: "urlBack", isSignal: true, isRequired: false, transformFunction: null }, textValid: { classPropertyName: "textValid", publicName: "textValid", isSignal: true, isRequired: false, transformFunction: null }, formValid: { classPropertyName: "formValid", publicName: "formValid", isSignal: true, isRequired: false, transformFunction: null } }, outputs: { callbackBack: "callbackBack", callback: "callback" }, ngImport: i0, template: "<form (submit)=\"onSubmit($event)\" class=\"form-container\" novalidate>\n <div>\n <ng-content></ng-content>\n </div>\n <div class=\"form-buttons\">\n @if (urlBack()) {\n <dsv-button\n color=\"default\"\n variant=\"outlined\"\n [routerLink]=\"urlBack()\"\n [prevent]=\"false\"\n >{{ \"RETOUR\" | translate }}</dsv-button\n >\n }\n @if (isCallbackBack()) {\n <dsv-button color=\"default\" variant=\"outlined\" (callback)=\"goBack()\">{{\n \"RETOUR\" | translate\n }}</dsv-button>\n }\n @if (textValid() && textValid() !== \"\") {\n <dsv-button type=\"submit\" color=\"primary\">{{\n textValid()! | translate\n }}</dsv-button>\n }\n </div>\n</form>\n", styles: [":host{display:flex;width:100%;height:100%}:host form{flex-direction:column;display:flex;margin-top:0;unicode-bidi:isolate}:host form>div:nth-child(1){flex-direction:column;display:flex;gap:10px;overflow:auto;scrollbar-width:thin}:host .form-buttons{display:flex;justify-content:flex-end;gap:10px;padding-top:10px}\n"], dependencies: [{ kind: "component", type: DsvButtonComponent, selector: "dsv-button", inputs: ["libelle", "icon", "iconEnd", "disabled", "noHover", "type", "prevent"], outputs: ["callback"] }, { kind: "directive", type: RouterLink, selector: "[routerLink]", inputs: ["target", "queryParams", "fragment", "queryParamsHandling", "state", "info", "relativeTo", "preserveFragment", "skipLocationChange", "replaceUrl", "routerLink"] }, { kind: "pipe", type: TranslatePipe, name: "translate" }] });
|
|
162
|
+
}
|
|
163
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.7", ngImport: i0, type: FormSignalComponent, decorators: [{
|
|
164
|
+
type: Component,
|
|
165
|
+
args: [{ selector: 'app-form-signal', imports: [DsvButtonComponent, RouterLink, TranslatePipe], template: "<form (submit)=\"onSubmit($event)\" class=\"form-container\" novalidate>\n <div>\n <ng-content></ng-content>\n </div>\n <div class=\"form-buttons\">\n @if (urlBack()) {\n <dsv-button\n color=\"default\"\n variant=\"outlined\"\n [routerLink]=\"urlBack()\"\n [prevent]=\"false\"\n >{{ \"RETOUR\" | translate }}</dsv-button\n >\n }\n @if (isCallbackBack()) {\n <dsv-button color=\"default\" variant=\"outlined\" (callback)=\"goBack()\">{{\n \"RETOUR\" | translate\n }}</dsv-button>\n }\n @if (textValid() && textValid() !== \"\") {\n <dsv-button type=\"submit\" color=\"primary\">{{\n textValid()! | translate\n }}</dsv-button>\n }\n </div>\n</form>\n", styles: [":host{display:flex;width:100%;height:100%}:host form{flex-direction:column;display:flex;margin-top:0;unicode-bidi:isolate}:host form>div:nth-child(1){flex-direction:column;display:flex;gap:10px;overflow:auto;scrollbar-width:thin}:host .form-buttons{display:flex;justify-content:flex-end;gap:10px;padding-top:10px}\n"] }]
|
|
166
|
+
}], propDecorators: { form: [{ type: i0.Input, args: [{ isSignal: true, alias: "form", required: true }] }], urlBack: [{ type: i0.Input, args: [{ isSignal: true, alias: "urlBack", required: false }] }], textValid: [{ type: i0.Input, args: [{ isSignal: true, alias: "textValid", required: false }] }], formValid: [{ type: i0.Input, args: [{ isSignal: true, alias: "formValid", required: false }] }], callbackBack: [{ type: i0.Output, args: ["callbackBack"] }], callback: [{ type: i0.Output, args: ["callback"] }] } });
|
|
167
|
+
|
|
168
|
+
class FormSignalInputComponent extends FormSignalInputBase {
|
|
169
|
+
type = input('text', ...(ngDevMode ? [{ debugName: "type" }] : /* istanbul ignore next */ []));
|
|
170
|
+
icon = input(...(ngDevMode ? [undefined, { debugName: "icon" }] : /* istanbul ignore next */ []));
|
|
171
|
+
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.7", ngImport: i0, type: FormSignalInputComponent, deps: null, target: i0.ɵɵFactoryTarget.Component });
|
|
172
|
+
static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "21.2.7", type: FormSignalInputComponent, isStandalone: true, selector: "dsv-form-signal-input", inputs: { type: { classPropertyName: "type", publicName: "type", isSignal: true, isRequired: false, transformFunction: null }, icon: { classPropertyName: "icon", publicName: "icon", isSignal: true, isRequired: false, transformFunction: null } }, usesInheritance: true, ngImport: i0, template: "<div>\n @if (getSignal()) {\n @if (withLabel()) {\n <dsv-form-signal-label\n [name]=\"fieldName()\"\n [label]=\"label() ?? fieldName()\"\n [signal]=\"getSignal()()\"\n />\n }\n @if (type() === \"textarea\") {\n <textarea\n [id]=\"fieldName()\"\n [formField]=\"getSignal()\"\n [placeholder]=\"placeholder()\"\n class=\"form-control\"\n ></textarea>\n } @else {\n <input\n #input\n [type]=\"type()\"\n [id]=\"fieldName()\"\n class=\"form-control\"\n [class.error]=\"isError()\"\n [formField]=\"getSignal()\"\n [placeholder]=\"placeholder()\"\n [class.icon]=\"icon()\"\n (blur)=\"doOnSend()\"\n (keydown.enter)=\"doOnSend()\"\n />\n }\n @if (icon()) {\n <i [class]=\"icon()\"></i>\n }\n @if (isTouched()) {\n <dsv-signal-form-error [errors]=\"getSignal()().errors()\" />\n }\n }\n</div>\n", styles: [":host{width:100%}:host>div{display:flex;flex-direction:column;position:relative}:host>div .form-control{font-family:inherit;display:block;width:calc(100% - 20px);margin:0;padding:6px 6px 6px 10px;font-size:1rem;line-height:1.5;color:#495057;background-color:#fff;background-clip:padding-box;border:1px solid #ced4da;border-radius:5px;transition:border-color .15s ease-in-out,box-shadow .15s ease-in-out;outline-color:#0000004d}:host>div .form-control.icon{padding-left:25px}:host>div .form-control.error{border:1px solid var(--error)}:host>div .form-control:disabled{opacity:.6}:host>div i{position:absolute;z-index:1000;top:10px;left:7px}:host>div textarea{overflow:auto;scrollbar-width:thin;resize:vertical}:host>div textarea.form-control{height:auto;min-height:90px}::ng-deep .dark .form-control{color-scheme:dark;background-color:var(--background-dark)!important;color:var(--text-dark)!important}\n"], dependencies: [{ kind: "directive", type: FormField, selector: "[formField]", inputs: ["formField"], exportAs: ["formField"] }, { kind: "component", type: FormSignalLabelComponent, selector: "dsv-form-signal-label", inputs: ["label", "name", "signal", "show"] }, { kind: "component", type: FormSignalErrorComponent, selector: "dsv-signal-form-error", inputs: ["errors"] }] });
|
|
173
|
+
}
|
|
174
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.7", ngImport: i0, type: FormSignalInputComponent, decorators: [{
|
|
175
|
+
type: Component,
|
|
176
|
+
args: [{ selector: 'dsv-form-signal-input', imports: [
|
|
177
|
+
FormField,
|
|
178
|
+
FormSignalLabelComponent,
|
|
179
|
+
FormSignalErrorComponent
|
|
180
|
+
], template: "<div>\n @if (getSignal()) {\n @if (withLabel()) {\n <dsv-form-signal-label\n [name]=\"fieldName()\"\n [label]=\"label() ?? fieldName()\"\n [signal]=\"getSignal()()\"\n />\n }\n @if (type() === \"textarea\") {\n <textarea\n [id]=\"fieldName()\"\n [formField]=\"getSignal()\"\n [placeholder]=\"placeholder()\"\n class=\"form-control\"\n ></textarea>\n } @else {\n <input\n #input\n [type]=\"type()\"\n [id]=\"fieldName()\"\n class=\"form-control\"\n [class.error]=\"isError()\"\n [formField]=\"getSignal()\"\n [placeholder]=\"placeholder()\"\n [class.icon]=\"icon()\"\n (blur)=\"doOnSend()\"\n (keydown.enter)=\"doOnSend()\"\n />\n }\n @if (icon()) {\n <i [class]=\"icon()\"></i>\n }\n @if (isTouched()) {\n <dsv-signal-form-error [errors]=\"getSignal()().errors()\" />\n }\n }\n</div>\n", styles: [":host{width:100%}:host>div{display:flex;flex-direction:column;position:relative}:host>div .form-control{font-family:inherit;display:block;width:calc(100% - 20px);margin:0;padding:6px 6px 6px 10px;font-size:1rem;line-height:1.5;color:#495057;background-color:#fff;background-clip:padding-box;border:1px solid #ced4da;border-radius:5px;transition:border-color .15s ease-in-out,box-shadow .15s ease-in-out;outline-color:#0000004d}:host>div .form-control.icon{padding-left:25px}:host>div .form-control.error{border:1px solid var(--error)}:host>div .form-control:disabled{opacity:.6}:host>div i{position:absolute;z-index:1000;top:10px;left:7px}:host>div textarea{overflow:auto;scrollbar-width:thin;resize:vertical}:host>div textarea.form-control{height:auto;min-height:90px}::ng-deep .dark .form-control{color-scheme:dark;background-color:var(--background-dark)!important;color:var(--text-dark)!important}\n"] }]
|
|
181
|
+
}], propDecorators: { type: [{ type: i0.Input, args: [{ isSignal: true, alias: "type", required: false }] }], icon: [{ type: i0.Input, args: [{ isSignal: true, alias: "icon", required: false }] }] } });
|
|
182
|
+
|
|
183
|
+
class BaseFormSignalComponent {
|
|
184
|
+
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.7", ngImport: i0, type: BaseFormSignalComponent, deps: [], target: i0.ɵɵFactoryTarget.Component });
|
|
185
|
+
static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "21.2.7", type: BaseFormSignalComponent, isStandalone: true, selector: "ng-component", ngImport: i0, template: '', isInline: true });
|
|
186
|
+
}
|
|
187
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.7", ngImport: i0, type: BaseFormSignalComponent, decorators: [{
|
|
188
|
+
type: Component,
|
|
189
|
+
args: [{
|
|
190
|
+
template: '',
|
|
191
|
+
}]
|
|
192
|
+
}] });
|
|
193
|
+
|
|
194
|
+
class FormSignalSearchbarComponent extends BaseFormSignalComponent {
|
|
195
|
+
search = input('', ...(ngDevMode ? [{ debugName: "search" }] : /* istanbul ignore next */ []));
|
|
196
|
+
onSearch = output();
|
|
197
|
+
form = form(signal({ search: this.search() }));
|
|
198
|
+
onSend(value) {
|
|
199
|
+
this.onSearch.emit(value);
|
|
200
|
+
}
|
|
201
|
+
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.7", ngImport: i0, type: FormSignalSearchbarComponent, deps: null, target: i0.ɵɵFactoryTarget.Component });
|
|
202
|
+
static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.1.0", version: "21.2.7", type: FormSignalSearchbarComponent, isStandalone: true, selector: "form-signal-searchbar", inputs: { search: { classPropertyName: "search", publicName: "search", isSignal: true, isRequired: false, transformFunction: null } }, outputs: { onSearch: "onSearch" }, usesInheritance: true, ngImport: i0, template: "<app-form-signal [form]=\"form\" textValid=\"\">\n <dsv-form-signal-input\n [form]=\"form\"\n fieldName=\"search\"\n type=\"search\"\n [withLabel]=\"false\"\n (onSend)=\"onSend($event)\"\n icon=\"icon ri-search-line\"\n ></dsv-form-signal-input>\n</app-form-signal>\n", styles: [":host{display:flex;margin:5px}::ng-deep form-searchbar input{width:100%!important;overflow:hidden!important}\n"], dependencies: [{ kind: "component", type: FormSignalComponent, selector: "app-form-signal", inputs: ["form", "urlBack", "textValid", "formValid"], outputs: ["callbackBack", "callback"] }, { kind: "component", type: FormSignalInputComponent, selector: "dsv-form-signal-input", inputs: ["type", "icon"] }] });
|
|
203
|
+
}
|
|
204
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.7", ngImport: i0, type: FormSignalSearchbarComponent, decorators: [{
|
|
205
|
+
type: Component,
|
|
206
|
+
args: [{ selector: 'form-signal-searchbar', imports: [FormSignalComponent, FormSignalInputComponent], template: "<app-form-signal [form]=\"form\" textValid=\"\">\n <dsv-form-signal-input\n [form]=\"form\"\n fieldName=\"search\"\n type=\"search\"\n [withLabel]=\"false\"\n (onSend)=\"onSend($event)\"\n icon=\"icon ri-search-line\"\n ></dsv-form-signal-input>\n</app-form-signal>\n", styles: [":host{display:flex;margin:5px}::ng-deep form-searchbar input{width:100%!important;overflow:hidden!important}\n"] }]
|
|
207
|
+
}], propDecorators: { search: [{ type: i0.Input, args: [{ isSignal: true, alias: "search", required: false }] }], onSearch: [{ type: i0.Output, args: ["onSearch"] }] } });
|
|
208
|
+
|
|
209
|
+
class FormSignalSelectComponent extends FormSignalInputBase {
|
|
210
|
+
list = input([], ...(ngDevMode ? [{ debugName: "list" }] : /* istanbul ignore next */ []));
|
|
211
|
+
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.7", ngImport: i0, type: FormSignalSelectComponent, deps: null, target: i0.ɵɵFactoryTarget.Component });
|
|
212
|
+
static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "21.2.7", type: FormSignalSelectComponent, isStandalone: true, selector: "dsv-form-signal-select", inputs: { list: { classPropertyName: "list", publicName: "list", isSignal: true, isRequired: false, transformFunction: null } }, usesInheritance: true, ngImport: i0, template: "<div>\n @if (getSignal()) {\n <dsv-form-signal-label\n [name]=\"fieldName()\"\n [label]=\"label() ?? fieldName()\"\n [signal]=\"getSignal()()\"\n [show]=\"withLabel()\"\n />\n <div>\n <select\n [id]=\"fieldName()\"\n [formField]=\"getSignal()\"\n class=\"form-control\"\n (change)=\"doChange()\"\n [class.error]=\"isError()\"\n >\n @for (list of list(); track list.id) {\n <option\n [value]=\"list.id\"\n [selected]=\"\n list.id?.toString() === getSignal()().value().toString()\n \"\n >\n {{ list.name }}\n </option>\n }\n </select>\n @if (isTouched()) {\n <dsv-signal-form-error [errors]=\"getSignal()().errors()\" />\n }\n </div>\n }\n</div>\n", styles: [":host{width:100%}:host>div{display:flex;flex-direction:column;position:relative}:host>div .form-control{font-family:inherit;display:block;width:calc(100% - 20px);margin:0;padding:6px 6px 6px 10px;font-size:1rem;line-height:1.5;color:#495057;background-color:#fff;background-clip:padding-box;border:1px solid #ced4da;border-radius:5px;transition:border-color .15s ease-in-out,box-shadow .15s ease-in-out;outline-color:#0000004d}:host>div .form-control.icon{padding-left:25px}:host>div .form-control.error{border:1px solid var(--error)}:host>div .form-control:disabled{opacity:.6}:host>div i{position:absolute;z-index:1000;top:10px;left:7px}:host>div textarea{overflow:auto;scrollbar-width:thin;resize:vertical}:host>div textarea.form-control{height:auto;min-height:90px}::ng-deep .dark .form-control{color-scheme:dark;background-color:var(--background-dark)!important;color:var(--text-dark)!important}\n", ":host{width:100%}:host>div .form-control{width:calc(100% - 2px)}\n"], dependencies: [{ kind: "directive", type: FormField, selector: "[formField]", inputs: ["formField"], exportAs: ["formField"] }, { kind: "component", type: FormSignalLabelComponent, selector: "dsv-form-signal-label", inputs: ["label", "name", "signal", "show"] }, { kind: "component", type: FormSignalErrorComponent, selector: "dsv-signal-form-error", inputs: ["errors"] }] });
|
|
213
|
+
}
|
|
214
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.7", ngImport: i0, type: FormSignalSelectComponent, decorators: [{
|
|
215
|
+
type: Component,
|
|
216
|
+
args: [{ selector: 'dsv-form-signal-select', imports: [FormField, FormSignalLabelComponent, FormSignalErrorComponent], template: "<div>\n @if (getSignal()) {\n <dsv-form-signal-label\n [name]=\"fieldName()\"\n [label]=\"label() ?? fieldName()\"\n [signal]=\"getSignal()()\"\n [show]=\"withLabel()\"\n />\n <div>\n <select\n [id]=\"fieldName()\"\n [formField]=\"getSignal()\"\n class=\"form-control\"\n (change)=\"doChange()\"\n [class.error]=\"isError()\"\n >\n @for (list of list(); track list.id) {\n <option\n [value]=\"list.id\"\n [selected]=\"\n list.id?.toString() === getSignal()().value().toString()\n \"\n >\n {{ list.name }}\n </option>\n }\n </select>\n @if (isTouched()) {\n <dsv-signal-form-error [errors]=\"getSignal()().errors()\" />\n }\n </div>\n }\n</div>\n", styles: [":host{width:100%}:host>div{display:flex;flex-direction:column;position:relative}:host>div .form-control{font-family:inherit;display:block;width:calc(100% - 20px);margin:0;padding:6px 6px 6px 10px;font-size:1rem;line-height:1.5;color:#495057;background-color:#fff;background-clip:padding-box;border:1px solid #ced4da;border-radius:5px;transition:border-color .15s ease-in-out,box-shadow .15s ease-in-out;outline-color:#0000004d}:host>div .form-control.icon{padding-left:25px}:host>div .form-control.error{border:1px solid var(--error)}:host>div .form-control:disabled{opacity:.6}:host>div i{position:absolute;z-index:1000;top:10px;left:7px}:host>div textarea{overflow:auto;scrollbar-width:thin;resize:vertical}:host>div textarea.form-control{height:auto;min-height:90px}::ng-deep .dark .form-control{color-scheme:dark;background-color:var(--background-dark)!important;color:var(--text-dark)!important}\n", ":host{width:100%}:host>div .form-control{width:calc(100% - 2px)}\n"] }]
|
|
217
|
+
}], propDecorators: { list: [{ type: i0.Input, args: [{ isSignal: true, alias: "list", required: false }] }] } });
|
|
218
|
+
|
|
219
|
+
const requiredTrim = (value) => value.value().trim() != "" ? null : { kind: 'required' };
|
|
220
|
+
|
|
221
|
+
/**
|
|
222
|
+
* Generated bundle index. Do not edit.
|
|
223
|
+
*/
|
|
224
|
+
|
|
225
|
+
export { FormSignalCheckboxComponent, FormSignalComponent, FormSignalErrorComponent, FormSignalInputBase, FormSignalInputComponent, FormSignalLabelComponent, FormSignalSearchbarComponent, FormSignalSelectComponent, requiredTrim };
|
|
226
|
+
//# sourceMappingURL=ng-vagabond-lab-ng-dsv-ds-form-signal.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ng-vagabond-lab-ng-dsv-ds-form-signal.mjs","sources":["../../../projects/ng-dsv/ds/form/signal/base/form.signal.input.base.ts","../../../projects/ng-dsv/ds/form/signal/label/component/form.signal.label.component.ts","../../../projects/ng-dsv/ds/form/signal/label/component/form.signal.label.component.html","../../../projects/ng-dsv/ds/form/signal/checkbox/component/form.signal.checkbox.component.ts","../../../projects/ng-dsv/ds/form/signal/checkbox/component/form.signal.checkbox.component.html","../../../projects/ng-dsv/ds/form/signal/error/component/form.signal.error.component.ts","../../../projects/ng-dsv/ds/form/signal/error/component/form.signal.error.component.html","../../../projects/ng-dsv/ds/form/signal/form/component/form.signal.component.ts","../../../projects/ng-dsv/ds/form/signal/form/component/form.signal.component.html","../../../projects/ng-dsv/ds/form/signal/input/component/form.signal.input.component.ts","../../../projects/ng-dsv/ds/form/signal/input/component/form.signal.input.component.html","../../../projects/ng-dsv/ds/form/signal/form/base/base.form.signal.component.ts","../../../projects/ng-dsv/ds/form/signal/searchbar/component/form.signal.searchbar.component.ts","../../../projects/ng-dsv/ds/form/signal/searchbar/component/form.signal.searchbar.component.html","../../../projects/ng-dsv/ds/form/signal/select/component/form.signal.select.component.ts","../../../projects/ng-dsv/ds/form/signal/select/component/form.signal.select.component.html","../../../projects/ng-dsv/ds/form/signal/utils/form.signal.utils.ts","../../../projects/ng-dsv/ds/form/signal/ng-vagabond-lab-ng-dsv-ds-form-signal.ts"],"sourcesContent":["import { Component, effect, input, output, signal } from \"@angular/core\";\nimport { FieldTree } from \"@angular/forms/signals\";\n\n@Component({\n template: ``\n})\nexport abstract class FormSignalInputBase<T> {\n form = input.required<FieldTree<T, string | number>>();\n fieldName = input.required<string>();\n label = input<string>();\n withLabel = input<boolean>(true);\n placeholder = input<string>('');\n required = input<boolean>(false);\n debug = input<boolean>(false);\n\n isError = signal<boolean>(false);\n\n onSend = output<string>();\n callbackChange = output<string>();\n\n constructor() {\n effect(() => {\n this.isError.set(this.getSignal()?.().touched() && this.getSignal()?.().errors().length > 0);\n });\n }\n\n isTouched() {\n return this.getSignal()().touched();\n }\n\n getSignal() {\n return this.form()?.[this.fieldName() as keyof FieldTree<T, string | number>] as FieldTree<string, string | number>;\n }\n\n doOnSend() {\n this.getValue() && this.onSend.emit(this.getValue());\n }\n\n doChange() {\n this.getValue() && this.callbackChange.emit(this.getValue());\n }\n\n protected getValue() {\n const signal = this.getSignal();\n if (signal) {\n const value = signal().value();\n this.debug() && console.log(signal, signal().errors(), value);\n return value;\n }\n return \"\";\n }\n}\n","import { Component, effect, input, signal } from \"@angular/core\";\nimport { FieldState } from \"@angular/forms/signals\";\n\n@Component({\n selector: 'dsv-form-signal-label',\n templateUrl: './form.signal.label.component.html',\n styleUrls: ['../../../reactive/label/component/form.reactive.label.component.scss'],\n})\nexport class FormSignalLabelComponent<T> {\n label = input.required<string>();\n name = input.required<string>();\n signal = input.required<FieldState<T>>();\n show = input<boolean>(true);\n\n isRequired = signal<boolean>(false);\n\n constructor() {\n effect(() => {\n this.isRequired.set(this.signal().required());\n })\n }\n}","@if (show()) {\n <label\n [for]=\"name()\"\n class=\"text\"\n [class.error]=\"signal().touched() && signal().errors().length! > 0\"\n >\n {{ label() }} {{ isRequired() ? \"*\" : \"\" }}\n </label>\n}\n","import { Component } from '@angular/core';\nimport { FieldTree, FormField } from '@angular/forms/signals';\nimport { FormSignalLabelComponent } from '../../label/component/form.signal.label.component';\nimport { FormSignalInputBase } from '../../public-api';\n\n@Component({\n selector: 'dsv-form-signal-checkbox',\n imports: [FormField, FormSignalLabelComponent],\n templateUrl: './form.signal.checkbox.component.html',\n styleUrls: [\n '../../../reactive/input/component/form.reactive.input.component.scss',\n '../../../reactive/checkbox/component/form.reactive.checkbox.component.scss',\n ],\n})\nexport class FormSignalCheckboxComponent<T> extends FormSignalInputBase<T> {\n\n\n getBooleanSignal() {\n return this.form()?.[this.fieldName() as keyof FieldTree<T, string | number>] as FieldTree<boolean, string | number>;\n }\n}\n","<div>\n @if (getSignal()) {\n <dsv-form-signal-label\n [name]=\"fieldName()\"\n [label]=\"label() ?? fieldName()\"\n [signal]=\"getSignal()()\"\n [show]=\"withLabel()\"\n />\n <div>\n <input\n type=\"checkbox\"\n [id]=\"fieldName()\"\n class=\"form-control\"\n [class.error]=\"isError()\"\n [formField]=\"getBooleanSignal()\"\n (change)=\"doChange()\"\n />\n </div>\n }\n</div>\n","import { Component, effect, HostBinding, input, signal } from \"@angular/core\";\nimport { ValidationError } from \"@angular/forms/signals\";\nimport { TranslatePipe } from \"@ngx-translate/core\";\n\n@Component({\n selector: 'dsv-signal-form-error',\n imports: [TranslatePipe],\n templateUrl: './form.signal.error.component.html',\n styleUrls: ['../../../reactive/error/component/form.reactive.error.component.scss']\n})\nexport class FormSignalErrorComponent {\n errors = input.required<ValidationError[]>();\n\n error = signal<string>('');\n\n @HostBinding('class')\n get hostClasses(): string {\n const classes: string[] = ['text', 'error'];\n return classes.join(' ');\n }\n\n constructor() {\n effect(() => {\n let errorMessage = \"\";\n this.errors().forEach(error => {\n switch (error.kind) {\n case \"required\":\n errorMessage = \"Le champ est obligatoire.\";\n break;\n case \"minLength\":\n errorMessage = \"La taille minimum est de \" + error['minLength' as keyof ValidationError] + \".\";\n break;\n case \"maxLength\":\n errorMessage = \"La taille maximum est de \" + error['maxLength' as keyof ValidationError] + \".\";\n break;\n case \"email\":\n errorMessage = \"Le format n'est pas celui d'un email.\";\n break;\n default:\n errorMessage = error.message ?? \"Erreur inconnue.\";\n break;\n }\n });\n this.error.set(errorMessage);\n })\n }\n}","@if (errors().length > 0) {\n @if (error() !== \"\") {\n <div>{{ error() | translate }}</div>\n }\n}\n","import { Component, computed, inject, input, output } from '@angular/core';\nimport { FieldTree, submit } from '@angular/forms/signals';\nimport { RouterLink } from '@angular/router';\nimport { ApiDto } from '@ng-vagabond-lab/ng-dsv/api';\nimport { isCallback } from '@ng-vagabond-lab/ng-dsv/base';\nimport { DsvButtonComponent } from '@ng-vagabond-lab/ng-dsv/ds/button';\nimport { ToastService } from '@ng-vagabond-lab/ng-dsv/ds/toast';\nimport { TranslatePipe } from '@ngx-translate/core';\n\n@Component({\n selector: 'app-form-signal',\n imports: [DsvButtonComponent, RouterLink, TranslatePipe],\n templateUrl: './form.signal.component.html',\n styleUrl: '../../../reactive/form/component/form.reactive.component.scss',\n})\nexport class FormSignalComponent<T> {\n toastService = inject(ToastService);\n\n form = input.required<FieldTree<T, string | number>>();\n\n urlBack = input<string>();\n textValid = input<string>('ENREGISTRER');\n formValid = input<string>('Formulaire envoyé !');\n\n callbackBack = output<void>();\n callback = output<ApiDto>();\n\n isCallbackBack = computed(() => isCallback(this.callbackBack));\n\n goBack() {\n this.callbackBack.emit();\n }\n\n onSubmit(event: Event) {\n event.preventDefault();\n submit(this.form(), async (form) => {\n if (form().valid()) {\n this.callback.emit(form().value() as ApiDto);\n this.toastService.showToast({\n text: this.formValid(),\n });\n } else {\n this.toastService.showToast({\n text: 'Erreur dans le formulaire !',\n type: 'error',\n });\n }\n });\n }\n}\n","<form (submit)=\"onSubmit($event)\" class=\"form-container\" novalidate>\n <div>\n <ng-content></ng-content>\n </div>\n <div class=\"form-buttons\">\n @if (urlBack()) {\n <dsv-button\n color=\"default\"\n variant=\"outlined\"\n [routerLink]=\"urlBack()\"\n [prevent]=\"false\"\n >{{ \"RETOUR\" | translate }}</dsv-button\n >\n }\n @if (isCallbackBack()) {\n <dsv-button color=\"default\" variant=\"outlined\" (callback)=\"goBack()\">{{\n \"RETOUR\" | translate\n }}</dsv-button>\n }\n @if (textValid() && textValid() !== \"\") {\n <dsv-button type=\"submit\" color=\"primary\">{{\n textValid()! | translate\n }}</dsv-button>\n }\n </div>\n</form>\n","import { Component, input } from '@angular/core';\nimport { FormField } from '@angular/forms/signals';\nimport { INPUT_TYPE } from '@ng-vagabond-lab/ng-dsv/type';\nimport { FormSignalInputBase } from '../../base/form.signal.input.base';\nimport { FormSignalErrorComponent } from '../../error/component/form.signal.error.component';\nimport { FormSignalLabelComponent } from '../../label/component/form.signal.label.component';\n\n@Component({\n selector: 'dsv-form-signal-input',\n imports: [\n FormField,\n FormSignalLabelComponent,\n FormSignalErrorComponent\n ],\n templateUrl: './form.signal.input.component.html',\n styleUrl: '../../../reactive/input/component/form.reactive.input.component.scss',\n})\nexport class FormSignalInputComponent<T> extends FormSignalInputBase<T> {\n\n type = input<INPUT_TYPE>('text');\n icon = input<string>();\n}\n","<div>\n @if (getSignal()) {\n @if (withLabel()) {\n <dsv-form-signal-label\n [name]=\"fieldName()\"\n [label]=\"label() ?? fieldName()\"\n [signal]=\"getSignal()()\"\n />\n }\n @if (type() === \"textarea\") {\n <textarea\n [id]=\"fieldName()\"\n [formField]=\"getSignal()\"\n [placeholder]=\"placeholder()\"\n class=\"form-control\"\n ></textarea>\n } @else {\n <input\n #input\n [type]=\"type()\"\n [id]=\"fieldName()\"\n class=\"form-control\"\n [class.error]=\"isError()\"\n [formField]=\"getSignal()\"\n [placeholder]=\"placeholder()\"\n [class.icon]=\"icon()\"\n (blur)=\"doOnSend()\"\n (keydown.enter)=\"doOnSend()\"\n />\n }\n @if (icon()) {\n <i [class]=\"icon()\"></i>\n }\n @if (isTouched()) {\n <dsv-signal-form-error [errors]=\"getSignal()().errors()\" />\n }\n }\n</div>\n","import { Component } from '@angular/core';\n\n@Component({\n template: '',\n})\nexport abstract class BaseFormSignalComponent {\n}\n","import { Component, input, output, signal } from '@angular/core';\nimport { form } from '@angular/forms/signals';\nimport { BaseFormSignalComponent } from '../../form/base/base.form.signal.component';\nimport {\n FormSignalComponent,\n FormSignalInputComponent\n} from '../../public-api';\n\n@Component({\n selector: 'form-signal-searchbar',\n imports: [FormSignalComponent, FormSignalInputComponent],\n templateUrl: './form.signal.searchbar.component.html',\n styleUrls: ['../../../reactive/searchbar/component/reactive.searchbar.component.scss'],\n})\nexport class FormSignalSearchbarComponent extends BaseFormSignalComponent {\n search = input<string>('');\n onSearch = output<string>();\n\n form = form(signal({ search: this.search() }));\n\n onSend(value: string) {\n this.onSearch.emit(value);\n }\n}\n","<app-form-signal [form]=\"form\" textValid=\"\">\n <dsv-form-signal-input\n [form]=\"form\"\n fieldName=\"search\"\n type=\"search\"\n [withLabel]=\"false\"\n (onSend)=\"onSend($event)\"\n icon=\"icon ri-search-line\"\n ></dsv-form-signal-input>\n</app-form-signal>\n","import { Component, input } from '@angular/core';\nimport { FormField } from '@angular/forms/signals';\nimport { ApiDto } from '@ng-vagabond-lab/ng-dsv/api';\nimport { FormSignalErrorComponent } from '../../error/component/form.signal.error.component';\nimport { FormSignalLabelComponent } from '../../label/component/form.signal.label.component';\nimport { FormSignalInputBase } from '../../public-api';\n\n@Component({\n selector: 'dsv-form-signal-select',\n imports: [FormField, FormSignalLabelComponent, FormSignalErrorComponent],\n templateUrl: './form.signal.select.component.html',\n styleUrls: [\n '../../../reactive/input/component/form.reactive.input.component.scss',\n '../../../reactive/select/component/form.reactive.select.component.scss',\n ],\n})\nexport class FormSignalSelectComponent<T> extends FormSignalInputBase<T> {\n\n list = input<(ApiDto & { name: string })[]>([]);\n\n}\n","<div>\n @if (getSignal()) {\n <dsv-form-signal-label\n [name]=\"fieldName()\"\n [label]=\"label() ?? fieldName()\"\n [signal]=\"getSignal()()\"\n [show]=\"withLabel()\"\n />\n <div>\n <select\n [id]=\"fieldName()\"\n [formField]=\"getSignal()\"\n class=\"form-control\"\n (change)=\"doChange()\"\n [class.error]=\"isError()\"\n >\n @for (list of list(); track list.id) {\n <option\n [value]=\"list.id\"\n [selected]=\"\n list.id?.toString() === getSignal()().value().toString()\n \"\n >\n {{ list.name }}\n </option>\n }\n </select>\n @if (isTouched()) {\n <dsv-signal-form-error [errors]=\"getSignal()().errors()\" />\n }\n </div>\n }\n</div>\n","import { ChildFieldContext } from \"@angular/forms/signals\";\n\nexport const requiredTrim = (value: ChildFieldContext<string>) => value.value().trim() != \"\" ? null : { kind: 'required' };","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './public-api';\n"],"names":[],"mappings":";;;;;;;;;MAMsB,mBAAmB,CAAA;AACrC,IAAA,IAAI,GAAG,KAAK,CAAC,QAAQ,0EAAiC;AACtD,IAAA,SAAS,GAAG,KAAK,CAAC,QAAQ,+EAAU;IACpC,KAAK,GAAG,KAAK,CAAA,IAAA,SAAA,GAAA,CAAA,SAAA,EAAA,EAAA,SAAA,EAAA,OAAA,EAAA,CAAA,8BAAA,EAAA,CAAA,CAAU;AACvB,IAAA,SAAS,GAAG,KAAK,CAAU,IAAI,gFAAC;AAChC,IAAA,WAAW,GAAG,KAAK,CAAS,EAAE,kFAAC;AAC/B,IAAA,QAAQ,GAAG,KAAK,CAAU,KAAK,+EAAC;AAChC,IAAA,KAAK,GAAG,KAAK,CAAU,KAAK,4EAAC;A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,CAAC,EAAA,QAAA,EAAA,80BAAA,EAAA,MAAA,EAAA,CAAA,w4BAAA,EAAA,oEAAA,CAAA,EAAA;;;AEPnE,MAAM,YAAY,GAAG,CAAC,KAAgC,KAAK,KAAK,CAAC,KAAK,EAAE,CAAC,IAAI,EAAE,IAAI,EAAE,GAAG,IAAI,GAAG,EAAE,IAAI,EAAE,UAAU;;ACFxH;;AAEG;;;;"}
|
|
@@ -0,0 +1,167 @@
|
|
|
1
|
+
import { CommonModule } from '@angular/common';
|
|
2
|
+
import * as i0 from '@angular/core';
|
|
3
|
+
import { inject, output, effect, Component, signal, Injectable } from '@angular/core';
|
|
4
|
+
import { ModalButtonComponent, ModalAlertComponent } from '@ng-vagabond-lab/ng-dsv/ds/modal';
|
|
5
|
+
import { EnvironmentService } from '@ng-vagabond-lab/ng-dsv/environment';
|
|
6
|
+
import { PlatformService } from '@ng-vagabond-lab/ng-dsv/platform';
|
|
7
|
+
import { ApiService } from '@ng-vagabond-lab/ng-dsv/api';
|
|
8
|
+
import { ToastService } from '@ng-vagabond-lab/ng-dsv/ds/toast';
|
|
9
|
+
import { StorageService } from '@ng-vagabond-lab/ng-dsv/storage';
|
|
10
|
+
import { Router } from '@angular/router';
|
|
11
|
+
|
|
12
|
+
class AuthComponent {
|
|
13
|
+
authGoogleService = inject(AuthGoogleService);
|
|
14
|
+
authService = inject(AuthService);
|
|
15
|
+
environmentService = inject(EnvironmentService);
|
|
16
|
+
platformService = inject(PlatformService);
|
|
17
|
+
initMember = output();
|
|
18
|
+
constructor() {
|
|
19
|
+
effect(() => {
|
|
20
|
+
if (this.environmentService.env() && this.platformService.isPlatformBrowser()) {
|
|
21
|
+
this.authService.loginFromCache();
|
|
22
|
+
this.authGoogleService.initGoogleAuth();
|
|
23
|
+
if (this.authService.userConnected() === null) {
|
|
24
|
+
this.authGoogleService.loginWithGoogle();
|
|
25
|
+
}
|
|
26
|
+
else {
|
|
27
|
+
this.initMember.emit(this.authService.userConnected()?.user?.id);
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
});
|
|
31
|
+
}
|
|
32
|
+
logout() {
|
|
33
|
+
this.authService.logout();
|
|
34
|
+
}
|
|
35
|
+
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.7", ngImport: i0, type: AuthComponent, deps: [], target: i0.ɵɵFactoryTarget.Component });
|
|
36
|
+
static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "21.2.7", type: AuthComponent, isStandalone: true, selector: "app-auth", outputs: { initMember: "initMember" }, ngImport: i0, template: "<div class=\"auth-button\">\n <button\n id=\"google-signin-button\"\n [class.hidden]=\"authService.userConnected() !== null\"\n ></button>\n</div>\n\n@if (authService.userConnected()) {\n <div class=\"profile\">\n <img [src]=\"authService.userConnected()?.user?.avatar\" alt=\"profile\" />\n <app-modal-button id=\"logout\" icon=\"ri-logout-box-line\" />\n </div>\n <app-modal-alert\n id=\"logout\"\n title=\"De\u0301connexion\"\n text=\"Voulez-vous vraiment vous de\u0301connecter ?\"\n button=\"Oui\"\n buttonClose=\"Non\"\n (callback)=\"logout()\"\n ></app-modal-alert>\n}\n", styles: [".auth-button button{margin:0;padding:0;background:transparent;border:0px}.profile{display:flex;gap:.5rem;flex-flow:nowrap;align-items:center}.profile img{width:30px;height:30px;border-radius:50%}\n"], dependencies: [{ kind: "ngmodule", type: CommonModule }, { kind: "component", type: ModalButtonComponent, selector: "app-modal-button", inputs: ["id", "icon", "variant", "text", "color"], outputs: ["callback"] }, { kind: "component", type: ModalAlertComponent, selector: "app-modal-alert", inputs: ["id", "titleText", "text", "button", "buttonClose"], outputs: ["callback"] }] });
|
|
37
|
+
}
|
|
38
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.7", ngImport: i0, type: AuthComponent, decorators: [{
|
|
39
|
+
type: Component,
|
|
40
|
+
args: [{ selector: 'app-auth', imports: [CommonModule, ModalButtonComponent, ModalAlertComponent], template: "<div class=\"auth-button\">\n <button\n id=\"google-signin-button\"\n [class.hidden]=\"authService.userConnected() !== null\"\n ></button>\n</div>\n\n@if (authService.userConnected()) {\n <div class=\"profile\">\n <img [src]=\"authService.userConnected()?.user?.avatar\" alt=\"profile\" />\n <app-modal-button id=\"logout\" icon=\"ri-logout-box-line\" />\n </div>\n <app-modal-alert\n id=\"logout\"\n title=\"De\u0301connexion\"\n text=\"Voulez-vous vraiment vous de\u0301connecter ?\"\n button=\"Oui\"\n buttonClose=\"Non\"\n (callback)=\"logout()\"\n ></app-modal-alert>\n}\n", styles: [".auth-button button{margin:0;padding:0;background:transparent;border:0px}.profile{display:flex;gap:.5rem;flex-flow:nowrap;align-items:center}.profile img{width:30px;height:30px;border-radius:50%}\n"] }]
|
|
41
|
+
}], ctorParameters: () => [], propDecorators: { initMember: [{ type: i0.Output, args: ["initMember"] }] } });
|
|
42
|
+
|
|
43
|
+
const authGuard = (route) => {
|
|
44
|
+
const platformService = inject(PlatformService);
|
|
45
|
+
if (!platformService.isPlatformBrowser()) {
|
|
46
|
+
return true;
|
|
47
|
+
}
|
|
48
|
+
const authService = inject(AuthService);
|
|
49
|
+
const router = inject(Router);
|
|
50
|
+
const requiredRole = route.data['role'];
|
|
51
|
+
if (!requiredRole) {
|
|
52
|
+
console.warn('No role specified in route data.');
|
|
53
|
+
return false;
|
|
54
|
+
}
|
|
55
|
+
authService.loginFromCache();
|
|
56
|
+
const profiles = authService.userConnected()?.user?.profiles;
|
|
57
|
+
if (hasRole(requiredRole, profiles)) {
|
|
58
|
+
return true;
|
|
59
|
+
}
|
|
60
|
+
router.navigate(['/']);
|
|
61
|
+
return false;
|
|
62
|
+
};
|
|
63
|
+
|
|
64
|
+
class AuthService {
|
|
65
|
+
apiService = inject(ApiService);
|
|
66
|
+
toastService = inject(ToastService);
|
|
67
|
+
storageService = inject(StorageService);
|
|
68
|
+
userConnected = signal(null, ...(ngDevMode ? [{ debugName: "userConnected" }] : /* istanbul ignore next */ []));
|
|
69
|
+
googleLogin(credential) {
|
|
70
|
+
this.apiService.post('auth/google-identity-connect', {
|
|
71
|
+
googleToken: credential,
|
|
72
|
+
}, (data) => {
|
|
73
|
+
this.storageService.setItem('user-connected', JSON.stringify(data));
|
|
74
|
+
this.userConnected.set(data);
|
|
75
|
+
this.toastService.showToast({
|
|
76
|
+
type: 'success',
|
|
77
|
+
text: 'Connexion réussie',
|
|
78
|
+
});
|
|
79
|
+
});
|
|
80
|
+
}
|
|
81
|
+
loginFromCache() {
|
|
82
|
+
const userConnected = typeof window !== 'undefined' &&
|
|
83
|
+
JSON.parse(this.storageService?.getItem('user-connected'));
|
|
84
|
+
this.userConnected.set(userConnected);
|
|
85
|
+
this.apiService.info('userConnected', userConnected);
|
|
86
|
+
return userConnected;
|
|
87
|
+
}
|
|
88
|
+
logout() {
|
|
89
|
+
this.storageService?.removeItem('user-connected');
|
|
90
|
+
this.userConnected.set(null);
|
|
91
|
+
this.toastService.showToast({
|
|
92
|
+
type: 'success',
|
|
93
|
+
text: 'Déconnexion réussie',
|
|
94
|
+
});
|
|
95
|
+
}
|
|
96
|
+
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.7", ngImport: i0, type: AuthService, deps: [], target: i0.ɵɵFactoryTarget.Injectable });
|
|
97
|
+
static ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "21.2.7", ngImport: i0, type: AuthService, providedIn: 'root' });
|
|
98
|
+
}
|
|
99
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.7", ngImport: i0, type: AuthService, decorators: [{
|
|
100
|
+
type: Injectable,
|
|
101
|
+
args: [{
|
|
102
|
+
providedIn: 'root',
|
|
103
|
+
}]
|
|
104
|
+
}] });
|
|
105
|
+
|
|
106
|
+
class AuthGoogleService {
|
|
107
|
+
authService = inject(AuthService);
|
|
108
|
+
environmentService = inject(EnvironmentService);
|
|
109
|
+
initGoogle = false;
|
|
110
|
+
initGoogleAuth() {
|
|
111
|
+
if (!this.initGoogle) {
|
|
112
|
+
this.initGoogle = true;
|
|
113
|
+
google.accounts.id.initialize({
|
|
114
|
+
client_id: this.environmentService.env()?.GOOGLE_CLIENT_ID,
|
|
115
|
+
callback: this.handleCredentialResponse.bind(this),
|
|
116
|
+
});
|
|
117
|
+
google.accounts.id.renderButton(document.getElementById('google-signin-button'), {
|
|
118
|
+
theme: 'outline',
|
|
119
|
+
size: 'medium',
|
|
120
|
+
type: 'icon',
|
|
121
|
+
});
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
handleCredentialResponse(response) {
|
|
125
|
+
this.authService.googleLogin(response.credential);
|
|
126
|
+
}
|
|
127
|
+
decodeJwtToken(token) {
|
|
128
|
+
const base64Url = token.split('.')[1];
|
|
129
|
+
const base64 = base64Url.replace(/-/g, '+').replace(/_/g, '/');
|
|
130
|
+
const jsonPayload = decodeURIComponent(atob(base64)
|
|
131
|
+
.split('')
|
|
132
|
+
.map(function (c) {
|
|
133
|
+
return '%' + ('00' + c.charCodeAt(0).toString(16)).slice(-2);
|
|
134
|
+
})
|
|
135
|
+
.join(''));
|
|
136
|
+
return JSON.parse(jsonPayload);
|
|
137
|
+
}
|
|
138
|
+
loginWithGoogle() {
|
|
139
|
+
google.accounts.id.prompt();
|
|
140
|
+
}
|
|
141
|
+
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.7", ngImport: i0, type: AuthGoogleService, deps: [], target: i0.ɵɵFactoryTarget.Injectable });
|
|
142
|
+
static ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "21.2.7", ngImport: i0, type: AuthGoogleService, providedIn: 'root' });
|
|
143
|
+
}
|
|
144
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.7", ngImport: i0, type: AuthGoogleService, decorators: [{
|
|
145
|
+
type: Injectable,
|
|
146
|
+
args: [{
|
|
147
|
+
providedIn: 'root',
|
|
148
|
+
}]
|
|
149
|
+
}] });
|
|
150
|
+
|
|
151
|
+
const hasRole = (roles, userRoles) => {
|
|
152
|
+
const roleSplit = roles.split(',');
|
|
153
|
+
let find = false;
|
|
154
|
+
roleSplit.forEach(role => {
|
|
155
|
+
if (userRoles?.find(userRole => userRole['roles']?.toString().includes(role) || userRole['name'] === role)) {
|
|
156
|
+
find = true;
|
|
157
|
+
}
|
|
158
|
+
});
|
|
159
|
+
return find;
|
|
160
|
+
};
|
|
161
|
+
|
|
162
|
+
/**
|
|
163
|
+
* Generated bundle index. Do not edit.
|
|
164
|
+
*/
|
|
165
|
+
|
|
166
|
+
export { AuthComponent, AuthGoogleService, AuthService, authGuard, hasRole };
|
|
167
|
+
//# sourceMappingURL=ng-vagabond-lab-ng-dsv-modules-auth.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ng-vagabond-lab-ng-dsv-modules-auth.mjs","sources":["../../../projects/ng-dsv/modules/auth/component/auth.component.ts","../../../projects/ng-dsv/modules/auth/component/auth.component.html","../../../projects/ng-dsv/modules/auth/guard/auth.guard.ts","../../../projects/ng-dsv/modules/auth/service/auth.service.ts","../../../projects/ng-dsv/modules/auth/service/auth.google.service.ts","../../../projects/ng-dsv/modules/auth/utils/auth.utils.ts","../../../projects/ng-dsv/modules/auth/ng-vagabond-lab-ng-dsv-modules-auth.ts"],"sourcesContent":["import { CommonModule } from '@angular/common';\nimport {\n Component,\n effect,\n inject,\n output\n} from '@angular/core';\nimport { ID } from '@ng-vagabond-lab/ng-dsv/api';\nimport {\n ModalAlertComponent,\n ModalButtonComponent,\n} from '@ng-vagabond-lab/ng-dsv/ds/modal';\nimport { EnvironmentService } from '@ng-vagabond-lab/ng-dsv/environment';\nimport { PlatformService } from '@ng-vagabond-lab/ng-dsv/platform';\nimport { AuthGoogleService, AuthService } from '../public-api';\n\n@Component({\n selector: 'app-auth',\n imports: [CommonModule, ModalButtonComponent, ModalAlertComponent],\n templateUrl: './auth.component.html',\n styleUrls: ['./auth.component.scss'],\n})\nexport class AuthComponent {\n readonly authGoogleService = inject(AuthGoogleService);\n readonly authService = inject(AuthService);\n readonly environmentService = inject(EnvironmentService);\n readonly platformService = inject(PlatformService);\n\n readonly initMember = output<ID>();\n\n constructor() {\n effect(() => {\n if (this.environmentService.env() && this.platformService.isPlatformBrowser()) {\n this.authService.loginFromCache();\n this.authGoogleService.initGoogleAuth();\n if (this.authService.userConnected() === null) {\n this.authGoogleService.loginWithGoogle();\n } else {\n this.initMember.emit(this.authService.userConnected()?.user?.id);\n }\n }\n });\n }\n\n logout() {\n this.authService.logout();\n }\n}\n","<div class=\"auth-button\">\n <button\n id=\"google-signin-button\"\n [class.hidden]=\"authService.userConnected() !== null\"\n ></button>\n</div>\n\n@if (authService.userConnected()) {\n <div class=\"profile\">\n <img [src]=\"authService.userConnected()?.user?.avatar\" alt=\"profile\" />\n <app-modal-button id=\"logout\" icon=\"ri-logout-box-line\" />\n </div>\n <app-modal-alert\n id=\"logout\"\n title=\"Déconnexion\"\n text=\"Voulez-vous vraiment vous déconnecter ?\"\n button=\"Oui\"\n buttonClose=\"Non\"\n (callback)=\"logout()\"\n ></app-modal-alert>\n}\n","import { inject } from '@angular/core';\nimport { ActivatedRouteSnapshot, CanActivateFn, Router } from '@angular/router';\nimport { PlatformService } from '@ng-vagabond-lab/ng-dsv/platform';\nimport { AuthService, hasRole } from '../public-api';\n\nexport const authGuard: CanActivateFn = (\n route: ActivatedRouteSnapshot,\n) => {\n const platformService = inject(PlatformService);\n\n if (!platformService.isPlatformBrowser()) {\n return true;\n }\n\n const authService = inject(AuthService);\n const router = inject(Router);\n\n const requiredRole = route.data['role'];\n\n if (!requiredRole) {\n console.warn('No role specified in route data.');\n return false;\n }\n\n authService.loginFromCache();\n const profiles = authService.userConnected()?.user?.profiles;\n if (hasRole(requiredRole, profiles)) {\n return true;\n }\n\n router.navigate(['/']);\n return false;\n};\n","import { inject, Injectable, signal } from '@angular/core';\nimport { ApiService } from '@ng-vagabond-lab/ng-dsv/api';\nimport { ToastService } from '@ng-vagabond-lab/ng-dsv/ds/toast';\nimport { StorageService } from '@ng-vagabond-lab/ng-dsv/storage';\nimport { UserConnectedDto } from '../dto/user.dto';\n\n@Injectable({\n providedIn: 'root',\n})\nexport class AuthService {\n apiService = inject(ApiService);\n toastService = inject(ToastService);\n storageService = inject(StorageService);\n\n userConnected = signal<UserConnectedDto | null>(null);\n\n googleLogin(credential: string) {\n this.apiService.post<UserConnectedDto>(\n 'auth/google-identity-connect',\n {\n googleToken: credential,\n },\n (data) => {\n this.storageService.setItem('user-connected', JSON.stringify(data));\n this.userConnected.set(data);\n this.toastService.showToast({\n type: 'success',\n text: 'Connexion réussie',\n });\n }\n );\n }\n\n loginFromCache() {\n const userConnected =\n typeof window !== 'undefined' &&\n JSON.parse(this.storageService?.getItem('user-connected')!);\n this.userConnected.set(userConnected);\n this.apiService.info('userConnected', userConnected);\n return userConnected;\n }\n\n logout() {\n this.storageService?.removeItem('user-connected');\n this.userConnected.set(null);\n this.toastService.showToast({\n type: 'success',\n text: 'Déconnexion réussie',\n });\n }\n}\n","import { inject, Injectable } from '@angular/core';\nimport { EnvironmentService } from '@ng-vagabond-lab/ng-dsv/environment';\nimport { AuthService } from './auth.service';\n\ndeclare const google: any;\n\n@Injectable({\n providedIn: 'root',\n})\nexport class AuthGoogleService {\n private readonly authService = inject(AuthService);\n private readonly environmentService = inject(EnvironmentService);\n\n initGoogle: boolean = false;\n\n initGoogleAuth() {\n if (!this.initGoogle) {\n this.initGoogle = true;\n google.accounts.id.initialize({\n client_id: this.environmentService.env()?.GOOGLE_CLIENT_ID,\n callback: this.handleCredentialResponse.bind(this),\n });\n google.accounts.id.renderButton(\n document.getElementById('google-signin-button')!,\n {\n theme: 'outline',\n size: 'medium',\n type: 'icon',\n }\n );\n }\n }\n\n handleCredentialResponse(response: { credential: string }) {\n this.authService.googleLogin(response.credential);\n }\n\n decodeJwtToken(token: string) {\n const base64Url = token.split('.')[1];\n const base64 = base64Url.replace(/-/g, '+').replace(/_/g, '/');\n const jsonPayload = decodeURIComponent(\n atob(base64)\n .split('')\n .map(function (c) {\n return '%' + ('00' + c.charCodeAt(0).toString(16)).slice(-2);\n })\n .join('')\n );\n return JSON.parse(jsonPayload);\n }\n\n loginWithGoogle() {\n google.accounts.id.prompt();\n }\n}\n","import { ApiDto } from \"@ng-vagabond-lab/ng-dsv/api\";\n\nexport const hasRole = (roles: string, userRoles?: ApiDto[]) => {\n const roleSplit = roles.split(',');\n let find = false;\n roleSplit.forEach(role => {\n if (userRoles?.find(userRole => userRole['roles' as keyof ApiDto]?.toString().includes(role) || userRole['name' as keyof ApiDto] === role)) {\n find = true;\n }\n });\n return find;\n}","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './public-api';\n"],"names":[],"mappings":";;;;;;;;;;;MAsBa,aAAa,CAAA;AACf,IAAA,iBAAiB,GAAG,MAAM,CAAC,iBAAiB,CAAC;AAC7C,IAAA,WAAW,GAAG,MAAM,CAAC,WAAW,CAAC;AACjC,IAAA,kBAAkB,GAAG,MAAM,CAAC,kBAAkB,CAAC;AAC/C,IAAA,eAAe,GAAG,MAAM,CAAC,eAAe,CAAC;IAEzC,UAAU,GAAG,MAAM,EAAM;AAElC,IAAA,WAAA,GAAA;QACE,MAAM,CAAC,MAAK;AACV,YAAA,IAAI,IAAI,CAAC,kBAAkB,CAAC,GAAG,EAAE,IAAI,IAAI,CAAC,eAAe,CAAC,iBAAiB,EAAE,EAAE;AAC7E,gBAAA,IAAI,CAAC,WAAW,CAAC,cAAc,EAAE;AACjC,gBAAA,IAAI,CAAC,iBAAiB,CAAC,cAAc,EAAE;gBACvC,IAAI,IAAI,CAAC,WAAW,CAAC,aAAa,EAAE,KAAK,IAAI,EAAE;AAC7C,oBAAA,IAAI,CAAC,iBAAiB,CAAC,eAAe,EAAE;gBAC1C;qBAAO;AACL,oBAAA,IAAI,CAAC,UAAU,CAAC,IAAI,CAAC,IAAI,CAAC,WAAW,CAAC,aAAa,EAAE,EAAE,I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CAAC,MAAM,EAAE;IAC7B;uGA5CW,iBAAiB,EAAA,IAAA,EAAA,EAAA,EAAA,MAAA,EAAA,EAAA,CAAA,eAAA,CAAA,UAAA,EAAA,CAAA;AAAjB,IAAA,OAAA,KAAA,GAAA,EAAA,CAAA,qBAAA,CAAA,EAAA,UAAA,EAAA,QAAA,EAAA,OAAA,EAAA,QAAA,EAAA,QAAA,EAAA,EAAA,EAAA,IAAA,EAAA,iBAAiB,cAFhB,MAAM,EAAA,CAAA;;2FAEP,iBAAiB,EAAA,UAAA,EAAA,CAAA;kBAH7B,UAAU;AAAC,YAAA,IAAA,EAAA,CAAA;AACV,oBAAA,UAAU,EAAE,MAAM;AACnB,iBAAA;;;MCNY,OAAO,GAAG,CAAC,KAAa,EAAE,SAAoB,KAAI;IAC3D,MAAM,SAAS,GAAG,KAAK,CAAC,KAAK,CAAC,GAAG,CAAC;IAClC,IAAI,IAAI,GAAG,KAAK;AAChB,IAAA,SAAS,CAAC,OAAO,CAAC,IAAI,IAAG;AACrB,QAAA,IAAI,SAAS,EAAE,IAAI,CAAC,QAAQ,IAAI,QAAQ,CAAC,OAAuB,CAAC,EAAE,QAAQ,EAAE,CAAC,QAAQ,CAAC,IAAI,CAAC,IAAI,QAAQ,CAAC,MAAsB,CAAC,KAAK,IAAI,CAAC,EAAE;YACxI,IAAI,GAAG,IAAI;QACf;AACJ,IAAA,CAAC,CAAC;AACF,IAAA,OAAO,IAAI;AACf;;ACXA;;AAEG;;;;"}
|
package/package.json
CHANGED
|
@@ -0,0 +1,105 @@
|
|
|
1
|
+
import * as _angular_core from '@angular/core';
|
|
2
|
+
import * as _angular_forms_signals from '@angular/forms/signals';
|
|
3
|
+
import { FieldTree, ValidationError, FieldState, ChildFieldContext } from '@angular/forms/signals';
|
|
4
|
+
import { ApiDto } from '@ng-vagabond-lab/ng-dsv/api';
|
|
5
|
+
import { ToastService } from '@ng-vagabond-lab/ng-dsv/ds/toast';
|
|
6
|
+
import { INPUT_TYPE } from '@ng-vagabond-lab/ng-dsv/type';
|
|
7
|
+
|
|
8
|
+
declare abstract class FormSignalInputBase<T> {
|
|
9
|
+
form: _angular_core.InputSignal<FieldTree<T, string | number>>;
|
|
10
|
+
fieldName: _angular_core.InputSignal<string>;
|
|
11
|
+
label: _angular_core.InputSignal<string | undefined>;
|
|
12
|
+
withLabel: _angular_core.InputSignal<boolean>;
|
|
13
|
+
placeholder: _angular_core.InputSignal<string>;
|
|
14
|
+
required: _angular_core.InputSignal<boolean>;
|
|
15
|
+
debug: _angular_core.InputSignal<boolean>;
|
|
16
|
+
isError: _angular_core.WritableSignal<boolean>;
|
|
17
|
+
onSend: _angular_core.OutputEmitterRef<string>;
|
|
18
|
+
callbackChange: _angular_core.OutputEmitterRef<string>;
|
|
19
|
+
constructor();
|
|
20
|
+
isTouched(): boolean;
|
|
21
|
+
getSignal(): FieldTree<string, string | number>;
|
|
22
|
+
doOnSend(): void;
|
|
23
|
+
doChange(): void;
|
|
24
|
+
protected getValue(): string;
|
|
25
|
+
static ɵfac: _angular_core.ɵɵFactoryDeclaration<FormSignalInputBase<any>, never>;
|
|
26
|
+
static ɵcmp: _angular_core.ɵɵComponentDeclaration<FormSignalInputBase<any>, "ng-component", never, { "form": { "alias": "form"; "required": true; "isSignal": true; }; "fieldName": { "alias": "fieldName"; "required": true; "isSignal": true; }; "label": { "alias": "label"; "required": false; "isSignal": true; }; "withLabel": { "alias": "withLabel"; "required": false; "isSignal": true; }; "placeholder": { "alias": "placeholder"; "required": false; "isSignal": true; }; "required": { "alias": "required"; "required": false; "isSignal": true; }; "debug": { "alias": "debug"; "required": false; "isSignal": true; }; }, { "onSend": "onSend"; "callbackChange": "callbackChange"; }, never, never, true, never>;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
declare class FormSignalCheckboxComponent<T> extends FormSignalInputBase<T> {
|
|
30
|
+
getBooleanSignal(): FieldTree<boolean, string | number>;
|
|
31
|
+
static ɵfac: _angular_core.ɵɵFactoryDeclaration<FormSignalCheckboxComponent<any>, never>;
|
|
32
|
+
static ɵcmp: _angular_core.ɵɵComponentDeclaration<FormSignalCheckboxComponent<any>, "dsv-form-signal-checkbox", never, {}, {}, never, never, true, never>;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
declare class FormSignalErrorComponent {
|
|
36
|
+
errors: _angular_core.InputSignal<ValidationError[]>;
|
|
37
|
+
error: _angular_core.WritableSignal<string>;
|
|
38
|
+
get hostClasses(): string;
|
|
39
|
+
constructor();
|
|
40
|
+
static ɵfac: _angular_core.ɵɵFactoryDeclaration<FormSignalErrorComponent, never>;
|
|
41
|
+
static ɵcmp: _angular_core.ɵɵComponentDeclaration<FormSignalErrorComponent, "dsv-signal-form-error", never, { "errors": { "alias": "errors"; "required": true; "isSignal": true; }; }, {}, never, never, true, never>;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
declare class FormSignalComponent<T> {
|
|
45
|
+
toastService: ToastService;
|
|
46
|
+
form: _angular_core.InputSignal<FieldTree<T, string | number>>;
|
|
47
|
+
urlBack: _angular_core.InputSignal<string | undefined>;
|
|
48
|
+
textValid: _angular_core.InputSignal<string>;
|
|
49
|
+
formValid: _angular_core.InputSignal<string>;
|
|
50
|
+
callbackBack: _angular_core.OutputEmitterRef<void>;
|
|
51
|
+
callback: _angular_core.OutputEmitterRef<ApiDto>;
|
|
52
|
+
isCallbackBack: _angular_core.Signal<boolean>;
|
|
53
|
+
goBack(): void;
|
|
54
|
+
onSubmit(event: Event): void;
|
|
55
|
+
static ɵfac: _angular_core.ɵɵFactoryDeclaration<FormSignalComponent<any>, never>;
|
|
56
|
+
static ɵcmp: _angular_core.ɵɵComponentDeclaration<FormSignalComponent<any>, "app-form-signal", never, { "form": { "alias": "form"; "required": true; "isSignal": true; }; "urlBack": { "alias": "urlBack"; "required": false; "isSignal": true; }; "textValid": { "alias": "textValid"; "required": false; "isSignal": true; }; "formValid": { "alias": "formValid"; "required": false; "isSignal": true; }; }, { "callbackBack": "callbackBack"; "callback": "callback"; }, never, ["*"], true, never>;
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
declare class FormSignalInputComponent<T> extends FormSignalInputBase<T> {
|
|
60
|
+
type: _angular_core.InputSignal<INPUT_TYPE>;
|
|
61
|
+
icon: _angular_core.InputSignal<string | undefined>;
|
|
62
|
+
static ɵfac: _angular_core.ɵɵFactoryDeclaration<FormSignalInputComponent<any>, never>;
|
|
63
|
+
static ɵcmp: _angular_core.ɵɵComponentDeclaration<FormSignalInputComponent<any>, "dsv-form-signal-input", never, { "type": { "alias": "type"; "required": false; "isSignal": true; }; "icon": { "alias": "icon"; "required": false; "isSignal": true; }; }, {}, never, never, true, never>;
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
declare class FormSignalLabelComponent<T> {
|
|
67
|
+
label: _angular_core.InputSignal<string>;
|
|
68
|
+
name: _angular_core.InputSignal<string>;
|
|
69
|
+
signal: _angular_core.InputSignal<FieldState<T, string | number>>;
|
|
70
|
+
show: _angular_core.InputSignal<boolean>;
|
|
71
|
+
isRequired: _angular_core.WritableSignal<boolean>;
|
|
72
|
+
constructor();
|
|
73
|
+
static ɵfac: _angular_core.ɵɵFactoryDeclaration<FormSignalLabelComponent<any>, never>;
|
|
74
|
+
static ɵcmp: _angular_core.ɵɵComponentDeclaration<FormSignalLabelComponent<any>, "dsv-form-signal-label", never, { "label": { "alias": "label"; "required": true; "isSignal": true; }; "name": { "alias": "name"; "required": true; "isSignal": true; }; "signal": { "alias": "signal"; "required": true; "isSignal": true; }; "show": { "alias": "show"; "required": false; "isSignal": true; }; }, {}, never, never, true, never>;
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
declare abstract class BaseFormSignalComponent {
|
|
78
|
+
static ɵfac: _angular_core.ɵɵFactoryDeclaration<BaseFormSignalComponent, never>;
|
|
79
|
+
static ɵcmp: _angular_core.ɵɵComponentDeclaration<BaseFormSignalComponent, "ng-component", never, {}, {}, never, never, true, never>;
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
declare class FormSignalSearchbarComponent extends BaseFormSignalComponent {
|
|
83
|
+
search: _angular_core.InputSignal<string>;
|
|
84
|
+
onSearch: _angular_core.OutputEmitterRef<string>;
|
|
85
|
+
form: _angular_forms_signals.FieldTree<{
|
|
86
|
+
search: string;
|
|
87
|
+
}, string | number>;
|
|
88
|
+
onSend(value: string): void;
|
|
89
|
+
static ɵfac: _angular_core.ɵɵFactoryDeclaration<FormSignalSearchbarComponent, never>;
|
|
90
|
+
static ɵcmp: _angular_core.ɵɵComponentDeclaration<FormSignalSearchbarComponent, "form-signal-searchbar", never, { "search": { "alias": "search"; "required": false; "isSignal": true; }; }, { "onSearch": "onSearch"; }, never, never, true, never>;
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
declare class FormSignalSelectComponent<T> extends FormSignalInputBase<T> {
|
|
94
|
+
list: _angular_core.InputSignal<(ApiDto & {
|
|
95
|
+
name: string;
|
|
96
|
+
})[]>;
|
|
97
|
+
static ɵfac: _angular_core.ɵɵFactoryDeclaration<FormSignalSelectComponent<any>, never>;
|
|
98
|
+
static ɵcmp: _angular_core.ɵɵComponentDeclaration<FormSignalSelectComponent<any>, "dsv-form-signal-select", never, { "list": { "alias": "list"; "required": false; "isSignal": true; }; }, {}, never, never, true, never>;
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
declare const requiredTrim: (value: ChildFieldContext<string>) => {
|
|
102
|
+
kind: string;
|
|
103
|
+
} | null;
|
|
104
|
+
|
|
105
|
+
export { FormSignalCheckboxComponent, FormSignalComponent, FormSignalErrorComponent, FormSignalInputBase, FormSignalInputComponent, FormSignalLabelComponent, FormSignalSearchbarComponent, FormSignalSelectComponent, requiredTrim };
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
import * as i0 from '@angular/core';
|
|
2
|
+
import { ID, ApiDto, ApiService } from '@ng-vagabond-lab/ng-dsv/api';
|
|
3
|
+
import { EnvironmentService } from '@ng-vagabond-lab/ng-dsv/environment';
|
|
4
|
+
import { PlatformService } from '@ng-vagabond-lab/ng-dsv/platform';
|
|
5
|
+
import { ToastService } from '@ng-vagabond-lab/ng-dsv/ds/toast';
|
|
6
|
+
import { StorageService } from '@ng-vagabond-lab/ng-dsv/storage';
|
|
7
|
+
import { CanActivateFn } from '@angular/router';
|
|
8
|
+
|
|
9
|
+
declare class AuthComponent {
|
|
10
|
+
readonly authGoogleService: AuthGoogleService;
|
|
11
|
+
readonly authService: AuthService;
|
|
12
|
+
readonly environmentService: EnvironmentService;
|
|
13
|
+
readonly platformService: PlatformService;
|
|
14
|
+
readonly initMember: i0.OutputEmitterRef<ID>;
|
|
15
|
+
constructor();
|
|
16
|
+
logout(): void;
|
|
17
|
+
static ɵfac: i0.ɵɵFactoryDeclaration<AuthComponent, never>;
|
|
18
|
+
static ɵcmp: i0.ɵɵComponentDeclaration<AuthComponent, "app-auth", never, {}, { "initMember": "initMember"; }, never, never, true, never>;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
interface UserDto extends ApiDto {
|
|
22
|
+
avatar?: string;
|
|
23
|
+
creationDate?: string;
|
|
24
|
+
facebookId?: string;
|
|
25
|
+
googleId?: string;
|
|
26
|
+
username?: string;
|
|
27
|
+
profiles?: [];
|
|
28
|
+
}
|
|
29
|
+
interface UserConnectedDto {
|
|
30
|
+
googleToken?: string;
|
|
31
|
+
jwt?: string;
|
|
32
|
+
jwtRefresh?: string;
|
|
33
|
+
user?: UserDto;
|
|
34
|
+
}
|
|
35
|
+
interface GoogleRequest {
|
|
36
|
+
googleToken: string;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
declare const authGuard: CanActivateFn;
|
|
40
|
+
|
|
41
|
+
declare class AuthGoogleService {
|
|
42
|
+
private readonly authService;
|
|
43
|
+
private readonly environmentService;
|
|
44
|
+
initGoogle: boolean;
|
|
45
|
+
initGoogleAuth(): void;
|
|
46
|
+
handleCredentialResponse(response: {
|
|
47
|
+
credential: string;
|
|
48
|
+
}): void;
|
|
49
|
+
decodeJwtToken(token: string): any;
|
|
50
|
+
loginWithGoogle(): void;
|
|
51
|
+
static ɵfac: i0.ɵɵFactoryDeclaration<AuthGoogleService, never>;
|
|
52
|
+
static ɵprov: i0.ɵɵInjectableDeclaration<AuthGoogleService>;
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
declare class AuthService {
|
|
56
|
+
apiService: ApiService;
|
|
57
|
+
toastService: ToastService;
|
|
58
|
+
storageService: StorageService;
|
|
59
|
+
userConnected: i0.WritableSignal<UserConnectedDto | null>;
|
|
60
|
+
googleLogin(credential: string): void;
|
|
61
|
+
loginFromCache(): any;
|
|
62
|
+
logout(): void;
|
|
63
|
+
static ɵfac: i0.ɵɵFactoryDeclaration<AuthService, never>;
|
|
64
|
+
static ɵprov: i0.ɵɵInjectableDeclaration<AuthService>;
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
declare const hasRole: (roles: string, userRoles?: ApiDto[]) => boolean;
|
|
68
|
+
|
|
69
|
+
export { AuthComponent, AuthGoogleService, AuthService, authGuard, hasRole };
|
|
70
|
+
export type { GoogleRequest, UserConnectedDto, UserDto };
|