This repository has been archived by the owner on Mar 27, 2023. It is now read-only.
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: assign correct described-by id to form input and control helpers
* provide another service for creating container/control ID * set correct role to elements * set describe by id and link it to control helper/error/success Signed-off-by: Bozhidar Dryanovski <bozhidar.dryanovski@gmail.com>
- Loading branch information
1 parent
2ffead7
commit bcae31d
Showing
21 changed files
with
631 additions
and
181 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
47 changes: 47 additions & 0 deletions
47
packages/angular/projects/clr-angular/src/forms/common/abstract-control.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
/** | ||
* Copyright (c) 2016-2021 VMware, Inc. All Rights Reserved. | ||
* This software is released under MIT license. | ||
* The full license information can be found in LICENSE in the root directory of this project. | ||
*/ | ||
|
||
import { Directive, Optional } from '@angular/core'; | ||
import { ControlIdService } from './providers/control-id.service'; | ||
import { ContainerIdService } from './providers/container-id.service'; | ||
|
||
export const CONTROL_SUFFIX: { [key: string]: string | null } = { | ||
HELPER: 'helper', | ||
ERROR: 'error', | ||
SUCCESS: 'success', | ||
NONE: null, | ||
}; | ||
|
||
@Directive() | ||
export abstract class ClrAbstractControl { | ||
/** | ||
* Hold the suffix for the ID | ||
*/ | ||
public controlIdSuffix = 'abstract'; | ||
|
||
constructor( | ||
@Optional() protected controlIdService: ControlIdService, | ||
@Optional() protected containerIdService: ContainerIdService | ||
) {} | ||
|
||
public get id(): string { | ||
/** | ||
* The order of witch the id will be pick is: | ||
* - Container ID (Wrapper arround multiple Controls like, Checkbox, Radio, ...) | ||
* - Control ID (Single Control wrapper like Input, Textarea, Password, ...) | ||
* - None | ||
*/ | ||
if (this.containerIdService) { | ||
return `${this.containerIdService.id}-${this.controlIdSuffix}`; | ||
} | ||
|
||
if (this.controlIdService) { | ||
return `${this.controlIdService.id}-${this.controlIdSuffix}`; | ||
} | ||
|
||
return null; | ||
} | ||
} |
Oops, something went wrong.