@uiowa/uiowa-mfk
Version:
mfk, uiowa-mfk, uiowa-favorite-mfk, mfk-string
156 lines (145 loc) • 5.32 kB
TypeScript
import * as i0 from '@angular/core';
import { OnChanges, ElementRef, SimpleChanges, PipeTransform } from '@angular/core';
import { DigitOnlyDirective } from '@uiowa/digit-only';
interface Mfk {
fund: string;
org: string;
dept: string;
subdept: string;
grantpgm: string;
iact: string;
oact: string;
dact: string;
fn: string;
cctr: string;
brf?: string;
}
/**
* Options for MFK field.
*
* allows to set field default value, set readonly attribute, set validation regex pattern. Example usage:
*
* ```typescript
* new MfkFieldOption(MfkFieldName.IACT, '6218')
* new MfkFieldOption(MfkFieldName.IACT, '6218', true)
* new MfkFieldOption(MfkFieldName.BRF)
* ```
*/
declare class MfkFieldOption {
readonly name: keyof Mfk;
readonly defaultValue: string;
readonly readonly: boolean;
readonly valuePattern: string;
readonly label: string;
readonly width: number;
readonly length: number;
private readonly numericRegex;
/**
* Options for MFK field.
*
* allows to set field default value, set readonly attribute, set validation regex pattern. Example usage:
*
* ```typescript
* new MfkFieldOption(MfkFieldName.IACT, '6218')
* new MfkFieldOption(MfkFieldName.IACT, '6218', true)
* new MfkFieldOption(MfkFieldName.BRF)
* ```
*
* @param name (Required) the input field name. Use MfkFieldName type to get a proper value.
* @param defaultValue (Optional) set a default value for this field. Default: ''.
* @param readonly (Optional) set to true if the input field is readonly. Default: false.
* @param valuePattern (Optional) set a regex for this field. Default: '^[0-9]+$'.
*/
constructor(name: keyof Mfk, defaultValue?: string, readonly?: boolean, valuePattern?: string);
}
declare class MfkInput implements OnChanges {
private _mfk;
set mfk(mfk: Mfk);
get mfk(): Mfk;
mfkChange: i0.OutputEmitterRef<Mfk>;
options: i0.InputSignal<MfkFieldOption[]>;
protected _options: MfkFieldOption[];
mfkInputFields: i0.Signal<readonly DigitOnlyDirective[]>;
elementId: string;
elementName: string;
constructor(el: ElementRef);
ngOnChanges(changes: SimpleChanges): void;
paste(e: ClipboardEvent): void;
private originalMfk;
onKeydown(e: KeyboardEvent): void;
onKeyup(e: KeyboardEvent): void;
private mergeOptions;
static ɵfac: i0.ɵɵFactoryDeclaration<MfkInput, never>;
static ɵcmp: i0.ɵɵComponentDeclaration<MfkInput, "uiowa-mfk-input", never, { "mfk": { "alias": "mfk"; "required": false; }; "options": { "alias": "options"; "required": false; "isSignal": true; }; }, { "mfkChange": "mfkChange"; }, never, never, true, never>;
}
declare class MfkString {
mfk: i0.InputSignal<Mfk | undefined>;
static ɵfac: i0.ɵɵFactoryDeclaration<MfkString, never>;
static ɵcmp: i0.ɵɵComponentDeclaration<MfkString, "uiowa-mfk-string", never, { "mfk": { "alias": "mfk"; "required": false; "isSignal": true; }; }, {}, never, never, true, never>;
}
declare class MfkFieldName {
static FUND: keyof Mfk;
static ORG: keyof Mfk;
static DEPT: keyof Mfk;
static SUBDEPT: keyof Mfk;
static GRANTPGM: keyof Mfk;
static IACT: keyof Mfk;
static OACT: keyof Mfk;
static DACT: keyof Mfk;
static FN: keyof Mfk;
static CCTR: keyof Mfk;
static BRF: keyof Mfk;
}
/**
* checks the equality of two Mfk objects
* @param mfk1 an Mfk object
* @param mfk2 an Mfk object
*/
declare function areEqual(mfk1: Mfk, mfk2: Mfk): boolean;
/**
* converts an Mfk object to a string by joining 10 fields with '-' symbol.
* @param mfk An Mfk object
*/
declare function stringify(mfk: Mfk | null): string;
/**
* creates an empty Mfk object with all 10 fields being empty string
*/
declare function emptyMfk(): Mfk;
/**
* checks if an Mfk object is in a valid format
*/
declare function validFormat(mfk: Mfk): boolean;
/**
* checks if an Mfk string is in a valid format
*/
declare function validMfkString(mfkString: string): boolean;
/**
* checks if each field of an Mfk object is in a valid format
* returns an array of error messages
* If the format is valid, then the returning array is empty.
*/
declare function validateStructure(mfk: Mfk): string[];
/**
* Convert a string to an MFK object
* @param mfkString MFK string
* @returns MFK object
*/
declare function toMfk(mfkString: string): Mfk;
interface ValidatedMfk {
mfk: Mfk;
statusCode: number;
statusMessage: string;
valid: boolean;
}
declare class MfkStringPipe implements PipeTransform {
transform(value: Mfk, ...args: unknown[]): string;
static ɵfac: i0.ɵɵFactoryDeclaration<MfkStringPipe, never>;
static ɵpipe: i0.ɵɵPipeDeclaration<MfkStringPipe, "mfkString", true>;
}
declare class WhoKeyStringPipe implements PipeTransform {
transform(value: Mfk, ...args: unknown[]): string;
static ɵfac: i0.ɵɵFactoryDeclaration<WhoKeyStringPipe, never>;
static ɵpipe: i0.ɵɵPipeDeclaration<WhoKeyStringPipe, "whoKeyString", true>;
}
export { MfkFieldName, MfkFieldOption, MfkInput, MfkString, MfkStringPipe, WhoKeyStringPipe, areEqual, emptyMfk, stringify, toMfk, validFormat, validMfkString, validateStructure };
export type { Mfk, ValidatedMfk };