diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..3e759b7 --- /dev/null +++ b/.gitignore @@ -0,0 +1,330 @@ +## Ignore Visual Studio temporary files, build results, and +## files generated by popular Visual Studio add-ons. +## +## Get latest from https://github.com/github/gitignore/blob/master/VisualStudio.gitignore + +# User-specific files +*.suo +*.user +*.userosscache +*.sln.docstates + +# User-specific files (MonoDevelop/Xamarin Studio) +*.userprefs + +# Build results +[Dd]ebug/ +[Dd]ebugPublic/ +[Rr]elease/ +[Rr]eleases/ +x64/ +x86/ +bld/ +[Bb]in/ +[Oo]bj/ +[Ll]og/ + +# Visual Studio 2015/2017 cache/options directory +.vs/ +# Uncomment if you have tasks that create the project's static files in wwwroot +#wwwroot/ + +# Visual Studio 2017 auto generated files +Generated\ Files/ + +# MSTest test Results +[Tt]est[Rr]esult*/ +[Bb]uild[Ll]og.* + +# NUNIT +*.VisualState.xml +TestResult.xml + +# Build Results of an ATL Project +[Dd]ebugPS/ +[Rr]eleasePS/ +dlldata.c + +# Benchmark Results +BenchmarkDotNet.Artifacts/ + +# .NET Core +project.lock.json +project.fragment.lock.json +artifacts/ +**/Properties/launchSettings.json + +# StyleCop +StyleCopReport.xml + +# Files built by Visual Studio +*_i.c +*_p.c +*_i.h +*.ilk +*.meta +*.obj +*.iobj +*.pch +*.pdb +*.ipdb +*.pgc +*.pgd +*.rsp +*.sbr +*.tlb +*.tli +*.tlh +*.tmp +*.tmp_proj +*.log +*.vspscc +*.vssscc +.builds +*.pidb +*.svclog +*.scc + +# Chutzpah Test files +_Chutzpah* + +# Visual C++ cache files +ipch/ +*.aps +*.ncb +*.opendb +*.opensdf +*.sdf +*.cachefile +*.VC.db +*.VC.VC.opendb + +# Visual Studio profiler +*.psess +*.vsp +*.vspx +*.sap + +# Visual Studio Trace Files +*.e2e + +# TFS 2012 Local Workspace +$tf/ + +# Guidance Automation Toolkit +*.gpState + +# ReSharper is a .NET coding add-in +_ReSharper*/ +*.[Rr]e[Ss]harper +*.DotSettings.user + +# JustCode is a .NET coding add-in +.JustCode + +# TeamCity is a build add-in +_TeamCity* + +# DotCover is a Code Coverage Tool +*.dotCover + +# AxoCover is a Code Coverage Tool +.axoCover/* +!.axoCover/settings.json + +# Visual Studio code coverage results +*.coverage +*.coveragexml + +# NCrunch +_NCrunch_* +.*crunch*.local.xml +nCrunchTemp_* + +# MightyMoose +*.mm.* +AutoTest.Net/ + +# Web workbench (sass) +.sass-cache/ + +# Installshield output folder +[Ee]xpress/ + +# DocProject is a documentation generator add-in +DocProject/buildhelp/ +DocProject/Help/*.HxT +DocProject/Help/*.HxC +DocProject/Help/*.hhc +DocProject/Help/*.hhk +DocProject/Help/*.hhp +DocProject/Help/Html2 +DocProject/Help/html + +# Click-Once directory +publish/ + +# Publish Web Output +*.[Pp]ublish.xml +*.azurePubxml +# Note: Comment the next line if you want to checkin your web deploy settings, +# but database connection strings (with potential passwords) will be unencrypted +*.pubxml +*.publishproj + +# Microsoft Azure Web App publish settings. Comment the next line if you want to +# checkin your Azure Web App publish settings, but sensitive information contained +# in these scripts will be unencrypted +PublishScripts/ + +# NuGet Packages +*.nupkg +# The packages folder can be ignored because of Package Restore +**/[Pp]ackages/* +# except build/, which is used as an MSBuild target. +!**/[Pp]ackages/build/ +# Uncomment if necessary however generally it will be regenerated when needed +#!**/[Pp]ackages/repositories.config +# NuGet v3's project.json files produces more ignorable files +*.nuget.props +*.nuget.targets + +# Microsoft Azure Build Output +csx/ +*.build.csdef + +# Microsoft Azure Emulator +ecf/ +rcf/ + +# Windows Store app package directories and files +AppPackages/ +BundleArtifacts/ +Package.StoreAssociation.xml +_pkginfo.txt +*.appx + +# Visual Studio cache files +# files ending in .cache can be ignored +*.[Cc]ache +# but keep track of directories ending in .cache +!*.[Cc]ache/ + +# Others +ClientBin/ +~$* +*~ +*.dbmdl +*.dbproj.schemaview +*.jfm +*.pfx +*.publishsettings +orleans.codegen.cs + +# Including strong name files can present a security risk +# (https://github.com/github/gitignore/pull/2483#issue-259490424) +#*.snk + +# Since there are multiple workflows, uncomment next line to ignore bower_components +# (https://github.com/github/gitignore/pull/1529#issuecomment-104372622) +#bower_components/ + +# RIA/Silverlight projects +Generated_Code/ + +# Backup & report files from converting an old project file +# to a newer Visual Studio version. Backup files are not needed, +# because we have git ;-) +_UpgradeReport_Files/ +Backup*/ +UpgradeLog*.XML +UpgradeLog*.htm +ServiceFabricBackup/ +*.rptproj.bak + +# SQL Server files +*.mdf +*.ldf +*.ndf + +# Business Intelligence projects +*.rdl.data +*.bim.layout +*.bim_*.settings +*.rptproj.rsuser + +# Microsoft Fakes +FakesAssemblies/ + +# GhostDoc plugin setting file +*.GhostDoc.xml + +# Node.js Tools for Visual Studio +.ntvs_analysis.dat +node_modules/ + +# Visual Studio 6 build log +*.plg + +# Visual Studio 6 workspace options file +*.opt + +# Visual Studio 6 auto-generated workspace file (contains which files were open etc.) +*.vbw + +# Visual Studio LightSwitch build output +**/*.HTMLClient/GeneratedArtifacts +**/*.DesktopClient/GeneratedArtifacts +**/*.DesktopClient/ModelManifest.xml +**/*.Server/GeneratedArtifacts +**/*.Server/ModelManifest.xml +_Pvt_Extensions + +# Paket dependency manager +.paket/paket.exe +paket-files/ + +# FAKE - F# Make +.fake/ + +# JetBrains Rider +.idea/ +*.sln.iml + +# CodeRush +.cr/ + +# Python Tools for Visual Studio (PTVS) +__pycache__/ +*.pyc + +# Cake - Uncomment if you are using it +# tools/** +# !tools/packages.config + +# Tabs Studio +*.tss + +# Telerik's JustMock configuration file +*.jmconfig + +# BizTalk build output +*.btp.cs +*.btm.cs +*.odx.cs +*.xsd.cs + +# OpenCover UI analysis results +OpenCover/ + +# Azure Stream Analytics local run output +ASALocalRun/ + +# MSBuild Binary and Structured Log +*.binlog + +# NVidia Nsight GPU debugger configuration file +*.nvuser + +# MFractors (Xamarin productivity tool) working folder +.mfractor/ diff --git a/CODE_OF_CONDUCT.md b/CODE_OF_CONDUCT.md deleted file mode 100644 index f9ba8cf..0000000 --- a/CODE_OF_CONDUCT.md +++ /dev/null @@ -1,9 +0,0 @@ -# Microsoft Open Source Code of Conduct - -This project has adopted the [Microsoft Open Source Code of Conduct](https://opensource.microsoft.com/codeofconduct/). - -Resources: - -- [Microsoft Open Source Code of Conduct](https://opensource.microsoft.com/codeofconduct/) -- [Microsoft Code of Conduct FAQ](https://opensource.microsoft.com/codeofconduct/faq/) -- Contact [opencode@microsoft.com](mailto:opencode@microsoft.com) with questions or concerns diff --git a/README.md b/README.md deleted file mode 100644 index 5cd7cec..0000000 --- a/README.md +++ /dev/null @@ -1,33 +0,0 @@ -# Project - -> This repo has been populated by an initial template to help get you started. Please -> make sure to update the content to build a great experience for community-building. - -As the maintainer of this project, please make a few updates: - -- Improving this README.MD file to provide a great experience -- Updating SUPPORT.MD with content about this project's support experience -- Understanding the security reporting process in SECURITY.MD -- Remove this section from the README - -## Contributing - -This project welcomes contributions and suggestions. Most contributions require you to agree to a -Contributor License Agreement (CLA) declaring that you have the right to, and actually do, grant us -the rights to use your contribution. For details, visit https://cla.opensource.microsoft.com. - -When you submit a pull request, a CLA bot will automatically determine whether you need to provide -a CLA and decorate the PR appropriately (e.g., status check, comment). Simply follow the instructions -provided by the bot. You will only need to do this once across all repos using our CLA. - -This project has adopted the [Microsoft Open Source Code of Conduct](https://opensource.microsoft.com/codeofconduct/). -For more information see the [Code of Conduct FAQ](https://opensource.microsoft.com/codeofconduct/faq/) or -contact [opencode@microsoft.com](mailto:opencode@microsoft.com) with any additional questions or comments. - -## Trademarks - -This project may contain trademarks or logos for projects, products, or services. Authorized use of Microsoft -trademarks or logos is subject to and must follow -[Microsoft's Trademark & Brand Guidelines](https://www.microsoft.com/en-us/legal/intellectualproperty/trademarks/usage/general). -Use of Microsoft trademarks or logos in modified versions of this project must not cause confusion or imply Microsoft sponsorship. -Any use of third-party trademarks or logos are subject to those third-party's policies. diff --git a/SECURITY.md b/SECURITY.md deleted file mode 100644 index f7b8998..0000000 --- a/SECURITY.md +++ /dev/null @@ -1,41 +0,0 @@ - - -## Security - -Microsoft takes the security of our software products and services seriously, which includes all source code repositories managed through our GitHub organizations, which include [Microsoft](https://github.com/Microsoft), [Azure](https://github.com/Azure), [DotNet](https://github.com/dotnet), [AspNet](https://github.com/aspnet), [Xamarin](https://github.com/xamarin), and [our GitHub organizations](https://opensource.microsoft.com/). - -If you believe you have found a security vulnerability in any Microsoft-owned repository that meets [Microsoft's definition of a security vulnerability](https://docs.microsoft.com/en-us/previous-versions/tn-archive/cc751383(v=technet.10)), please report it to us as described below. - -## Reporting Security Issues - -**Please do not report security vulnerabilities through public GitHub issues.** - -Instead, please report them to the Microsoft Security Response Center (MSRC) at [https://msrc.microsoft.com/create-report](https://msrc.microsoft.com/create-report). - -If you prefer to submit without logging in, send email to [secure@microsoft.com](mailto:secure@microsoft.com). If possible, encrypt your message with our PGP key; please download it from the [Microsoft Security Response Center PGP Key page](https://www.microsoft.com/en-us/msrc/pgp-key-msrc). - -You should receive a response within 24 hours. If for some reason you do not, please follow up via email to ensure we received your original message. Additional information can be found at [microsoft.com/msrc](https://www.microsoft.com/msrc). - -Please include the requested information listed below (as much as you can provide) to help us better understand the nature and scope of the possible issue: - - * Type of issue (e.g. buffer overflow, SQL injection, cross-site scripting, etc.) - * Full paths of source file(s) related to the manifestation of the issue - * The location of the affected source code (tag/branch/commit or direct URL) - * Any special configuration required to reproduce the issue - * Step-by-step instructions to reproduce the issue - * Proof-of-concept or exploit code (if possible) - * Impact of the issue, including how an attacker might exploit the issue - -This information will help us triage your report more quickly. - -If you are reporting for a bug bounty, more complete reports can contribute to a higher bounty award. Please visit our [Microsoft Bug Bounty Program](https://microsoft.com/msrc/bounty) page for more details about our active programs. - -## Preferred Languages - -We prefer all communications to be in English. - -## Policy - -Microsoft follows the principle of [Coordinated Vulnerability Disclosure](https://www.microsoft.com/en-us/msrc/cvd). - - \ No newline at end of file diff --git a/SUPPORT.md b/SUPPORT.md deleted file mode 100644 index 291d4d4..0000000 --- a/SUPPORT.md +++ /dev/null @@ -1,25 +0,0 @@ -# TODO: The maintainer of this repo has not yet edited this file - -**REPO OWNER**: Do you want Customer Service & Support (CSS) support for this product/project? - -- **No CSS support:** Fill out this template with information about how to file issues and get help. -- **Yes CSS support:** Fill out an intake form at [aka.ms/onboardsupport](https://aka.ms/onboardsupport). CSS will work with/help you to determine next steps. -- **Not sure?** Fill out an intake as though the answer were "Yes". CSS will help you decide. - -*Then remove this first heading from this SUPPORT.MD file before publishing your repo.* - -# Support - -## How to file issues and get help - -This project uses GitHub Issues to track bugs and feature requests. Please search the existing -issues before filing new issues to avoid duplicates. For new issues, file your bug or -feature request as a new Issue. - -For help and questions about using this project, please **REPO MAINTAINER: INSERT INSTRUCTIONS HERE -FOR HOW TO ENGAGE REPO OWNERS OR COMMUNITY FOR HELP. COULD BE A STACK OVERFLOW TAG OR OTHER -CHANNEL. WHERE WILL YOU HELP PEOPLE?**. - -## Microsoft Support Policy - -Support for this **PROJECT or PRODUCT** is limited to the resources listed above. diff --git a/index.d.ts b/index.d.ts new file mode 100644 index 0000000..2c8eb66 --- /dev/null +++ b/index.d.ts @@ -0,0 +1,629 @@ +/* + * Power BI Visualizations + * + * Copyright (c) Microsoft Corporation + * All rights reserved. + * MIT License + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the ""Software""), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED *AS IS*, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +import powerbi_api from "powerbi-visuals-api"; + +import DataViewObjectPropertyIdentifier = powerbi_api.DataViewObjectPropertyIdentifier; +import ValueTypeDescriptor = powerbi_api.ValueTypeDescriptor; +import Selector = powerbi_api.data.Selector; +import VisualEnumerationInstanceKinds = powerbi_api.VisualEnumerationInstanceKinds; +import EnumMemberValue = powerbi_api.EnumMemberValue; +import IEnumMember = powerbi_api.IEnumMember; +import ImageValue = powerbi_api.ImageValue; +import GeoJson = powerbi_api.GeoJson; +import ISQExpr = powerbi_api.data.ISQExpr; +import DisplayNameGetter = powerbi_api.data.DisplayNameGetter; +import FieldKind = powerbi_api.data.FieldKind; + +declare module powerbi { + export namespace visuals { + export type FormattingModelWarnings = { [cardUid: string]: IVisualWarning }; + + export interface FormattingModel { + cards: (FormattingCard | FormattingCardPlaceholder)[]; + modelUnavailableImageName?: string; + modelUnavailableMessageKey?: string; + modelUnavailableLearnMoreLink?: string; + // this is used for displaying messages in formatting pane, with an action to usually open some dialog. + formattingModelMessage?: FormattingModelMessage; + warnings?: FormattingModelWarnings; + } + + export interface FormattingModelMessage { + messageKey: string; + action?: FormattingModelMessageAction; + } + + export interface FormattingModelMessageAction { + key: string; + fn: () => void; + } + + export interface FormattingWarning { + warningMessage?: IVisualErrorMessage; + } + + export interface FormattingCard extends VisualFormattingUid, VisualFormattingDisplayName, FormattingWarning { + disabled?: boolean; + /** card disabled reason */ + disabledReason?: string; + /** This is top-level card On/Off property */ + topLevelToggle?: EnabledSlice; + groups: (FormattingGroup | FormattingGroupPlaceholder)[]; + /** This contains the list of descriptors for revert to default, note the descriptors of all the slices ever possible in the card must be added */ + revertToDefaultDescriptors?: FormattingDescriptor[]; + /** if true, this card should be populated into the analytics pane */ + analyticsPane?: boolean; + } + + export interface FormattingGroup extends VisualFormattingUid, VisualFormattingDisplayName { + disabled?: boolean; + /** card disabled reason */ + disabledReason?: string; + /** This is top-level card On/Off property */ + topLevelToggle?: EnabledSlice; + slices?: (FormattingSlice | FormattingSlicePlaceholder)[]; + container?: FormattingContainer; + containerDisabled?: boolean; + /** Allows slices in the same group as containers. Slices are outside of the container's context */ + sliceWithContainer?: boolean; + /** + * 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; + collapsible?: boolean; + /** defaulted to true, if false, we will keep the group enabled even though it's parent card has topLevelToggle value set to false */ + inheritDisabled?: boolean; + } + + export interface FormattingContainer extends VisualFormattingUid, VisualFormattingDisplayName { + containerItems: FormattingContainerItem[]; + /** + * Whether this container allows editing, including add/remove container items, and + * edit of indivisual container item's value itself. + */ + isEditable?: boolean; + } + + export interface FormattingContainerItem extends VisualFormattingUid { + displayName: string; + disabled?: boolean; + slices?: FormattingSlice[]; + groups?: Omit[]; + } + + export type FormattingSlice = SimpleVisualFormattingSlice | CompositeVisualFormattingSlice; + + export interface BaseVisualFormattingSlice extends VisualFormattingUid { + control: TControl; + disabled?: boolean; + suppressUndoRedoRegister?: boolean; + } + + /** Slice display name is required for composite slices */ + export interface CompositeVisualFormattingSlice extends BaseVisualFormattingSlice, VisualFormattingDisplayName, VisualFormattingInfoIconText { + } + + /** Slice display name is optional for simple slices */ + export interface SimpleVisualFormattingSlice extends BaseVisualFormattingSlice, Partial, VisualFormattingInfoIconText { + // Properties added here to add comments + /** Only set if needed to override the capabilities */ + displayName?: string; + /** Only set if needed to override the capabilities */ + description?: string; + } + + export interface EnabledSlice extends BaseVisualFormattingSlice>> { + suppressDisplayName: boolean; + } + + export interface VisualFormattingUid { + /** A unique Identifier */ + uid: string; + } + + export interface VisualFormattingDisplayName { + displayName: string; + description?: string; + /** + * It will be used as an alternate name for the formatting card (will be only used for searching purposes) + */ + aliasName?: string; + suppressDisplayName?: boolean; + } + + export interface VisualFormattingInfoIconText { + /** Only set if needed to display info icon with tooltip for the slice */ + infoIconText?: string; + } + + export interface FormattingDescriptor extends DataViewObjectPropertyIdentifier { + selector?: Selector; + /** (Optional) Set the required type for particular property that support variant types. */ + propertyTypes?: ValueTypeDescriptor; + instanceKind?: VisualEnumerationInstanceKinds; + /** (Optional) Allows visuals to specify an alternate selector to be used when the value is a constant, + * as opposed to a data-bound expression. This selector may be used to place the object at a higher scope, + * such as the static scope, to avoid repeating the same constant value on each instance of a scope.*/ + altConstantValueSelector?: Selector; + } + + export const enum FormattingPlaceholderType { + Card = 'card', + Group = 'group', + Slice = 'slice', + } + + export interface FormattingPlaceholder { + type: FormattingPlaceholderType; + source: string; + name: string; + /** Whether a default value should be returned if the placeholder isn't able to be resolved normally */ + suppressDefaultValue?: boolean; + } + + export interface FormattingCardPlaceholder extends FormattingPlaceholder { + type: FormattingPlaceholderType.Card; + + /** if true, this card should be populated into the analytics pane. */ + analyticsPane?: boolean; + } + + export interface FormattingGroupPlaceholder extends FormattingPlaceholder { + type: FormattingPlaceholderType.Group; + } + + export interface FormattingSlicePlaceholder extends FormattingPlaceholder { + type: FormattingPlaceholderType.Slice; + } + + export const enum FormattingPlaceholderSource { + Host = 'host', + Visual = 'visual', + } + + // Host placeholders are placeholders that use data provided by the host (Minerva, aka Visual Container properties) + + export const enum HostFormattingCardPlaceholderName { + Actions = 'actions', + } + + // No placeholders of these types yet + export type HostFormattingGroupPlaceholderName = never; + export type HostFormattingSlicePlaceholderName = never; + + export interface HostFormattingPlaceholder extends FormattingPlaceholder { + source: FormattingPlaceholderSource.Host; + } + + export interface HostFormattingCardPlaceholder extends HostFormattingPlaceholder { + type: FormattingPlaceholderType.Card; + name: HostFormattingCardPlaceholderName; + } + + export interface HostFormattingGroupPlaceholder extends HostFormattingPlaceholder { + type: FormattingPlaceholderType.Group; + name: HostFormattingGroupPlaceholderName; + } + + export interface HostFormattingSlicePlaceholder extends HostFormattingPlaceholder { + type: FormattingPlaceholderType.Slice; + name: HostFormattingSlicePlaceholderName; + } + + // Visual placeholders that use data provided by the visual + + export type VisualFormattingCardPlaceholderName = never; + export type VisualFormattingGroupPlaceholderName = never; + export const enum VisualFormattingSlicePlaceholderName { + DataVolume = 'dataVolume', + Responsive = 'responsive', + } + + export interface VisualFormattingPlaceholder extends FormattingPlaceholder { + source: FormattingPlaceholderSource.Visual; + } + + export interface VisualFormattingCardPlaceholder extends VisualFormattingPlaceholder { + type: FormattingPlaceholderType.Card; + name: VisualFormattingCardPlaceholderName; + } + + export interface VisualFormattingGroupPlaceholder extends VisualFormattingPlaceholder { + type: FormattingPlaceholderType.Group; + name: VisualFormattingGroupPlaceholderName; + } + + export interface VisualFormattingSlicePlaceholder extends VisualFormattingPlaceholder { + type: FormattingPlaceholderType.Slice; + name: VisualFormattingSlicePlaceholderName; + } + + /** + * Handles resolving the type of placeholder that's expected to be return. + * If you give it a slice placeholder, you should get a slice back, etc + */ + export interface ResolvedFormattingPlaceholder { + item: TFormattingPlaceholder extends FormattingCardPlaceholder + ? FormattingCard + : TFormattingPlaceholder extends FormattingGroupPlaceholder + ? FormattingGroup + : TFormattingPlaceholder extends FormattingSlicePlaceholder + ? FormattingSlice + : never; + revertToDefaultDescriptors?: FormattingDescriptor[]; + } + + + /** + * Takes in a group of controls (ex. Simple or Composite). + * Creates a dictionary where the key is the control name. + * The value is an object with property `type` typed to match to the control name, + * as well as a `properties` property that is set to the properties of the control. + * + * Note that this returns a dictionary containing all the controls included in `TControlGroupType` + */ + type AllControls = { + [ControlName in keyof TControlGroupType]: { + type: ControlName; + properties: TControlGroupType[ControlName]; + } + }; + + /** + * Returns an object with property `type` typed to match the control name, + * and property `properties` containing the properties for the control. + * + * This indexes into the dictionary generated by `AllControls` to return a union of all possible controls instead of a dictionary. + */ + export type FormattingControls = AllControls[keyof TControlGroupType]; + + export type FormattingComponentType = SimpleComponentType & CompositeComponentType; + + /** Generates a union of all possible types of the controls in the given Component Group */ + export type ControlType = { [ControlName in keyof TComponentGroupType]: TComponentGroupType[ControlName] }[keyof TComponentGroupType]; + /** Defines an interface where the value of a `CompositeComponent`'s properties must be a `SimpleComponent`. */ + type CompositeComponentPropertyType = { [key: string]: ControlType | undefined }; + + export type FormattingSimpleControl = FormattingControls; + export type FormattingCompositeControl = FormattingControls; + + export type FormattingControl = FormattingSimpleControl | FormattingCompositeControl; + + export const enum FormattingComponent { + AlignmentGroup = "AlignmentGroup", + ColorPicker = "ColorPicker", + ConditionalFormattingControl = "ConditionalFormattingControl", + DatePicker = "DatePicker", + Dropdown = "Dropdown", + DurationPicker = "DurationPicker", + EmptyControl = "EmptyControl", + ErrorRangeControl = "ErrorRangeControl", + FieldPicker = "FieldPicker", + FlagsSelection = "FlagsSelection", + FontControl = "FontControl", + FontPicker = "FontPicker", + GradientBar = "GradientBar", + ImageUpload = "ImageUpload", + Link = "Link", + ListEditor = "ListEditor", + MarginPadding = "MarginPadding", + NumUpDown = "NumUpDown", + ReadOnlyText = "ReadOnlyText", + SeriesDialogLink = "SeriesDialogLink", + ShapeMapSelector = "ShapeMapSelector", + Slider = "Slider", + TextArea = "TextArea", + TextInput = "TextInput", + ToggleSwitch = "ToggleSwitch", + } + + export type SimpleComponentType = { + AlignmentGroup: AlignmentGroup; + ColorPicker: ColorPicker; + ConditionalFormattingControl: ConditionalFormattingControl; + DatePicker: DatePicker; + Dropdown: Dropdown; + DurationPicker: DurationPicker; + ErrorRangeControl: ErrorRangeControl; + EmptyControl: EmptyControl; + FieldPicker: FieldPicker; + FlagsSelection: FlagsSelection; + FontPicker: FontPicker; + GradientBar: GradientBar; + ImageUpload: ImageUpload; + Link: Link; + ListEditor: ListEditor; + NumUpDown: NumUpDown; + ReadOnlyText: ReadOnlyText; + SeriesDialogLink: SeriesDialogLink; + ShapeMapSelector: ShapeMapSelector; + Slider: Slider; + TextArea: TextArea; + TextInput: TextInput; + ToggleSwitch: ToggleSwitch; + }; + + export type CompositeComponentType = { + FontControl: FontControl; + MarginPadding: MarginPadding; + }; + + export interface SimpleComponentBase { + descriptor: FormattingDescriptor; + value: T; + } + + export const enum ValidatorType { + Min = 0, + Max = 1, + Required = 2, + } + + export interface Validator { + type: ValidatorType; + } + + export interface MinValidator extends Validator { + type: ValidatorType.Min; + value: T; + } + + export interface MaxValidator extends Validator { + type: ValidatorType.Max; + value: T; + } + + export interface RequiredValidator extends Validator { + type: ValidatorType.Required; + } + + interface ColorPicker extends SimpleComponentBase { + defaultColor?: ThemeColorData; + isNoFillItemSupported?: boolean; + } + interface MarginPadding extends CompositeComponentPropertyType { + left: NumUpDown; + right: NumUpDown; + top: NumUpDown; + bottom: NumUpDown; + } + + export interface NumUpDownFormat extends NumUpDownValidators { + unitSymbol?: string; + unitSymbolAfterInput?: boolean; + } + + interface NumUpDownValidators { + minValue?: MinValidator; + maxValue?: MaxValidator; + required?: RequiredValidator; + } + + interface NumUpDown extends SimpleComponentBase { + options?: NumUpDownFormat; + placeholderText?: string; + } + + interface NumUpDownWithoutUnit extends NumUpDown { + options?: NumUpDownValidators; + } + + interface FieldPicker extends SimpleComponentBase { + validators: powerbi.explore.directives.ValidationInfo; + allowMultipleValues?: boolean; + } + + /** Error-range settings. Value is intentionally undefined as it can only be data-bound */ + interface ErrorRangeControl extends SimpleComponentBase { + validators: powerbi.explore.directives.ValidationInfo; + + // Other aspects of the Error Range settings the Visual can customize (e.g. allow relative values, allow 1-sided bounds, .. etc) + } + + interface FontControl extends CompositeComponentPropertyType { + fontFamily: FontPicker; + fontSize: NumUpDownWithoutUnit; + bold?: ToggleButton; + italic?: ToggleButton; + underline?: ToggleButton; + } + + interface FontPicker extends SimpleComponentBase { } + + interface ToggleButton extends SimpleComponentBase { } + + interface ToggleSwitch extends SimpleComponentBase { } + + interface TextValidators { + required?: RequiredValidator; + } + interface TextInput extends SimpleComponentBase { + placeholder: string; + validators?: TextValidators; + } + + interface TextArea extends TextInput { } + + export const enum AlignmentGroupMode { + Horizonal = 'horizontalAlignment', + Vertical = 'verticalAlignment', + } + + interface AlignmentGroup extends SimpleComponentBase { + mode: AlignmentGroupMode; + supportsNoSelection?: boolean; + } + + interface Slider extends NumUpDown { } + + // ideally we would set type here to number, but the old formatting pane always converts enum members to string + // values before binding - so using string here to keep it consistent for the flags control + interface ItemFlagsSelection extends SimpleComponentBase { + items: IEnumMember[]; + } + interface AutoFlagsSelection extends SimpleComponentBase { } + + type FlagsSelection = ItemFlagsSelection | AutoFlagsSelection; + + type Dropdown = ItemDropdown | AutoDropdown; + + interface ItemDropdown extends SimpleComponentBase { + items: IEnumMember[]; + } + + /** + * Automatically generates items based on the property's type + */ + interface AutoDropdown extends SimpleComponentBase { + /** Values to add should be merged with the items */ + mergeValues?: IEnumMember[]; + /** Values to filter the list of items by */ + filterValues?: EnumMemberValue[]; + } + + export interface ListEditorValue { + items: ListItemEditorValue[]; + selectedItem: ListItemEditorValue; + } + + export interface ListItemEditorValue extends IEnumMember { + update?: ListEditorItemUpdateType; + oldDisplayName?: DisplayNameGetter; + } + + export const enum ListEditorItemUpdateType { + New = "New", + Removed = "Removed", + DisplayNameUpdated = "DisplayNameUpdated", + } + + interface ListEditor extends SimpleComponentBase { } + + interface ImageUpload extends SimpleComponentBase { } + + interface DurationPicker extends SimpleComponentBase { + /** These are specfic to this control */ + validators?: { + min?: string; + max?: string; + integer?: boolean; + }; + } + + /** This will be used for showing only "fx" button without any other content */ + interface EmptyControl extends SimpleComponentBase { } + + interface GradientBar extends SimpleComponentBase { } + + interface ShapeMapSelector extends SimpleComponentBase { + isAzMapReferenceSelector?: boolean; + } + + interface DatePicker extends SimpleComponentBase { + placeholder: string; + validators?: { + max?: MaxValidator; + min?: MinValidator; + }; + } + + interface ReadOnlyText extends SimpleComponentBase { } + + interface ConditionalFormattingControl extends SimpleComponentBase { + displayName: string; + } + + interface Link extends SimpleComponentBase<() => (any | void)> { + ariaLabel?: string; + } + + interface SeriesDialogLink extends Link { + type: FormattingComponent.SeriesDialogLink; + warningIcon?: boolean; + resetToDefaultDescriptors?: FormattingDescriptor[]; + } + } +} + + + +// ========================== +// themColorData.d.ts +// ========================== +declare namespace powerbi { + export interface ThemeColorData { + value: string; + id?: number; + shade?: number; + } +} + + +// ========================== +// inputValidation.d.ts +// ========================== +declare namespace powerbi { + export interface ValidationRequiredInfo { + required?: boolean; + } + + export interface ValidationNumericInfo { + decimal?: boolean; + integer?: boolean; + min?: number | Date | string; + max?: number | Date | string; + } +} + +declare namespace powerbi.explore.directives { + type ValidationAllInfo = powerbi.ValidationRequiredInfo & powerbi.ValidationNumericInfo; + export interface ValidationInfo extends ValidationAllInfo { + url?: boolean; + field?: FieldValidationInfo; + } + + export interface FieldValidationInfo { + kind: FieldKind; + // For more than 1 type to validate on, we can use Variant type descriptor + type?: ValueTypeDescriptor; + } +} + +declare module powerbi { + export interface IVisualErrorMessage { + message: string; + title: string; + detail: string; + } + export interface IVisualWarning { + code: string; + // getMessages(resourceProvider: jsCommon.IStringResourceProvider): IVisualErrorMessage; + } +} +export default powerbi; \ No newline at end of file diff --git a/index.js b/index.js new file mode 100644 index 0000000..e57a5ca --- /dev/null +++ b/index.js @@ -0,0 +1,6 @@ +const semver = require('semver'); + +let packageVersion = require('./package.json').version; +let apiVersion = `${semver.major(packageVersion)}.${semver.minor(packageVersion)}.0`; + +exports.version = apiVersion; diff --git a/package-lock.json b/package-lock.json new file mode 100644 index 0000000..3f10678 --- /dev/null +++ b/package-lock.json @@ -0,0 +1,93 @@ +{ + "name": "powerbi-visuals-formattingmodel", + "version": "1.0.0", + "lockfileVersion": 2, + "requires": true, + "packages": { + "": { + "name": "powerbi-visuals-formattingmodel", + "version": "1.0.0", + "license": "MIT", + "devDependencies": { + "powerbi-visuals-api": "4.4.0" + } + }, + "node_modules/lru-cache": { + "version": "6.0.0", + "resolved": "https://registry.npmjs.org/lru-cache/-/lru-cache-6.0.0.tgz", + "integrity": "sha512-Jo6dJ04CmSjuznwJSS3pUeWmd/H0ffTlkXXgwZi+eq1UCmqQwCh+eLsYOYCwY991i2Fah4h1BEMCx4qThGbsiA==", + "dev": true, + "dependencies": { + "yallist": "^4.0.0" + }, + "engines": { + "node": ">=10" + } + }, + "node_modules/powerbi-visuals-api": { + "version": "4.4.0", + "resolved": "https://registry.npmjs.org/powerbi-visuals-api/-/powerbi-visuals-api-4.4.0.tgz", + "integrity": "sha512-rWak8l+yXm4SCUCQmawFOqGYuvrxwufmvqX+LbaIzXB60LB58XwvXkJASKTJgobUOqcLkMk21vDXLX+/qHu3+w==", + "dev": true, + "dependencies": { + "semver": "^7.3.5" + } + }, + "node_modules/semver": { + "version": "7.3.7", + "resolved": "https://registry.npmjs.org/semver/-/semver-7.3.7.tgz", + "integrity": "sha512-QlYTucUYOews+WeEujDoEGziz4K6c47V/Bd+LjSSYcA94p+DmINdf7ncaUinThfvZyu13lN9OY1XDxt8C0Tw0g==", + "dev": true, + "dependencies": { + "lru-cache": "^6.0.0" + }, + "bin": { + "semver": "bin/semver.js" + }, + "engines": { + "node": ">=10" + } + }, + "node_modules/yallist": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/yallist/-/yallist-4.0.0.tgz", + "integrity": "sha512-3wdGidZyq5PB084XLES5TpOSRA3wjXAlIWMhum2kRcv/41Sn2emQ0dycQW4uZXLejwKvg6EsvbdlVL+FYEct7A==", + "dev": true + } + }, + "dependencies": { + "lru-cache": { + "version": "6.0.0", + "resolved": "https://registry.npmjs.org/lru-cache/-/lru-cache-6.0.0.tgz", + "integrity": "sha512-Jo6dJ04CmSjuznwJSS3pUeWmd/H0ffTlkXXgwZi+eq1UCmqQwCh+eLsYOYCwY991i2Fah4h1BEMCx4qThGbsiA==", + "dev": true, + "requires": { + "yallist": "^4.0.0" + } + }, + "powerbi-visuals-api": { + "version": "4.4.0", + "resolved": "https://registry.npmjs.org/powerbi-visuals-api/-/powerbi-visuals-api-4.4.0.tgz", + "integrity": "sha512-rWak8l+yXm4SCUCQmawFOqGYuvrxwufmvqX+LbaIzXB60LB58XwvXkJASKTJgobUOqcLkMk21vDXLX+/qHu3+w==", + "dev": true, + "requires": { + "semver": "^7.3.5" + } + }, + "semver": { + "version": "7.3.7", + "resolved": "https://registry.npmjs.org/semver/-/semver-7.3.7.tgz", + "integrity": "sha512-QlYTucUYOews+WeEujDoEGziz4K6c47V/Bd+LjSSYcA94p+DmINdf7ncaUinThfvZyu13lN9OY1XDxt8C0Tw0g==", + "dev": true, + "requires": { + "lru-cache": "^6.0.0" + } + }, + "yallist": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/yallist/-/yallist-4.0.0.tgz", + "integrity": "sha512-3wdGidZyq5PB084XLES5TpOSRA3wjXAlIWMhum2kRcv/41Sn2emQ0dycQW4uZXLejwKvg6EsvbdlVL+FYEct7A==", + "dev": true + } + } +} diff --git a/package.json b/package.json new file mode 100644 index 0000000..bd1ea03 --- /dev/null +++ b/package.json @@ -0,0 +1,30 @@ +{ + "name": "powerbi-visuals-formattingmodel", + "version": "1.0.0", + "description": "Power BI Custom Visuals Formatting Model API type definitions for typescript", + "types": "index", + "main": "index.js", + "keywords": [ + "PowerBI", + "BI", + "visuals", + "visualization" + ], + "repository": { + "type": "git", + "url": "https://github.com/microsoft/powerbi-visuals-formattingmodel.git" + }, + "author": "Microsoft", + "license": "MIT", + "bugs": { + "url": "https://github.com/microsoft/powerbi-visuals-formattingmodel/issues" + }, + "homepage": "https://github.com/microsoft/powerbi-visuals-formattingmodel", + "dependencies": { + "semver": "^7.3.5" + }, + "devDependencies": { + "powerbi-visuals-api": "4.5.0" + } + } + \ No newline at end of file