@theseam/ui-common 1.0.2-beta.39 → 1.0.2-beta.42
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/fesm2022/theseam-ui-common-framework.mjs +276 -7
- package/fesm2022/theseam-ui-common-framework.mjs.map +1 -1
- package/fesm2022/theseam-ui-common-validators.mjs +46 -28
- package/fesm2022/theseam-ui-common-validators.mjs.map +1 -1
- package/framework/index.d.ts +122 -6
- package/package.json +1 -1
- package/validators/index.d.ts +17 -11
|
@@ -1,19 +1,21 @@
|
|
|
1
|
+
import { isEmptyInputValue, isNumeric } from '@theseam/ui-common/utils';
|
|
1
2
|
import { isObservable } from 'rxjs';
|
|
2
3
|
import { map } from 'rxjs/operators';
|
|
3
4
|
import { Validators } from '@angular/forms';
|
|
4
|
-
import { isEmptyInputValue, isNumeric } from '@theseam/ui-common/utils';
|
|
5
5
|
|
|
6
|
+
const TAX_ID_PATTERN = /^\d{9}$|^\d{2}-\d{7}$|^\d{3}-\d{2}-\d{4}$/;
|
|
6
7
|
/**
|
|
7
|
-
* Validates that value matches
|
|
8
|
-
* '' // empty string
|
|
8
|
+
* Validates that value matches one of the following:
|
|
9
9
|
* 'xxxxxxxxx' // 'x' is a number
|
|
10
10
|
* 'xx-xxxxxxx' // 'x' is a number
|
|
11
11
|
* 'xxx-xx-xxxx' // 'x' is a number
|
|
12
12
|
*/
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
}
|
|
13
|
+
const taxIdValidator = (control) => {
|
|
14
|
+
if (isEmptyInputValue(control.value)) {
|
|
15
|
+
return null;
|
|
16
|
+
}
|
|
17
|
+
return TAX_ID_PATTERN.test(control.value) ? null : { taxId: {} };
|
|
18
|
+
};
|
|
17
19
|
|
|
18
20
|
/**
|
|
19
21
|
* Validates that an email already exists.
|
|
@@ -31,61 +33,77 @@ function emailExistsValidator(emailExists) {
|
|
|
31
33
|
};
|
|
32
34
|
}
|
|
33
35
|
|
|
36
|
+
const DEFAULT_CONFIG$2 = {
|
|
37
|
+
minLength: 7,
|
|
38
|
+
maxLength: 18,
|
|
39
|
+
};
|
|
34
40
|
/**
|
|
35
41
|
* Validates that a value is a valid phone number length.
|
|
36
42
|
*/
|
|
37
|
-
function phoneLengthValidator(
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
43
|
+
function phoneLengthValidator(config) {
|
|
44
|
+
const c = { ...DEFAULT_CONFIG$2, ...config };
|
|
45
|
+
return (control) => {
|
|
46
|
+
if (isEmptyInputValue(control.value)) {
|
|
47
|
+
return null;
|
|
48
|
+
}
|
|
49
|
+
return control.value.length <= c.maxLength &&
|
|
50
|
+
control.value.length >= c.minLength
|
|
51
|
+
? null
|
|
52
|
+
: { phoneLength: {} };
|
|
53
|
+
};
|
|
42
54
|
}
|
|
43
55
|
|
|
44
56
|
const DECIMAL_REGEX = /^([-+]{1})?\d*(\.\d*)?$/;
|
|
45
|
-
|
|
57
|
+
const DEFAULT_CONFIG$1 = {
|
|
58
|
+
regex: DECIMAL_REGEX,
|
|
59
|
+
};
|
|
60
|
+
/**
|
|
61
|
+
* Validates control value is a valid decimal number.
|
|
62
|
+
*
|
|
63
|
+
* NOTE: This does not allow any js valid decimal number. It only accepts them
|
|
64
|
+
* in a format expected by our backend.
|
|
65
|
+
*/
|
|
66
|
+
function decimalValidator(config) {
|
|
67
|
+
const c = { ...DEFAULT_CONFIG$1, ...config };
|
|
46
68
|
return (control) => {
|
|
47
69
|
if (isEmptyInputValue(control.value)) {
|
|
48
70
|
return null; // don't validate empty values to allow optional controls
|
|
49
71
|
}
|
|
50
72
|
const isDecimal = !Array.isArray(control.value) &&
|
|
51
73
|
isNumeric(control.value) &&
|
|
52
|
-
Validators.pattern(
|
|
74
|
+
Validators.pattern(c.regex)(control) === null;
|
|
53
75
|
if (!isDecimal) {
|
|
54
76
|
return { decimal: { reason: 'Must be valid decimal number.' } };
|
|
55
77
|
}
|
|
56
78
|
return null;
|
|
57
79
|
};
|
|
58
80
|
}
|
|
81
|
+
|
|
82
|
+
const INTEGER_REGEX = /^([-+]{1})?[0-9]*$/;
|
|
83
|
+
const DEFAULT_CONFIG = {
|
|
84
|
+
regex: INTEGER_REGEX,
|
|
85
|
+
};
|
|
59
86
|
/**
|
|
60
|
-
* Validates control value is a valid
|
|
87
|
+
* Validates control value is a valid integer number.
|
|
61
88
|
*
|
|
62
|
-
* NOTE: This does not allow any js valid
|
|
89
|
+
* NOTE: This does not allow any js valid integer number. It only accepts them
|
|
63
90
|
* in a format expected by our backend.
|
|
64
91
|
*/
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
const INTEGER_REGEX = /^([-+]{1})?[0-9]*$/;
|
|
68
|
-
function _integerValidator() {
|
|
92
|
+
function integerValidator(config) {
|
|
93
|
+
const c = { ...DEFAULT_CONFIG, ...config };
|
|
69
94
|
return (control) => {
|
|
70
95
|
if (isEmptyInputValue(control.value)) {
|
|
71
96
|
return null; // don't validate empty values to allow optional controls
|
|
72
97
|
}
|
|
73
98
|
const isInteger = !Array.isArray(control.value) &&
|
|
74
99
|
isNumeric(control.value) &&
|
|
75
|
-
Validators.pattern(
|
|
100
|
+
Validators.pattern(c.regex)(control) === null;
|
|
76
101
|
if (!isInteger) {
|
|
77
102
|
return { integer: { reason: 'Must be valid integer.' } };
|
|
78
103
|
}
|
|
79
104
|
return null;
|
|
80
105
|
};
|
|
81
106
|
}
|
|
82
|
-
/**
|
|
83
|
-
* Validates control value is a valid integer number.
|
|
84
|
-
*
|
|
85
|
-
* NOTE: This does not allow any js valid integer number. It only accepts them
|
|
86
|
-
* in a format expected by our backend.
|
|
87
|
-
*/
|
|
88
|
-
const integerValidator = _integerValidator();
|
|
89
107
|
|
|
90
108
|
/**
|
|
91
109
|
* Generated bundle index. Do not edit.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"theseam-ui-common-validators.mjs","sources":["../../../projects/ui-common/validators/tax-id.validator.ts","../../../projects/ui-common/validators/email-exists.validator.ts","../../../projects/ui-common/validators/phone-length.validator.ts","../../../projects/ui-common/validators/decimal.validator.ts","../../../projects/ui-common/validators/integer.validator.ts","../../../projects/ui-common/validators/theseam-ui-common-validators.ts"],"sourcesContent":["import {
|
|
1
|
+
{"version":3,"file":"theseam-ui-common-validators.mjs","sources":["../../../projects/ui-common/validators/tax-id.validator.ts","../../../projects/ui-common/validators/email-exists.validator.ts","../../../projects/ui-common/validators/phone-length.validator.ts","../../../projects/ui-common/validators/decimal.validator.ts","../../../projects/ui-common/validators/integer.validator.ts","../../../projects/ui-common/validators/theseam-ui-common-validators.ts"],"sourcesContent":["import { AbstractControl, ValidatorFn } from '@angular/forms'\n\nimport { isEmptyInputValue } from '@theseam/ui-common/utils'\n\nconst TAX_ID_PATTERN = /^\\d{9}$|^\\d{2}-\\d{7}$|^\\d{3}-\\d{2}-\\d{4}$/\n\n/**\n * Validates that value matches one of the following:\n * 'xxxxxxxxx' // 'x' is a number\n * 'xx-xxxxxxx' // 'x' is a number\n * 'xxx-xx-xxxx' // 'x' is a number\n */\nexport const taxIdValidator: ValidatorFn = (control: AbstractControl) => {\n if (isEmptyInputValue(control.value)) {\n return null\n }\n return TAX_ID_PATTERN.test(control.value) ? null : { taxId: {} }\n}\n","import { FormControl } from '@angular/forms'\nimport { isObservable, Observable } from 'rxjs'\nimport { map } from 'rxjs/operators'\n\n/**\n * Validates that an email already exists.\n */\nexport function emailExistsValidator(\n emailExists: (\n email: string,\n ) => Promise<boolean> | Observable<boolean> | boolean,\n) {\n return (control: FormControl) => {\n const validationResult = (exists: boolean) => {\n return exists === false ? null : { emailExists: {} }\n }\n\n const fnRes = emailExists(control.value)\n if (isObservable(fnRes)) {\n return fnRes.pipe(map(validationResult))\n }\n return Promise.resolve(fnRes).then(validationResult)\n }\n}\n","import { AbstractControl, ValidatorFn } from '@angular/forms'\n\nimport { isEmptyInputValue } from '@theseam/ui-common/utils'\n\nexport interface TheSeamPhoneLengthConfig {\n minLength: number\n maxLength: number\n}\n\nconst DEFAULT_CONFIG: TheSeamPhoneLengthConfig = {\n minLength: 7,\n maxLength: 18,\n}\n\n/**\n * Validates that a value is a valid phone number length.\n */\nexport function phoneLengthValidator(\n config?: Partial<TheSeamPhoneLengthConfig>,\n): ValidatorFn {\n const c = { ...DEFAULT_CONFIG, ...config }\n return (control: AbstractControl) => {\n if (isEmptyInputValue(control.value)) {\n return null\n }\n return control.value.length <= c.maxLength &&\n control.value.length >= c.minLength\n ? null\n : { phoneLength: {} }\n }\n}\n","import { AbstractControl, ValidatorFn, Validators } from '@angular/forms'\n\nimport { isEmptyInputValue, isNumeric } from '@theseam/ui-common/utils'\n\nexport const DECIMAL_REGEX = /^([-+]{1})?\\d*(\\.\\d*)?$/\n\nexport interface TheSeamDecimalConfig {\n regex: RegExp\n}\n\nconst DEFAULT_CONFIG: TheSeamDecimalConfig = {\n regex: DECIMAL_REGEX,\n}\n\n/**\n * Validates control value is a valid decimal number.\n *\n * NOTE: This does not allow any js valid decimal number. It only accepts them\n * in a format expected by our backend.\n */\nexport function decimalValidator(\n config?: Partial<TheSeamDecimalConfig>,\n): ValidatorFn {\n const c = { ...DEFAULT_CONFIG, ...config }\n return (control: AbstractControl) => {\n if (isEmptyInputValue(control.value)) {\n return null // don't validate empty values to allow optional controls\n }\n\n const isDecimal =\n !Array.isArray(control.value) &&\n isNumeric(control.value) &&\n Validators.pattern(c.regex)(control) === null\n\n if (!isDecimal) {\n return { decimal: { reason: 'Must be valid decimal number.' } }\n }\n\n return null\n }\n}\n","import { AbstractControl, ValidatorFn, Validators } from '@angular/forms'\n\nimport { isEmptyInputValue, isNumeric } from '@theseam/ui-common/utils'\n\nexport const INTEGER_REGEX = /^([-+]{1})?[0-9]*$/\n\nexport interface TheSeamIntegerConfig {\n regex: RegExp\n}\n\nconst DEFAULT_CONFIG: TheSeamIntegerConfig = {\n regex: INTEGER_REGEX,\n}\n\n/**\n * Validates control value is a valid integer number.\n *\n * NOTE: This does not allow any js valid integer number. It only accepts them\n * in a format expected by our backend.\n */\nexport function integerValidator(\n config?: Partial<TheSeamIntegerConfig>,\n): ValidatorFn {\n const c = { ...DEFAULT_CONFIG, ...config }\n return (control: AbstractControl) => {\n if (isEmptyInputValue(control.value)) {\n return null // don't validate empty values to allow optional controls\n }\n\n const isInteger =\n !Array.isArray(control.value) &&\n isNumeric(control.value) &&\n Validators.pattern(c.regex)(control) === null\n\n if (!isInteger) {\n return { integer: { reason: 'Must be valid integer.' } }\n }\n return null\n }\n}\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './public-api';\n"],"names":["DEFAULT_CONFIG"],"mappings":"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"}
|
package/framework/index.d.ts
CHANGED
|
@@ -1,8 +1,9 @@
|
|
|
1
|
+
import { ValidatorFn, AsyncValidatorFn, FormControl, FormGroup, AbstractControl } from '@angular/forms';
|
|
1
2
|
import * as i0 from '@angular/core';
|
|
2
|
-
import { ElementRef, TemplateRef, OnInit, InjectionToken, OnDestroy, EventEmitter, ComponentRef, EmbeddedViewRef, AfterViewInit, QueryList, ViewContainerRef, AfterContentInit } from '@angular/core';
|
|
3
|
-
import { HasElementRef, CanDisableCtor } from '@theseam/ui-common/core';
|
|
3
|
+
import { DestroyRef, ElementRef, TemplateRef, OnInit, InjectionToken, OnDestroy, EventEmitter, ComponentRef, EmbeddedViewRef, AfterViewInit, QueryList, ViewContainerRef, AfterContentInit } from '@angular/core';
|
|
4
4
|
import * as rxjs from 'rxjs';
|
|
5
|
-
import { Observable, Subject, BehaviorSubject } from 'rxjs';
|
|
5
|
+
import { Observable, Subscription, Subject, BehaviorSubject } from 'rxjs';
|
|
6
|
+
import { HasElementRef, CanDisableCtor } from '@theseam/ui-common/core';
|
|
6
7
|
import * as _fortawesome_fontawesome_common_types from '@fortawesome/fontawesome-common-types';
|
|
7
8
|
import { TemplatePortal, ComponentType, ComponentPortal, BasePortalOutlet, Portal, CdkPortalOutletAttachedRef } from '@angular/cdk/portal';
|
|
8
9
|
import { MediaQueryAliases, TheSeamLayoutService } from '@theseam/ui-common/layout';
|
|
@@ -18,9 +19,124 @@ import * as _angular_animations from '@angular/animations';
|
|
|
18
19
|
import * as i2 from '@angular/common';
|
|
19
20
|
import * as i2$1 from '@ajsf/core';
|
|
20
21
|
import { JsonSchemaFormService, isArray, TitleMapItem, Framework } from '@ajsf/core';
|
|
21
|
-
import { AbstractControl } from '@angular/forms';
|
|
22
22
|
import { TheSeamTiledSelectItem, TheSeamTiledSelectLayout } from '@theseam/ui-common/tiled-select';
|
|
23
23
|
|
|
24
|
+
interface TheSeamControlValidators {
|
|
25
|
+
validators: ValidatorFn[];
|
|
26
|
+
asyncValidators: AsyncValidatorFn[];
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
interface TheSeamValidatorOverrides {
|
|
30
|
+
/**
|
|
31
|
+
* Include `Validators.required`. Set to `false` to exclude it.
|
|
32
|
+
*
|
|
33
|
+
* default: true
|
|
34
|
+
*/
|
|
35
|
+
required?: boolean;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
interface TheSeamAddressFieldConfig {
|
|
39
|
+
address1MaxLength: number;
|
|
40
|
+
address2MaxLength: number;
|
|
41
|
+
cityMaxLength: number;
|
|
42
|
+
stateMaxLength: number;
|
|
43
|
+
countryMaxLength: number;
|
|
44
|
+
zipcodePattern: RegExp;
|
|
45
|
+
}
|
|
46
|
+
declare const DEFAULT_ADDRESS_FIELD_CONFIG: TheSeamAddressFieldConfig;
|
|
47
|
+
|
|
48
|
+
interface TheSeamUsernameFieldConfig {
|
|
49
|
+
minLength: number;
|
|
50
|
+
pattern: RegExp;
|
|
51
|
+
}
|
|
52
|
+
declare const DEFAULT_USERNAME_FIELD_CONFIG: TheSeamUsernameFieldConfig;
|
|
53
|
+
|
|
54
|
+
interface TheSeamCreateCountryControlOptions {
|
|
55
|
+
/**
|
|
56
|
+
* Only allow 'USA' as the value.
|
|
57
|
+
*
|
|
58
|
+
* default: false
|
|
59
|
+
*/
|
|
60
|
+
onlyAllowUsa?: boolean;
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
interface TheSeamAddressFormValue {
|
|
64
|
+
address1: string | null;
|
|
65
|
+
address2: string | null;
|
|
66
|
+
city: string | null;
|
|
67
|
+
state: string | null;
|
|
68
|
+
zip: string | null;
|
|
69
|
+
country: string | null;
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
interface TheSeamAddressFormGroupOptions {
|
|
73
|
+
config?: Partial<TheSeamAddressFieldConfig>;
|
|
74
|
+
stateCodes: Observable<string[]>;
|
|
75
|
+
/** default: true */
|
|
76
|
+
countryRequiredOutsideUSA?: boolean;
|
|
77
|
+
/** default: 'USA' */
|
|
78
|
+
defaultCountry?: string;
|
|
79
|
+
/** If provided, country-change subscription is auto-cleaned up. */
|
|
80
|
+
destroyRef?: DestroyRef;
|
|
81
|
+
}
|
|
82
|
+
type TheSeamAddressFormControls = Record<keyof TheSeamAddressFormValue, FormControl<string | null>>;
|
|
83
|
+
type TheSeamAddressFormGroupResult<T extends TheSeamAddressFormGroupOptions> = T extends {
|
|
84
|
+
destroyRef: DestroyRef;
|
|
85
|
+
} ? FormGroup<TheSeamAddressFormControls> : {
|
|
86
|
+
group: FormGroup<TheSeamAddressFormControls>;
|
|
87
|
+
subscription: Subscription;
|
|
88
|
+
};
|
|
89
|
+
|
|
90
|
+
declare function isCountryUSA(control: AbstractControl): boolean;
|
|
91
|
+
|
|
92
|
+
/**
|
|
93
|
+
* Use Validator if 'country' control value is 'USA'.
|
|
94
|
+
*
|
|
95
|
+
* If `countryControlOrPath` is not provided, it will be assumed there is a
|
|
96
|
+
* sibling named 'country'.
|
|
97
|
+
*/
|
|
98
|
+
declare function ifUSA(fn: ValidatorFn, countryControlOrPath?: AbstractControl | string | (string | number)[]): ValidatorFn;
|
|
99
|
+
|
|
100
|
+
declare function stateProvinceRegionValidator(stateCodes: Observable<string[]>): AsyncValidatorFn;
|
|
101
|
+
|
|
102
|
+
type TheSeamUserExistsFn = (userName: string) => Promise<boolean> | Observable<boolean> | boolean;
|
|
103
|
+
/**
|
|
104
|
+
* Validates that a username already exists.
|
|
105
|
+
*
|
|
106
|
+
* Mirrors the `emailExistsValidator` pattern from `@theseam/ui-common/validators`.
|
|
107
|
+
*/
|
|
108
|
+
declare function usernameExistsValidator(userExists: TheSeamUserExistsFn): AsyncValidatorFn;
|
|
109
|
+
|
|
110
|
+
declare function getAddress1Validators(config?: Partial<TheSeamAddressFieldConfig>, overrides?: TheSeamValidatorOverrides): TheSeamControlValidators;
|
|
111
|
+
|
|
112
|
+
declare function getAddress2Validators(config?: Partial<TheSeamAddressFieldConfig>, overrides?: TheSeamValidatorOverrides): TheSeamControlValidators;
|
|
113
|
+
|
|
114
|
+
declare function getCityValidators(config?: Partial<TheSeamAddressFieldConfig>, overrides?: TheSeamValidatorOverrides): TheSeamControlValidators;
|
|
115
|
+
|
|
116
|
+
declare function getCountryValidators(config?: Partial<TheSeamAddressFieldConfig>, options?: TheSeamCreateCountryControlOptions, overrides?: TheSeamValidatorOverrides): TheSeamControlValidators;
|
|
117
|
+
|
|
118
|
+
declare function getStateValidators(stateCodes: Observable<string[]>, countryControlOrPath?: AbstractControl | string | (string | number)[], requiredOutsideUSA?: boolean, config?: Partial<TheSeamAddressFieldConfig>): TheSeamControlValidators;
|
|
119
|
+
|
|
120
|
+
declare function getZipValidators(countryControlOrPath?: AbstractControl | string | (string | number)[], config?: Partial<TheSeamAddressFieldConfig>): TheSeamControlValidators;
|
|
121
|
+
|
|
122
|
+
declare function getUsernameValidators(userExists: TheSeamUserExistsFn, config?: Partial<TheSeamUsernameFieldConfig>, overrides?: TheSeamValidatorOverrides): TheSeamControlValidators;
|
|
123
|
+
|
|
124
|
+
declare function createAddress1Control(formState?: string | null, config?: Partial<TheSeamAddressFieldConfig>, overrides?: TheSeamValidatorOverrides): FormControl<string | null>;
|
|
125
|
+
|
|
126
|
+
declare function createAddress2Control(formState?: string | null, config?: Partial<TheSeamAddressFieldConfig>, overrides?: TheSeamValidatorOverrides): FormControl<string | null>;
|
|
127
|
+
|
|
128
|
+
declare function createCityControl(formState?: string | null, config?: Partial<TheSeamAddressFieldConfig>, overrides?: TheSeamValidatorOverrides): FormControl<string | null>;
|
|
129
|
+
|
|
130
|
+
declare function createCountryControl(formState?: string | null, options?: TheSeamCreateCountryControlOptions, overrides?: TheSeamValidatorOverrides): FormControl<string | null>;
|
|
131
|
+
|
|
132
|
+
declare function createStateControl(formState: string | null | undefined, stateCodes: Observable<string[]>, requiredOutsideUSA?: boolean): FormControl<string | null>;
|
|
133
|
+
|
|
134
|
+
declare function createZipControl(formState?: string | null): FormControl<string | null>;
|
|
135
|
+
|
|
136
|
+
declare function createUsernameControl(formState: string | null | undefined, userExists: TheSeamUserExistsFn, config?: Partial<TheSeamUsernameFieldConfig>, overrides?: TheSeamValidatorOverrides): FormControl<string | null>;
|
|
137
|
+
|
|
138
|
+
declare function createAddressFormGroup<T extends TheSeamAddressFormGroupOptions>(options: T): TheSeamAddressFormGroupResult<T>;
|
|
139
|
+
|
|
24
140
|
declare class BaseLayoutContentFooterDirective implements HasElementRef {
|
|
25
141
|
readonly _elementRef: ElementRef<any>;
|
|
26
142
|
static ɵfac: i0.ɵɵFactoryDeclaration<BaseLayoutContentFooterDirective, never>;
|
|
@@ -1454,5 +1570,5 @@ declare class SeamRouteShellComponent {
|
|
|
1454
1570
|
static ɵcmp: i0.ɵɵComponentDeclaration<SeamRouteShellComponent, "seam-route-shell", never, {}, {}, never, never, true, never>;
|
|
1455
1571
|
}
|
|
1456
1572
|
|
|
1457
|
-
export { BaseLayoutContentDirective, BaseLayoutContentFooterDirective, BaseLayoutContentHeaderDirective, BaseLayoutSideBarDirective, BaseLayoutSideBarFooterDirective, BaseLayoutSideBarHeaderDirective, BaseLayoutTopBarDirective, DEFAULT_SIDE_NAV_CONFIG, DashboardComponent, DashboardWidgetContainerComponent, DashboardWidgetPortalOutletDirective, DashboardWidgetTemplateContainerComponent, DashboardWidgetsComponent, DashboardWidgetsPreferencesService, DashboardWidgetsService, HierarchyLevelResolver, HierarchyRouterOutletComponent, HorizontalNavComponent, NavItemComponent, SeamRouteShellComponent, SideNavComponent, SideNavItemComponent, SideNavToggleComponent, THESEAM_BASE_LAYOUT_REF, THESEAM_DASHBOARD_WIDGETS_PREFERENCES_ACCESSOR, THESEAM_SCHEMA_FRAMEWORK_OVERRIDES, THESEAM_SIDE_NAV_ACCESSOR, THESEAM_SIDE_NAV_CONFIG, THE_SEAM_BASE_LAYOUT, TheSeamBaseLayoutComponent, TheSeamBaseLayoutModule, TheSeamBaseLayoutNavToggleDirective, TheSeamDashboardModule, TheSeamDynamicRouterModule, TheSeamFramework, TheSeamNavModule, TheSeamSchemaFormFrameworkComponent, TheSeamSchemaFormModule, TheSeamSideNavModule, TheSeamTopBarComponent, TheSeamTopBarModule, TopBarCompactMenuBtnDetailDirective, TopBarItemDirective, TopBarMenuBtnDetailDirective, TopBarMenuButtonComponent, TopBarMenuDirective, TopBarNavToggleBtnDetailDirective, TopBarTitleComponent, applyItemConfig, areSameHorizontalNavItem, canBeActive, canExpand, canHaveChildren, computeDirection, extendFramework, fader, findHorizontalNavLinkItems, findLinkItems, getHorizontalNavItemStateProp, getItemStateProp, getUrlSegments, hasActiveChild, hasChildren, hasExpandedChild, horizontalNavItemCanBeActive, horizontalNavItemCanExpand, horizontalNavItemCanHaveChildren, horizontalNavItemHasActiveChild, horizontalNavItemHasChildren, horizontalNavItemHasExpandedChild, isExpanded, isHorizontalNavItemActive, isHorizontalNavItemExpanded, isHorizontalNavItemFocused, isHorizontalNavItemType, isNavItemActive, isNavItemType, routeChanges, seamRouteTransition, setDefaultHorizontalNavItemState, setDefaultState, setHorizontalNavItemStateProp, setItemStateProp, sideNavExpandStateChangeFn, sideToSide, slider, stepper, transformer };
|
|
1458
|
-
export type { IDashboardWidgetItemLayout, IDashboardWidgetItemLayoutPreference, IDashboardWidgetsColumnRecord, IDashboardWidgetsItem, IDashboardWidgetsItemDef, IDashboardWidgetsItemSerialized, IDashboardWidgetsPreferences, IDashboardWidgetsPreferencesMapRecord, IDynamicRouteDef, INavBadge, INavBasic, INavButton, INavDivider, INavItem, INavItemBase, INavItemState, INavLink, INavTitle, ISideNavBadge, ISideNavBasic, ISideNavButton, ISideNavDivider, ISideNavItem, ISideNavItemBase, ISideNavItemState, ISideNavLink, ISideNavTitle, ITheSeamDashboardWidgetsPreferencesAccessor, NavItemBadgeTooltip, NavItemCanHaveChildren, NavItemCanHaveState, NavItemChildAction, NavItemExpandAction, NavItemExpandedEvent, NavItemStateChanged, RouteDirection, SideNavAccessor, SideNavConfig, SideNavItemBadgeTooltip, SideNavItemCanBeActive, SideNavItemCanHaveChildren, SideNavItemCanHaveState, SideNavItemMenuItemTooltipBehavior, SideNavItemMenuItemTooltipConfig, SideNavItemStateChanged, TheSeamBaseLayoutAction, TheSeamBaseLayoutActionBase, TheSeamBaseLayoutActionButton, TheSeamBaseLayoutActionHref, TheSeamBaseLayoutActionRouterLink, TheSeamBaseLayoutActionTemplate, TheSeamBaseLayoutNav, TheSeamBaseLayoutRef, TheSeamSchemaFormControlWidget, TheSeamSchemaFormFrameworkOverrides, TheSeamSchemaFormWidget, TheSeamSchemaFormWidgetLayoutNodeOptions, TopBarPosition };
|
|
1573
|
+
export { BaseLayoutContentDirective, BaseLayoutContentFooterDirective, BaseLayoutContentHeaderDirective, BaseLayoutSideBarDirective, BaseLayoutSideBarFooterDirective, BaseLayoutSideBarHeaderDirective, BaseLayoutTopBarDirective, DEFAULT_ADDRESS_FIELD_CONFIG, DEFAULT_SIDE_NAV_CONFIG, DEFAULT_USERNAME_FIELD_CONFIG, DashboardComponent, DashboardWidgetContainerComponent, DashboardWidgetPortalOutletDirective, DashboardWidgetTemplateContainerComponent, DashboardWidgetsComponent, DashboardWidgetsPreferencesService, DashboardWidgetsService, HierarchyLevelResolver, HierarchyRouterOutletComponent, HorizontalNavComponent, NavItemComponent, SeamRouteShellComponent, SideNavComponent, SideNavItemComponent, SideNavToggleComponent, THESEAM_BASE_LAYOUT_REF, THESEAM_DASHBOARD_WIDGETS_PREFERENCES_ACCESSOR, THESEAM_SCHEMA_FRAMEWORK_OVERRIDES, THESEAM_SIDE_NAV_ACCESSOR, THESEAM_SIDE_NAV_CONFIG, THE_SEAM_BASE_LAYOUT, TheSeamBaseLayoutComponent, TheSeamBaseLayoutModule, TheSeamBaseLayoutNavToggleDirective, TheSeamDashboardModule, TheSeamDynamicRouterModule, TheSeamFramework, TheSeamNavModule, TheSeamSchemaFormFrameworkComponent, TheSeamSchemaFormModule, TheSeamSideNavModule, TheSeamTopBarComponent, TheSeamTopBarModule, TopBarCompactMenuBtnDetailDirective, TopBarItemDirective, TopBarMenuBtnDetailDirective, TopBarMenuButtonComponent, TopBarMenuDirective, TopBarNavToggleBtnDetailDirective, TopBarTitleComponent, applyItemConfig, areSameHorizontalNavItem, canBeActive, canExpand, canHaveChildren, computeDirection, createAddress1Control, createAddress2Control, createAddressFormGroup, createCityControl, createCountryControl, createStateControl, createUsernameControl, createZipControl, extendFramework, fader, findHorizontalNavLinkItems, findLinkItems, getAddress1Validators, getAddress2Validators, getCityValidators, getCountryValidators, getHorizontalNavItemStateProp, getItemStateProp, getStateValidators, getUrlSegments, getUsernameValidators, getZipValidators, hasActiveChild, hasChildren, hasExpandedChild, horizontalNavItemCanBeActive, horizontalNavItemCanExpand, horizontalNavItemCanHaveChildren, horizontalNavItemHasActiveChild, horizontalNavItemHasChildren, horizontalNavItemHasExpandedChild, ifUSA, isCountryUSA, isExpanded, isHorizontalNavItemActive, isHorizontalNavItemExpanded, isHorizontalNavItemFocused, isHorizontalNavItemType, isNavItemActive, isNavItemType, routeChanges, seamRouteTransition, setDefaultHorizontalNavItemState, setDefaultState, setHorizontalNavItemStateProp, setItemStateProp, sideNavExpandStateChangeFn, sideToSide, slider, stateProvinceRegionValidator, stepper, transformer, usernameExistsValidator };
|
|
1574
|
+
export type { IDashboardWidgetItemLayout, IDashboardWidgetItemLayoutPreference, IDashboardWidgetsColumnRecord, IDashboardWidgetsItem, IDashboardWidgetsItemDef, IDashboardWidgetsItemSerialized, IDashboardWidgetsPreferences, IDashboardWidgetsPreferencesMapRecord, IDynamicRouteDef, INavBadge, INavBasic, INavButton, INavDivider, INavItem, INavItemBase, INavItemState, INavLink, INavTitle, ISideNavBadge, ISideNavBasic, ISideNavButton, ISideNavDivider, ISideNavItem, ISideNavItemBase, ISideNavItemState, ISideNavLink, ISideNavTitle, ITheSeamDashboardWidgetsPreferencesAccessor, NavItemBadgeTooltip, NavItemCanHaveChildren, NavItemCanHaveState, NavItemChildAction, NavItemExpandAction, NavItemExpandedEvent, NavItemStateChanged, RouteDirection, SideNavAccessor, SideNavConfig, SideNavItemBadgeTooltip, SideNavItemCanBeActive, SideNavItemCanHaveChildren, SideNavItemCanHaveState, SideNavItemMenuItemTooltipBehavior, SideNavItemMenuItemTooltipConfig, SideNavItemStateChanged, TheSeamAddressFieldConfig, TheSeamAddressFormControls, TheSeamAddressFormGroupOptions, TheSeamAddressFormGroupResult, TheSeamAddressFormValue, TheSeamBaseLayoutAction, TheSeamBaseLayoutActionBase, TheSeamBaseLayoutActionButton, TheSeamBaseLayoutActionHref, TheSeamBaseLayoutActionRouterLink, TheSeamBaseLayoutActionTemplate, TheSeamBaseLayoutNav, TheSeamBaseLayoutRef, TheSeamControlValidators, TheSeamCreateCountryControlOptions, TheSeamSchemaFormControlWidget, TheSeamSchemaFormFrameworkOverrides, TheSeamSchemaFormWidget, TheSeamSchemaFormWidgetLayoutNodeOptions, TheSeamUserExistsFn, TheSeamUsernameFieldConfig, TheSeamValidatorOverrides, TopBarPosition };
|
package/package.json
CHANGED
package/validators/index.d.ts
CHANGED
|
@@ -1,16 +1,13 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { ValidatorFn, FormControl } from '@angular/forms';
|
|
2
2
|
import { Observable } from 'rxjs';
|
|
3
3
|
|
|
4
4
|
/**
|
|
5
|
-
* Validates that value matches
|
|
6
|
-
* '' // empty string
|
|
5
|
+
* Validates that value matches one of the following:
|
|
7
6
|
* 'xxxxxxxxx' // 'x' is a number
|
|
8
7
|
* 'xx-xxxxxxx' // 'x' is a number
|
|
9
8
|
* 'xxx-xx-xxxx' // 'x' is a number
|
|
10
9
|
*/
|
|
11
|
-
declare
|
|
12
|
-
taxId: {};
|
|
13
|
-
} | null;
|
|
10
|
+
declare const taxIdValidator: ValidatorFn;
|
|
14
11
|
|
|
15
12
|
/**
|
|
16
13
|
* Validates that an email already exists.
|
|
@@ -21,29 +18,38 @@ declare function emailExistsValidator(emailExists: (email: string) => Promise<bo
|
|
|
21
18
|
emailExists: {};
|
|
22
19
|
} | null>;
|
|
23
20
|
|
|
21
|
+
interface TheSeamPhoneLengthConfig {
|
|
22
|
+
minLength: number;
|
|
23
|
+
maxLength: number;
|
|
24
|
+
}
|
|
24
25
|
/**
|
|
25
26
|
* Validates that a value is a valid phone number length.
|
|
26
27
|
*/
|
|
27
|
-
declare function phoneLengthValidator(
|
|
28
|
-
phoneLength: {};
|
|
29
|
-
} | null;
|
|
28
|
+
declare function phoneLengthValidator(config?: Partial<TheSeamPhoneLengthConfig>): ValidatorFn;
|
|
30
29
|
|
|
31
30
|
declare const DECIMAL_REGEX: RegExp;
|
|
31
|
+
interface TheSeamDecimalConfig {
|
|
32
|
+
regex: RegExp;
|
|
33
|
+
}
|
|
32
34
|
/**
|
|
33
35
|
* Validates control value is a valid decimal number.
|
|
34
36
|
*
|
|
35
37
|
* NOTE: This does not allow any js valid decimal number. It only accepts them
|
|
36
38
|
* in a format expected by our backend.
|
|
37
39
|
*/
|
|
38
|
-
declare
|
|
40
|
+
declare function decimalValidator(config?: Partial<TheSeamDecimalConfig>): ValidatorFn;
|
|
39
41
|
|
|
40
42
|
declare const INTEGER_REGEX: RegExp;
|
|
43
|
+
interface TheSeamIntegerConfig {
|
|
44
|
+
regex: RegExp;
|
|
45
|
+
}
|
|
41
46
|
/**
|
|
42
47
|
* Validates control value is a valid integer number.
|
|
43
48
|
*
|
|
44
49
|
* NOTE: This does not allow any js valid integer number. It only accepts them
|
|
45
50
|
* in a format expected by our backend.
|
|
46
51
|
*/
|
|
47
|
-
declare
|
|
52
|
+
declare function integerValidator(config?: Partial<TheSeamIntegerConfig>): ValidatorFn;
|
|
48
53
|
|
|
49
54
|
export { DECIMAL_REGEX, INTEGER_REGEX, decimalValidator, emailExistsValidator, integerValidator, phoneLengthValidator, taxIdValidator };
|
|
55
|
+
export type { TheSeamDecimalConfig, TheSeamIntegerConfig, TheSeamPhoneLengthConfig };
|