/** * Powerbi utils components classes for custom visual formatting pane objects * */ import powerbi from "powerbi-visuals-api"; import { IFormattingSettingsSlice, ILocalizedItemMember } from "./FormattingSettingsInterfaces"; import data = powerbi.data; import visuals = powerbi.visuals; /** * Names of the data (non-method) properties of T. * * NOTE: the filter is purely structural — a property is dropped when its type is a function. * Two consequences to keep in mind when adding members to a component: * - A consumer-provided callback declared as a plain function (e.g. `onChange?: () => void`) * would be dropped here too. If such a field is ever needed in the init object, add it back * explicitly (e.g. `Pick> & Pick`). * - Component methods must stay required. An optional method (`method?()`) has type * `(() => ...) | undefined`, which does NOT match the function check, so it would leak in * as if it were a data property. */ type NonFunctionPropertyNames = { [K in keyof T]: T[K] extends (...args: any[]) => any ? never : K; }[keyof T]; /** * Initialization object for slice components: data properties only. * Every function-typed member (the formatting methods implemented by the component classes) * is excluded automatically, so object-literal initialization works (e.g. new ToggleSwitch({ ... })) * and the type stays correct as components add or change methods — no method names are hard-coded. * * Components must be created with `new` — a bare object literal does not satisfy the component * type because the slice methods are required. Wrap initializers in the constructor: * `new ColorPicker({ ... })`, not `{ ... }`. */ export type SliceInit = Pick>; export declare class NamedEntity { displayName?: string; displayNameKey?: string; description?: string; descriptionKey?: string; } export declare class CardGroupEntity extends NamedEntity { /** groups doesn't exist in capabilities, it's a custom object to be used in formatting pane, however it should have a unique name */ name: string; slices?: Array; container?: Container; disabled?: boolean; /** group disabled reason */ disabledReason?: string; disabledReasonKey?: string; /** * If delaySaveSlices is true, then this group's slices' value changes won't be saved to the visual until a * signal action is taken. E.g., for an Analytics Pane forecast, the forecast parameter values shouldn't be * saved to the visual until the Apply button is clicked. Note that this applies to all slices in the group. */ delaySaveSlices?: boolean; /** Group can expand/collapse */ collapsible?: boolean; /** if true, this group will be populated into the formatting pane */ visible?: boolean; /** Slice, usually a ToggleSwitch, to be rendered at the top of the card/group */ topLevelSlice?: SimpleSlice; } export declare class Model { cards: Array; } /** CompositeCard is use to populate a card into the formatting pane with multiple groups */ export declare abstract class CompositeCard extends NamedEntity { /** name should be the exact same object name from capabilities objects that this formatting card is representing */ name: string; abstract groups: Array; /** if true, this card will be populated into the formatting pane */ visible?: boolean; disabled?: boolean; /** card disabled reason */ disabledReason?: string; disabledReasonKey?: string; /** if true, this card should be populated into the analytics pane */ analyticsPane?: boolean; /** Slice, usually a ToggleSwitch, to be rendered at the top of the card/group */ topLevelSlice?: SimpleSlice; /** * Called before the card is populated. * This is useful for setting the card's slices' visibility before the card is populated into the formatting pane. */ onPreProcess?(): void; } export declare class Group extends CardGroupEntity { constructor(object?: Group); } /** SimpleCard is use to populate a card into the formatting pane in a single group */ export declare class SimpleCard extends CardGroupEntity { /** if true, this card should be populated into the analytics pane */ analyticsPane?: boolean; /** * Called before the card is populated. * This is useful for setting the card's slices' visibility before the card is populated into the formatting pane. */ onPreProcess?(): void; } export type Cards = SimpleCard | CompositeCard; export type Slice = SimpleSlice | CompositeSlice; export declare abstract class SimpleSlice extends NamedEntity implements IFormattingSettingsSlice { /** name should be the exact same property name from capabilities object properties list that this formatting slice is representing */ name: string; value: T; selector?: data.Selector; altConstantSelector?: data.Selector; instanceKind?: powerbi.VisualEnumerationInstanceKinds; /** if true, this slice will be populated into the formatting pane */ visible?: boolean; /** if true, this slice will be disabled */ disabled?: boolean; /** slice disabled reason */ disabledReason?: string; disabledReasonKey?: string; /** type declared in each slice sub class, No need to declare it in initializing object */ type?: visuals.FormattingComponent; constructor(object: SliceInit>); getFormattingSlice(objectName: string, localizationManager?: powerbi.extensibility.ILocalizationManager): visuals.SimpleVisualFormattingSlice; getFormattingComponent(objectName: string, localizationManager?: powerbi.extensibility.ILocalizationManager): visuals.SimpleComponentBase; getRevertToDefaultDescriptor(objectName: string): visuals.FormattingDescriptor[]; setPropertiesValues(dataViewObjects: powerbi.DataViewObjects, objectName: string): void; } export declare class AlignmentGroup extends SimpleSlice { mode: visuals.AlignmentGroupMode; supportsNoSelection?: boolean; type?: visuals.FormattingComponent | undefined; constructor(object: SliceInit); getFormattingComponent(objectName: string): visuals.AlignmentGroup; } export declare class ToggleSwitch extends SimpleSlice { type?: visuals.FormattingComponent | undefined; /** @example new ToggleSwitch({ name: "show", value: false }) — use the constructor, not a bare `{ ... }` literal. */ constructor(object: SliceInit); } export declare class ColorPicker extends SimpleSlice { defaultColor?: powerbi.ThemeColorData; isNoFillItemSupported?: boolean; type?: visuals.FormattingComponent | undefined; /** @example new ColorPicker({ name: "fill", value: { value: "#000" } }) — use the constructor, not a bare `{ ... }` literal. */ constructor(object: SliceInit); getFormattingComponent(objectName: string): visuals.ColorPicker; } export declare class NumUpDown extends SimpleSlice { options?: visuals.NumUpDownFormat; type?: visuals.FormattingComponent | undefined; /** @example new NumUpDown({ name: "width", value: 10 }) — use the constructor, not a bare `{ ... }` literal. */ constructor(object: SliceInit); getFormattingComponent(objectName: string): visuals.NumUpDown; } export declare class Slider extends NumUpDown { type?: visuals.FormattingComponent | undefined; } export declare class DatePicker extends SimpleSlice { placeholder: string; placeholderKey?: string; validators?: { max?: visuals.MaxValidator; min?: visuals.MinValidator; }; type?: visuals.FormattingComponent | undefined; constructor(object: SliceInit); getFormattingComponent(objectName: string, localizationManager?: powerbi.extensibility.ILocalizationManager): visuals.DatePicker; } export declare class ItemDropdown extends SimpleSlice { items: powerbi.IEnumMember[] | ILocalizedItemMember[]; type?: visuals.FormattingComponent | undefined; /** @example new ItemDropdown({ name: "shape", items: [], value: { value: null, displayName: "" } }) — use the constructor, not a bare `{ ... }` literal. */ constructor(object: SliceInit); getFormattingComponent(objectName: string, localizationManager?: powerbi.extensibility.ILocalizationManager): visuals.ItemDropdown; getFormattingItems(localizationManager: powerbi.extensibility.ILocalizationManager | undefined, items: powerbi.IEnumMember[] | ILocalizedItemMember[]): powerbi.IEnumMember[]; setValue(value: powerbi.EnumMemberValue, localizationManager?: powerbi.extensibility.ILocalizationManager): void; } export declare class AutoDropdown extends SimpleSlice { mergeValues?: powerbi.IEnumMember[] | ILocalizedItemMember[]; filterValues?: powerbi.EnumMemberValue[]; type?: visuals.FormattingComponent | undefined; constructor(object: SliceInit); getFormattingComponent(objectName: string, localizationManager?: powerbi.extensibility.ILocalizationManager): visuals.AutoDropdown; getFormattingItems(localizationManager: powerbi.extensibility.ILocalizationManager | undefined, items: powerbi.IEnumMember[] | ILocalizedItemMember[] | undefined): powerbi.IEnumMember[]; } export declare class DurationPicker extends SimpleSlice { validators?: { min?: string; max?: string; integer?: boolean; }; type?: visuals.FormattingComponent | undefined; constructor(object: SliceInit); getFormattingComponent(objectName: string): visuals.DurationPicker; } export declare class ErrorRangeControl extends SimpleSlice { validators: powerbi.explore.directives.ValidationInfo; type?: visuals.FormattingComponent | undefined; constructor(object: SliceInit); getFormattingComponent(objectName: string): visuals.ErrorRangeControl; } export declare class FieldPicker extends SimpleSlice { validators: powerbi.explore.directives.ValidationInfo; allowMultipleValues?: boolean; type?: visuals.FormattingComponent | undefined; constructor(object: SliceInit); getFormattingComponent(objectName: string): visuals.FieldPicker; } /** * Allows selecting multiple flags from a predefined list of items with bitwise values. * The selected flags are stored as a single number using bitwise representation, * where each flag corresponds to a specific bit position. * @example * 0 = no flags * 1 = show category * 2 = show value * 4 = show percent */ export declare class ItemFlagsSelection extends SimpleSlice { items: powerbi.IEnumMember[] | ILocalizedItemMember[]; type?: visuals.FormattingComponent | undefined; constructor(object: SliceInit); getFormattingComponent(objectName: string, localizationManager?: powerbi.extensibility.ILocalizationManager): visuals.ItemFlagsSelection; getFormattingItems(localizationManager: powerbi.extensibility.ILocalizationManager | undefined, items: powerbi.IEnumMember[] | ILocalizedItemMember[]): powerbi.IEnumMember[]; } /** * Multiple flags selection component with enumeration values defined in capabilities.json, * using bitwise number values in a string representation. * The selected flags are stored as a single number using bitwise representation, * where each flag corresponds to a specific bit position. * @example * 0 = no flags * 1 = show category * 2 = show value * 4 = show percent */ export declare class AutoFlagsSelection extends SimpleSlice { type?: visuals.FormattingComponent | undefined; } export declare class TextInput extends SimpleSlice { placeholder: string; type?: visuals.FormattingComponent | undefined; constructor(object: SliceInit); getFormattingComponent(objectName: string): visuals.TextInput; } export declare class TextArea extends TextInput { type?: visuals.FormattingComponent | undefined; } export declare class FontPicker extends SimpleSlice { type?: visuals.FormattingComponent | undefined; } export declare class GradientBar extends SimpleSlice { type?: visuals.FormattingComponent | undefined; } export declare class ImageUpload extends SimpleSlice { type?: visuals.FormattingComponent | undefined; } export declare class ListEditor extends SimpleSlice { type?: visuals.FormattingComponent | undefined; } export declare class ReadOnlyText extends SimpleSlice { type?: visuals.FormattingComponent | undefined; } export declare class ShapeMapSelector extends SimpleSlice { isAzMapReferenceSelector?: boolean; type?: visuals.FormattingComponent | undefined; constructor(object: SliceInit); getFormattingComponent(objectName: string): visuals.ShapeMapSelector; } export declare abstract class CompositeSlice extends NamedEntity implements IFormattingSettingsSlice { /** composite slice name isn't required to be from capabilities * it will only be used for building formatting slice uid*/ name: string; type?: visuals.FormattingComponent; /** slice disabled reason */ disabledReason?: string; disabledReasonKey?: string; disabled?: boolean; visible?: boolean; constructor(object: SliceInit); getFormattingSlice(objectName: string, localizationManager?: powerbi.extensibility.ILocalizationManager): visuals.CompositeVisualFormattingSlice; abstract getFormattingComponent(objectName: string): visuals.CompositeComponentPropertyType; abstract getRevertToDefaultDescriptor(objectName: string): visuals.FormattingDescriptor[]; abstract setPropertiesValues(dataViewObjects: powerbi.DataViewObjects, objectName: string): void; } export declare class FontControl extends CompositeSlice { fontFamily: FontPicker; fontSize: NumUpDown; bold?: ToggleSwitch; italic?: ToggleSwitch; underline?: ToggleSwitch; type?: visuals.FormattingComponent | undefined; constructor(object: SliceInit); getFormattingComponent(objectName: string): visuals.FontControl; getRevertToDefaultDescriptor(objectName: string): visuals.FormattingDescriptor[]; setPropertiesValues(dataViewObjects: powerbi.DataViewObjects, objectName: string): void; } export declare class MarginPadding extends CompositeSlice { left: NumUpDown; right: NumUpDown; top: NumUpDown; bottom: NumUpDown; type?: visuals.FormattingComponent | undefined; constructor(object: SliceInit); getFormattingComponent(objectName: string): visuals.MarginPadding; getRevertToDefaultDescriptor(objectName: string): visuals.FormattingDescriptor[]; setPropertiesValues(dataViewObjects: powerbi.DataViewObjects, objectName: string): void; } export declare class Container extends NamedEntity { constructor(object: SliceInit); containerItems: ContainerItem[]; /** * Whether this container allows editing, including add/remove container items, and * edit of individual container item's value itself. */ isEditable?: boolean; } export declare class ContainerItem extends NamedEntity { slices?: Slice[]; groups?: Group[]; visible?: boolean; } export {}; //# sourceMappingURL=FormattingSettingsComponents.d.ts.map