@carefirst/library 1.3.10 → 1.3.12
Sign up to get free protection for your applications and to get access to all the features.
- package/esm2022/carefirst-library.mjs +2 -0
- package/esm2022/lib/components/alert/alert.component.mjs +56 -0
- package/esm2022/lib/components/badge/badge.component.mjs +39 -0
- package/esm2022/lib/components/button/button.component.mjs +92 -0
- package/esm2022/lib/components/calendar/calendar.component.mjs +39 -0
- package/esm2022/lib/components/chat-bubble/chat-bubble.component.mjs +31 -0
- package/esm2022/lib/components/form-input/form-input.component.mjs +87 -0
- package/esm2022/lib/components/form-input-select/form-input-select.component.mjs +46 -0
- package/esm2022/lib/components/form-input-text-area/form-input-text-area.component.mjs +61 -0
- package/esm2022/lib/components/form-validation/form-validation.component.mjs +20 -0
- package/esm2022/lib/components/icon/icon.component.mjs +29 -0
- package/esm2022/lib/components/logo/logo.component.mjs +18 -0
- package/esm2022/lib/components/notification/notification.component.mjs +22 -0
- package/esm2022/lib/components/page/page.component.mjs +31 -0
- package/esm2022/lib/components/spacer/spacer.component.mjs +30 -0
- package/esm2022/lib/components/spinner/spinner.component.mjs +19 -0
- package/esm2022/lib/directives/button-loader.directive.mjs +41 -0
- package/esm2022/lib/interfaces/alert.interface.mjs +2 -0
- package/esm2022/lib/interfaces/icon.interface.mjs +52 -0
- package/esm2022/lib/interfaces/input.interface.mjs +2 -0
- package/esm2022/lib/interfaces/notification.interface.mjs +2 -0
- package/esm2022/lib/interfaces/spacer.interface.mjs +2 -0
- package/esm2022/lib/library.module.mjs +100 -0
- package/esm2022/lib/utils/attribute.util.mjs +34 -0
- package/esm2022/lib/utils/form-validators-utility.mjs +113 -0
- package/esm2022/public-api.mjs +24 -0
- package/fesm2022/carefirst-library.mjs +890 -0
- package/fesm2022/carefirst-library.mjs.map +1 -0
- package/index.d.ts +2 -0
- package/lib/components/alert/alert.component.d.ts +14 -0
- package/lib/components/badge/badge.component.d.ts +15 -0
- package/lib/components/button/button.component.d.ts +32 -0
- package/lib/components/calendar/calendar.component.d.ts +15 -0
- package/lib/components/chat-bubble/chat-bubble.component.d.ts +13 -0
- package/lib/components/form-input/form-input.component.d.ts +37 -0
- package/lib/components/form-input-select/form-input-select.component.d.ts +21 -0
- package/lib/components/form-input-text-area/form-input-text-area.component.d.ts +27 -0
- package/lib/components/form-validation/form-validation.component.d.ts +9 -0
- package/lib/components/icon/icon.component.d.ts +13 -0
- package/lib/components/logo/logo.component.d.ts +7 -0
- package/lib/components/notification/notification.component.d.ts +9 -0
- package/lib/components/page/page.component.d.ts +13 -0
- package/lib/components/spacer/spacer.component.d.ts +14 -0
- package/lib/components/spinner/spinner.component.d.ts +9 -0
- package/lib/directives/button-loader.directive.d.ts +12 -0
- package/lib/interfaces/alert.interface.d.ts +11 -0
- package/lib/interfaces/icon.interface.d.ts +4 -0
- package/lib/interfaces/input.interface.d.ts +4 -0
- package/lib/interfaces/notification.interface.d.ts +11 -0
- package/lib/interfaces/spacer.interface.d.ts +3 -0
- package/lib/library.module.d.ts +25 -0
- package/lib/utils/attribute.util.d.ts +4 -0
- package/lib/utils/form-validators-utility.d.ts +8 -0
- package/package.json +14 -11
- package/{src/public-api.ts → public-api.d.ts} +0 -18
- package/.eslintrc.json +0 -31
- package/ng-package.json +0 -8
- package/src/lib/components/alert/alert.component.html +0 -0
- package/src/lib/components/alert/alert.component.scss +0 -63
- package/src/lib/components/alert/alert.component.spec.ts +0 -23
- package/src/lib/components/alert/alert.component.ts +0 -73
- package/src/lib/components/badge/badge.component.html +0 -5
- package/src/lib/components/badge/badge.component.scss +0 -96
- package/src/lib/components/badge/badge.component.spec.ts +0 -23
- package/src/lib/components/badge/badge.component.ts +0 -61
- package/src/lib/components/button/button.component.html +0 -20
- package/src/lib/components/button/button.component.scss +0 -153
- package/src/lib/components/button/button.component.spec.ts +0 -21
- package/src/lib/components/button/button.component.ts +0 -94
- package/src/lib/components/calendar/calendar.component.html +0 -9
- package/src/lib/components/calendar/calendar.component.scss +0 -34
- package/src/lib/components/calendar/calendar.component.spec.ts +0 -23
- package/src/lib/components/calendar/calendar.component.ts +0 -53
- package/src/lib/components/chat-bubble/chat-bubble.component.html +0 -9
- package/src/lib/components/chat-bubble/chat-bubble.component.scss +0 -31
- package/src/lib/components/chat-bubble/chat-bubble.component.spec.ts +0 -23
- package/src/lib/components/chat-bubble/chat-bubble.component.ts +0 -43
- package/src/lib/components/form-input/form-input.component.html +0 -37
- package/src/lib/components/form-input/form-input.component.scss +0 -23
- package/src/lib/components/form-input/form-input.component.spec.ts +0 -23
- package/src/lib/components/form-input/form-input.component.ts +0 -95
- package/src/lib/components/form-input-select/form-input-select.component.html +0 -27
- package/src/lib/components/form-input-select/form-input-select.component.scss +0 -40
- package/src/lib/components/form-input-select/form-input-select.component.spec.ts +0 -23
- package/src/lib/components/form-input-select/form-input-select.component.ts +0 -61
- package/src/lib/components/form-input-text-area/form-input-text-area.component.html +0 -29
- package/src/lib/components/form-input-text-area/form-input-text-area.component.scss +0 -19
- package/src/lib/components/form-input-text-area/form-input-text-area.component.spec.ts +0 -23
- package/src/lib/components/form-input-text-area/form-input-text-area.component.ts +0 -76
- package/src/lib/components/form-validation/form-validation.component.html +0 -8
- package/src/lib/components/form-validation/form-validation.component.scss +0 -8
- package/src/lib/components/form-validation/form-validation.component.spec.ts +0 -23
- package/src/lib/components/form-validation/form-validation.component.ts +0 -34
- package/src/lib/components/icon/icon.component.html +0 -529
- package/src/lib/components/icon/icon.component.scss +0 -61
- package/src/lib/components/icon/icon.component.spec.ts +0 -21
- package/src/lib/components/icon/icon.component.ts +0 -40
- package/src/lib/components/logo/logo.component.html +0 -10
- package/src/lib/components/logo/logo.component.scss +0 -5
- package/src/lib/components/logo/logo.component.spec.ts +0 -23
- package/src/lib/components/logo/logo.component.ts +0 -21
- package/src/lib/components/notification/notification.component.html +0 -39
- package/src/lib/components/notification/notification.component.scss +0 -20
- package/src/lib/components/notification/notification.component.spec.ts +0 -21
- package/src/lib/components/notification/notification.component.ts +0 -23
- package/src/lib/components/page/page.component.html +0 -5
- package/src/lib/components/page/page.component.scss +0 -35
- package/src/lib/components/page/page.component.spec.ts +0 -21
- package/src/lib/components/page/page.component.ts +0 -42
- package/src/lib/components/spacer/spacer.component.html +0 -4
- package/src/lib/components/spacer/spacer.component.scss +0 -27
- package/src/lib/components/spacer/spacer.component.spec.ts +0 -21
- package/src/lib/components/spacer/spacer.component.ts +0 -43
- package/src/lib/components/spinner/spinner.component.html +0 -1
- package/src/lib/components/spinner/spinner.component.scss +0 -14
- package/src/lib/components/spinner/spinner.component.spec.ts +0 -23
- package/src/lib/components/spinner/spinner.component.ts +0 -33
- package/src/lib/directives/button-loader.directive.spec.ts +0 -8
- package/src/lib/directives/button-loader.directive.ts +0 -77
- package/src/lib/interfaces/alert.interface.ts +0 -20
- package/src/lib/interfaces/icon.interface.ts +0 -62
- package/src/lib/interfaces/input.interface.ts +0 -8
- package/src/lib/interfaces/notification.interface.ts +0 -15
- package/src/lib/interfaces/spacer.interface.ts +0 -6
- package/src/lib/library.module.ts +0 -66
- package/src/lib/utils/attribute.util.ts +0 -66
- package/src/lib/utils/form-validators-utility.ts +0 -186
- package/tsconfig.lib.json +0 -12
- package/tsconfig.lib.prod.json +0 -10
- package/tsconfig.spec.json +0 -14
@@ -1,186 +0,0 @@
|
|
1
|
-
/**
|
2
|
-
* Form validators
|
3
|
-
*
|
4
|
-
* @file form-validators
|
5
|
-
* @description Various form validators
|
6
|
-
* @author Jacques Coetzee
|
7
|
-
* @since 2022 - 01 - 20
|
8
|
-
* @usage Display "errorMessage" key value as validator response message
|
9
|
-
*/
|
10
|
-
|
11
|
-
import { AbstractControl } from '@angular/forms';
|
12
|
-
import passwordValidator from 'password-validator';
|
13
|
-
import dayjs from 'dayjs';
|
14
|
-
import customParseFormat from 'dayjs/plugin/customParseFormat';
|
15
|
-
dayjs.extend(customParseFormat);
|
16
|
-
//--- Interfaces
|
17
|
-
import type { ValidationErrors, ValidatorFn } from '@angular/forms';
|
18
|
-
|
19
|
-
export class CFPFormValidators {
|
20
|
-
/**----------------------------------------------------------------
|
21
|
-
* @name checkPSWRetype
|
22
|
-
* @description Check if passwords match
|
23
|
-
* @param {string} controlNameToCheckAgainst
|
24
|
-
* @returns {ValidatorFn}
|
25
|
-
* @usage FormValidators.compareTo('password')
|
26
|
-
*/
|
27
|
-
static compareTo(controlNameToCheckAgainst: string): ValidatorFn {
|
28
|
-
return (control: AbstractControl): ValidationErrors | null => {
|
29
|
-
//--- Compare controls
|
30
|
-
const controlToCheckTo: AbstractControl | null = control?.parent?.get(controlNameToCheckAgainst) || null;
|
31
|
-
|
32
|
-
//--- Check primary control value
|
33
|
-
if (!controlToCheckTo?.value) return { errorMessage: `Password Required` };
|
34
|
-
//--- Check secondary control value
|
35
|
-
else if (!control.value) return { errorMessage: `Password confirmation required` };
|
36
|
-
//--- Compare controls
|
37
|
-
else if (control.value && control?.value !== controlToCheckTo?.value) return { errorMessage: `Passwords do not match` };
|
38
|
-
|
39
|
-
return null;
|
40
|
-
};
|
41
|
-
}
|
42
|
-
|
43
|
-
/**----------------------------------------------------------------
|
44
|
-
* @name asPassword
|
45
|
-
* @description Validate control as password
|
46
|
-
* @returns {ValidatorFn}
|
47
|
-
* @usage FormValidators.asPassword()
|
48
|
-
*/
|
49
|
-
static asPassword(): ValidatorFn {
|
50
|
-
return (control: AbstractControl): ValidationErrors | null => {
|
51
|
-
const schema = new passwordValidator();
|
52
|
-
|
53
|
-
//--- Setup password requirements
|
54
|
-
schema
|
55
|
-
//--- Minimum length 8
|
56
|
-
.is()
|
57
|
-
.min(8, 'Minimum of 8 characters')
|
58
|
-
//--- Maximum length 50
|
59
|
-
.is()
|
60
|
-
.max(30, 'Maximum of 30 characters')
|
61
|
-
//--- Must have uppercase letters
|
62
|
-
.has()
|
63
|
-
.uppercase(undefined, 'At least one UPPERCASE character')
|
64
|
-
//--- Must have lowercase letters
|
65
|
-
.has()
|
66
|
-
.lowercase(undefined, 'At least one lowercase character')
|
67
|
-
//--- Must have at least 1 digits
|
68
|
-
.has()
|
69
|
-
.digits(undefined, 'At least one digit')
|
70
|
-
//--- Special characters
|
71
|
-
.has()
|
72
|
-
.symbols(undefined, 'At least one special character');
|
73
|
-
|
74
|
-
//--- Validate string
|
75
|
-
const inValid = schema.validate(control.value, { details: true }) as {
|
76
|
-
validation: string;
|
77
|
-
message: string;
|
78
|
-
arguments?: number;
|
79
|
-
}[];
|
80
|
-
|
81
|
-
const returnResponse: { [key: string]: unknown } = {};
|
82
|
-
inValid.forEach((error) => {
|
83
|
-
returnResponse['password-' + error.validation] = error.message;
|
84
|
-
});
|
85
|
-
return inValid.length ? returnResponse : null;
|
86
|
-
};
|
87
|
-
}
|
88
|
-
|
89
|
-
/**----------------------------------------------------------------
|
90
|
-
* @name asEmail
|
91
|
-
* @description Validate control as email
|
92
|
-
* @param {true} canBeEmpty
|
93
|
-
* @returns {ValidatorFn}
|
94
|
-
* @usage FormValidators.asEmail(true?)
|
95
|
-
*/
|
96
|
-
static asEmail(canBeEmpty?: true): ValidatorFn {
|
97
|
-
return (control: AbstractControl): ValidationErrors | null => {
|
98
|
-
let setErrors = null;
|
99
|
-
const emailRegEx = new RegExp('^[\\w-.]+@[\\w]+\\.[\\w]+');
|
100
|
-
|
101
|
-
//--- Check if email can be empty
|
102
|
-
if (canBeEmpty && (control.value === null || control.value === '')) {
|
103
|
-
return null;
|
104
|
-
}
|
105
|
-
|
106
|
-
//--- Test RegExp
|
107
|
-
if (!(control.value && emailRegEx.test(control.value))) {
|
108
|
-
setErrors = { errorMessage: `Not a valid email address` };
|
109
|
-
}
|
110
|
-
|
111
|
-
return setErrors;
|
112
|
-
};
|
113
|
-
}
|
114
|
-
|
115
|
-
/**----------------------------------------------------------------
|
116
|
-
* @name isIn
|
117
|
-
* @description Validate control value is part of a given list
|
118
|
-
* @param {string | number[]} list
|
119
|
-
* @returns {ValidatorFn}
|
120
|
-
* @usage FormValidators.isIn()
|
121
|
-
*/
|
122
|
-
static isIn(list: (string | number)[]): ValidatorFn {
|
123
|
-
return (control: AbstractControl): ValidationErrors | null => {
|
124
|
-
if (!list.includes(control.value)) return { errorMessage: 'Control value not part of eligible values' };
|
125
|
-
return null;
|
126
|
-
};
|
127
|
-
}
|
128
|
-
|
129
|
-
/**----------------------------------------------------------------
|
130
|
-
* @name isSAIDNumber
|
131
|
-
* @description Validate control value is a valid RSA ID Number
|
132
|
-
* @param {true} canBeEmpty
|
133
|
-
* @returns {ValidatorFn}
|
134
|
-
* @usage FormValidators.isSAIDNumber(true?)
|
135
|
-
*/
|
136
|
-
static isSAIDNumber(canBeEmpty?: true): ValidatorFn {
|
137
|
-
return (control: AbstractControl): ValidationErrors | null => {
|
138
|
-
const validateDate = (): boolean => {
|
139
|
-
if (typeof control.value !== 'string' || control.value.length < 6) return false;
|
140
|
-
const month = control.value.slice(2, 4);
|
141
|
-
const day = control.value.slice(4, 6);
|
142
|
-
if (+month < 0 && +month > 13) return false;
|
143
|
-
if (+day < 0 && +day > 31) return false;
|
144
|
-
if (!dayjs(control.value.slice(0, 6), 'YYMMDD', true).isValid()) return false;
|
145
|
-
return true;
|
146
|
-
};
|
147
|
-
|
148
|
-
const checksum = (): boolean => {
|
149
|
-
if (typeof control.value !== 'string' || control.value.length !== 13) return false;
|
150
|
-
let nSum = 0; //--- Total sum of all the values
|
151
|
-
let isSecond = false; //--- To double every other value
|
152
|
-
//--- Start from the end
|
153
|
-
for (let i = control.value.length - 1; i >= 0; i--) {
|
154
|
-
const val: string | undefined = control.value[i];
|
155
|
-
if (!val) return false;
|
156
|
-
//--- Get numerical value from ascii string
|
157
|
-
let d: number = val.charCodeAt(0) - '0'.charCodeAt(0);
|
158
|
-
//--- Double every other value
|
159
|
-
if (isSecond == true) d = d * 2;
|
160
|
-
//--- Sum the total of the doubled values if available
|
161
|
-
nSum += Math.floor(d / 10);
|
162
|
-
nSum += d % 10;
|
163
|
-
//--- Inverse second to determine every other index value
|
164
|
-
isSecond = !isSecond;
|
165
|
-
}
|
166
|
-
//--- Return the modulus 10 of the summation
|
167
|
-
return nSum % 10 == 0;
|
168
|
-
};
|
169
|
-
|
170
|
-
let error: string | null = null;
|
171
|
-
if (canBeEmpty && (!control.value || control.value?.length === 0)) return null;
|
172
|
-
//--- string
|
173
|
-
else if (typeof control.value !== 'string') error = 'Invalid RSA ID Number';
|
174
|
-
//--- Length = 13
|
175
|
-
else if (control.value.length !== 13) error = `Length required: ${13 - control.value.length}`;
|
176
|
-
//--- Validate date
|
177
|
-
else if (!validateDate()) error = `Invalid date of birth`;
|
178
|
-
//--- Citizenship
|
179
|
-
else if (!['0', '1'].includes(control.value.slice(10, 11))) error = `Invalid citizenship value`;
|
180
|
-
//--- Checksum
|
181
|
-
else if (!checksum()) error = `Invalid RSA ID number checksum`;
|
182
|
-
|
183
|
-
return error ? { errorMessage: error } : null;
|
184
|
-
};
|
185
|
-
}
|
186
|
-
}
|
package/tsconfig.lib.json
DELETED
@@ -1,12 +0,0 @@
|
|
1
|
-
/* To learn more about this file see: https://angular.io/config/tsconfig. */
|
2
|
-
{
|
3
|
-
"extends": "../../../tsconfig.json",
|
4
|
-
"compilerOptions": {
|
5
|
-
"outDir": "../../../out-tsc/lib",
|
6
|
-
"declaration": true,
|
7
|
-
"declarationMap": true,
|
8
|
-
"inlineSources": true,
|
9
|
-
"types": []
|
10
|
-
},
|
11
|
-
"exclude": ["**/*.spec.ts"]
|
12
|
-
}
|
package/tsconfig.lib.prod.json
DELETED
package/tsconfig.spec.json
DELETED
@@ -1,14 +0,0 @@
|
|
1
|
-
/* To learn more about this file see: https://angular.io/config/tsconfig. */
|
2
|
-
{
|
3
|
-
"extends": "../../../tsconfig.json",
|
4
|
-
"compilerOptions": {
|
5
|
-
"outDir": "../../../out-tsc/spec",
|
6
|
-
"types": [
|
7
|
-
"jasmine"
|
8
|
-
]
|
9
|
-
},
|
10
|
-
"include": [
|
11
|
-
"**/*.spec.ts",
|
12
|
-
"**/*.d.ts"
|
13
|
-
]
|
14
|
-
}
|