forked from NationalBankBelgium/stark
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(stark-ui): implement text-mask-directive
ISSUES CLOSED: #680
- Loading branch information
1 parent
6ea3d9b
commit dd2f9f8
Showing
32 changed files
with
987 additions
and
34 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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
export * from "./input-mask-directives/directives"; | ||
export * from "./input-mask-directives/input-mask-directives.module"; |
3 changes: 3 additions & 0 deletions
3
packages/stark-ui/src/modules/input-mask-directives/directives.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,3 @@ | ||
export * from "./directives/text-mask.constants"; | ||
export * from "./directives/text-mask.directive"; | ||
export * from "./directives/text-mask-config.intf"; |
46 changes: 46 additions & 0 deletions
46
packages/stark-ui/src/modules/input-mask-directives/directives/text-mask-config.intf.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,46 @@ | ||
import * as textMaskCore from "text-mask-core"; | ||
|
||
/** | ||
* Defines the base configuration for the mask directives provided by Stark. | ||
*/ | ||
export interface StarkTextMaskBaseConfig { | ||
/** | ||
* Whether to show the mask while the user is typing in the input field in order to guide him. Default: true. | ||
* | ||
* See {@link https://github.com/text-mask/text-mask/blob/master/componentDocumentation.md#guide} | ||
*/ | ||
guide?: boolean; | ||
|
||
/** | ||
* Placeholder character represents the fillable spot in the mask. Default: "_". | ||
* | ||
* See {@link https://github.com/text-mask/text-mask/blob/master/componentDocumentation.md#placeholderchar} | ||
*/ | ||
placeholderChar?: string; | ||
|
||
/** | ||
* Whether to keep the spaces used by character after they are added/deleted. Default: true. | ||
* | ||
* See {@link https://github.com/text-mask/text-mask/blob/master/componentDocumentation.md#keepcharpositions} | ||
*/ | ||
keepCharPositions?: boolean; | ||
} | ||
|
||
/** | ||
* Defines the configuration for the {@link StarkTextMaskDirective}. | ||
*/ | ||
export interface StarkTextMaskConfig extends StarkTextMaskBaseConfig { | ||
/** | ||
* Array or a function that defines how the user input is going to be masked. If is set to false, the mask will be removed. | ||
* | ||
* See {@link https://github.com/text-mask/text-mask/blob/master/componentDocumentation.md#mask} | ||
*/ | ||
mask: textMaskCore.Mask | false; | ||
|
||
/** | ||
* Function that can modify the conformed value before it is displayed on the screen. | ||
* | ||
* See {@link https://github.com/text-mask/text-mask/blob/master/componentDocumentation.md#pipe} | ||
*/ | ||
pipe?: textMaskCore.PipeFunction; | ||
} |
55 changes: 55 additions & 0 deletions
55
packages/stark-ui/src/modules/input-mask-directives/directives/text-mask.constants.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,55 @@ | ||
/** | ||
* Util class containing some constants with predefined masks for common mask patterns to be used with the {@link StarkTextMaskDirective}. | ||
*/ | ||
export class StarkTextMasks { | ||
/** | ||
* Mask for Belgian Structured Communication numbers: "+++ddd/dddd/ddddd/+++" | ||
*/ | ||
public static STRUCTURED_COMMUNICATION_NUMBER: (RegExp | string)[] = [ | ||
"+", | ||
"+", | ||
"+", | ||
/\d/, | ||
/\d/, | ||
/\d/, | ||
"/", | ||
/\d/, | ||
/\d/, | ||
/\d/, | ||
/\d/, | ||
"/", | ||
/\d/, | ||
/\d/, | ||
/\d/, | ||
/\d/, | ||
/\d/, | ||
"+", | ||
"+", | ||
"+" | ||
]; | ||
|
||
/** | ||
* Mask for credit card numbers: "dddd-dddd-dddd-dddd" | ||
*/ | ||
public static CREDITCARD_NUMBER: (RegExp | string)[] = [ | ||
/\d/, | ||
/\d/, | ||
/\d/, | ||
/\d/, | ||
"-", | ||
/\d/, | ||
/\d/, | ||
/\d/, | ||
/\d/, | ||
"-", | ||
/\d/, | ||
/\d/, | ||
/\d/, | ||
/\d/, | ||
"-", | ||
/\d/, | ||
/\d/, | ||
/\d/, | ||
/\d/ | ||
]; | ||
} |
Oops, something went wrong.