npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

adaptivecards-fluentui

v0.5.3

Published

Renders Adaptive Card inputs using Fluent UI controls

Downloads

778

Readme

Adaptive Cards Fluent UI controls

This package "lights-up" the Adaptive Card renderer with Microsoft's Fluent UI controls.

Adaptive cards fluent animation

Extended Controls

| AdaptiveCard Element | Fluent UI Control | | ----------------------------------------------------- | --------------------------------------------------------------------------------------- | | Input.Date | DatePicker | | Input.Number, Input.Text, Input.Time | TextField | | Input.Toggle | Toggle | | Input.ChoiceSet (style:compact) | Dropdown | | Input.ChoiceSet (style:expanded, isMultiSelect:false) | ChoiceGroup | | Input.ChoiceSet (style:expanded, isMultiSelect:true) | Checkbox | | Actions | Button |

Install

npm install adaptivecards-fluentui

IMPORTANT: you must also install the necessary peer dependencies:

  • adaptivecards
  • @fluentui/react
  • react
  • react-dom

Usage

Import the module

// Import modules:
import * as AdaptiveCards from "adaptivecards";
import * as ACFluentUI from "adaptivecards-fluentui";

Render a card

// Author a card
// In practice you'll probably get this from a service
// see http://adaptivecards.io/samples/ for inspiration
let card = {
	"type": "AdaptiveCard",
	"version": "1.3",
	"body": [
		{
			"type": "Image",
			"url": "https://adaptivecards.io/content/adaptive-card-50.png"
		},
		{
			"type": "TextBlock",
			"text": "Hello **Adaptive Cards!**"
		},
		{
			"type": "Input.Text",
			"placeholder": "Enter your name",
			"label": "Name",
			"isRequired": false,
			"style": "text",
			"id": "Name"
		}
	],
	"actions": [
		{
			"type": "Action.OpenUrl",
			"title": "Learn more",
			"url": "https://adaptivecards.io"
		},
		{
			"type": "Action.Submit",
			"title": "Submit"
		}
	]
};

// Create an AdaptiveCard instance
let adaptiveCard = new AdaptiveCards.AdaptiveCard();

// Use Fluent UI controls when rendering Adaptive Cards
ACFluentUI.useFluentUI();

// Set its hostConfig property unless you want to use the default Host Config
// Host Config defines the style and behavior of a card
adaptiveCard.hostConfig = new AdaptiveCards.HostConfig({
	fontFamily: "Segoe UI, Helvetica Neue, sans-serif"
	// More host config options
});

// Set the adaptive card's event handlers. onExecuteAction is invoked
// whenever an action is clicked in the card
adaptiveCard.onExecuteAction = function (action) {
	var message = "Action executed\n";
	message += "    Title: " + action.title + "\n";

	if (action instanceof AdaptiveCards.OpenUrlAction) {
		message += "    Type: OpenUrl\n";
		message += "    Url: " + action.url + "\n";
	}
	else if (action instanceof AdaptiveCards.SubmitAction) {
		message += "    Type: Submit\n";
		message += "    Data: " + JSON.stringify(action.data);
	}
	else {
		message += "    Type: <unknown>";
	}

	alert(message);
}

// Parse the card payload
adaptiveCard.parse(card);

// Render the card to an HTML element:
let renderedCard = adaptiveCard.render();

// And finally insert it somewhere in your page:
document.body.appendChild(renderedCard);