UNPKG

@ctodev/cclibrary-typings

Version:

Library typings for use with CLARC INFINITY

483 lines (482 loc) 18.6 kB
import { Observable } from "rxjs"; import { TccBoProperty, TccClarcDate, TccKeyValuePair, TccPrimitiveValue, TccTranslation } from "../../odata/models/shared.model"; import { TccGroupValidator, TccValidators } from "./form-error.model"; import { TccSearchListDialogServiceNamespace } from "../services/tcc-search-list-dialog/tcc-search-list-dialog.service"; import { TccInputElementComponent } from "../components/tcc-input-mask/tcc-display-elements/tcc-input-element/tcc-input-element.component"; import { TccAutocompleteInputElementComponent } from "../components/tcc-input-mask/tcc-display-elements/tcc-autocomplete-input-element/tcc-autocomplete-input-element.component"; import { TccBooleanElementComponent } from "../components/tcc-input-mask/tcc-display-elements/tcc-boolean-element/tcc-boolean-element.component"; import { TccButtonElementComponent } from "../components/tcc-input-mask/tcc-display-elements/tcc-button-element/tcc-button-element.component"; import { TccCreateListDialogElementComponent } from "../components/tcc-input-mask/tcc-display-elements/tcc-create-list-dialog-element/tcc-create-list-dialog-element.component"; import { TccCreateSimpleListDialogElementComponent } from "../components/tcc-input-mask/tcc-display-elements/tcc-create-simple-list-dialog-element/tcc-create-simple-list-dialog-element.component"; import { TccRadioButtonElementComponent } from "../components/tcc-input-mask/tcc-display-elements/tcc-radio-button-element/tcc-radio-button-element.component"; import { TccSearchListDialogElementComponent } from "../components/tcc-input-mask/tcc-display-elements/tcc-search-list-dialog-element/tcc-search-list-dialog-element.component"; import { TccSelectElementComponent } from "../components/tcc-input-mask/tcc-display-elements/tcc-select-element/tcc-select-element.component"; import { TemplateRef } from "@angular/core"; export declare namespace TccInputMask { export type displayElementComponentUnion = TccInputElementComponent | TccAutocompleteInputElementComponent | TccSelectElementComponent | TccBooleanElementComponent | TccButtonElementComponent | TccRadioButtonElementComponent | TccSearchListDialogElementComponent | TccCreateListDialogElementComponent | TccCreateSimpleListDialogElementComponent; export enum sectionType { standard = 0, chips = 1, tabs = 2 } export enum elementtype { section = 0, row = 1, input = 2, autocomplete = 3, tagInput = 4, textfield = 5, select = 6, checkbox = 7, switch = 8, button = 9, radiobutton = 10, text = 11, translation = 12, datepicker = 13, htmlElement = 14, searchlist = 15, searchlistDialog = 16, createListDialog = 17, createSimpleListDialog = 18, multiProperty = 19, emptySpace = 20 } export type displayelementtypeunion = elementtype.button | elementtype.text | elementtype.textfield | elementtype.tagInput | elementtype.translation | elementtype.checkbox | elementtype.datepicker | elementtype.input | elementtype.autocomplete | elementtype.select | elementtype.switch | elementtype.searchlistDialog | elementtype.createListDialog | elementtype.createSimpleListDialog | elementtype.radiobutton | elementtype.multiProperty | elementtype.emptySpace | elementtype.htmlElement; export enum inputDataType { number = "number", string = "string" } export enum inputType { text = "text", number = "number", password = "password", passwordAlt = "passwordAlt" } export enum passwordAutocomplete { username = "username", password = "current-password", newPassword = "new-password" } export enum inputWidth { medium = 0, long = 1, doublelong = 2, fullLength = 3 } export enum buttonStyle { clarcPrimaryButton = 0, clarcSecondaryButton = 1, clarcOutlinedButton = 2 } export enum buttonHeight { clarcButtonSmall = 0, clarcButtonMedium = 1 } export enum colors { clarcPrimary = "clarcPrimary", clarcWhite = "clarcWhite", clarcBlack = "clarcBlack", clarcBackground = "clarcBackground", clarcBackgroundAlt = "clarcBackgroundAlt", clarcGrey = "clarcGrey", clarcLightgrey = "clarcLightgrey", clarcDarkgrey = "clarcDarkgrey", clarcGreyDisabled = "clarcGreyDisabled", clarcSuccess = "clarcSuccess", clarcError = "clarcError", clarcAttention = "clarcAttention" } export enum notificationType { Success = "successIcon", Information = "infoIcon", Attention = "warningIcon", Error = "errorIcon" } export enum tooltipPosition { Below = "below", Above = "above", Left = "left", Right = "right" } export enum createListDialogEventValueState { Create = "create", Change = "change", Delete = "delete" } export enum validationStrategy { Change = "change", Blur = "blur", Submit = "submit" } export type density = 0 | -1 | -2 | -3 | -4 | -5; export interface sidePaddingOptions { left?: number; right?: number; rightWithRowButton?: number; } export interface options { density?: density; markLastFocused?: boolean; openSelectOnEnter?: boolean; sidePadding?: sidePaddingOptions; width?: number; } export interface chooseInputElementOptions { markLastFocused?: boolean; } export interface IConfigElement { id: string; name: string | TccTranslation; permissionLevel?: number; type: elementtype; divider?: boolean; class?: string; hide?: boolean; } export type SectionElement = NormalSectionElement | TabsSectionElement | ChipsSectionElement; export type SectionElements = SectionElement[]; export type RowElements = SectionContent[]; export type SectionContent = RowElement | DisplayElement; export type DisplayElement = _DisplayCheckboxElement | _DisplaySwitchElement | _DisplayButtonElement | _DisplayRadiobuttonElement | _DisplayTextElement | _DisplayTranslationElement | DisplayFullFieldElement | EmptySpace | _DisplayHTMLElement; export type DisplayFullFieldElement = _DisplayDatepickerfieldElement | _DisplaySearchListDialogElement | _DisplayCreateListDialogElement | _DisplayCreateSimpleListDialogElement | DisplayExtraButtonFieldElement; export type DisplayExtraButtonFieldElement = _DisplayInputElement | _DisplayInputIntegerElement | _DisplayAutocompleteElement | _DisplayTagInputElement | _DisplayTextfieldElement | _DisplaySelectElement | _DisplayMultiPropertyElement; export type DisplayElements = DisplayElement[]; export interface NormalSectionElement extends BaseSectionElement { sectionType?: sectionType.standard; children: SectionContent[]; } export interface TabsSectionElement extends BaseSectionElement { sectionType: sectionType.tabs; children: NormalSectionElement[]; } export interface ChipsSectionElement extends BaseSectionElement { sectionType: sectionType.chips; children: NormalSectionElement[]; } export interface BaseSectionElement extends IGroupingElement, IConfigElement { open?: boolean; expandable?: boolean; children: SectionContent[] | SectionElement[]; type: elementtype.section; color?: colors; sectionType?: sectionType; icon?: string; matIcon?: string; } export interface IGroupingElement { search?: boolean; paginator?: paginatorOptions; searchList?: searchListOptions; validators?: Array<TccGroupValidator>; validationStrategy?: validationStrategy; } export interface RowElement extends IGroupingElement, IConfigElement { children: DisplayElement[]; type: elementtype.row; icon?: string; /** * Adds a rowButton to the row to copy the row and all child elements. All child element values will turn into array<value>. */ collection?: boolean; /** * to identify rows that belong to a collection (will be set internally, dont use) */ _connectedTo?: string; } export interface _IDisplayElement extends IConfigElement { validators?: Array<TccValidators>; validationStrategy?: validationStrategy; visible?: boolean; readonly?: boolean; color?: colors; _section?: string; _row?: string; type: displayelementtypeunion; notification?: notification; prefix?: string; rowButton?: rowButtonOptions; matPrefix?: string; disabled?: boolean; transformValueFunction?: (value: ValueUnion) => ValueUnion; /** * Adds a rowButton to the parent row to copy the row and all collection elements inside. Value of the element turns into array<value>. * Can only be used inside of a row! */ collection?: boolean; } export interface _BasicField extends _IDisplayElement { value?: ValueUnion; default?: ValueUnion; } export interface _WidthField extends _BasicField { width?: inputWidth; widthString?: string; _autoSize?: boolean; path?: string[]; } interface _FullField extends _WidthField { placeholder?: PrintableUnion; hint?: { message: PrintableUnion; type?: notificationType; }; label?: boolean; } export interface _ExtraButtonField { button?: extraButtonOptions; } export type ValueUnion = TccPrimitiveValue | TccTranslation | TccBoProperty.EnumValue | ValueUnion[]; export type FormGroupValueUnion = string | number | boolean | Date; type PrintableUnion = string; export interface EmptySpace extends _WidthField { type: elementtype.emptySpace; } export interface _BaseDisplayInputElement extends _FullField, _ExtraButtonField { type: elementtype.input | elementtype.autocomplete; inputType?: inputType; passwordAutocomplete?: passwordAutocomplete; value?: string | number; default?: string | number; dataType?: 'string' | 'number'; } export interface _DisplayInputElement extends _BaseDisplayInputElement { type: elementtype.input; children?: SectionContent[]; } export interface _DisplayInputIntegerElement extends _DisplayInputElement { value?: number; decimalPlaces?: number; dataType: inputDataType.number; } export interface _DisplayAutocompleteElement extends _BaseDisplayInputElement { type: elementtype.autocomplete; autocomplete?: Array<string | TccKeyValuePair>; forceSelection?: boolean; } export interface _DisplayTagInputElement extends _FullField, _ExtraButtonField { type: elementtype.tagInput; selections: Array<string> | Array<TccKeyValuePair>; value?: string; default?: string; } export interface _DisplayTextfieldElement extends _FullField, _ExtraButtonField { type: elementtype.textfield; value?: string | number; default?: string | number; } export interface _DisplayDatepickerfieldElement extends _FullField { type: elementtype.datepicker; value?: TccClarcDate; default?: string; } export type _DisplaySelectElement = _DisplaySyncSelectElement | _DisplayASyncSelectElement; export interface _DisplayBaseSelectElement extends _FullField, _ExtraButtonField { type: elementtype.select; value?: string | number; default?: string | number; multiple?: boolean; tooltip?: boolean; openOnEnter?: boolean; notSelectedOption?: boolean; } export interface _DisplaySyncSelectElement extends _DisplayBaseSelectElement { selections: Array<string> | Array<number> | Array<TccKeyValuePair> | Array<_SelectGroupSelection>; getSelectionsFunction?: never; } export interface _DisplayASyncSelectElement extends _DisplayBaseSelectElement { getSelectionsFunction: () => Observable<Array<string> | Array<number> | Array<TccKeyValuePair> | Array<_SelectGroupSelection>>; selections?: never; } export interface _SelectGroupSelection extends TccKeyValuePair { children?: Array<string> | Array<number> | Array<TccKeyValuePair>; } export interface _DisplayCheckboxElement extends _WidthField { type: elementtype.checkbox; value?: boolean; default?: boolean; } export interface _DisplayTranslationElement extends _WidthField { type: elementtype.translation; value?: TccTranslation; default?: TccTranslation; longTranslation?: boolean; } export interface _DisplaySwitchElement extends _WidthField { type: elementtype.switch; value?: boolean; default?: boolean; } export interface _DisplayButtonElement extends _WidthField { type: elementtype.button; buttonStyle?: buttonStyle; buttonHeight?: buttonHeight; } export interface _DisplayRadiobuttonElement extends _WidthField { type: elementtype.radiobutton; options: radiobuttonOption[]; } export interface radiobuttonOption { value: string; name: string | TccTranslation; } export interface _DisplayTextElement extends _WidthField { type: elementtype.text; value?: string | TccTranslation; } export interface _DisplayHTMLElement extends _WidthField { type: elementtype.htmlElement; index: number; data?: any; htmlTemplate?: TemplateRef<any>; } export interface _DisplayMultiPropertyElement extends _FullField, _ExtraButtonField { type: elementtype.multiProperty; children: DisplayElement[]; seperatorString?: string; } export interface _DisplaySearchListDialogElement<T = any> extends _FullField { type: elementtype.searchlistDialog; chips: searchListDialogChipData<T>[]; searchElementOptions?: TccKeyValuePair[]; path?: undefined; dialogWidth?: number; } export interface searchListDialogChipData<T> extends TccSearchListDialogServiceNamespace.chipData<T> { prefix?: string; matPrefix?: string; permanentPrefix?: string; permanentMatPrefix?: string; } export interface _DisplayCreateListDialogElement extends _FullField { type: elementtype.createListDialog; dialogTitle: string; chips: createListDialogChip[]; hasValue?: boolean; path?: undefined; } export interface createListDialogChip { Id: string; Name: string; ActiveItems: createListDialogActiveItem[]; Prefix: string; } export interface createListDialogActiveItem { Element: TccTranslation; Id: string; Permanent?: boolean; } export interface _DisplayCreateSimpleListDialogElement extends _FullField { type: elementtype.createSimpleListDialog; dialogTitle: string; inputLabel: string; ActiveItems: string[]; path?: undefined; } export interface searchListOptions extends IConfigElement { type: elementtype.searchlist; value?: Array<string>; selection?: Array<TccKeyValuePair>; complete: boolean; width?: inputWidth; widthString?: string; filter?: Array<string>; visible?: boolean; pageSize?: number; count?: number; next?: Observable<{ data: Array<TccKeyValuePair>; count?: number; }>; _setValue?: Function; noDataMessage?: string; readonly?: boolean; } export interface paginatorOptions { count: number; pageSize: number; hidePageSize?: boolean; } export interface extraButtonOptions { icon?: string; matIcon?: string; tooltip?: string; hover?: boolean; class?: string; disabled?: boolean; } export interface rowButtonOptions { caption: string; tooltip?: string; icon?: string; matIcon?: string; } export interface notification { type: notificationType; value: string; tooltipPosition?: tooltipPosition; class?: string; link?: string; } export interface sectionPosition { id: string; name: string; position: number; open: boolean; } export type sectionPositions = Array<sectionPosition>; export interface eventOutput<T = ValueUnion> extends eventTrigger { value: T; } export interface eventTrigger { id: string; section?: string; row?: string; index?: number; } export enum specialElementType { search = "search" } export interface specialElementSearch { type: specialElementType.search; data: { id: string; }; } export type specialElement = specialElementSearch; export interface searchListDialogEvent extends eventTrigger { value: TccInputMask.valueChanges; } export interface createListDialogEventValueItem { value: TccTranslation; type: string; state: createListDialogEventValueState; } export interface createListDialogEventValue { [propname: string]: createListDialogEventValueItem; } export interface createListDialogEvent extends eventTrigger { value: createListDialogEventValue; } export interface valueChanges { [k: string]: { value: any; state?: TccInputMask.createListDialogEventValueState; row?: string; section?: string; }; } export interface cloneValidators { [displayElementId: string]: { validators: TccValidators[]; children?: cloneValidators; }; } export interface setValueOptions { setValueChange?: boolean; emitChangeEvent?: boolean; index?: number; confidence?: number; } export {}; }