From d18c19ca39319a866898df0f319ba3f25cae67ef Mon Sep 17 00:00:00 2001 From: Alex Terentiev Date: Wed, 1 Nov 2023 09:38:16 -0400 Subject: [PATCH] feat: Support for SharePoint (Viva) Adaptive Card Extension (#4551) * SP API * comments * return comments * update api file * fix all lint errors * more lint errors * address comments * formatting * incorrect comment * more lint fixes * updated comments * export SP activity handler * update public API md --------- Co-authored-by: Alex Terentiev --- libraries/botbuilder/etc/botbuilder.api.md | 16 + libraries/botbuilder/src/index.ts | 1 + .../sharepoint/sharePointActivityHandler.ts | 152 +++++ .../etc/botframework-schema.api.md | 538 ++++++++++++++++++ libraries/botframework-schema/package.json | 3 +- libraries/botframework-schema/src/index.ts | 3 + .../src/sharepoint/aceData.ts | 44 ++ .../src/sharepoint/aceRequest.ts | 16 + .../src/sharepoint/actions/cardAction.ts | 265 +++++++++ .../src/sharepoint/actions/focusParameters.ts | 20 + .../src/sharepoint/actions/index.ts | 5 + .../sharepoint/cardView/baseCardComponent.ts | 22 + .../sharepoint/cardView/cardBarComponent.ts | 23 + .../src/sharepoint/cardView/cardButtonBase.ts | 18 + .../cardView/cardButtonComponent.ts | 23 + .../src/sharepoint/cardView/cardImage.ts | 16 + .../cardView/cardSearchBoxComponent.ts | 35 ++ .../cardView/cardSearchFooterComponent.ts | 35 ++ .../sharepoint/cardView/cardTextComponent.ts | 18 + .../cardView/cardTextInputComponent.ts | 60 ++ .../sharepoint/cardView/cardViewParameters.ts | 313 ++++++++++ .../src/sharepoint/cardView/index.ts | 10 + .../src/sharepoint/cardViewResponse.ts | 28 + .../getPropertyPaneConfigurationResponse.ts | 26 + .../src/sharepoint/handleActionResponse.ts | 74 +++ .../src/sharepoint/index.ts | 32 ++ .../propertyPaneCheckboxProperties.ts | 22 + .../propertyPaneChoiceGroupIconProperties.ts | 12 + .../propertyPaneChoiceGroupImageSize.ts | 16 + .../propertyPaneChoiceGroupOption.ts | 43 ++ .../propertyPaneChoiceGroupProperties.ts | 19 + .../sharepoint/propertyPaneDropDownOption.ts | 42 ++ .../propertyPaneDropDownProperties.ts | 43 ++ .../sharepoint/propertyPaneFieldProperties.ts | 10 + .../src/sharepoint/propertyPaneGroup.ts | 27 + .../src/sharepoint/propertyPaneGroupField.ts | 68 +++ .../propertyPaneGroupOrConditionalGroup.ts | 7 + .../sharepoint/propertyPaneLabelProperties.ts | 18 + .../propertyPaneLinkPopupWindowProperties.ts | 50 ++ .../sharepoint/propertyPaneLinkProperties.ts | 35 ++ .../src/sharepoint/propertyPanePage.ts | 23 + .../src/sharepoint/propertyPanePageHeader.ts | 12 + .../propertyPaneSliderProperties.ts | 42 ++ .../propertyPaneTextFieldProperties.ts | 62 ++ .../propertyPaneToggleProperties.ts | 46 ++ .../src/sharepoint/quickViewData.ts | 6 + .../src/sharepoint/quickViewResponse.ts | 37 ++ .../setPropertyPaneConfigurationResponse.ts | 5 + yarn.lock | 5 + 49 files changed, 2445 insertions(+), 1 deletion(-) create mode 100644 libraries/botbuilder/src/sharepoint/sharePointActivityHandler.ts create mode 100644 libraries/botframework-schema/src/sharepoint/aceData.ts create mode 100644 libraries/botframework-schema/src/sharepoint/aceRequest.ts create mode 100644 libraries/botframework-schema/src/sharepoint/actions/cardAction.ts create mode 100644 libraries/botframework-schema/src/sharepoint/actions/focusParameters.ts create mode 100644 libraries/botframework-schema/src/sharepoint/actions/index.ts create mode 100644 libraries/botframework-schema/src/sharepoint/cardView/baseCardComponent.ts create mode 100644 libraries/botframework-schema/src/sharepoint/cardView/cardBarComponent.ts create mode 100644 libraries/botframework-schema/src/sharepoint/cardView/cardButtonBase.ts create mode 100644 libraries/botframework-schema/src/sharepoint/cardView/cardButtonComponent.ts create mode 100644 libraries/botframework-schema/src/sharepoint/cardView/cardImage.ts create mode 100644 libraries/botframework-schema/src/sharepoint/cardView/cardSearchBoxComponent.ts create mode 100644 libraries/botframework-schema/src/sharepoint/cardView/cardSearchFooterComponent.ts create mode 100644 libraries/botframework-schema/src/sharepoint/cardView/cardTextComponent.ts create mode 100644 libraries/botframework-schema/src/sharepoint/cardView/cardTextInputComponent.ts create mode 100644 libraries/botframework-schema/src/sharepoint/cardView/cardViewParameters.ts create mode 100644 libraries/botframework-schema/src/sharepoint/cardView/index.ts create mode 100644 libraries/botframework-schema/src/sharepoint/cardViewResponse.ts create mode 100644 libraries/botframework-schema/src/sharepoint/getPropertyPaneConfigurationResponse.ts create mode 100644 libraries/botframework-schema/src/sharepoint/handleActionResponse.ts create mode 100644 libraries/botframework-schema/src/sharepoint/index.ts create mode 100644 libraries/botframework-schema/src/sharepoint/propertyPaneCheckboxProperties.ts create mode 100644 libraries/botframework-schema/src/sharepoint/propertyPaneChoiceGroupIconProperties.ts create mode 100644 libraries/botframework-schema/src/sharepoint/propertyPaneChoiceGroupImageSize.ts create mode 100644 libraries/botframework-schema/src/sharepoint/propertyPaneChoiceGroupOption.ts create mode 100644 libraries/botframework-schema/src/sharepoint/propertyPaneChoiceGroupProperties.ts create mode 100644 libraries/botframework-schema/src/sharepoint/propertyPaneDropDownOption.ts create mode 100644 libraries/botframework-schema/src/sharepoint/propertyPaneDropDownProperties.ts create mode 100644 libraries/botframework-schema/src/sharepoint/propertyPaneFieldProperties.ts create mode 100644 libraries/botframework-schema/src/sharepoint/propertyPaneGroup.ts create mode 100644 libraries/botframework-schema/src/sharepoint/propertyPaneGroupField.ts create mode 100644 libraries/botframework-schema/src/sharepoint/propertyPaneGroupOrConditionalGroup.ts create mode 100644 libraries/botframework-schema/src/sharepoint/propertyPaneLabelProperties.ts create mode 100644 libraries/botframework-schema/src/sharepoint/propertyPaneLinkPopupWindowProperties.ts create mode 100644 libraries/botframework-schema/src/sharepoint/propertyPaneLinkProperties.ts create mode 100644 libraries/botframework-schema/src/sharepoint/propertyPanePage.ts create mode 100644 libraries/botframework-schema/src/sharepoint/propertyPanePageHeader.ts create mode 100644 libraries/botframework-schema/src/sharepoint/propertyPaneSliderProperties.ts create mode 100644 libraries/botframework-schema/src/sharepoint/propertyPaneTextFieldProperties.ts create mode 100644 libraries/botframework-schema/src/sharepoint/propertyPaneToggleProperties.ts create mode 100644 libraries/botframework-schema/src/sharepoint/quickViewData.ts create mode 100644 libraries/botframework-schema/src/sharepoint/quickViewResponse.ts create mode 100644 libraries/botframework-schema/src/sharepoint/setPropertyPaneConfigurationResponse.ts diff --git a/libraries/botbuilder/etc/botbuilder.api.md b/libraries/botbuilder/etc/botbuilder.api.md index 103f2f78b2..8a20feada0 100644 --- a/libraries/botbuilder/etc/botbuilder.api.md +++ b/libraries/botbuilder/etc/botbuilder.api.md @@ -4,6 +4,7 @@ ```ts +import { AceRequest } from 'botbuilder-core'; import { Activity } from 'botbuilder-core'; import { ActivityHandler } from 'botbuilder-core'; import { ActivityHandlerBase } from 'botbuilder-core'; @@ -22,6 +23,7 @@ import { BotFrameworkClient } from 'botbuilder-core'; import { BotFrameworkSkill } from 'botbuilder-core'; import { BotState } from 'botbuilder-core'; import { CancelOperationResponse } from 'botframework-connector'; +import { CardViewResponse } from 'botbuilder-core'; import { ChannelAccount } from 'botbuilder-core'; import { ChannelInfo } from 'botbuilder-core'; import { ClaimsIdentity } from 'botframework-connector'; @@ -39,6 +41,8 @@ import { ConversationState } from 'botbuilder-core'; import { CoreAppCredentials } from 'botbuilder-core'; import { ExtendedUserTokenProvider } from 'botbuilder-core'; import { FileConsentCardResponse } from 'botbuilder-core'; +import { GetPropertyPaneConfigurationResponse } from 'botbuilder-core'; +import { HandleActionResponse } from 'botbuilder-core'; import { HttpClient } from '@azure/ms-rest-js'; import { HttpOperationResponse } from '@azure/ms-rest-js'; import { ICredentialProvider } from 'botframework-connector'; @@ -63,9 +67,11 @@ import { O365ConnectorCardActionQuery } from 'botbuilder-core'; import { OnBehalfOf } from 'botbuilder-core'; import { PagedMembersResult } from 'botbuilder-core'; import { PagedResult } from 'botbuilder-core'; +import { QuickViewResponse } from 'botbuilder-core'; import { ReadReceiptInfo } from 'botframework-connector'; import { RequestHandler } from 'botframework-streaming'; import { ResourceResponse } from 'botbuilder-core'; +import { SetPropertyPaneConfigurationResponse } from 'botbuilder-core'; import { SigninStateVerificationQuery } from 'botbuilder-core'; import { SignInUrlResponse } from 'botframework-connector'; import { SimpleCredentialProvider } from 'botframework-connector'; @@ -338,6 +344,16 @@ export class SetSpeakMiddleware implements Middleware { onTurn(turnContext: TurnContext, next: () => Promise): Promise; } +// @public +export class SharePointActivityHandler extends ActivityHandler { + protected onInvokeActivity(context: TurnContext): Promise; + protected onSharePointTaskGetCardViewAsync(_context: TurnContext, _aceRequest: AceRequest): Promise; + protected onSharePointTaskGetPropertyPaneConfigurationAsync(_context: TurnContext, _aceRequest: AceRequest): Promise; + protected onSharePointTaskGetQuickViewAsync(_context: TurnContext, _aceRequest: AceRequest): Promise; + protected onSharePointTaskHandleActionAsync(_context: TurnContext, _aceRequest: AceRequest): Promise; + protected onSharePointTaskSetPropertyPaneConfigurationAsync(_context: TurnContext, _aceRequest: AceRequest): Promise; +} + // @public @deprecated (undocumented) export class SkillHandler extends ChannelServiceHandler { constructor(adapter: BotAdapter, bot: ActivityHandlerBase, conversationIdFactory: SkillConversationIdFactoryBase, credentialProvider: ICredentialProvider, authConfig: AuthenticationConfiguration, channelService?: string); diff --git a/libraries/botbuilder/src/index.ts b/libraries/botbuilder/src/index.ts index edfa3d8ffb..072b3edc80 100644 --- a/libraries/botbuilder/src/index.ts +++ b/libraries/botbuilder/src/index.ts @@ -29,3 +29,4 @@ export { HandoffEventNames } from './handoffEventNames'; export { Request, Response, WebRequest, WebResponse } from './interfaces'; export { StatusCodeError } from './statusCodeError'; export { StreamingHttpClient, TokenResolver } from './streaming'; +export { SharePointActivityHandler } from './sharepoint/sharePointActivityHandler'; diff --git a/libraries/botbuilder/src/sharepoint/sharePointActivityHandler.ts b/libraries/botbuilder/src/sharepoint/sharePointActivityHandler.ts new file mode 100644 index 0000000000..0a017f68b7 --- /dev/null +++ b/libraries/botbuilder/src/sharepoint/sharePointActivityHandler.ts @@ -0,0 +1,152 @@ +/** + * @module botbuilder + */ +/** + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. + */ + +import { + ActivityHandler, + InvokeResponse, + AceRequest, + TurnContext, + CardViewResponse, + QuickViewResponse, + GetPropertyPaneConfigurationResponse, + SetPropertyPaneConfigurationResponse, + HandleActionResponse, +} from 'botbuilder-core'; + +/** + * The SharePointActivityHandler is derived from ActivityHandler. It adds support for + * the SharePoint specific events and interactions + */ +export class SharePointActivityHandler extends ActivityHandler { + /** + * Invoked when an invoke activity is received from the connector. + * Invoke activities can be used to communicate many different things. + * * Invoke activities communicate programmatic commands from a client or channel to a bot. + * + * @param context A strongly-typed context object for this turn + * @returns A task that represents the work queued to execute + */ + protected async onInvokeActivity(context: TurnContext): Promise { + try { + if (!context.activity.name && context.activity.channelId === 'sharepoint') { + throw new Error('NotImplemented'); + } else { + switch (context.activity.name) { + case 'cardExtension/getCardView': + return ActivityHandler.createInvokeResponse( + await this.onSharePointTaskGetCardViewAsync(context, context.activity.value as AceRequest) + ); + + case 'cardExtension/getQuickView': + return ActivityHandler.createInvokeResponse( + await this.onSharePointTaskGetQuickViewAsync(context, context.activity.value as AceRequest) + ); + + case 'cardExtension/getPropertyPaneConfiguration': + return ActivityHandler.createInvokeResponse( + await this.onSharePointTaskGetPropertyPaneConfigurationAsync( + context, + context.activity.value as AceRequest + ) + ); + + case 'cardExtension/setPropertyPaneConfiguration': + return ActivityHandler.createInvokeResponse( + await this.onSharePointTaskSetPropertyPaneConfigurationAsync( + context, + context.activity.value as AceRequest + ) + ); + case 'cardExtension/handleAction': + return ActivityHandler.createInvokeResponse( + await this.onSharePointTaskHandleActionAsync(context, context.activity.value as AceRequest) + ); + default: + return super.onInvokeActivity(context); + } + } + } catch (err) { + if (err.message === 'NotImplemented') { + return { status: 501 }; + } else if (err.message === 'BadRequest') { + return { status: 400 }; + } + throw err; + } + } + + /** + * Override this in a derived class to provide logic for when a card view is fetched + * + * @param _context - A strongly-typed context object for this turn + * @param _aceRequest - The Ace invoke request value payload + * @returns A Card View Response for the request + */ + protected async onSharePointTaskGetCardViewAsync( + _context: TurnContext, + _aceRequest: AceRequest + ): Promise { + throw new Error('NotImplemented'); + } + + /** + * Override this in a derived class to provide logic for when a quick view is fetched + * + * @param _context - A strongly-typed context object for this turn + * @param _aceRequest - The Ace invoke request value payload + * @returns A Quick View Response for the request + */ + protected async onSharePointTaskGetQuickViewAsync( + _context: TurnContext, + _aceRequest: AceRequest + ): Promise { + throw new Error('NotImplemented'); + } + + /** + * Override this in a derived class to provide logic for getting configuration pane properties. + * + * @param _context - A strongly-typed context object for this turn + * @param _aceRequest - The Ace invoke request value payload + * @returns A Property Pane Configuration Response for the request + */ + protected async onSharePointTaskGetPropertyPaneConfigurationAsync( + _context: TurnContext, + _aceRequest: AceRequest + ): Promise { + throw new Error('NotImplemented'); + } + + /** + * Override this in a derived class to provide logic for setting configuration pane properties. + * + * @param _context - A strongly-typed context object for this turn + * @param _aceRequest - The Ace invoke request value payload + * @returns A Card view or no-op action response + */ + protected async onSharePointTaskSetPropertyPaneConfigurationAsync( + _context: TurnContext, + _aceRequest: AceRequest + ): Promise { + throw new Error('NotImplemented'); + } + + /** + * Override this in a derived class to provide logic for setting configuration pane properties. + * + * @param _context - A strongly-typed context object for this turn + * @param _aceRequest - The Ace invoke request value payload + * @returns A handle action response + */ + protected async onSharePointTaskHandleActionAsync( + _context: TurnContext, + _aceRequest: AceRequest + ): Promise { + throw new Error('NotImplemented'); + } +} diff --git a/libraries/botframework-schema/etc/botframework-schema.api.md b/libraries/botframework-schema/etc/botframework-schema.api.md index 2f9078df2c..279563dfaa 100644 --- a/libraries/botframework-schema/etc/botframework-schema.api.md +++ b/libraries/botframework-schema/etc/botframework-schema.api.md @@ -4,6 +4,28 @@ ```ts +import { AdaptiveCard } from 'adaptivecards'; + +// @public +export type AceCardSize = 'Medium' | 'Large'; + +// @public +export interface AceData { + cardSize: AceCardSize; + dataVersion: string; + description: string; + iconProperty: string; + id: string; + properties: any; + title: string; +} + +// @public +export interface AceRequest { + data?: any; + properties?: any; +} + // @public export type Action = 'accept' | 'decline'; @@ -357,6 +379,23 @@ export interface AudioCard { value: any; } +// @public +export interface BaseCardComponent { + componentName: CardComponentName; + id?: string; +} + +// @public +export interface BaseCardViewParameters { + cardBar: [CardBarComponent]; +} + +// @public +export interface BaseHandleActionResponse { + renderArguments?: CardViewResponse | QuickViewResponse; + type: ViewResponseType; +} + // @public export interface BasicCard { buttons: CardAction[]; @@ -367,6 +406,9 @@ export interface BasicCard { title: string; } +// @public +export function BasicCardView(cardBar: CardBarComponent, header: CardTextComponent, footer?: CardViewFooterParameters): TextCardViewParameters; + // @public export interface BatchFailedEntriesResponse { continuationToken: string; @@ -440,6 +482,31 @@ export interface CardAction { value: any; } +// @public +export interface CardBarComponent extends BaseCardComponent { + componentName: 'cardBar'; + // Warning: (ae-forgotten-export) The symbol "CardImage" needs to be exported by the entry point index.d.ts + icon?: CardImage_2; + title?: string; +} + +// @public +export interface CardButtonBase { + // Warning: (ae-forgotten-export) The symbol "CardAction" needs to be exported by the entry point index.d.ts + action: CardAction_2; + id?: string; +} + +// @public +export interface CardButtonComponent extends BaseCardComponent, CardButtonBase { + componentName: 'cardButton'; + style?: 'default' | 'positive'; + title: string; +} + +// @public +export type CardComponentName = 'text' | 'cardButton' | 'cardBar' | 'textInput' | 'searchBox' | 'searchFooter'; + // @public export interface CardImage { alt?: string; @@ -447,6 +514,64 @@ export interface CardImage { url: string; } +// @public +export interface CardSearchBoxComponent extends BaseCardComponent { + button: ICardSearchBoxButton; + componentName: 'searchBox'; + defaultValue?: string; + placeholder?: string; +} + +// @public +export interface CardSearchFooterComponent extends BaseCardComponent { + componentName: 'searchFooter'; + imageInitials?: string; + imageUrl?: string; + onSelection?: CardAction_2; + text: string; + title: string; +} + +// @public +export interface CardTextComponent extends BaseCardComponent { + componentName: 'text'; + text: string; +} + +// @public +export interface CardTextInputComponent extends BaseCardComponent { + ariaLabel?: string; + button?: ICardTextInputIconButton | ICardTextInputTitleButton; + componentName: 'textInput'; + defaultValue?: string; + iconAfter?: CardImage_2; + iconBefore?: CardImage_2; + placeholder?: string; +} + +// @public +export type CardViewActionsFooterParameters = [CardButtonComponent] | [CardButtonComponent, CardButtonComponent] | undefined; + +// @public +export type CardViewFooterParameters = CardViewActionsFooterParameters | [CardTextInputComponent]; + +// @public +export interface CardViewHandleActionResponse extends BaseHandleActionResponse { + renderArguments: CardViewResponse; + type: 'Card'; +} + +// @public +export type CardViewParameters = TextCardViewParameters | TextInputCardViewParameters | SearchCardViewParameters | SignInCardViewParameters; + +// @public +export interface CardViewResponse { + aceData: AceData; + cardViewParameters: CardViewParameters; + onCardSelection?: OnCardSelectionAction; + viewId: string; +} + // @public export interface ChannelAccount { aadObjectId?: string; @@ -541,6 +666,12 @@ export interface ConfigResponse { export interface ConfigTaskResponse extends ConfigResponse { } +// @public +export interface ConfirmationDialog { + message: string; + title: string; +} + // @public export enum ContactRelationUpdateActionTypes { // (undocumented) @@ -625,6 +756,13 @@ export enum DeliveryModes { Notification = "notification" } +// @public +export enum DropDownOptionType { + Divider = 1, + Header = 2, + Normal = 0 +} + // @public export enum EndOfConversationCodes { // (undocumented) @@ -659,17 +797,54 @@ export interface ErrorResponse { error: ErrorModel; } +// @public +export interface ExecuteCardAction { + parameters: ExecuteCardParameters; + type: 'Execute'; + verb?: string; +} + +// @public +export interface ExecuteCardParameters { + [key: string]: unknown; +} + // @public export interface ExpectedReplies { activities: Activity[]; } +// @public +export interface ExternalLinkActionParameters { + isTeamsDeepLink?: boolean; + target: string; +} + +// @public +export interface ExternalLinkCardAction { + parameters: ExternalLinkActionParameters; + type: 'ExternalLink'; +} + // @public export interface Fact { key: string; value: string; } +// @public +export enum FieldType { + CheckBox = 2, + ChoiceGroup = 10, + Dropdown = 6, + HorizontalRule = 12, + Label = 7, + Link = 13, + Slider = 8, + TextField = 3, + Toggle = 5 +} + // @public export interface FileConsentCard { acceptContext?: any; @@ -712,6 +887,12 @@ export interface FileUploadInfo { uploadUrl?: string; } +// @public +export interface FocusParameters { + ariaLive?: 'polite' | 'assertive' | 'off'; + focusTarget?: string; +} + // @public export interface GeoCoordinates { elevation: number; @@ -721,6 +902,28 @@ export interface GeoCoordinates { type: string; } +// @public +export interface GetLocationActionParameters { + chooseLocationOnMap?: boolean; +} + +// @public +export interface GetLocationCardAction { + parameters?: GetLocationActionParameters; + type: 'VivaAction.GetLocation'; +} + +// @public +export interface GetPropertyPaneConfigurationResponse { + currentPage: number; + loadingIndicatorDelayTime: number; + pages: PropertyPanePage[]; + showLoadingIndicator: boolean; +} + +// @public +export type HandleActionResponse = CardViewHandleActionResponse | QuickViewHandleActionResponse | NoOpHandleActionResponse; + // @public export interface HeroCard { buttons: CardAction[]; @@ -747,6 +950,20 @@ export interface IActivity { type: ActivityTypes | string; } +// @public +export interface ICardSearchBoxButton extends CardButtonBase { +} + +// @public +export interface ICardTextInputIconButton extends CardButtonBase { + icon: CardImage_2; +} + +// @public +export interface ICardTextInputTitleButton extends CardButtonBase { + title: string; +} + // @public export interface ICommandActivity extends IActivity { name: string; @@ -802,6 +1019,9 @@ export interface IInvokeActivity extends IActivity { value?: any; } +// @public +export function ImageCardView(cardBar: CardBarComponent, header: CardTextComponent, image: CardImage_2, footer?: CardViewFooterParameters): TextCardViewParameters; + // @public (undocumented) export interface IMessageActivity extends IActivity { attachmentLayout?: AttachmentLayoutTypes | string; @@ -950,6 +1170,16 @@ export interface ITraceActivity extends IActivity { // @public (undocumented) export type ITypingActivity = IActivity; +// @public +interface Location_2 { + accuracy?: number; + latitude: number; + longitude: number; + timestamp?: number; +} + +export { Location_2 as Location } + // @public export interface MediaCard { aspect: string; @@ -971,6 +1201,16 @@ export interface MediaEventValue { cardValue: any; } +// @public +export enum MediaType { + // (undocumented) + Audio = 4, + // (undocumented) + Document = 8, + // (undocumented) + Image = 1 +} + // @public export interface MediaUrl { profile?: string; @@ -1237,6 +1477,12 @@ export interface MicrosoftPayMethodData { supportedTypes: string[]; } +// @public +export interface NoOpHandleActionResponse extends BaseHandleActionResponse { + renderArguments?: undefined; + type: 'NoOp'; +} + // @public export interface NotificationInfo { alert?: boolean; @@ -1380,6 +1626,9 @@ export interface OnBehalfOf { mri: string; } +// @public +export type OnCardSelectionAction = QuickViewCardAction | ExternalLinkCardAction | SelectMediaCardAction | GetLocationCardAction | ShowLocationCardAction | ExecuteCardAction | undefined; + // @public export type Os = 'default' | 'iOS' | 'android' | 'windows'; @@ -1529,6 +1778,209 @@ export interface Place { type: string; } +// @public +export enum PopupWindowPosition { + Center = 0, + LeftBottom = 4, + LeftTop = 2, + RightBottom = 3, + RightTop = 1 +} + +// @public +export function PrimaryTextCardView(cardBar: CardBarComponent, header: CardTextComponent, body: CardTextComponent, footer?: CardViewFooterParameters): TextCardViewParameters; + +// @public +export interface PropertyPaneCheckboxProperties extends PropertyPaneFieldProperties { + checked?: boolean; + disabled?: boolean; + text?: string; +} + +// @public +export interface PropertyPaneChoiceGroupIconProperties { + officeFabricIconFontName?: string; +} + +// @public +export interface PropertyPaneChoiceGroupImageSize { + height: number; + width: number; +} + +// @public +export interface PropertyPaneChoiceGroupOption { + ariaLabel?: string; + checked?: boolean; + disabled?: boolean; + iconProps?: PropertyPaneChoiceGroupIconProperties; + imageSize?: PropertyPaneChoiceGroupImageSize; + imageSrc?: string; + key: string; + text: string; +} + +// @public +export interface PropertyPaneChoiceGroupProperties extends PropertyPaneFieldProperties { + label?: string; + options: PropertyPaneChoiceGroupOption[]; +} + +// @public +export interface PropertyPaneDropDownOption { + index?: number; + key: string; + text: string; + type?: DropDownOptionType; +} + +// @public +export interface PropertyPaneDropDownProperties extends PropertyPaneFieldProperties { + ariaLabel?: string; + ariaPositionInSet?: number; + ariaSetSize?: number; + disabled?: boolean; + errorMessage?: string; + label: string; + options?: PropertyPaneDropDownOption[]; + selectedKey?: string; +} + +// @public +export interface PropertyPaneFieldProperties { +} + +// @public +export interface PropertyPaneGroup extends PropertyPaneGroupOrConditionalGroup { + groupFields: PropertyPaneGroupField[]; + groupName?: string; + isCollapsed?: boolean; + isGroupNameHidden?: boolean; +} + +// @public +export interface PropertyPaneGroupField { + properties: PropertyPaneFieldProperties; + shouldFocus?: boolean; + targetProperty: string; + type: FieldType; +} + +// @public +export interface PropertyPaneGroupOrConditionalGroup { +} + +// @public +export interface PropertyPaneLabelProperties extends PropertyPaneFieldProperties { + required?: boolean; + text: string; +} + +// @public +export interface PropertyPaneLinkPopupWindowProperties { + height: number; + positionWindowPosition: PopupWindowPosition; + title: string; + width: number; +} + +// @public +export interface PropertyPaneLinkProperties extends PropertyPaneFieldProperties { + ariaLabel?: string; + disabled?: boolean; + href: string; + popupWindowProps?: PropertyPaneLinkPopupWindowProperties; + target?: string; + text: string; +} + +// @public +export interface PropertyPanePage { + displayGroupsAsAccordion?: boolean; + groups: PropertyPaneGroupOrConditionalGroup[]; + header?: PropertyPanePageHeader; +} + +// @public +export interface PropertyPanePageHeader { + description: string; +} + +// @public +export interface PropertyPaneSliderProperties extends PropertyPaneFieldProperties { + ariaLabel?: string; + disabled?: boolean; + label?: string; + max: number; + min: number; + showValue?: boolean; + step?: number; + value?: string; +} + +// @public +export interface PropertyPaneTextFieldProperties extends PropertyPaneFieldProperties { + ariaLabel?: string; + description?: string; + disabled?: boolean; + errorMessage?: string; + label?: string; + logName?: string; + maxLength?: number; + multiline?: boolean; + placeholder?: string; + resizable?: boolean; + rows?: number; + underlined?: boolean; + value?: string; +} + +// @public +export interface PropertyPaneToggleProperties extends PropertyPaneFieldProperties { + ariaLabel?: string; + checked?: boolean; + disabled?: boolean; + key?: string; + label?: string; + offAriaLabel?: string; + offText?: string; + onAriaLabel?: string; + onText?: string; +} + +// @public +export interface QuickViewCardAction { + parameters: QuickViewParameters; + type: 'QuickView'; +} + +// @public (undocumented) +export interface QuickViewData { + // (undocumented) + [key: string]: unknown; +} + +// @public +export interface QuickViewHandleActionResponse extends BaseHandleActionResponse { + renderArguments: QuickViewResponse; + type: 'QuickView'; +} + +// @public +export interface QuickViewParameters { + view: string; +} + +// @public +export interface QuickViewResponse { + data: QuickViewData; + externalLink: ExternalLinkActionParameters; + focusParameters: FocusParameters; + template: AdaptiveCard; + title: string; + viewId: string; +} + // @public export type ReactionType = 'like' | 'heart' | 'laugh' | 'surprised' | 'sad' | 'angry'; @@ -1570,6 +2022,17 @@ export enum RoleTypes { User = "user" } +// @public +export function SearchCardView(cardBar: CardBarComponent, header: CardTextComponent, body: CardSearchBoxComponent, footer: CardSearchFooterComponent): SearchCardViewParameters; + +// @public +export interface SearchCardViewParameters extends BaseCardViewParameters { + body: [CardSearchBoxComponent]; + cardViewType: 'search'; + footer?: [CardSearchFooterComponent]; + header: [CardTextComponent]; +} + // @public export interface SearchInvokeOptions { skip: number; @@ -1588,6 +2051,20 @@ export interface SearchInvokeValue { queryText: string; } +// @public +export interface SelectMediaActionParameters { + allowMultipleCapture?: boolean; + maxSizePerFile?: number; + mediaType: MediaType; + supportedFileFormats?: string[]; +} + +// @public +export interface SelectMediaCardAction { + parameters: SelectMediaActionParameters; + type: 'VivaAction.SelectMedia'; +} + // @public export interface SemanticAction { entities: { @@ -1607,12 +2084,37 @@ export enum SemanticActionStateTypes { Start = "start" } +// @public (undocumented) +export type SetPropertyPaneConfigurationResponse = CardViewHandleActionResponse | NoOpHandleActionResponse; + +// @public +export interface ShowLocationActionParameters { + locationCoordinates?: Location_2; +} + +// @public +export interface ShowLocationCardAction { + parameters?: ShowLocationActionParameters; + type: 'VivaAction.ShowLocation'; +} + // @public export interface SigninCard { buttons: CardAction[]; text?: string; } +// @public +export function SignInCardView(cardBar: CardBarComponent, header: CardTextComponent, body: CardTextComponent, footer: CardButtonComponent): SignInCardViewParameters; + +// @public +export interface SignInCardViewParameters extends BaseCardViewParameters { + body: [CardTextComponent] | undefined; + cardViewType: 'signIn'; + footer?: [CardButtonComponent]; + header: [CardTextComponent]; +} + // @public export interface SigninStateVerificationQuery { state?: string; @@ -1663,6 +2165,18 @@ export enum StatusCodes { // @public export type Style = 'compact' | 'expanded'; +// @public +export interface SubmitCardAction { + confirmationDialog?: ConfirmationDialog; + parameters: SubmitCardParameters; + type: 'Submit'; +} + +// @public +export interface SubmitCardParameters { + [key: string]: unknown; +} + // @public export interface SuggestedActions { actions: CardAction[]; @@ -1872,6 +2386,15 @@ export interface TenantInfo { id?: string; } +// @public +export interface TextCardViewParameters extends BaseCardViewParameters { + body: [CardTextComponent] | undefined; + cardViewType: 'text'; + footer?: CardViewFooterParameters; + header: [CardTextComponent]; + image?: CardImage_2; +} + // @public export enum TextFormatTypes { // (undocumented) @@ -1888,6 +2411,18 @@ export interface TextHighlight { text: string; } +// @public +export function TextInputCardView(cardBar: CardBarComponent, header: CardTextComponent, body: CardTextInputComponent, footer?: CardViewActionsFooterParameters): TextInputCardViewParameters; + +// @public +export interface TextInputCardViewParameters extends BaseCardViewParameters { + body: [CardTextInputComponent]; + cardViewType: 'textInput'; + footer?: CardViewActionsFooterParameters; + header: [CardTextComponent]; + image?: CardImage_2; +} + // @public export interface Thing { name: string; @@ -2020,6 +2555,9 @@ export interface VideoCard { value: any; } +// @public +export type ViewResponseType = 'Card' | 'QuickView' | 'NoOp'; + // (No @packageDocumentation comment for this package) diff --git a/libraries/botframework-schema/package.json b/libraries/botframework-schema/package.json index 45d6bca1f1..fab3d0030c 100644 --- a/libraries/botframework-schema/package.json +++ b/libraries/botframework-schema/package.json @@ -28,7 +28,8 @@ }, "dependencies": { "uuid": "^8.3.2", - "zod": "~1.11.17" + "zod": "~1.11.17", + "adaptivecards": "1.2.3" }, "scripts": { "build": "tsc -b", diff --git a/libraries/botframework-schema/src/index.ts b/libraries/botframework-schema/src/index.ts index 34d5cc53ff..ea98f9aa5e 100644 --- a/libraries/botframework-schema/src/index.ts +++ b/libraries/botframework-schema/src/index.ts @@ -17,6 +17,9 @@ export { TokenExchangeInvokeResponse } from './tokenExchangeInvokeResponse'; // The Teams schemas was manually added to this library. This file has been updated to export those schemas. export * from './teams'; +// The SharePoint schemas was manually added to this library. This file has been updated to export those schemas. +export * from './sharepoint'; + /** * Attachment View name and size */ diff --git a/libraries/botframework-schema/src/sharepoint/aceData.ts b/libraries/botframework-schema/src/sharepoint/aceData.ts new file mode 100644 index 0000000000..ec56b9c34d --- /dev/null +++ b/libraries/botframework-schema/src/sharepoint/aceData.ts @@ -0,0 +1,44 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +/** + * SharePoint ACE Data object + */ +export interface AceData { + /** + * The card size. + */ + cardSize: AceCardSize; + /** + * The value of this property is stored in the serialized data of the Adaptive Card Extension. + * It can be used to manage versioning of the Adaptive Card Extension. + * + * @remarks - although there is no restriction on the format of this property, it is recommended to use semantic versioning. + */ + dataVersion: string; + /** + * The unique id (Guid) of the ACE. + */ + id: string; + /** + * The title of the ACE. + */ + title: string; + /** + * The icon of the ACE. + */ + iconProperty: string; + /** + * The description of the ACE. + */ + description: string; + /** + * The properties of the ACE. + */ + properties: any; +} + +/** + * SharePoint ACE Card Size + */ +export type AceCardSize = 'Medium' | 'Large'; diff --git a/libraries/botframework-schema/src/sharepoint/aceRequest.ts b/libraries/botframework-schema/src/sharepoint/aceRequest.ts new file mode 100644 index 0000000000..009374bbbd --- /dev/null +++ b/libraries/botframework-schema/src/sharepoint/aceRequest.ts @@ -0,0 +1,16 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +/** + * ACE invoke request payload. + */ +export interface AceRequest { + /** + * User ACE request data. Free payload with key-value pairs. + */ + data?: any; + /** + * ACE properties data. + */ + properties?: any; +} diff --git a/libraries/botframework-schema/src/sharepoint/actions/cardAction.ts b/libraries/botframework-schema/src/sharepoint/actions/cardAction.ts new file mode 100644 index 0000000000..9b3bd96606 --- /dev/null +++ b/libraries/botframework-schema/src/sharepoint/actions/cardAction.ts @@ -0,0 +1,265 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +/** + * SharePoint Confirmation Dialog option that is passed through `Submit` Action is executed. + */ +export interface ConfirmationDialog { + /** + * Dialog title. + */ + title: string; + /** + * Dialog message. + */ + message: string; +} + +/** + * Interface for location coordinates + */ +export interface Location { + /** + * Latitude of the location. + */ + latitude: number; + /** + * Longitude of the location. + */ + longitude: number; + /** + * Timestamp in ISO milliseconds since epoch. + */ + timestamp?: number; + /** + * Accuracy of the location. + */ + accuracy?: number; +} + +/** + * Enum value to specify the type of media for VivaAction.SelectMedia action. + */ +export enum MediaType { + Image = 1, + Audio = 4, + Document = 8, +} + +/** + * SharePoint QuickView action. + */ +export interface QuickViewCardAction { + /** + * Indicates this action opens the quick view. + */ + type: 'QuickView'; + /** + * Parameters for the quick view opened by this action + */ + parameters: QuickViewParameters; +} + +/** + * Parameters for opening a Quick view. + */ +export interface QuickViewParameters { + /** + * The view of the Quick view to open. + */ + view: string; +} + +/** + * SharePoint ExternalLink action. + */ +export interface ExternalLinkCardAction { + /** + * Indicates this is an external link button. + */ + type: 'ExternalLink'; + /** + * Parameters for the external link. + */ + parameters: ExternalLinkActionParameters; +} + +/** + * Parameters for opening an external link. + */ +export interface ExternalLinkActionParameters { + /** + * Indicates whether this is a Teams Deep Link. + */ + isTeamsDeepLink?: boolean; + /** + * The URL of the link. + */ + target: string; +} + +/** + * SharePoint `Action.Submit` event. + */ +export interface SubmitCardAction { + /** + * Indicates this is a Submit button. + */ + type: 'Submit'; + /** + * Parameters passed to the Submit event handler. + */ + parameters: SubmitCardParameters; + /** + * Confirmation dialog option passed to the submit handler. + */ + confirmationDialog?: ConfirmationDialog; +} + +/** + * SharePoint `Action.Execute` event. + */ +export interface ExecuteCardAction { + /** + * Indicates this is an Execute button. + */ + type: 'Execute'; + /** + * Verb associated with this action + */ + verb?: string; + /** + * Parameters passed to the Execute event handler + */ + parameters: ExecuteCardParameters; +} + +/** + * Parameters for SharePoint Action.Execute card action. + */ +export interface ExecuteCardParameters { + /** + * Key value pair property that can be defined for execute card action parameters. + */ + [key: string]: unknown; +} + +/** + * Parameters for SharePoint Action.Submit card action. + */ +export interface SubmitCardParameters { + /** + * Key value pair property that can be defined for submit card action parameters. + */ + [key: string]: unknown; +} + +/** + * SharePoint `VivaAction.SelectMedia` event. + */ +export interface SelectMediaCardAction { + /** + * Indicates this is a Viva Select Media button. + */ + type: 'VivaAction.SelectMedia'; + /** + * Parameters for the Select Media Action + */ + parameters: SelectMediaActionParameters; +} + +/** + * Parameters that can be supplied with the SharePoint VivaAction.SelectMendia action. + */ +export interface SelectMediaActionParameters { + /** + * Specifies the specific media type that should be selected + */ + mediaType: MediaType; + /** + * Allow multiple images to be selected. + */ + allowMultipleCapture?: boolean; + /** + * Max file size that can be uploaded. + */ + maxSizePerFile?: number; + /** + * File formats supported for upload. + */ + supportedFileFormats?: string[]; +} + +/** + * SharePoint `VivaAction.ShowLocation` event. + */ +export interface ShowLocationCardAction { + /** + * Indicates this is a Viva show Location button. + */ + type: 'VivaAction.ShowLocation'; + /** + * Parameters that can be supplied with the Viva Show Location action. + */ + parameters?: ShowLocationActionParameters; +} + +/** + * Parameters that can be supplied with the SharePoint VivaAction.ShowLocation action. + */ +export interface ShowLocationActionParameters { + /** + * If set, show the coordinates that were passed. + * Otherwise, show the current location. + */ + locationCoordinates?: Location; +} + +/** + * SharePoint `VivaAction.GetLocation` event. + */ +export interface GetLocationCardAction { + /** + * Indicates this is a Viva Select Location button. + */ + type: 'VivaAction.GetLocation'; + /** + * Parameters that can be supplied with the Viva Get Location Action. + */ + parameters?: GetLocationActionParameters; +} + +/** + * Parameters that can be supplied with the SharePoint VivaAction.GetLocation action. + */ +export interface GetLocationActionParameters { + /** + * If true, allow the user to choose a location by opening a map. + * Otherwise, get the current location. + */ + chooseLocationOnMap?: boolean; +} + +/** + * Type of handler for when a card button is pressed. + */ +export type CardAction = + | QuickViewCardAction + | ExternalLinkCardAction + | SubmitCardAction + | SelectMediaCardAction + | GetLocationCardAction + | ShowLocationCardAction + | ExecuteCardAction; + +/** + * Type of handler for when a card is selected. + */ +export type OnCardSelectionAction = + | QuickViewCardAction + | ExternalLinkCardAction + | SelectMediaCardAction + | GetLocationCardAction + | ShowLocationCardAction + | ExecuteCardAction + | undefined; diff --git a/libraries/botframework-schema/src/sharepoint/actions/focusParameters.ts b/libraries/botframework-schema/src/sharepoint/actions/focusParameters.ts new file mode 100644 index 0000000000..2ad03ac373 --- /dev/null +++ b/libraries/botframework-schema/src/sharepoint/actions/focusParameters.ts @@ -0,0 +1,20 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +/** + * Interface to give third party developers the capability to determine which element should recieve focus, when, and how often content should be read. + */ +export interface FocusParameters { + /** + * Sets the default focus on the DOM. Developers pass in the id of a unique element that is to attain focus within a quick view. + * If the `focusTarget` is not defined then the root element is selected. + */ + focusTarget?: string; + /** + * Sets the accessibility reading of the contents within the focus target. + * Polite - Content in the target's subtree is read when the user is idle. + * Assertive - Disrupts any announcement in favor of the changed contents within the target's subtree. + * Off - The screen reader will not read contents within the target's subtree. + */ + ariaLive?: 'polite' | 'assertive' | 'off'; +} diff --git a/libraries/botframework-schema/src/sharepoint/actions/index.ts b/libraries/botframework-schema/src/sharepoint/actions/index.ts new file mode 100644 index 0000000000..855ecf3ed9 --- /dev/null +++ b/libraries/botframework-schema/src/sharepoint/actions/index.ts @@ -0,0 +1,5 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +export * from './cardAction'; +export * from './focusParameters'; diff --git a/libraries/botframework-schema/src/sharepoint/cardView/baseCardComponent.ts b/libraries/botframework-schema/src/sharepoint/cardView/baseCardComponent.ts new file mode 100644 index 0000000000..def5e076f0 --- /dev/null +++ b/libraries/botframework-schema/src/sharepoint/cardView/baseCardComponent.ts @@ -0,0 +1,22 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +/** + * Names of the components allowed in a card view. + */ +export type CardComponentName = 'text' | 'cardButton' | 'cardBar' | 'textInput' | 'searchBox' | 'searchFooter'; + +/** + * Base Adaptive Card Extension card view component. + */ +export interface BaseCardComponent { + /** + * Unique component name. + * For example, "textInput" + */ + componentName: CardComponentName; + /** + * Optional unique identifier of the component's instance. + */ + id?: string; +} diff --git a/libraries/botframework-schema/src/sharepoint/cardView/cardBarComponent.ts b/libraries/botframework-schema/src/sharepoint/cardView/cardBarComponent.ts new file mode 100644 index 0000000000..16d088c5ec --- /dev/null +++ b/libraries/botframework-schema/src/sharepoint/cardView/cardBarComponent.ts @@ -0,0 +1,23 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +import type { CardImage } from './cardImage'; +import type { BaseCardComponent } from './baseCardComponent'; + +/** + * Adaptive Card Extension Card view title area (card bar) component + */ +export interface CardBarComponent extends BaseCardComponent { + /** + * Unique component name. + */ + componentName: 'cardBar'; + /** + * The icon to display. + */ + icon?: CardImage; + /** + * The title to display. + */ + title?: string; +} diff --git a/libraries/botframework-schema/src/sharepoint/cardView/cardButtonBase.ts b/libraries/botframework-schema/src/sharepoint/cardView/cardButtonBase.ts new file mode 100644 index 0000000000..5934cebb87 --- /dev/null +++ b/libraries/botframework-schema/src/sharepoint/cardView/cardButtonBase.ts @@ -0,0 +1,18 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +import type { CardAction } from '../actions/cardAction'; + +/** + * Base properties for the buttons used in different Adaptive Card Extension card view components, such as Text Input, Search Box and Card Button. + */ +export interface CardButtonBase { + /** + * The type of the button. + */ + action: CardAction; + /** + * Unique Id of the button. + */ + id?: string; +} diff --git a/libraries/botframework-schema/src/sharepoint/cardView/cardButtonComponent.ts b/libraries/botframework-schema/src/sharepoint/cardView/cardButtonComponent.ts new file mode 100644 index 0000000000..591b4e4543 --- /dev/null +++ b/libraries/botframework-schema/src/sharepoint/cardView/cardButtonComponent.ts @@ -0,0 +1,23 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +import type { BaseCardComponent } from './baseCardComponent'; +import type { CardButtonBase } from './cardButtonBase'; + +/** + * Adaptive Card Extension Card button component. + */ +export interface CardButtonComponent extends BaseCardComponent, CardButtonBase { + /** + * Unique component name. + */ + componentName: 'cardButton'; + /** + * Text displayed on the button. + */ + title: string; + /** + * Controls the style of the button. + */ + style?: 'default' | 'positive'; +} diff --git a/libraries/botframework-schema/src/sharepoint/cardView/cardImage.ts b/libraries/botframework-schema/src/sharepoint/cardView/cardImage.ts new file mode 100644 index 0000000000..4d032f6a32 --- /dev/null +++ b/libraries/botframework-schema/src/sharepoint/cardView/cardImage.ts @@ -0,0 +1,16 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +/** + * Properties for the image or icon rendered in a card view. + */ +export interface CardImage { + /** + * The URL to display as image or icon. + */ + url: string; + /** + * The alt text. + */ + altText?: string; +} diff --git a/libraries/botframework-schema/src/sharepoint/cardView/cardSearchBoxComponent.ts b/libraries/botframework-schema/src/sharepoint/cardView/cardSearchBoxComponent.ts new file mode 100644 index 0000000000..e1894ed17e --- /dev/null +++ b/libraries/botframework-schema/src/sharepoint/cardView/cardSearchBoxComponent.ts @@ -0,0 +1,35 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +import type { BaseCardComponent } from './baseCardComponent'; +import type { CardButtonBase } from './cardButtonBase'; + +/** + * Search box button properties. + */ +// eslint-disable-next-line @typescript-eslint/no-empty-interface +export interface ICardSearchBoxButton extends CardButtonBase { + // reserved for future. Not additional properties. +} + +/** + * Adaptive Card Extension Search box component. Represents a search box rendered in the card view. + */ +export interface CardSearchBoxComponent extends BaseCardComponent { + /** + * Unique component name. + */ + componentName: 'searchBox'; + /** + * Placeholder text to display. + */ + placeholder?: string; + /** + * Default value to display. + */ + defaultValue?: string; + /** + * Button displayed on the search box. + */ + button: ICardSearchBoxButton; +} diff --git a/libraries/botframework-schema/src/sharepoint/cardView/cardSearchFooterComponent.ts b/libraries/botframework-schema/src/sharepoint/cardView/cardSearchFooterComponent.ts new file mode 100644 index 0000000000..126c431be9 --- /dev/null +++ b/libraries/botframework-schema/src/sharepoint/cardView/cardSearchFooterComponent.ts @@ -0,0 +1,35 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +import type { CardAction } from '../actions/cardAction'; +import type { BaseCardComponent } from './baseCardComponent'; + +/** + * Adaptive Card Extension Search footer component. Represents a container with an image (in the shape of a circle) and text. + */ +export interface CardSearchFooterComponent extends BaseCardComponent { + /** + * Unique component name. + */ + componentName: 'searchFooter'; + /** + * Title text to display. + */ + title: string; + /** + * Url to the image to use, should be a square aspect ratio and big enough to fit in the image area. + */ + imageUrl?: string; + /** + * The initials to display in the image area when there is no image. + */ + imageInitials?: string; + /** + * Primary text to display. For example, name of the person for people search. + */ + text: string; + /** + * Action to invoke when the footer is selected. + */ + onSelection?: CardAction; +} diff --git a/libraries/botframework-schema/src/sharepoint/cardView/cardTextComponent.ts b/libraries/botframework-schema/src/sharepoint/cardView/cardTextComponent.ts new file mode 100644 index 0000000000..2038e1aee1 --- /dev/null +++ b/libraries/botframework-schema/src/sharepoint/cardView/cardTextComponent.ts @@ -0,0 +1,18 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +import type { BaseCardComponent } from './baseCardComponent'; + +/** + * Adaptive Card Extension Text component. Represents a text block rendered in the card view. + */ +export interface CardTextComponent extends BaseCardComponent { + /** + * Unique component name. + */ + componentName: 'text'; + /** + * Text to display. + */ + text: string; +} diff --git a/libraries/botframework-schema/src/sharepoint/cardView/cardTextInputComponent.ts b/libraries/botframework-schema/src/sharepoint/cardView/cardTextInputComponent.ts new file mode 100644 index 0000000000..7e0a82d2f1 --- /dev/null +++ b/libraries/botframework-schema/src/sharepoint/cardView/cardTextInputComponent.ts @@ -0,0 +1,60 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +import type { CardImage } from './cardImage'; +import type { BaseCardComponent } from './baseCardComponent'; +import type { CardButtonBase } from './cardButtonBase'; + +/** + * Text input icon button. + */ +export interface ICardTextInputIconButton extends CardButtonBase { + /** + * Properties for the icon displayed on the button. + */ + icon: CardImage; +} + +/** + * Text input title button. + */ +export interface ICardTextInputTitleButton extends CardButtonBase { + /** + * Text displayed on the button. + */ + title: string; +} + +/** + * Adaptive Card Extension Text input component. + */ +export interface CardTextInputComponent extends BaseCardComponent { + /** + * Unique component name. + */ + componentName: 'textInput'; + /** + * Placeholder text to display. + */ + placeholder?: string; + /** + * Default value to display. + */ + defaultValue?: string; + /** + * Properties for an optional icon, displayed in the left end of the text input. + */ + iconBefore?: CardImage; + /** + * Properties for an optional icon, displayed in the right end of the text input. + */ + iconAfter?: CardImage; + /** + * Optional button to display. + */ + button?: ICardTextInputIconButton | ICardTextInputTitleButton; + /** + * Aria label for the text field. + */ + ariaLabel?: string; +} diff --git a/libraries/botframework-schema/src/sharepoint/cardView/cardViewParameters.ts b/libraries/botframework-schema/src/sharepoint/cardView/cardViewParameters.ts new file mode 100644 index 0000000000..8de587613b --- /dev/null +++ b/libraries/botframework-schema/src/sharepoint/cardView/cardViewParameters.ts @@ -0,0 +1,313 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +import { CardImage } from './cardImage'; +import { CardBarComponent } from './cardBarComponent'; +import { CardButtonComponent } from './cardButtonComponent'; +import { CardSearchBoxComponent } from './cardSearchBoxComponent'; +import { CardSearchFooterComponent } from './cardSearchFooterComponent'; +import { CardTextComponent } from './cardTextComponent'; +import { CardTextInputComponent } from './cardTextInputComponent'; + +/** + * The actions-only footer parameters for the card view. + */ +export type CardViewActionsFooterParameters = + | [CardButtonComponent] + | [CardButtonComponent, CardButtonComponent] + | undefined; + +/** + * The footer parameters for the card view. Can contain either 0 to 2 buttons or a single text input. + */ +export type CardViewFooterParameters = CardViewActionsFooterParameters | [CardTextInputComponent]; + +/** + * Base parameters for the card view. + */ +export interface BaseCardViewParameters { + /** + * Card view title area (card bar) components. + */ + cardBar: [CardBarComponent]; +} + +/** + * The parameters for the card view with text or empty body. + */ +export interface TextCardViewParameters extends BaseCardViewParameters { + /** + * Card View type + */ + cardViewType: 'text'; + /** + * Header area components. + */ + header: [CardTextComponent]; + /** + * Body area components. + */ + body: [CardTextComponent] | undefined; + /** + * Footer area components. + */ + footer?: CardViewFooterParameters; + + /** + * Image displayed on the card. + */ + image?: CardImage; +} + +/** + * The parameters for the card view with text input in the body. + */ +export interface TextInputCardViewParameters extends BaseCardViewParameters { + /** + * Card View type + */ + cardViewType: 'textInput'; + /** + * Header area components. + */ + header: [CardTextComponent]; + /** + * Body area components. + */ + body: [CardTextInputComponent]; + /** + * Footer area components. + */ + footer?: CardViewActionsFooterParameters; + /** + * Image displayed on the card. + */ + image?: CardImage; +} + +/** + * The parameters for the search card view. + */ +export interface SearchCardViewParameters extends BaseCardViewParameters { + /** + * Card View type + */ + cardViewType: 'search'; + /** + * Header area components. Contains a single text field. + */ + header: [CardTextComponent]; + /** + * Body area components. Contains a single search box. + */ + body: [CardSearchBoxComponent]; + /** + * Footer area components. Contains a single search footer. + */ + footer?: [CardSearchFooterComponent]; +} + +/** + * The parameters for the sign in card view. + */ +export interface SignInCardViewParameters extends BaseCardViewParameters { + /** + * Card View type + */ + cardViewType: 'signIn'; + /** + * Header area components. + */ + header: [CardTextComponent]; + /** + * Body area components. + */ + body: [CardTextComponent] | undefined; + /** + * Footer area components. + */ + footer?: [CardButtonComponent]; +} + +/** + * Card View Parameters. + */ +export type CardViewParameters = + | TextCardViewParameters + | TextInputCardViewParameters + | SearchCardViewParameters + | SignInCardViewParameters; + +/** + * Helper method to create a Basic Card View. + * The Basic Text card view displays the following: + * - Card bar + * - One primary text field + * - Zero or one button in the Medium card size, up to two buttons in Large card size; or text input. + * + * @param cardBar - card bar component + * @param header - text component to display as header + * @param footer - up to two buttons or text input to display as footer + * @returns basic card view parameters. + */ +export function BasicCardView( + cardBar: CardBarComponent, + header: CardTextComponent, + footer?: CardViewFooterParameters +): TextCardViewParameters { + return { + cardViewType: 'text', + body: undefined, + cardBar: [cardBar], + header: [header], + footer: footer, + }; +} + +/** + * Helper method to create a Primary Text Card View. + * The Primary Text card view displays the following: + * - Card bar + * - One primary text field + * - One description text field + * - Zero or one button in the Medium card size, up to two buttons in Large card size; or text input. + * + * @param cardBar - card bar component + * @param header - text component to display as header + * @param body - text component to display as body + * @param footer - up to two buttons or text input to display as footer + * @returns primary text card view parameters. + */ +export function PrimaryTextCardView( + cardBar: CardBarComponent, + header: CardTextComponent, + body: CardTextComponent, + footer?: CardViewFooterParameters +): TextCardViewParameters { + return { + cardViewType: 'text', + cardBar: [cardBar], + header: [header], + body: [body], + footer: footer, + }; +} + +/** + * Helper method to create an Image Card View. + * The Image Card view displays the following: + * - Card bar + * - One primary text field + * - One image + * - Zero buttons in the Medium card size, up to two buttons in Large card size; or text input. + * + * @param cardBar - card bar component + * @param header - text component to display as header + * @param image - image to display + * @param footer - up to two buttons or text input to display as footer + * @returns image card view parameters + */ +export function ImageCardView( + cardBar: CardBarComponent, + header: CardTextComponent, + image: CardImage, + footer?: CardViewFooterParameters +): TextCardViewParameters { + return { + cardViewType: 'text', + image: image, + cardBar: [cardBar], + header: [header], + body: undefined, + footer: footer, + }; +} + +/** + * Helper method to create an Text Input Card View. + * The Text Input Card view displays the following: + * - Card bar + * - One primary text field + * - Zero or one image + * - Zero text input in Medium card size if image is presented, one text input in Medium card size if no image is presented, one text input in Large card size + * - Zero buttons in the Medium card size if image is presented, one button in Medium card size if no image is presented, up to two buttons in Large card size; or text input. + * + * @param cardBar - card bar component + * @param header - text component to display as header + * @param body - text input component to display as body + * @param footer - up to two buttons to display as footer + * @returns text input card view parameters + */ +export function TextInputCardView( + cardBar: CardBarComponent, + header: CardTextComponent, + body: CardTextInputComponent, + footer?: CardViewActionsFooterParameters +): TextInputCardViewParameters { + return { + cardViewType: 'textInput', + cardBar: [cardBar], + header: [header], + body: [body], + footer: footer, + }; +} + +/** + * Helper method to create a Search Card View. + * The Search Card view displays the following: + * - Card bar + * - One primary text field + * - One search box + * - One search footer + * + * @param cardBar - card bar component + * @param header - text component to display as header + * @param body - search box component to display as body + * @param footer - search footer component to display as footer + * @returns search card view parameters + */ +export function SearchCardView( + cardBar: CardBarComponent, + header: CardTextComponent, + body: CardSearchBoxComponent, + footer: CardSearchFooterComponent +): SearchCardViewParameters { + return { + cardViewType: 'search', + cardBar: [cardBar], + header: [header], + body: [body], + footer: [footer], + }; +} + +/** + * Helper method to create a Sign In Card View. + * The Sign In Card view displays the following: + * - Card bar + * - One primary text field + * - One description text field + * - Two buttons. + * + * @remarks The first button (sign in button) is always displayed based on the signInText property of the Adaptive Card Extension. Here you should specify the second button (sign in complete button) to display. + * @param cardBar - card bar component + * @param header - text component to display as header + * @param body - text component to display as body + * @param footer - sign in complete button to display as footer + * @returns sign in card view parameters + */ +export function SignInCardView( + cardBar: CardBarComponent, + header: CardTextComponent, + body: CardTextComponent, + footer: CardButtonComponent +): SignInCardViewParameters { + return { + cardViewType: 'signIn', + cardBar: [cardBar], + header: [header], + body: [body], + footer: [footer], + }; +} diff --git a/libraries/botframework-schema/src/sharepoint/cardView/index.ts b/libraries/botframework-schema/src/sharepoint/cardView/index.ts new file mode 100644 index 0000000000..295096a12f --- /dev/null +++ b/libraries/botframework-schema/src/sharepoint/cardView/index.ts @@ -0,0 +1,10 @@ +export * from './baseCardComponent'; +export * from './cardBarComponent'; +export * from './cardButtonBase'; +export * from './cardButtonComponent'; +export * from './cardImage'; +export * from './cardSearchBoxComponent'; +export * from './cardSearchFooterComponent'; +export * from './cardTextComponent'; +export * from './cardTextInputComponent'; +export * from './cardViewParameters'; diff --git a/libraries/botframework-schema/src/sharepoint/cardViewResponse.ts b/libraries/botframework-schema/src/sharepoint/cardViewResponse.ts new file mode 100644 index 0000000000..51c80a70b5 --- /dev/null +++ b/libraries/botframework-schema/src/sharepoint/cardViewResponse.ts @@ -0,0 +1,28 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +import { AceData } from './aceData'; +import { OnCardSelectionAction } from './actions/cardAction'; +import { CardViewParameters } from './cardView/cardViewParameters'; + +/** + * SharePoint ACE Card view response payload. + */ +export interface CardViewResponse { + /** + * The ACE data. + */ + aceData: AceData; + /** + * The card view parameters. + */ + cardViewParameters: CardViewParameters; + /** + * The on card selection action. + */ + onCardSelection?: OnCardSelectionAction; + /** + * The view id. + */ + viewId: string; +} diff --git a/libraries/botframework-schema/src/sharepoint/getPropertyPaneConfigurationResponse.ts b/libraries/botframework-schema/src/sharepoint/getPropertyPaneConfigurationResponse.ts new file mode 100644 index 0000000000..cafecb42c4 --- /dev/null +++ b/libraries/botframework-schema/src/sharepoint/getPropertyPaneConfigurationResponse.ts @@ -0,0 +1,26 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +import { PropertyPanePage } from './propertyPanePage'; + +/** + * SharePoint ACE get property pane configuration response. + */ +export interface GetPropertyPaneConfigurationResponse { + /** + * Property pane pages. + */ + pages: PropertyPanePage[]; + /** + * Current page number. + */ + currentPage: number; + /** + * Loading indicator delay time. + */ + loadingIndicatorDelayTime: number; + /** + * Value indicating whether to show loading indicator on top of the property pane. + */ + showLoadingIndicator: boolean; +} diff --git a/libraries/botframework-schema/src/sharepoint/handleActionResponse.ts b/libraries/botframework-schema/src/sharepoint/handleActionResponse.ts new file mode 100644 index 0000000000..3e4c427575 --- /dev/null +++ b/libraries/botframework-schema/src/sharepoint/handleActionResponse.ts @@ -0,0 +1,74 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +import { CardViewResponse } from './cardViewResponse'; +import { QuickViewResponse } from './quickViewResponse'; + +/** + * The type of the view in the handle action response. + */ +export type ViewResponseType = 'Card' | 'QuickView' | 'NoOp'; + +/** + * The base handle action response. + */ +export interface BaseHandleActionResponse { + /** + * The type of the view in the handle action response. + */ + type: ViewResponseType; + /** + * The render arguments. + */ + renderArguments?: CardViewResponse | QuickViewResponse; +} + +/** + * The handle action response for card view. + */ +export interface CardViewHandleActionResponse extends BaseHandleActionResponse { + /** + * Card view. + */ + type: 'Card'; + /** + * Card view render arguments. + */ + renderArguments: CardViewResponse; +} + +/** + * The handle action response for quick view. + */ +export interface QuickViewHandleActionResponse extends BaseHandleActionResponse { + /** + * Quick view. + */ + type: 'QuickView'; + /** + * Quick view render arguments. + */ + renderArguments: QuickViewResponse; +} + +/** + * The handle action response for no op. + */ +export interface NoOpHandleActionResponse extends BaseHandleActionResponse { + /** + * No op. + */ + type: 'NoOp'; + /** + * No op doesn't have render arguments. + */ + renderArguments?: undefined; +} + +/** + * The handle action response. + */ +export type HandleActionResponse = + | CardViewHandleActionResponse + | QuickViewHandleActionResponse + | NoOpHandleActionResponse; diff --git a/libraries/botframework-schema/src/sharepoint/index.ts b/libraries/botframework-schema/src/sharepoint/index.ts new file mode 100644 index 0000000000..7305500a50 --- /dev/null +++ b/libraries/botframework-schema/src/sharepoint/index.ts @@ -0,0 +1,32 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +export * from './aceData'; +export * from './aceRequest'; +export * from './getPropertyPaneConfigurationResponse'; +export * from './handleActionResponse'; +export * from './propertyPaneFieldProperties'; +export * from './propertyPaneGroupOrConditionalGroup'; +export * from './propertyPaneCheckboxProperties'; +export * from './propertyPaneChoiceGroupIconProperties'; +export * from './propertyPaneChoiceGroupImageSize'; +export * from './propertyPaneChoiceGroupOption'; +export * from './propertyPaneChoiceGroupProperties'; +export * from './propertyPaneDropDownOption'; +export * from './propertyPaneDropDownProperties'; +export * from './propertyPaneGroupField'; +export * from './propertyPaneGroup'; +export * from './propertyPaneLabelProperties'; +export * from './propertyPaneLinkPopupWindowProperties'; +export * from './propertyPaneLinkProperties'; +export * from './propertyPanePage'; +export * from './propertyPanePageHeader'; +export * from './propertyPaneSliderProperties'; +export * from './propertyPaneTextFieldProperties'; +export * from './propertyPaneToggleProperties'; +export * from './setPropertyPaneConfigurationResponse'; +export * from './cardViewResponse'; +export * from './quickViewData'; +export * from './quickViewResponse'; +export * from './actions'; +export * from './cardView'; diff --git a/libraries/botframework-schema/src/sharepoint/propertyPaneCheckboxProperties.ts b/libraries/botframework-schema/src/sharepoint/propertyPaneCheckboxProperties.ts new file mode 100644 index 0000000000..25a396d9a8 --- /dev/null +++ b/libraries/botframework-schema/src/sharepoint/propertyPaneCheckboxProperties.ts @@ -0,0 +1,22 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +import { PropertyPaneFieldProperties } from './propertyPaneFieldProperties'; + +/** + * SharePoint property pane checkbox field properties. + */ +export interface PropertyPaneCheckboxProperties extends PropertyPaneFieldProperties { + /** + * The label text to display next to the checkbox. + */ + text?: string; + /** + * Indicates whether the checkbox is disabled or not. + */ + disabled?: boolean; + /** + * Indicates whether the checkbox is checked or not. + */ + checked?: boolean; +} diff --git a/libraries/botframework-schema/src/sharepoint/propertyPaneChoiceGroupIconProperties.ts b/libraries/botframework-schema/src/sharepoint/propertyPaneChoiceGroupIconProperties.ts new file mode 100644 index 0000000000..c8ad8e32ec --- /dev/null +++ b/libraries/botframework-schema/src/sharepoint/propertyPaneChoiceGroupIconProperties.ts @@ -0,0 +1,12 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +/** + * SharePoint property pane choice group icon properties. + */ +export interface PropertyPaneChoiceGroupIconProperties { + /** + * The name of the icon to use from Office Fabric icon set. + */ + officeFabricIconFontName?: string; +} diff --git a/libraries/botframework-schema/src/sharepoint/propertyPaneChoiceGroupImageSize.ts b/libraries/botframework-schema/src/sharepoint/propertyPaneChoiceGroupImageSize.ts new file mode 100644 index 0000000000..f61c5f5e90 --- /dev/null +++ b/libraries/botframework-schema/src/sharepoint/propertyPaneChoiceGroupImageSize.ts @@ -0,0 +1,16 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +/** + * SharePoint property pane choice group image size. + */ +export interface PropertyPaneChoiceGroupImageSize { + /** + * The width of the image. + */ + width: number; + /** + * The height of the image. + */ + height: number; +} diff --git a/libraries/botframework-schema/src/sharepoint/propertyPaneChoiceGroupOption.ts b/libraries/botframework-schema/src/sharepoint/propertyPaneChoiceGroupOption.ts new file mode 100644 index 0000000000..44c0d92b55 --- /dev/null +++ b/libraries/botframework-schema/src/sharepoint/propertyPaneChoiceGroupOption.ts @@ -0,0 +1,43 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +import { PropertyPaneChoiceGroupIconProperties } from './propertyPaneChoiceGroupIconProperties'; +import { PropertyPaneChoiceGroupImageSize } from './propertyPaneChoiceGroupImageSize'; + +/** + * SharePoint property pane choice group option. + */ +export interface PropertyPaneChoiceGroupOption { + /** + * Optional ariaLabel flag. Text for screen-reader to announce regardless of toggle state. + */ + ariaLabel?: string; + /** + * Indicates whether the choice group option is disabled or not. + */ + disabled?: boolean; + /** + * Indicates whether the choice group option is checked or not. + */ + checked?: boolean; + /** + * The icon properties to use for the choice group option. + */ + iconProps?: PropertyPaneChoiceGroupIconProperties; + /** + * The image size to use for the choice group option. + */ + imageSize?: PropertyPaneChoiceGroupImageSize; + /** + * The image source to use for the choice group option. + */ + imageSrc?: string; + /** + * The key to uniquely identify the choice group option. + */ + key: string; + /** + * The text to display next for this choice group option. + */ + text: string; +} diff --git a/libraries/botframework-schema/src/sharepoint/propertyPaneChoiceGroupProperties.ts b/libraries/botframework-schema/src/sharepoint/propertyPaneChoiceGroupProperties.ts new file mode 100644 index 0000000000..4d52e2b62a --- /dev/null +++ b/libraries/botframework-schema/src/sharepoint/propertyPaneChoiceGroupProperties.ts @@ -0,0 +1,19 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +import { PropertyPaneFieldProperties } from './propertyPaneFieldProperties'; +import { PropertyPaneChoiceGroupOption } from './propertyPaneChoiceGroupOption'; + +/** + * SharePoint property pane choice group field properties. + */ +export interface PropertyPaneChoiceGroupProperties extends PropertyPaneFieldProperties { + /** + * The label text to display next to the choice group. + */ + label?: string; + /** + * The options for the choice group. + */ + options: PropertyPaneChoiceGroupOption[]; +} diff --git a/libraries/botframework-schema/src/sharepoint/propertyPaneDropDownOption.ts b/libraries/botframework-schema/src/sharepoint/propertyPaneDropDownOption.ts new file mode 100644 index 0000000000..0b536153e9 --- /dev/null +++ b/libraries/botframework-schema/src/sharepoint/propertyPaneDropDownOption.ts @@ -0,0 +1,42 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +/** + * SharePoint property pane drop down option. + */ +export interface PropertyPaneDropDownOption { + /** + * The index of the option. + */ + index?: number; + /** + * The key to uniquely identify the option. + */ + key: string; + /** + * The text to render for this option. + */ + text: string; + /** + * The type of option to render. + */ + type?: DropDownOptionType; +} + +/** + * SharePoint property pane drop down option type. + */ +export enum DropDownOptionType { + /** + * Render a normal option. + */ + Normal = 0, + /** + * Render a divider. + */ + Divider = 1, + /** + * Render a header. + */ + Header = 2, +} diff --git a/libraries/botframework-schema/src/sharepoint/propertyPaneDropDownProperties.ts b/libraries/botframework-schema/src/sharepoint/propertyPaneDropDownProperties.ts new file mode 100644 index 0000000000..6b48330c0c --- /dev/null +++ b/libraries/botframework-schema/src/sharepoint/propertyPaneDropDownProperties.ts @@ -0,0 +1,43 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +import { PropertyPaneFieldProperties } from './propertyPaneFieldProperties'; +import { PropertyPaneDropDownOption } from './propertyPaneDropDownOption'; + +/** + * SharePoint property pane dropdown field properties. + */ +export interface PropertyPaneDropDownProperties extends PropertyPaneFieldProperties { + /** + * Optional ariaLabel flag. Text for screen-reader to announce regardless of toggle state. + */ + ariaLabel?: string; + /** + * The elemement's number or position in the current set of controls. Maps to native aria-positionset attribute. It starts from 1. + */ + ariaPositionInSet?: number; + /** + * The total number of elements in the current set of controls. Maps to native aria-setsize attribute. + */ + ariaSetSize?: number; + /** + * The label text to display next to the dropdown. + */ + label: string; + /** + * Indicates whether the dropdown is disabled or not. + */ + disabled?: boolean; + /** + * The error message to display when the dropdown value is invalid. + */ + errorMessage?: string; + /** + * The key of the selected dropdown option. + */ + selectedKey?: string; + /** + * The options for the dropdown. + */ + options?: PropertyPaneDropDownOption[]; +} diff --git a/libraries/botframework-schema/src/sharepoint/propertyPaneFieldProperties.ts b/libraries/botframework-schema/src/sharepoint/propertyPaneFieldProperties.ts new file mode 100644 index 0000000000..62b8be7c0f --- /dev/null +++ b/libraries/botframework-schema/src/sharepoint/propertyPaneFieldProperties.ts @@ -0,0 +1,10 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +/** + * SharePoint base property pane field properties + */ +// eslint-disable-next-line @typescript-eslint/no-empty-interface +export interface PropertyPaneFieldProperties { + // keep this empty - used as base type in property group definition +} diff --git a/libraries/botframework-schema/src/sharepoint/propertyPaneGroup.ts b/libraries/botframework-schema/src/sharepoint/propertyPaneGroup.ts new file mode 100644 index 0000000000..ccdb9835d8 --- /dev/null +++ b/libraries/botframework-schema/src/sharepoint/propertyPaneGroup.ts @@ -0,0 +1,27 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +import { PropertyPaneGroupOrConditionalGroup } from './propertyPaneGroupOrConditionalGroup'; +import { PropertyPaneGroupField } from './propertyPaneGroupField'; + +/** + * SharePoint property pane group. + */ +export interface PropertyPaneGroup extends PropertyPaneGroupOrConditionalGroup { + /** + * The fields to be rendered inside this group. + */ + groupFields: PropertyPaneGroupField[]; + /** + * The name of the group. + */ + groupName?: string; + /** + * Whether the group is collapsed or not. + */ + isCollapsed?: boolean; + /** + * Whether the group name is hidden or not. + */ + isGroupNameHidden?: boolean; +} diff --git a/libraries/botframework-schema/src/sharepoint/propertyPaneGroupField.ts b/libraries/botframework-schema/src/sharepoint/propertyPaneGroupField.ts new file mode 100644 index 0000000000..59825fe5d5 --- /dev/null +++ b/libraries/botframework-schema/src/sharepoint/propertyPaneGroupField.ts @@ -0,0 +1,68 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +import { PropertyPaneFieldProperties } from './propertyPaneFieldProperties'; + +/** + * SharePoint property pane group field. + */ +export interface PropertyPaneGroupField { + /** + * The type of the field. + */ + type: FieldType; + /** + * The target property for the field. + */ + targetProperty: string; + /** + * The properties for the field. + */ + properties: PropertyPaneFieldProperties; + /** + * Indicates whether the field should be focused or not. + */ + shouldFocus?: boolean; +} + +/** + * SharePoint property pane group field type. + */ +export enum FieldType { + /** + * Checkbox field. + */ + CheckBox = 2, + /** + * Text field. + */ + TextField = 3, + /** + * Toggle field. + */ + Toggle = 5, + /** + * Dropdown field. + */ + Dropdown = 6, + /** + * Label field. + */ + Label = 7, + /** + * Slider field. + */ + Slider = 8, + /** + * Choice Group field. + */ + ChoiceGroup = 10, + /** + * Horizontal Rule field. + */ + HorizontalRule = 12, + /** + * Link field. + */ + Link = 13, +} diff --git a/libraries/botframework-schema/src/sharepoint/propertyPaneGroupOrConditionalGroup.ts b/libraries/botframework-schema/src/sharepoint/propertyPaneGroupOrConditionalGroup.ts new file mode 100644 index 0000000000..723c891508 --- /dev/null +++ b/libraries/botframework-schema/src/sharepoint/propertyPaneGroupOrConditionalGroup.ts @@ -0,0 +1,7 @@ +/** + * SharePoint property pane group or conditional group + */ +// eslint-disable-next-line @typescript-eslint/no-empty-interface +export interface PropertyPaneGroupOrConditionalGroup { + // keep this empty - used as base type in property page definition +} diff --git a/libraries/botframework-schema/src/sharepoint/propertyPaneLabelProperties.ts b/libraries/botframework-schema/src/sharepoint/propertyPaneLabelProperties.ts new file mode 100644 index 0000000000..28a8ccd8dd --- /dev/null +++ b/libraries/botframework-schema/src/sharepoint/propertyPaneLabelProperties.ts @@ -0,0 +1,18 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +import { PropertyPaneFieldProperties } from './propertyPaneFieldProperties'; + +/** + * SharePoint property pane label properties. + */ +export interface PropertyPaneLabelProperties extends PropertyPaneFieldProperties { + /** + * The text to display in the label. + */ + text: string; + /** + * Whether the label is required or not. + */ + required?: boolean; +} diff --git a/libraries/botframework-schema/src/sharepoint/propertyPaneLinkPopupWindowProperties.ts b/libraries/botframework-schema/src/sharepoint/propertyPaneLinkPopupWindowProperties.ts new file mode 100644 index 0000000000..a2d222d8d7 --- /dev/null +++ b/libraries/botframework-schema/src/sharepoint/propertyPaneLinkPopupWindowProperties.ts @@ -0,0 +1,50 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +/** + * SharePoint property pane link popup window properties. + */ +export interface PropertyPaneLinkPopupWindowProperties { + /** + * The width of the popup window. + */ + width: number; + /** + * The height of the popup window. + */ + height: number; + /** + * The title of the popup window. + */ + title: string; + /** + * The position of the popup window. + */ + positionWindowPosition: PopupWindowPosition; +} + +/** + * SharePoint property pane link popup window position. + */ +export enum PopupWindowPosition { + /** + * Center. + */ + Center = 0, + /** + * Right top. + */ + RightTop = 1, + /** + * Left top. + */ + LeftTop = 2, + /** + * Right bottom. + */ + RightBottom = 3, + /** + * Left bottom. + */ + LeftBottom = 4, +} diff --git a/libraries/botframework-schema/src/sharepoint/propertyPaneLinkProperties.ts b/libraries/botframework-schema/src/sharepoint/propertyPaneLinkProperties.ts new file mode 100644 index 0000000000..bdc1ab0de4 --- /dev/null +++ b/libraries/botframework-schema/src/sharepoint/propertyPaneLinkProperties.ts @@ -0,0 +1,35 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +import { PropertyPaneFieldProperties } from './propertyPaneFieldProperties'; +import { PropertyPaneLinkPopupWindowProperties } from './propertyPaneLinkPopupWindowProperties'; + +/** + * SharePoint property pane link field properties. + */ +export interface PropertyPaneLinkProperties extends PropertyPaneFieldProperties { + /** + * The text to display in the link. + */ + text: string; + /** + * The target of the link. + */ + target?: string; + /** + * The URL of the link. + */ + href: string; + /** + * Optional ariaLabel flag. Text for screen-reader to announce regardless of toggle state. + */ + ariaLabel?: string; + /** + * Whether the link is disabled or not. + */ + disabled?: boolean; + /** + * The properties of the popup window. + */ + popupWindowProps?: PropertyPaneLinkPopupWindowProperties; +} diff --git a/libraries/botframework-schema/src/sharepoint/propertyPanePage.ts b/libraries/botframework-schema/src/sharepoint/propertyPanePage.ts new file mode 100644 index 0000000000..f63062d41f --- /dev/null +++ b/libraries/botframework-schema/src/sharepoint/propertyPanePage.ts @@ -0,0 +1,23 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +import { PropertyPaneGroupOrConditionalGroup } from './propertyPaneGroupOrConditionalGroup'; +import { PropertyPanePageHeader } from './propertyPanePageHeader'; + +/** + * SharePoint property pane page. + */ +export interface PropertyPanePage { + /** + * Whether the groups should be displayed as an accordion or not. + */ + displayGroupsAsAccordion?: boolean; + /** + * The groups to be rendered inside this page. + */ + groups: PropertyPaneGroupOrConditionalGroup[]; + /** + * The header to be rendered inside this page. + */ + header?: PropertyPanePageHeader; +} diff --git a/libraries/botframework-schema/src/sharepoint/propertyPanePageHeader.ts b/libraries/botframework-schema/src/sharepoint/propertyPanePageHeader.ts new file mode 100644 index 0000000000..411cbeb134 --- /dev/null +++ b/libraries/botframework-schema/src/sharepoint/propertyPanePageHeader.ts @@ -0,0 +1,12 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +/** + * SharePoint property pane page header. + */ +export interface PropertyPanePageHeader { + /** + * The description of the page. + */ + description: string; +} diff --git a/libraries/botframework-schema/src/sharepoint/propertyPaneSliderProperties.ts b/libraries/botframework-schema/src/sharepoint/propertyPaneSliderProperties.ts new file mode 100644 index 0000000000..ef7b77e2b4 --- /dev/null +++ b/libraries/botframework-schema/src/sharepoint/propertyPaneSliderProperties.ts @@ -0,0 +1,42 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +import { PropertyPaneFieldProperties } from './propertyPaneFieldProperties'; + +/** + * SharePoint property pane slider field properties. + */ +export interface PropertyPaneSliderProperties extends PropertyPaneFieldProperties { + /** + * The label of the slider. + */ + label?: string; + /** + * The value of the slider. + */ + value?: string; + /** + * Optional ariaLabel flag. Text for screen-reader to announce regardless of toggle state. + */ + ariaLabel?: string; + /** + * Whether the slider is disabled or not. + */ + disabled?: boolean; + /** + * The maximum value of the slider. + */ + max: number; + /** + * The minimum value of the slider. + */ + min: number; + /** + * The step value of the slider. + */ + step?: number; + /** + * Whether to show the value on the right of the slider or no. + */ + showValue?: boolean; +} diff --git a/libraries/botframework-schema/src/sharepoint/propertyPaneTextFieldProperties.ts b/libraries/botframework-schema/src/sharepoint/propertyPaneTextFieldProperties.ts new file mode 100644 index 0000000000..b56df3a1a2 --- /dev/null +++ b/libraries/botframework-schema/src/sharepoint/propertyPaneTextFieldProperties.ts @@ -0,0 +1,62 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +import { PropertyPaneFieldProperties } from './propertyPaneFieldProperties'; + +/** + * SharePoint property pane text field properties. + */ +export interface PropertyPaneTextFieldProperties extends PropertyPaneFieldProperties { + /** + * The label of the text field. + */ + label?: string; + /** + * The value of the text field. + */ + value?: string; + /** + * Optional ariaLabel flag. Text for screen-reader to announce regardless of toggle state. + */ + ariaLabel?: string; + /** + * The description to display under the text field. + */ + description?: string; + /** + * Whether the text field is disabled or not. + */ + disabled?: boolean; + /** + * If set, this will be displayed as an error message underneath the text field.. + */ + errorMessage?: string; + /** + * Name used to log PropertyPaneTextField value changes for engagement tracking. + */ + logName?: string; + /** + * The maximum length of the text field. + */ + maxLength?: number; + /** + * Whether or not the text field is multiline. + */ + multiline?: boolean; + /** + * The placeholder text to display in the text field. + */ + placeholder?: string; + /** + * Whether or not the multiline text field is resizable. + */ + resizable?: boolean; + /** + * Specifies the visible height of a text area(multiline text TextField), in lines. + */ + rows?: number; + /** + * Whether or not the text field is underlined. + */ + underlined?: boolean; +} diff --git a/libraries/botframework-schema/src/sharepoint/propertyPaneToggleProperties.ts b/libraries/botframework-schema/src/sharepoint/propertyPaneToggleProperties.ts new file mode 100644 index 0000000000..563afb6b8b --- /dev/null +++ b/libraries/botframework-schema/src/sharepoint/propertyPaneToggleProperties.ts @@ -0,0 +1,46 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +import { PropertyPaneFieldProperties } from './propertyPaneFieldProperties'; + +/** + * SharePoint property pane toggle field properties. + */ +export interface PropertyPaneToggleProperties extends PropertyPaneFieldProperties { + /** + * Optional ariaLabel flag. Text for screen-reader to announce regardless of toggle state. + */ + ariaLabel?: string; + /** + * A label for the toggle. + */ + label?: string; + /** + * Indicates whether the toggle is disabled or not. + */ + disabled?: boolean; + /** + * Indicates whether the toggle is checked or not. + */ + checked?: boolean; + /** + * A key to uniquely identify the toggle. + */ + key?: string; + /** + * Text to display when toggle is OFF. + */ + offText?: string; + /** + * Text to display when toggle is ON. + */ + onText?: string; + /** + * Optional onAriaLabel flag. Text for screen-reader to announce when toggle is ON. + */ + onAriaLabel?: string; + /** + * Optional offAriaLabel flag. Text for screen-reader to announce when toggle is OFF. + */ + offAriaLabel?: string; +} diff --git a/libraries/botframework-schema/src/sharepoint/quickViewData.ts b/libraries/botframework-schema/src/sharepoint/quickViewData.ts new file mode 100644 index 0000000000..5900f892ca --- /dev/null +++ b/libraries/botframework-schema/src/sharepoint/quickViewData.ts @@ -0,0 +1,6 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +export interface QuickViewData { + [key: string]: unknown; +} diff --git a/libraries/botframework-schema/src/sharepoint/quickViewResponse.ts b/libraries/botframework-schema/src/sharepoint/quickViewResponse.ts new file mode 100644 index 0000000000..933209604b --- /dev/null +++ b/libraries/botframework-schema/src/sharepoint/quickViewResponse.ts @@ -0,0 +1,37 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +import { QuickViewData } from './quickViewData'; +import { AdaptiveCard } from 'adaptivecards'; +import { FocusParameters } from './actions/focusParameters'; +import { ExternalLinkActionParameters } from './actions/cardAction'; + +/** + * SharePoint ACE Quick view response payload. + */ +export interface QuickViewResponse { + /** + * The quick view data. + */ + data: QuickViewData; + /** + * The adaptive card template for the quick view. + */ + template: AdaptiveCard; + /** + * The view id. + */ + viewId: string; + /** + * The title of the quick view. + */ + title: string; + /** + * An optional external link to be displayed in the navigation bar above the Adaptive Card. + */ + externalLink: ExternalLinkActionParameters; + /** + * An optional focus element to set focus when the view is rendered for accessibility purposes. + */ + focusParameters: FocusParameters; +} diff --git a/libraries/botframework-schema/src/sharepoint/setPropertyPaneConfigurationResponse.ts b/libraries/botframework-schema/src/sharepoint/setPropertyPaneConfigurationResponse.ts new file mode 100644 index 0000000000..9a177c3f3e --- /dev/null +++ b/libraries/botframework-schema/src/sharepoint/setPropertyPaneConfigurationResponse.ts @@ -0,0 +1,5 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +import { CardViewHandleActionResponse, NoOpHandleActionResponse } from './handleActionResponse'; + +export type SetPropertyPaneConfigurationResponse = CardViewHandleActionResponse | NoOpHandleActionResponse; diff --git a/yarn.lock b/yarn.lock index ee56053f37..88c028701b 100644 --- a/yarn.lock +++ b/yarn.lock @@ -2828,6 +2828,11 @@ acorn@^8.5.0: resolved "https://registry.yarnpkg.com/acorn/-/acorn-8.10.0.tgz#8be5b3907a67221a81ab23c7889c4c5526b62ec5" integrity sha512-F0SAmZ8iUtS//m8DmCTA0jlh6TDKkHQyK6xc6V4KDTyZKA9dnvX9/3sRTVQrWm79glUAZbnmmNcdYwUIHWVybw== +adaptivecards@1.2.3: + version "1.2.3" + resolved "https://registry.yarnpkg.com/adaptivecards/-/adaptivecards-1.2.3.tgz#b69319c75bd214a5ec48119240c98449e7df685a" + integrity sha512-amQ5OSW3OpIkrxVKLjxVBPk/T49yuOtnqs1z5ZPfZr0+OpTovzmiHbyoAGDIsu5SNYHwOZFp/3LGOnRaALFa/g== + adm-zip@0.4.16: version "0.4.16" resolved "https://registry.yarnpkg.com/adm-zip/-/adm-zip-0.4.16.tgz#cf4c508fdffab02c269cbc7f471a875f05570365"