UNPKG

@sassoftware/vi-api

Version:
169 lines (168 loc) 7.69 kB
import { StandardPropertyTypes } from "./standardPropertyTypes"; import { ResourcedString } from "../svi-datahub"; import { Status } from "./status"; export interface ControlAttributeMap<T = any> { [StandardPropertyTypes.DataSource]: IControlAttributeDataSource; [StandardPropertyTypes.RadioChooser]: ISpbRadioChooserAttribute<T>; [StandardPropertyTypes.Picklist]: IControlAttributePicklist; [StandardPropertyTypes.RadioSwitch]: IControlAttributeRadioSwitch; [StandardPropertyTypes.StatusThresholdPicker]: IControlAttributeStatusThresholdPicker; [StandardPropertyTypes.FileCategoryDataSource]: IControlAttributeFileCategoryDataSource; [StandardPropertyTypes.MultiEditor]: IControlAttributeMultiEditor; [StandardPropertyTypes.LinkedPage]: IControlAttributeLinkedPage; [StandardPropertyTypes.InterpolatedTextInput]: IControlAttributeInterpolatedTextInput; [StandardPropertyTypes.NumericRange]: IControlAttributeNumericRange; [StandardPropertyTypes.ChartDataSource]: IControlAttributeChartDataSource; [StandardPropertyTypes.HeightEditor]: IControlAttributeHeightEditor; [StandardPropertyTypes.Checkbox]: IControlAttributeCheckbox; [StandardPropertyTypes.RelationshipSummary]: IControlAttributeRelationshipSummary; [StandardPropertyTypes.TextInput]: IControlAttributeTextInput; [StandardPropertyTypes.TileProviderChooser]: IControlAttributeTileProviderChooser; [StandardPropertyTypes.SeparatorStart]: IControlAttributeSeparatorStart; [StandardPropertyTypes.Separator]: IControlAttributeSeparator; [StandardPropertyTypes.ColumnDataType]: IControlAttributeColumnDataType; } export type UnmappedStandardPropertyTypes = Exclude<StandardPropertyTypes, keyof ControlAttributeMap>; export interface IBaseControlAttribute { type: UnmappedStandardPropertyTypes | `${UnmappedStandardPropertyTypes}`; displayName: ResourcedString; order?: number; required?: boolean | string; description?: ResourcedString; localizable?: boolean | string; defaultValue?: any; migrationValue?: never; disabledExpression?: string; hiddenExpression?: string; hideOnDisable?: boolean; cssClass?: string; triggerResizeOnChange?: boolean; } type BaseControlAttribute = Omit<IBaseControlAttribute, "type">; export interface IGenericControlAttribute extends BaseControlAttribute { type: string; [key: string]: any; } export interface ISpbRadioChooserOption<T = any> { value: T; resourceKey: string; } export interface ISpbRadioChooserAttribute<T = any> extends Omit<BaseControlAttribute, "migrationValue"> { type: StandardPropertyTypes.RadioChooser | `${StandardPropertyTypes.RadioChooser}`; migrationValue?: T; defaultValue?: T; radioConfig: { inline?: boolean; options: Array<ISpbRadioChooserOption<T>>; }; } export interface IControlAttributeCheckbox extends Omit<BaseControlAttribute, "migrationValue"> { type: StandardPropertyTypes.Checkbox | `${StandardPropertyTypes.Checkbox}`; migrationValue?: boolean; defaultValue?: boolean; } export interface IControlAttributePicklist extends BaseControlAttribute { type: StandardPropertyTypes.Picklist | `${StandardPropertyTypes.Picklist}`; picklistName: string; noSelectionText?: ResourcedString; relatedDataSource?: string; } export interface IControlAttributeDataSource extends BaseControlAttribute { type: StandardPropertyTypes.DataSource | `${StandardPropertyTypes.DataSource}`; limitDataSourceType?: string; ignoreRestrictions?: boolean; optional?: boolean; } interface RadioSwitchBaseOption { default?: boolean; iconClass: string; value: any; title: string; } export type RadioSwitchOption = RadioSwitchBaseOption | Omit<RadioSwitchBaseOption, "title"> | Omit<RadioSwitchBaseOption, "iconClass">; export interface IControlAttributeRadioSwitch extends BaseControlAttribute { type: StandardPropertyTypes.RadioSwitch | `${StandardPropertyTypes.RadioSwitch}`; options: RadioSwitchOption[]; } export interface IControlAttributeHeightEditor extends BaseControlAttribute { type: StandardPropertyTypes.HeightEditor | `${StandardPropertyTypes.HeightEditor}`; states?: { hideResizeByContent?: boolean; hideFill?: boolean; hideFixed?: boolean; }; labels?: { fixed: string; resize: string; }; defaultValue?: string; } export interface IControlAttributeChartDataSource extends BaseControlAttribute { type: StandardPropertyTypes.ChartDataSource | `${StandardPropertyTypes.ChartDataSource}`; groupFieldHidden?: any; valueFieldDisabledExpression?: string; } export interface IControlAttributeNumericRange extends BaseControlAttribute { type: StandardPropertyTypes.NumericRange | `${StandardPropertyTypes.NumericRange}`; min: number; max: number; defaultValue?: number; } export interface IControlAttributeLinkedPage extends BaseControlAttribute { type: StandardPropertyTypes.LinkedPage | `${StandardPropertyTypes.LinkedPage}`; allowNoDataSourcePages?: boolean; } export interface IControlAttributeMultiEditor extends BaseControlAttribute { type: StandardPropertyTypes.MultiEditor | `${StandardPropertyTypes.MultiEditor}`; editorAttributes: { buttonText: ResourcedString; category: "Container"; type: string; typePlural: string; }; } export interface IControlAttributeFileCategoryDataSource extends Omit<IControlAttributeDataSource, "type"> { type: StandardPropertyTypes.FileCategoryDataSource | `${StandardPropertyTypes.FileCategoryDataSource}`; allowMultiple?: boolean | string; } export interface IControlAttributeStatusThresholdPicker extends BaseControlAttribute { type: StandardPropertyTypes.StatusThresholdPicker | `${StandardPropertyTypes.StatusThresholdPicker}`; thresholds: Array<{ color: Status; label: string; resourceKey: string; lowerBound: number; }>; upperBound: number; } export interface IControlAttributeRelationshipSummary extends Omit<BaseControlAttribute, "displayName"> { type: StandardPropertyTypes.RelationshipSummary | `${StandardPropertyTypes.RelationshipSummary}`; displayName?: never; } export interface IControlAttributeTextInput extends BaseControlAttribute { type: StandardPropertyTypes.TextInput | `${StandardPropertyTypes.TextInput}`; defaultValue?: ResourcedString | string; } export interface IControlAttributeInterpolatedTextInput extends Omit<IControlAttributeTextInput, "type"> { type: StandardPropertyTypes.InterpolatedTextInput | `${StandardPropertyTypes.InterpolatedTextInput}`; interpolatedTextInputDialogTitle: ResourcedString; } export interface IControlAttributeTileProviderChooser extends BaseControlAttribute { type: StandardPropertyTypes.TileProviderChooser | `${StandardPropertyTypes.TileProviderChooser}`; optional?: boolean; } export interface IControlAttributeSeparatorStart extends Omit<BaseControlAttribute, "displayName"> { displayName?: never; separatorLabel?: ResourcedString; type: StandardPropertyTypes.SeparatorStart | `${StandardPropertyTypes.SeparatorStart}`; } export interface IControlAttributeSeparator extends Omit<BaseControlAttribute, "displayName"> { displayName?: never; separatorLabel?: ResourcedString; type: StandardPropertyTypes.Separator | `${StandardPropertyTypes.Separator}`; } export interface IControlAttributeColumnDataType extends Omit<BaseControlAttribute, "displayName"> { displayName?: never; type: StandardPropertyTypes.ColumnDataType | `${StandardPropertyTypes.ColumnDataType}`; } export {};