UNPKG

@ctodev/cclibrary-typings

Version:

Library typings for use with CLARC INFINITY

612 lines (611 loc) 24.6 kB
import { Observable } from "rxjs"; import { TccBoProperty, TccClarcDate, TccClarcDateRange, 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"; import { displayElement } from "../components/tcc-input-mask/tcc-abstract-display-element"; 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, hintbox = 21, slider = 22 } 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 | elementtype.hintbox | elementtype.slider; export enum inputDataType { number = "number", string = "string" } export enum inputType { text = "text", number = "number", password = "password", passwordAlt = "passwordAlt" } export enum browserAutocomplete { username = "username", password = "current-password", newPassword = "new-password", email = "email" } 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 { inputElements: SectionElements; basePath: string; density?: density; markLastFocused?: boolean; openSelectOnEnter?: boolean; sidePadding?: sidePaddingOptions; width?: number; noTitleContainerMargin?: number; /** * If the section header should be colored according to errors or warnings present in its children. * @default false */ showSectionStateColor?: boolean; } 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<T = any> = NormalSectionElement<T> | TabsSectionElement<T> | ChipsSectionElement<T>; export type SectionElements<T = any> = SectionElement<T>[]; export type RowElements<T = any> = SectionContent<T>[]; export type SectionContent<T = any> = RowElement<T> | DisplayElement<T>; export type DisplayElement<T = any> = _DisplayCheckboxElement<T> | _DisplaySwitchElement<T> | _DisplayButtonElement<T> | _DisplayRadiobuttonElement<T> | _DisplayTextElement<T> | DisplayFullFieldElement<T> | EmptySpace<T> | _DisplayHTMLElement<T> | TccHintBox<T> | TccSlider<T>; export type DisplayFullFieldElement<T = any> = _DisplayDatepickerfieldElement<T> | _DisplaySearchListDialogElement<T> | _DisplayCreateListDialogElement<T> | _DisplayCreateSimpleListDialogElement<T> | DisplayExtraButtonFieldElement<T> | _DisplayTranslationElement<T>; export type DisplayExtraButtonFieldElement<T = any> = _DisplayInputElement<T> | _DisplayInputIntegerElement<T> | _DisplayAutocompleteElement<T> | _DisplayTagInputElement<T> | _DisplayTextfieldElement<T> | _DisplaySelectElement<T> | _DisplayMultiPropertyElement<T>; export type DisplayElements<T = any> = DisplayElement<T>[]; export interface NormalSectionElement<T = any> extends BaseSectionElement<T> { sectionType?: sectionType.standard; children: SectionContent<T>[]; } export interface TabsSectionElement<T = any> extends BaseSectionElement<T> { sectionType: sectionType.tabs; children: NormalSectionElement<T>[]; } export interface ChipsSectionElement<T = any> extends BaseSectionElement<T> { sectionType: sectionType.chips; children: NormalSectionElement<T>[]; } export interface BaseSectionElement<T = any> extends IGroupingElement, IConfigElement { open?: boolean; expandable?: boolean; children: SectionContent<T>[] | SectionElement<T>[]; 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<T = any> extends IGroupingElement, IConfigElement { children: DisplayElement<T>[]; 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; /** * collection index of the row */ _index?: number; } 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; /** * Gets the value of the property specified with the path property and returns the modified value to the display element * @param value value of the property specified with the path property * @returns the value, that should be used */ transformValueFunction?: (value: any) => ValueUnion; /** * Gets the value of the displayElement and provides a modified value for all functions, that return the value out of the inputMask * @param value value of the displayElement * @returns the value, that should be returned */ returnTransformValueFunction?: (value: ValueUnion) => any; /** * 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; _siblings?: displayElement[]; _index?: number; /** * to identify elements that belong to a collection (will be set internally, dont use) */ _connectedToCollection?: string; /** * to identify elements that belong to a complex collextion (will be set internally, dont use) */ _connectedToComplex?: string; /** * string of the parent element. Will be set, if the element is a child of a complex element */ _parentId?: string; phonevalidation?: boolean; } export interface fieldMargin { top?: number; bottom?: number; } export interface _BasicField extends _IDisplayElement { value?: ValueUnion; default?: ValueUnion; required?: boolean; } type prev = [never, 0, 1, 2, 3, 4, 5]; type path<T, D extends number = 5> = [ D ] extends [never] ? never : T extends object ? { [K in keyof T]: [K] | [K, ...path<T[K], prev[D]>]; }[keyof T] : (string | number)[]; /** * Type to add all possible paths of type T to VSCode suggestions as string[]. If T === any, type will be string[] */ export interface _WidthField<T = any> extends _BasicField { width?: inputWidth; widthString?: string; _autoSize?: boolean; path?: path<T>; depricatedPath?: string[]; updateModel?: boolean; } interface _FullField<T = any> extends _WidthField<T> { placeholder?: PrintableUnion; hint?: { message: PrintableUnion; type?: notificationType; }; label?: boolean; confidence?: number; } export interface _ExtraButtonField { button?: extraButtonOptions; } export interface complexValueObjectChildren { [childId: string]: complexValueObject; } export interface complexValueObject { Value: ValueUnion | complexValueObjectChildren | ValueUnion[] | complexValueObjectChildren[]; Confidence?: number; } export type ValueUnion = TccPrimitiveValue | TccTranslation | TccBoProperty.EnumValue | TccClarcDateRange | ValueUnion[]; export type FormGroupValueUnion = string | number | boolean | Date; type PrintableUnion = string; export interface EmptySpace<T = any> extends _WidthField<T> { type: elementtype.emptySpace; } export interface _BaseDisplayInputElement<T = any> extends _FullField<T>, _ExtraButtonField { type: elementtype.input | elementtype.autocomplete | elementtype.multiProperty; inputType?: inputType; browserAutocomplete?: browserAutocomplete; value?: string | number; default?: string | number; dataType?: inputDataType; useTooltip?: boolean; customTooltip?: string; } export interface _DisplayInputElement<T = any> extends _BaseDisplayInputElement<T> { type: elementtype.input; children?: SectionContent<T>[]; unfolded?: boolean; showRoot?: boolean; _children?: displayElement[]; phonevalidation?: boolean; } export interface _DisplayInputIntegerElement<T = any> extends _DisplayInputElement<T> { value?: number; decimalPlaces?: number; dataType: inputDataType.number; } export interface _DisplayAutocompleteElement<T = any> extends _BaseDisplayInputElement<T> { type: elementtype.autocomplete; autocomplete?: Array<string | TccKeyValuePair>; forceSelection?: boolean; } export interface _DisplayMultiPropertyElement<T = any> extends _BaseDisplayInputElement<T> { type: elementtype.multiProperty; children: DisplayElement<T>[]; seperatorString?: string; } export interface _DisplayTagInputElement<T = any> extends _FullField<T>, _ExtraButtonField { type: elementtype.tagInput; selections: Array<string> | Array<TccKeyValuePair>; value?: string[]; default?: string[]; } export interface _DisplayTextfieldElement<T = any> extends _FullField<T>, _ExtraButtonField { type: elementtype.textfield; value?: string | number; default?: string | number; } export interface _DisplayDatepickerfieldElement<T = any> extends _FullField<T> { type: elementtype.datepicker; value?: TccClarcDate; default?: string; timeOnly?: boolean; range?: boolean; } export type _DisplaySelectElement<T = any> = _DisplayMultiSyncSelectElement<T> | _DisplaySingleSyncSelectElement<T> | _DisplayMultiASyncSelectElement<T> | _DisplaySingleASyncSelectElement<T>; export interface _DisplayBaseSelectElement<T = any> extends _FullField<T>, _ExtraButtonField { type: elementtype.select; value?: string | number; default?: string | number; multiple?: boolean; tooltip?: boolean; openOnEnter?: boolean; notSelectedOption?: boolean; disableLabelFloating?: boolean; /** * Default: true; if false, userinput will be taken as value without mapping the value to the options; */ forceSelection?: boolean; } export interface _DisplayBaseMultiSelectElement<T = any> extends _DisplayBaseSelectElement<T> { multiple: true; forceSelection?: true | never; labelAsCounter?: boolean; } export interface _DisplayBaseSingleSelectElement<T = any> extends _DisplayBaseSelectElement<T> { multiple?: false | never; } export interface _DisplayMultiSyncSelectElement<T = any> extends _DisplayBaseMultiSelectElement<T>, _DisplayBaseSyncSelectElement { } export interface _DisplaySingleSyncSelectElement<T = any> extends _DisplayBaseSingleSelectElement<T>, _DisplayBaseSyncSelectElement { } export interface _DisplayBaseSyncSelectElement { selections: Array<string> | Array<number> | Array<TccKeyValuePair> | Array<_SelectGroupSelection>; getSelectionsFunction?: never; } export interface _DisplayMultiASyncSelectElement<T = any> extends _DisplayBaseMultiSelectElement<T>, _DisplayBaseASyncSelectElement { } export interface _DisplaySingleASyncSelectElement<T = any> extends _DisplayBaseSingleSelectElement<T>, _DisplayBaseASyncSelectElement { } export interface _DisplayBaseASyncSelectElement { getSelectionsFunction: () => Observable<Array<string> | Array<number> | Array<TccKeyValuePair> | Array<_SelectGroupSelection>>; selections?: never; createElementPath?: string; createElementPathQueryParams?: TccKeyValuePair<string | number>[]; } export interface _SelectGroupSelection extends TccKeyValuePair { children?: Array<string> | Array<number> | Array<TccKeyValuePair>; } export interface _BaseBooleanElement<T = any> extends _WidthField<T> { value?: boolean; default?: boolean; treatUndefinedAsTrue?: boolean; margin?: fieldMargin; } export interface _DisplayCheckboxElement<T = any> extends _BaseBooleanElement<T> { type: elementtype.checkbox; } export interface _DisplayTranslationElement<T = any> extends _FullField<T> { type: elementtype.translation; value?: TccTranslation; default?: TccTranslation; longTranslation?: boolean; } export interface _DisplaySwitchElement<T = any> extends _BaseBooleanElement<T> { type: elementtype.switch; } export interface _DisplayButtonElement<T = any> extends _WidthField<T> { type: elementtype.button; buttonStyle?: buttonStyle; buttonHeight?: buttonHeight; } export interface _DisplayRadiobuttonElement<T = any> extends _WidthField<T> { type: elementtype.radiobutton; options: radiobuttonOption[]; } export interface radiobuttonOption { value: string; name: string | TccTranslation; } export interface _DisplayTextElement<T = any> extends _WidthField<T> { type: elementtype.text; value?: string | TccTranslation; } export interface _DisplayHTMLElement<T = any> extends _WidthField<T> { type: elementtype.htmlElement; index: number; data?: any; htmlTemplate?: TemplateRef<any>; } export interface _DisplaySearchListDialogElement<T = any, chipsData = any> extends _FullField<T> { type: elementtype.searchlistDialog; chips: searchListDialogChipData<chipsData>[]; searchElementOptions?: TccKeyValuePair[]; path?: undefined; dialogWidth?: number; } export interface searchListDialogChipData<T = any> extends TccSearchListDialogServiceNamespace.chipData<T> { prefix?: string; matPrefix?: string; permanentPrefix?: string; permanentMatPrefix?: string; } export interface _DisplayCreateListDialogElement<T = any> extends _FullField<T> { 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<T = any> extends _FullField<T> { 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, that gets opened, if the tooltip is clicked. No design or indicator implemented. * @deprecated use elementtype.hintbox instead */ 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; context?: string | string[]; } export interface eventTrigger { id: string; section?: string; row?: string; index?: number; } export interface addRowEvent extends eventOutput { options: setValueOptions; } export interface addRowForSuggestionEvent extends addRowEvent { count: number; value: ValueUnion; } 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 { [id: string]: eventOutput<any>; } export interface uncloneableObjects { [displayElementId: string]: _uncloneableObjects; } export interface _uncloneableObjects { validators: TccValidators[]; transformValueFunction?: (value: any) => ValueUnion; returnTransformValueFunction?: (value: ValueUnion) => any; children?: uncloneableObjects; } export interface setValueOptions { setValueChange?: boolean; emitChangeEvent?: boolean; index?: number; confidence?: number; } export interface setValueSuggestionOptions extends setValueOptions { color?: string; } export interface TccHintBox<T = any> extends _WidthField<T> { type: elementtype.hintbox; link?: string; formatText: formatText[]; } export interface formatText { text: string; highlight?: boolean; lineBreak?: boolean; bold?: boolean; } export interface TccSlider<T = any> extends _FullField<T> { type: elementtype.slider; min?: number; max?: number; step?: number; } export {}; }