The DeferralCards library provides a comprehensive API for creating Adaptive Cards in Lua. Adaptive Cards are a platform-agnostic way to create rich, interactive content that can be rendered across various applications and platforms.
Overview
The library is structured into five main modules:
Card: Core card creation
CardElement: Basic content elements
Container: Layout and grouping elements
Action: Interactive elements
Input: Form input elements
Installation
The library exports itself as a module:
local DeferralCards =exports('DeferralCards')()
Card Module
DeferralCards.Card:Create
Creates a complete Adaptive Card with the specified options.
local textInput = DeferralCards.Input:Text({
id = "username",
placeholder = "Enter your username",
maxLength = 50
})
local numberInput = DeferralCards.Input:Number({
id = "age",
placeholder = "Enter your age",
min = 0,
max = 120
})
local choiceSet = DeferralCards.Input:ChoiceSet({
id = "color",
placeholder = "Select a color",
choices = {
DeferralCards.Input:Choice({
title = "Red",
value = "red"
}),
DeferralCards.Input:Choice({
title = "Blue",
value = "blue"
})
}
})
local card = DeferralCards.Card:Create({
body = {
DeferralCards.CardElement:TextBlock({
text = "User Registration",
size = "large",
weight = "bolder",
horizontalAlignment = "center"
}),
DeferralCards.Container:Create({
items = {
DeferralCards.Input:Text({
id = "name",
placeholder = "Full Name"
}),
DeferralCards.Input:Number({
id = "age",
placeholder = "Age",
min = 18,
max = 100
}),
DeferralCards.Input:ChoiceSet({
id = "country",
placeholder = "Select Country",
choices = {
DeferralCards.Input:Choice({
title = "United States",
value = "US"
}),
DeferralCards.Input:Choice({
title = "Canada",
value = "CA"
})
}
})
}
}),
DeferralCards.Container:ActionSet({
actions = {
DeferralCards.Action:Submit({
title = "Register",
data = { action = "register" }
})
}
})
}
})