@theseam/ui-common 1.0.2-beta.42 → 1.0.2-beta.43

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.
@@ -65,6 +65,10 @@ const DEFAULT_USERNAME_FIELD_CONFIG = {
65
65
  pattern: /^[a-zA-Z0-9\-._@+]+$/,
66
66
  };
67
67
 
68
+ const DEFAULT_PASSWORD_FIELD_CONFIG = {
69
+ minLength: 8,
70
+ };
71
+
68
72
  function isCountryUSA(control) {
69
73
  return control.value === 'USA';
70
74
  }
@@ -156,6 +160,87 @@ function usernameExistsValidator(userExists) {
156
160
  };
157
161
  }
158
162
 
163
+ /**
164
+ * Rejects passwords that contain the word "password" (case-insensitive).
165
+ */
166
+ function passwordContentValidator(control) {
167
+ if (isEmptyInputValue(control.value)) {
168
+ return null;
169
+ }
170
+ return control.value.toLowerCase().indexOf('password') === -1
171
+ ? null
172
+ : { passwordContent: { value: 'password' } };
173
+ }
174
+
175
+ /**
176
+ * Requires at least one lowercase letter.
177
+ */
178
+ function passwordLowercaseValidator(control) {
179
+ if (isEmptyInputValue(control.value)) {
180
+ return null;
181
+ }
182
+ return control.value.match(/[a-z]/) ? null : { passwordLowercase: {} };
183
+ }
184
+
185
+ /**
186
+ * Requires at least one uppercase letter.
187
+ */
188
+ function passwordUppercaseValidator(control) {
189
+ if (isEmptyInputValue(control.value)) {
190
+ return null;
191
+ }
192
+ return control.value.match(/[A-Z]/) ? null : { passwordUppercase: {} };
193
+ }
194
+
195
+ /**
196
+ * Requires at least one digit.
197
+ */
198
+ function passwordNumberValidator(control) {
199
+ if (isEmptyInputValue(control.value)) {
200
+ return null;
201
+ }
202
+ return control.value.match(/\d/) ? null : { passwordNumber: {} };
203
+ }
204
+
205
+ /**
206
+ * Requires at least one special character.
207
+ */
208
+ function passwordSpecialCharValidator(control) {
209
+ if (isEmptyInputValue(control.value)) {
210
+ return null;
211
+ }
212
+ return control.value.match(/[-!@#$%^&*()_+|~=`{}[\]:";'<>?,./]/)
213
+ ? null
214
+ : { passwordSpecialChar: {} };
215
+ }
216
+
217
+ const DEFAULT_CONFIG = {
218
+ minLength: 8,
219
+ };
220
+ /**
221
+ * Requires password to meet a minimum length.
222
+ */
223
+ function passwordLengthValidator(config) {
224
+ const c = { ...DEFAULT_CONFIG, ...config };
225
+ return (control) => {
226
+ if (isEmptyInputValue(control.value)) {
227
+ return null;
228
+ }
229
+ return control.value.length >= c.minLength ? null : { passwordLength: {} };
230
+ };
231
+ }
232
+
233
+ /**
234
+ * Group-level validator that checks password1 and password2 controls match.
235
+ */
236
+ function passwordMatchValidator(g) {
237
+ const control1 = g.get('password1');
238
+ const control2 = g.get('password2');
239
+ const value1 = control1 && control1.value;
240
+ const value2 = control2 && control2.value;
241
+ return value1 === value2 ? null : { passwordMatch: true };
242
+ }
243
+
159
244
  function getAddress1Validators(config, overrides) {
160
245
  const c = { ...DEFAULT_ADDRESS_FIELD_CONFIG, ...config };
161
246
  const o = { required: true, ...overrides };
@@ -250,6 +335,22 @@ function getUsernameValidators(userExists, config, overrides) {
250
335
  };
251
336
  }
252
337
 
338
+ function getPasswordValidators(config, overrides) {
339
+ const o = { required: true, ...overrides };
340
+ return {
341
+ validators: [
342
+ ...(o.required ? [Validators.required] : []),
343
+ passwordContentValidator,
344
+ passwordLengthValidator(config),
345
+ passwordUppercaseValidator,
346
+ passwordLowercaseValidator,
347
+ passwordNumberValidator,
348
+ passwordSpecialCharValidator,
349
+ ],
350
+ asyncValidators: [],
351
+ };
352
+ }
353
+
253
354
  function createAddress1Control(formState = null, config, overrides) {
254
355
  const v = getAddress1Validators(config, overrides);
255
356
  return new FormControl(formState, v.validators, v.asyncValidators);
@@ -317,6 +418,14 @@ function createAddressFormGroup(options) {
317
418
  return { group, subscription };
318
419
  }
319
420
 
421
+ function createPasswordFormGroup(config) {
422
+ const v = getPasswordValidators(config);
423
+ return new FormGroup({
424
+ password1: new FormControl(null, v.validators, v.asyncValidators),
425
+ password2: new FormControl(null, Validators.required),
426
+ }, { validators: [passwordMatchValidator] });
427
+ }
428
+
320
429
  // Models
321
430
 
322
431
  class BaseLayoutContentFooterDirective {
@@ -4559,5 +4668,5 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.3.15", ngImpo
4559
4668
  * Generated bundle index. Do not edit.
4560
4669
  */
4561
4670
 
4562
- 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 };
4671
+ export { BaseLayoutContentDirective, BaseLayoutContentFooterDirective, BaseLayoutContentHeaderDirective, BaseLayoutSideBarDirective, BaseLayoutSideBarFooterDirective, BaseLayoutSideBarHeaderDirective, BaseLayoutTopBarDirective, DEFAULT_ADDRESS_FIELD_CONFIG, DEFAULT_PASSWORD_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, createPasswordFormGroup, createStateControl, createUsernameControl, createZipControl, extendFramework, fader, findHorizontalNavLinkItems, findLinkItems, getAddress1Validators, getAddress2Validators, getCityValidators, getCountryValidators, getHorizontalNavItemStateProp, getItemStateProp, getPasswordValidators, getStateValidators, getUrlSegments, getUsernameValidators, getZipValidators, hasActiveChild, hasChildren, hasExpandedChild, horizontalNavItemCanBeActive, horizontalNavItemCanExpand, horizontalNavItemCanHaveChildren, horizontalNavItemHasActiveChild, horizontalNavItemHasChildren, horizontalNavItemHasExpandedChild, ifUSA, isCountryUSA, isExpanded, isHorizontalNavItemActive, isHorizontalNavItemExpanded, isHorizontalNavItemFocused, isHorizontalNavItemType, isNavItemActive, isNavItemType, passwordContentValidator, passwordLengthValidator, passwordLowercaseValidator, passwordMatchValidator, passwordNumberValidator, passwordSpecialCharValidator, passwordUppercaseValidator, routeChanges, seamRouteTransition, setDefaultHorizontalNavItemState, setDefaultState, setHorizontalNavItemStateProp, setItemStateProp, sideNavExpandStateChangeFn, sideToSide, slider, stateProvinceRegionValidator, stepper, transformer, usernameExistsValidator };
4563
4672
  //# sourceMappingURL=theseam-ui-common-framework.mjs.map