mirror of
https://github.com/MindWorkAI/AI-Studio.git
synced 2026-03-29 19:51:39 +00:00
added accordions as new layout components - resembles MudExpansionPanels
This commit is contained in:
parent
5d8fee94b9
commit
dea9c9ed6f
@ -201,7 +201,7 @@
|
|||||||
<MudStack Row="@stack.IsRow"
|
<MudStack Row="@stack.IsRow"
|
||||||
Reverse="@stack.IsReverse"
|
Reverse="@stack.IsReverse"
|
||||||
Breakpoint="@AssistantComponentPropHelper.GetBreakpoint(stack.Breakpoint, Breakpoint.None)"
|
Breakpoint="@AssistantComponentPropHelper.GetBreakpoint(stack.Breakpoint, Breakpoint.None)"
|
||||||
AlignItems="@(AssistantComponentPropHelper.GetAlignment(stack.Align) ?? AlignItems.Stretch)"
|
AlignItems="@(AssistantComponentPropHelper.GetItemsAlignment(stack.Align) ?? AlignItems.Stretch)"
|
||||||
Justify="@(AssistantComponentPropHelper.GetJustify(stack.Justify) ?? Justify.FlexStart)"
|
Justify="@(AssistantComponentPropHelper.GetJustify(stack.Justify) ?? Justify.FlexStart)"
|
||||||
StretchItems="@(AssistantComponentPropHelper.GetStretching(stack.Stretch) ?? StretchItems.None)"
|
StretchItems="@(AssistantComponentPropHelper.GetStretching(stack.Stretch) ?? StretchItems.None)"
|
||||||
Wrap="@(AssistantComponentPropHelper.GetWrap(stack.Wrap) ?? Wrap.Wrap)"
|
Wrap="@(AssistantComponentPropHelper.GetWrap(stack.Wrap) ?? Wrap.Wrap)"
|
||||||
@ -212,6 +212,53 @@
|
|||||||
</MudStack>
|
</MudStack>
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
case AssistantComponentType.LAYOUT_ACCORDION:
|
||||||
|
if (component is AssistantAccordion assistantAccordion)
|
||||||
|
{
|
||||||
|
var accordion = assistantAccordion;
|
||||||
|
<MudExpansionPanels MultiExpansion="@accordion.AllowMultiSelection"
|
||||||
|
Dense="@accordion.IsDense"
|
||||||
|
Outlined="@accordion.HasOutline"
|
||||||
|
Square="@accordion.IsSquare"
|
||||||
|
Elevation="@accordion.Elevation"
|
||||||
|
Gutters="@accordion.HasSectionPaddings"
|
||||||
|
Class="@MergeClass(accordion.Class, "my-6")"
|
||||||
|
Style="@this.GetOptionalStyle(accordion.Style)">
|
||||||
|
@this.RenderChildren(accordion.Children)
|
||||||
|
</MudExpansionPanels>
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case AssistantComponentType.LAYOUT_ACCORDION_SECTION:
|
||||||
|
if (component is AssistantAccordionSection assistantAccordionSection)
|
||||||
|
{
|
||||||
|
var accordionSection = assistantAccordionSection;
|
||||||
|
var textColor = accordionSection.IsDisabled ? Color.Info : AssistantComponentPropHelper.GetColor(accordionSection.HeaderColor, Color.Inherit);
|
||||||
|
<MudExpansionPanel KeepContentAlive="@accordionSection.KeepContentAlive"
|
||||||
|
disabled="@accordionSection.IsDisabled"
|
||||||
|
Expanded="@accordionSection.IsExpanded"
|
||||||
|
Dense="@accordionSection.IsDense"
|
||||||
|
Gutters="@accordionSection.HasInnerPadding"
|
||||||
|
HideIcon="@accordionSection.HideIcon"
|
||||||
|
Icon="@AssistantComponentPropHelper.GetIconSvg(accordionSection.ExpandIcon)"
|
||||||
|
MaxHeight="@accordionSection.MaxHeight"
|
||||||
|
Class="@accordionSection.Class"
|
||||||
|
Style="@this.GetOptionalStyle(accordionSection.Style)">
|
||||||
|
<TitleContent>
|
||||||
|
<div class="d-flex">
|
||||||
|
<MudIcon Icon="@AssistantComponentPropHelper.GetIconSvg(accordionSection.HeaderIcon)" class="mr-3"></MudIcon>
|
||||||
|
<MudText Align="@AssistantComponentPropHelper.GetAlignment(accordionSection.HeaderAlign)"
|
||||||
|
Color="@textColor"
|
||||||
|
Typo="@AssistantComponentPropHelper.GetTypography(accordionSection.HeaderTypo)">
|
||||||
|
@accordionSection.HeaderText
|
||||||
|
</MudText>
|
||||||
|
</div>
|
||||||
|
</TitleContent>
|
||||||
|
<ChildContent>
|
||||||
|
@this.RenderChildren(accordionSection.Children)
|
||||||
|
</ChildContent>
|
||||||
|
</MudExpansionPanel>
|
||||||
|
}
|
||||||
|
break;
|
||||||
case AssistantComponentType.PROVIDER_SELECTION:
|
case AssistantComponentType.PROVIDER_SELECTION:
|
||||||
if (component is AssistantProviderSelection providerSelection)
|
if (component is AssistantProviderSelection providerSelection)
|
||||||
{
|
{
|
||||||
|
|||||||
@ -31,6 +31,8 @@ This folder keeps the Lua manifest (`plugin.lua`) that defines a custom assistan
|
|||||||
- [`LAYOUT_ITEM` reference](#layout_item-reference)
|
- [`LAYOUT_ITEM` reference](#layout_item-reference)
|
||||||
- [`LAYOUT_PAPER` reference](#layout_paper-reference)
|
- [`LAYOUT_PAPER` reference](#layout_paper-reference)
|
||||||
- [`LAYOUT_STACK` reference](#layout_stack-reference)
|
- [`LAYOUT_STACK` reference](#layout_stack-reference)
|
||||||
|
- [`LAYOUT_ACCORDION` reference](#layout_accordion-reference)
|
||||||
|
- [`LAYOUT_ACCORDION_SECTION` reference](#layout_accordion_section-reference)
|
||||||
- [Useful Lua Functions](#useful-lua-functions)
|
- [Useful Lua Functions](#useful-lua-functions)
|
||||||
- [Included lua libraries](#included-lua-libraries)
|
- [Included lua libraries](#included-lua-libraries)
|
||||||
- [Logging helpers](#logging-helpers)
|
- [Logging helpers](#logging-helpers)
|
||||||
@ -94,6 +96,8 @@ ASSISTANT = {
|
|||||||
- `LAYOUT_ITEM`: renders a `MudItem`; use it inside `LAYOUT_GRID` and configure breakpoints with `Xs`, `Sm`, `Md`, `Lg`, `Xl`, `Xxl`, plus optional `Class`, `Style`.
|
- `LAYOUT_ITEM`: renders a `MudItem`; use it inside `LAYOUT_GRID` and configure breakpoints with `Xs`, `Sm`, `Md`, `Lg`, `Xl`, `Xxl`, plus optional `Class`, `Style`.
|
||||||
- `LAYOUT_PAPER`: renders a `MudPaper`; may include `Elevation`, `Height`, `MaxHeight`, `MinHeight`, `Width`, `MaxWidth`, `MinWidth`, `IsOutlined`, `IsSquare`, `Class`, `Style`.
|
- `LAYOUT_PAPER`: renders a `MudPaper`; may include `Elevation`, `Height`, `MaxHeight`, `MinHeight`, `Width`, `MaxWidth`, `MinWidth`, `IsOutlined`, `IsSquare`, `Class`, `Style`.
|
||||||
- `LAYOUT_STACK`: renders a `MudStack`; may include `IsRow`, `IsReverse`, `Breakpoint`, `Align`, `Justify`, `Stretch`, `Wrap`, `Spacing`, `Class`, `Style`.
|
- `LAYOUT_STACK`: renders a `MudStack`; may include `IsRow`, `IsReverse`, `Breakpoint`, `Align`, `Justify`, `Stretch`, `Wrap`, `Spacing`, `Class`, `Style`.
|
||||||
|
- `LAYOUT_ACCORDION`: renders a `MudExpansionPanels`; may include `AllowMultiSelection`, `IsDense`, `HasOutline`, `IsSquare`, `Elevation`, `HasSectionPaddings`, `Class`, `Style`.
|
||||||
|
- `LAYOUT_ACCORDION_SECTION`: renders a `MudExpansionPanel`; requires `Name`, `HeaderText`, and may include `IsDisabled`, `IsExpanded`, `IsDense`, `HasInnerPadding`, `HideIcon`, `HeaderIcon`, `HeaderColor`, `HeaderTypo`, `HeaderAlign`, `MaxHeight`, `ExpandIcon`, `Class`, `Style`.
|
||||||
- `SWITCH`: boolean option; requires `Name`, `Label`, `Value`, and may include `Disabled`, `UserPrompt`, `LabelOn`, `LabelOff`, `LabelPlacement`, `Icon`, `IconColor`, `CheckedColor`, `UncheckedColor`, `Class`, `Style`.
|
- `SWITCH`: boolean option; requires `Name`, `Label`, `Value`, and may include `Disabled`, `UserPrompt`, `LabelOn`, `LabelOff`, `LabelPlacement`, `Icon`, `IconColor`, `CheckedColor`, `UncheckedColor`, `Class`, `Style`.
|
||||||
- `COLOR_PICKER`: color input based on `MudColorPicker`; requires `Name`, `Label`, and may include `Placeholder`, `ShowAlpha`, `ShowToolbar`, `ShowModeSwitch`, `PickerVariant`, `UserPrompt`, `Class`, `Style`.
|
- `COLOR_PICKER`: color input based on `MudColorPicker`; requires `Name`, `Label`, and may include `Placeholder`, `ShowAlpha`, `ShowToolbar`, `ShowModeSwitch`, `PickerVariant`, `UserPrompt`, `Class`, `Style`.
|
||||||
- `PROVIDER_SELECTION` / `PROFILE_SELECTION`: hooks into the shared provider/profile selectors.
|
- `PROVIDER_SELECTION` / `PROFILE_SELECTION`: hooks into the shared provider/profile selectors.
|
||||||
@ -105,7 +109,7 @@ ASSISTANT = {
|
|||||||
Images referenced via the `plugin://` scheme must exist in the plugin directory (e.g., `assets/example.png`). Drop the file there and point `Src` at it. The component will read the file at runtime, encode it as Base64, and render it inside the assistant UI.
|
Images referenced via the `plugin://` scheme must exist in the plugin directory (e.g., `assets/example.png`). Drop the file there and point `Src` at it. The component will read the file at runtime, encode it as Base64, and render it inside the assistant UI.
|
||||||
|
|
||||||
| Component | Required Props | Optional Props | Renders |
|
| Component | Required Props | Optional Props | Renders |
|
||||||
|-----------------------|-------------------------------------|----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|----------------------------------------------------------------------------------------------------------------------------------|
|
|----------------------------|-------------------------------------|----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|-------------------------------------------------------------------------------------------------------------------------------|
|
||||||
| `TEXT_AREA` | `Name`, `Label` | `HelperText`, `HelperTextOnFocus`, `Adornment`, `AdornmentIcon`, `AdornmentText`, `AdornmentColor`, `Counter`, `MaxLength`, `IsImmediate`, `UserPrompt`, `PrefillText`, `IsSingleLine`, `ReadOnly`, `Class`, `Style` | [MudTextField](https://www.mudblazor.com/components/textfield) |
|
| `TEXT_AREA` | `Name`, `Label` | `HelperText`, `HelperTextOnFocus`, `Adornment`, `AdornmentIcon`, `AdornmentText`, `AdornmentColor`, `Counter`, `MaxLength`, `IsImmediate`, `UserPrompt`, `PrefillText`, `IsSingleLine`, `ReadOnly`, `Class`, `Style` | [MudTextField](https://www.mudblazor.com/components/textfield) |
|
||||||
| `DROPDOWN` | `Name`, `Label`, `Default`, `Items` | `IsMultiselect`, `HasSelectAll`, `SelectAllText`, `HelperText`, `OpenIcon`, `CloseIcon`, `IconColor`, `IconPositon`, `Variant`, `ValueType`, `UserPrompt` | [MudSelect](https://www.mudblazor.com/components/select) |
|
| `DROPDOWN` | `Name`, `Label`, `Default`, `Items` | `IsMultiselect`, `HasSelectAll`, `SelectAllText`, `HelperText`, `OpenIcon`, `CloseIcon`, `IconColor`, `IconPositon`, `Variant`, `ValueType`, `UserPrompt` | [MudSelect](https://www.mudblazor.com/components/select) |
|
||||||
| `BUTTON` | `Name`, `Text`, `Action` | `Variant`, `Color`, `IsFullWidth`, `Size`, `StartIcon`, `EndIcon`, `IconColor`, `IconSize`, `Class`, `Style` | [MudButton](https://www.mudblazor.com/components/button) |
|
| `BUTTON` | `Name`, `Text`, `Action` | `Variant`, `Color`, `IsFullWidth`, `Size`, `StartIcon`, `EndIcon`, `IconColor`, `IconSize`, `Class`, `Style` | [MudButton](https://www.mudblazor.com/components/button) |
|
||||||
@ -124,6 +128,8 @@ Images referenced via the `plugin://` scheme must exist in the plugin directory
|
|||||||
| `LAYOUT_ITEM` | `None` | `Xs`, `Sm`, `Md`, `Lg`, `Xl`, `Xxl`, `Class`, `Style` | [MudItem](https://www.mudblazor.com/api/MudItem) |
|
| `LAYOUT_ITEM` | `None` | `Xs`, `Sm`, `Md`, `Lg`, `Xl`, `Xxl`, `Class`, `Style` | [MudItem](https://www.mudblazor.com/api/MudItem) |
|
||||||
| `LAYOUT_STACK` | `None` | `IsRow`, `IsReverse`, `Breakpoint`, `Align`, `Justify`, `Stretch`, `Wrap`, `Spacing`, `Class`, `Style` | [MudStack](https://www.mudblazor.com/components/stack) |
|
| `LAYOUT_STACK` | `None` | `IsRow`, `IsReverse`, `Breakpoint`, `Align`, `Justify`, `Stretch`, `Wrap`, `Spacing`, `Class`, `Style` | [MudStack](https://www.mudblazor.com/components/stack) |
|
||||||
| `LAYOUT_GRID` | `None` | `Justify`, `Spacing`, `Class`, `Style` | [MudGrid](https://www.mudblazor.com/components/grid) |
|
| `LAYOUT_GRID` | `None` | `Justify`, `Spacing`, `Class`, `Style` | [MudGrid](https://www.mudblazor.com/components/grid) |
|
||||||
|
| `LAYOUT_ACCORDION` | `None` | `AllowMultiSelection`, `IsDense`, `HasOutline`, `IsSquare`, `Elevation`, `HasSectionPaddings`, `Class`, `Style` | [MudExpansionPanels](https://www.mudblazor.com/components/expansionpanels) |
|
||||||
|
| `LAYOUT_ACCORDION_SECTION` | `Name`, `HeaderText` | `IsDisabled`, `IsExpanded`, `IsDense`, `HasInnerPadding`, `HideIcon`, `HeaderIcon`, `HeaderColor`, `HeaderTypo`, `HeaderAlign`, `MaxHeight`, `ExpandIcon`, `Class`, `Style` | [MudExpansionPanel](https://www.mudblazor.com/components/expansionpanels) |
|
||||||
More information on rendered components can be found [here](https://www.mudblazor.com/docs/overview).
|
More information on rendered components can be found [here](https://www.mudblazor.com/docs/overview).
|
||||||
|
|
||||||
## Component References
|
## Component References
|
||||||
@ -720,6 +726,108 @@ For a visual example and a full explanation look [here](https://www.mudblazor.co
|
|||||||
```
|
```
|
||||||
For a visual example and a full explanation look [here](https://www.mudblazor.com/components/stack#basic-usage)
|
For a visual example and a full explanation look [here](https://www.mudblazor.com/components/stack#basic-usage)
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
### `LAYOUT_ACCORDION` reference
|
||||||
|
- Use `Type = "LAYOUT_ACCORDION"` to render a MudBlazor accordion container (`MudExpansionPanels`).
|
||||||
|
- Required props:
|
||||||
|
- `Name`: unique identifier for the layout node.
|
||||||
|
- Required structure:
|
||||||
|
- `Children`: array of `LAYOUT_ACCORDION_SECTION` component tables. Other child component types are ignored by intent and should be avoided.
|
||||||
|
- Optional props:
|
||||||
|
- `AllowMultiSelection`: defaults to `false`; allows multiple sections to stay expanded at the same time.
|
||||||
|
- `IsDense`: defaults to `false`; reduces the visual density of the accordion.
|
||||||
|
- `HasOutline`: defaults to `false`; toggles outlined panel styling.
|
||||||
|
- `IsSquare`: defaults to `false`; removes rounded corners from the accordion container.
|
||||||
|
- `Elevation`: integer elevation; omitted values fall back to `0`.
|
||||||
|
- `HasSectionPaddings`: defaults to `false`; toggles the section gutter/padding behavior.
|
||||||
|
- `Class`, `Style`: forwarded to the rendered `MudExpansionPanels` for layout/styling.
|
||||||
|
|
||||||
|
#### Example: Define an accordion container
|
||||||
|
```lua
|
||||||
|
{
|
||||||
|
["Type"] = "LAYOUT_ACCORDION",
|
||||||
|
["Props"] = {
|
||||||
|
["Name"] = "settingsAccordion",
|
||||||
|
["AllowMultiSelection"] = true,
|
||||||
|
["IsDense"] = false,
|
||||||
|
["HasOutline"] = true,
|
||||||
|
["IsSquare"] = false,
|
||||||
|
["Elevation"] = 0,
|
||||||
|
["HasSectionPaddings"] = true
|
||||||
|
},
|
||||||
|
["Children"] = {
|
||||||
|
{
|
||||||
|
["Type"] = "LAYOUT_ACCORDION_SECTION",
|
||||||
|
["Props"] = {
|
||||||
|
["Name"] = "generalSection",
|
||||||
|
["HeaderText"] = "General"
|
||||||
|
},
|
||||||
|
["Children"] = {
|
||||||
|
{
|
||||||
|
["Type"] = "<TEXT_AREA|BUTTON|BUTTON_GROUP|SWITCH|PROVIDER_SELECTION|...>",
|
||||||
|
["Props"] = {...},
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
```
|
||||||
|
Use `LAYOUT_ACCORDION` as the outer wrapper and put the actual content into one or more `LAYOUT_ACCORDION_SECTION` children.
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
### `LAYOUT_ACCORDION_SECTION` reference
|
||||||
|
- Use `Type = "LAYOUT_ACCORDION_SECTION"` to render one expandable section inside `LAYOUT_ACCORDION`.
|
||||||
|
- Required props:
|
||||||
|
- `Name`: unique identifier for the layout node.
|
||||||
|
- `HeaderText`: visible header text shown in the section title row.
|
||||||
|
- Intended parent:
|
||||||
|
- Use this component inside `LAYOUT_ACCORDION`.
|
||||||
|
- Optional props:
|
||||||
|
- `IsDisabled`: defaults to `false`; disables user interaction for the section.
|
||||||
|
- `IsExpanded`: defaults to `false`; sets the initial expanded state.
|
||||||
|
- `IsDense`: defaults to `false`; reduces section density.
|
||||||
|
- `HasInnerPadding`: defaults to `true`; controls the inner content gutter/padding.
|
||||||
|
- `HideIcon`: defaults to `false`; hides the expand/collapse icon.
|
||||||
|
- `HeaderIcon`: MudBlazor icon identifier rendered before the header text.
|
||||||
|
- `HeaderColor`: one of the MudBlazor `Color` enum names such as `Primary`, `Secondary`, `Warning`; omitted values fall back to `Inherit`.
|
||||||
|
- `HeaderTypo`: one of the MudBlazor `Typo` enum names such as `body1`, `subtitle1`, `h6`; omitted values follow the renderer default.
|
||||||
|
- `HeaderAlign`: one of the MudBlazor `Align` enum names such as `Start`, `Center`, `End`; omitted values follow the renderer default.
|
||||||
|
- `MaxHeight`: nullable integer max height in pixels for the expanded content area.
|
||||||
|
- `ExpandIcon`: MudBlazor icon identifier used for the expand/collapse control.
|
||||||
|
- `Class`, `Style`: forwarded to the rendered `MudExpansionPanel` for layout/styling.
|
||||||
|
- `Children` may contain any other assistant components you want to reveal inside the section.
|
||||||
|
|
||||||
|
#### Example: Define an accordion section
|
||||||
|
```lua
|
||||||
|
{
|
||||||
|
["Type"] = "LAYOUT_ACCORDION_SECTION",
|
||||||
|
["Props"] = {
|
||||||
|
["Name"] = "advancedOptions",
|
||||||
|
["HeaderText"] = "Advanced options",
|
||||||
|
["IsDisabled"] = false,
|
||||||
|
["IsExpanded"] = true,
|
||||||
|
["IsDense"] = false,
|
||||||
|
["HasInnerPadding"] = true,
|
||||||
|
["HideIcon"] = false,
|
||||||
|
["HeaderIcon"] = "Icons.Material.Filled.Tune",
|
||||||
|
["HeaderColor"] = "Primary",
|
||||||
|
["HeaderTypo"] = "subtitle1",
|
||||||
|
["HeaderAlign"] = "Start",
|
||||||
|
["MaxHeight"] = 320,
|
||||||
|
["ExpandIcon"] = "Icons.Material.Filled.ExpandMore"
|
||||||
|
},
|
||||||
|
["Children"] = {
|
||||||
|
{
|
||||||
|
["Type"] = "<TEXT_AREA|BUTTON|BUTTON_GROUP|SWITCH|PROVIDER_SELECTION|...>",
|
||||||
|
["Props"] = {...},
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
```
|
||||||
|
`MaxHeight` is an integer pixel value, unlike `LAYOUT_PAPER` sizing props which accept CSS length strings such as `24rem` or `50vh`.
|
||||||
|
|
||||||
## Useful Lua Functions
|
## Useful Lua Functions
|
||||||
### Included lua libraries
|
### Included lua libraries
|
||||||
- [Basic Functions Library](https://www.lua.org/manual/5.2/manual.html#6.1)
|
- [Basic Functions Library](https://www.lua.org/manual/5.2/manual.html#6.1)
|
||||||
|
|||||||
@ -193,6 +193,46 @@ ASSISTANT = {
|
|||||||
-- CHILDREN
|
-- CHILDREN
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
["Type"] = "LAYOUT_ACCORDION",
|
||||||
|
["Props"] = {
|
||||||
|
["Name"] = "exampleAccordion",
|
||||||
|
["AllowMultiSelection"] = false, -- if true, multiple sections can stay open at the same time
|
||||||
|
["IsDense"] = false, -- denser layout with less spacing
|
||||||
|
["HasOutline"] = false, -- outlined accordion panels
|
||||||
|
["IsSquare"] = false, -- removes rounded corners
|
||||||
|
["Elevation"] = 0, -- shadow depth of the accordion container
|
||||||
|
["HasSectionPaddings"] = true, -- controls section gutters / inner frame paddings
|
||||||
|
["Class"] = "<optional MudBlazor or css classes>",
|
||||||
|
["Style"] = "<optional css styles>",
|
||||||
|
},
|
||||||
|
["Children"] = {
|
||||||
|
-- LAYOUT_ACCORDION_SECTION elements
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
["Type"] = "LAYOUT_ACCORDION_SECTION",
|
||||||
|
["Props"] = {
|
||||||
|
["Name"] = "exampleAccordionSection", -- required
|
||||||
|
["HeaderText"] = "<section title shown in the accordion header>", -- required
|
||||||
|
["IsDisabled"] = false, -- disables expanding/collapsing and interaction
|
||||||
|
["IsExpanded"] = false, -- initial expansion state
|
||||||
|
["IsDense"] = false, -- denser panel layout
|
||||||
|
["HasInnerPadding"] = true, -- controls padding around the section content
|
||||||
|
["HideIcon"] = false, -- hides the expand/collapse icon
|
||||||
|
["HeaderIcon"] = "Icons.Material.Filled.ExpandMore", -- icon shown before the header text
|
||||||
|
["HeaderColor"] = "<Dark|Error|Info|Inherit|Primary|Secondary|Success|Surface|Tertiary|Transparent|Warning>",
|
||||||
|
["HeaderTypo"] = "<body1|subtitle1|h6|...>", -- MudBlazor typo value used for the header
|
||||||
|
["HeaderAlign"] = "<Start|Center|End|Justify>", -- header text alignment
|
||||||
|
["MaxHeight"] = 320, -- nullable integer pixel height for the expanded content area
|
||||||
|
["ExpandIcon"] = "Icons.Material.Filled.ExpandMore", -- override the expand/collapse icon
|
||||||
|
["Class"] = "<optional MudBlazor or css classes>",
|
||||||
|
["Style"] = "<optional css styles>",
|
||||||
|
},
|
||||||
|
["Children"] = {
|
||||||
|
-- CHILDREN
|
||||||
|
}
|
||||||
|
},
|
||||||
{
|
{
|
||||||
["Type"] = "LAYOUT_PAPER",
|
["Type"] = "LAYOUT_PAPER",
|
||||||
["Props"] = {
|
["Props"] = {
|
||||||
|
|||||||
@ -52,6 +52,10 @@ public class AssistantComponentFactory
|
|||||||
return new AssistantPaper { Props = props, Children = children };
|
return new AssistantPaper { Props = props, Children = children };
|
||||||
case AssistantComponentType.LAYOUT_STACK:
|
case AssistantComponentType.LAYOUT_STACK:
|
||||||
return new AssistantStack { Props = props, Children = children };
|
return new AssistantStack { Props = props, Children = children };
|
||||||
|
case AssistantComponentType.LAYOUT_ACCORDION:
|
||||||
|
return new AssistantAccordion { Props = props, Children = children };
|
||||||
|
case AssistantComponentType.LAYOUT_ACCORDION_SECTION:
|
||||||
|
return new AssistantAccordionSection { Props = props, Children = children };
|
||||||
default:
|
default:
|
||||||
LOGGER.LogError($"Unknown assistant component type!\n{type} is not a supported assistant component type");
|
LOGGER.LogError($"Unknown assistant component type!\n{type} is not a supported assistant component type");
|
||||||
throw new Exception($"Unknown assistant component type: {type}");
|
throw new Exception($"Unknown assistant component type: {type}");
|
||||||
|
|||||||
@ -66,7 +66,9 @@ internal static class AssistantComponentPropHelper
|
|||||||
public static string GetIconSvg(string value) => MudBlazorIconRegistry.TryGetSvg(value, out var svg) ? svg : string.Empty;
|
public static string GetIconSvg(string value) => MudBlazorIconRegistry.TryGetSvg(value, out var svg) ? svg : string.Empty;
|
||||||
public static Size GetComponentSize(string value, Size fallback) => Enum.TryParse<Size>(value, out var size) ? size : fallback;
|
public static Size GetComponentSize(string value, Size fallback) => Enum.TryParse<Size>(value, out var size) ? size : fallback;
|
||||||
public static Justify? GetJustify(string value) => Enum.TryParse<Justify>(value, out var justify) ? justify : null;
|
public static Justify? GetJustify(string value) => Enum.TryParse<Justify>(value, out var justify) ? justify : null;
|
||||||
public static AlignItems? GetAlignment(string value) => Enum.TryParse<AlignItems>(value, out var alignment) ? alignment : null;
|
public static AlignItems? GetItemsAlignment(string value) => Enum.TryParse<AlignItems>(value, out var alignment) ? alignment : null;
|
||||||
|
public static Align GetAlignment(string value, Align fallback = Align.Inherit) => Enum.TryParse<Align>(value, out var alignment) ? alignment : fallback;
|
||||||
|
public static Typo GetTypography(string value, Typo fallback = Typo.body1) => Enum.TryParse<Typo>(value, out var typo) ? typo : fallback;
|
||||||
public static Wrap? GetWrap(string value) => Enum.TryParse<Wrap>(value, out var wrap) ? wrap : null;
|
public static Wrap? GetWrap(string value) => Enum.TryParse<Wrap>(value, out var wrap) ? wrap : null;
|
||||||
public static StretchItems? GetStretching(string value) => Enum.TryParse<StretchItems>(value, out var stretch) ? stretch : null;
|
public static StretchItems? GetStretching(string value) => Enum.TryParse<StretchItems>(value, out var stretch) ? stretch : null;
|
||||||
public static Breakpoint GetBreakpoint(string value, Breakpoint fallback) => Enum.TryParse<Breakpoint>(value, out var breakpoint) ? breakpoint : fallback;
|
public static Breakpoint GetBreakpoint(string value, Breakpoint fallback) => Enum.TryParse<Breakpoint>(value, out var breakpoint) ? breakpoint : fallback;
|
||||||
|
|||||||
@ -21,4 +21,6 @@ public enum AssistantComponentType
|
|||||||
LAYOUT_GRID,
|
LAYOUT_GRID,
|
||||||
LAYOUT_PAPER,
|
LAYOUT_PAPER,
|
||||||
LAYOUT_STACK,
|
LAYOUT_STACK,
|
||||||
|
LAYOUT_ACCORDION,
|
||||||
|
LAYOUT_ACCORDION_SECTION,
|
||||||
}
|
}
|
||||||
|
|||||||
@ -103,5 +103,19 @@ public static class ComponentPropSpecs
|
|||||||
"Wrap", "Spacing", "Class", "Style",
|
"Wrap", "Spacing", "Class", "Style",
|
||||||
]
|
]
|
||||||
),
|
),
|
||||||
|
[AssistantComponentType.LAYOUT_ACCORDION] = new(
|
||||||
|
required: ["Name"],
|
||||||
|
optional: [
|
||||||
|
"AllowMultiSelection", "IsDense", "HasOutline", "IsSquare", "Elevation",
|
||||||
|
"HasSectionPaddings", "Class", "Style",
|
||||||
|
]
|
||||||
|
),
|
||||||
|
[AssistantComponentType.LAYOUT_ACCORDION_SECTION] = new(
|
||||||
|
required: ["Name", "HeaderText"],
|
||||||
|
optional: [
|
||||||
|
"IsDisabled", "IsExpanded", "IsDense", "HasInnerPadding", "HideIcon", "HeaderIcon", "HeaderColor",
|
||||||
|
"HeaderTypo", "HeaderAlign", "MaxHeight","ExpandIcon", "Class", "Style",
|
||||||
|
]
|
||||||
|
),
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|||||||
@ -0,0 +1,64 @@
|
|||||||
|
using Lua;
|
||||||
|
|
||||||
|
namespace AIStudio.Tools.PluginSystem.Assistants.DataModel.Layout;
|
||||||
|
|
||||||
|
internal sealed class AssistantAccordion : AssistantComponentBase
|
||||||
|
{
|
||||||
|
public override AssistantComponentType Type => AssistantComponentType.LAYOUT_ACCORDION;
|
||||||
|
public override Dictionary<string, object> Props { get; set; } = new();
|
||||||
|
public override List<IAssistantComponent> Children { get; set; } = new();
|
||||||
|
|
||||||
|
public string Name
|
||||||
|
{
|
||||||
|
get => AssistantComponentPropHelper.ReadString(this.Props, nameof(this.Name));
|
||||||
|
set => AssistantComponentPropHelper.WriteString(this.Props, nameof(this.Name), value);
|
||||||
|
}
|
||||||
|
|
||||||
|
public bool AllowMultiSelection
|
||||||
|
{
|
||||||
|
get => AssistantComponentPropHelper.ReadBool(this.Props, nameof(this.AllowMultiSelection), false);
|
||||||
|
set => AssistantComponentPropHelper.WriteBool(this.Props, nameof(this.AllowMultiSelection), value);
|
||||||
|
}
|
||||||
|
|
||||||
|
public bool IsDense
|
||||||
|
{
|
||||||
|
get => AssistantComponentPropHelper.ReadBool(this.Props, nameof(this.IsDense), false);
|
||||||
|
set => AssistantComponentPropHelper.WriteBool(this.Props, nameof(this.IsDense), value);
|
||||||
|
}
|
||||||
|
|
||||||
|
public bool HasOutline
|
||||||
|
{
|
||||||
|
get => AssistantComponentPropHelper.ReadBool(this.Props, nameof(this.HasOutline), true);
|
||||||
|
set => AssistantComponentPropHelper.WriteBool(this.Props, nameof(this.HasOutline), value);
|
||||||
|
}
|
||||||
|
|
||||||
|
public bool IsSquare
|
||||||
|
{
|
||||||
|
get => AssistantComponentPropHelper.ReadBool(this.Props, nameof(this.IsSquare), false);
|
||||||
|
set => AssistantComponentPropHelper.WriteBool(this.Props, nameof(this.IsSquare), value);
|
||||||
|
}
|
||||||
|
|
||||||
|
public int Elevation
|
||||||
|
{
|
||||||
|
get => AssistantComponentPropHelper.ReadInt(this.Props, nameof(this.Elevation), 0);
|
||||||
|
set => AssistantComponentPropHelper.WriteInt(this.Props, nameof(this.Elevation), value);
|
||||||
|
}
|
||||||
|
|
||||||
|
public bool HasSectionPaddings
|
||||||
|
{
|
||||||
|
get => AssistantComponentPropHelper.ReadBool(this.Props, nameof(this.HasSectionPaddings), true);
|
||||||
|
set => AssistantComponentPropHelper.WriteBool(this.Props, nameof(this.HasSectionPaddings), value);
|
||||||
|
}
|
||||||
|
|
||||||
|
public string Class
|
||||||
|
{
|
||||||
|
get => AssistantComponentPropHelper.ReadString(this.Props, nameof(this.Class));
|
||||||
|
set => AssistantComponentPropHelper.WriteString(this.Props, nameof(this.Class), value);
|
||||||
|
}
|
||||||
|
|
||||||
|
public string Style
|
||||||
|
{
|
||||||
|
get => AssistantComponentPropHelper.ReadString(this.Props, nameof(this.Style));
|
||||||
|
set => AssistantComponentPropHelper.WriteString(this.Props, nameof(this.Style), value);
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -0,0 +1,102 @@
|
|||||||
|
using Lua;
|
||||||
|
|
||||||
|
namespace AIStudio.Tools.PluginSystem.Assistants.DataModel.Layout;
|
||||||
|
|
||||||
|
internal sealed class AssistantAccordionSection : AssistantComponentBase
|
||||||
|
{
|
||||||
|
public override AssistantComponentType Type => AssistantComponentType.LAYOUT_ACCORDION_SECTION;
|
||||||
|
public override Dictionary<string, object> Props { get; set; } = new();
|
||||||
|
public override List<IAssistantComponent> Children { get; set; } = new();
|
||||||
|
|
||||||
|
public bool KeepContentAlive = true;
|
||||||
|
|
||||||
|
public string Name
|
||||||
|
{
|
||||||
|
get => AssistantComponentPropHelper.ReadString(this.Props, nameof(this.Name));
|
||||||
|
set => AssistantComponentPropHelper.WriteString(this.Props, nameof(this.Name), value);
|
||||||
|
}
|
||||||
|
|
||||||
|
public string HeaderText
|
||||||
|
{
|
||||||
|
get => AssistantComponentPropHelper.ReadString(this.Props, nameof(this.HeaderText));
|
||||||
|
set => AssistantComponentPropHelper.WriteString(this.Props, nameof(this.HeaderText), value);
|
||||||
|
}
|
||||||
|
|
||||||
|
public string HeaderColor
|
||||||
|
{
|
||||||
|
get => AssistantComponentPropHelper.ReadString(this.Props, nameof(this.HeaderColor));
|
||||||
|
set => AssistantComponentPropHelper.WriteString(this.Props, nameof(this.HeaderColor), value);
|
||||||
|
}
|
||||||
|
|
||||||
|
public string HeaderIcon
|
||||||
|
{
|
||||||
|
get => AssistantComponentPropHelper.ReadString(this.Props, nameof(this.HeaderIcon));
|
||||||
|
set => AssistantComponentPropHelper.WriteString(this.Props, nameof(this.HeaderIcon), value);
|
||||||
|
}
|
||||||
|
|
||||||
|
public string HeaderTypo
|
||||||
|
{
|
||||||
|
get => AssistantComponentPropHelper.ReadString(this.Props, nameof(this.HeaderTypo));
|
||||||
|
set => AssistantComponentPropHelper.WriteString(this.Props, nameof(this.HeaderTypo), value);
|
||||||
|
}
|
||||||
|
|
||||||
|
public string HeaderAlign
|
||||||
|
{
|
||||||
|
get => AssistantComponentPropHelper.ReadString(this.Props, nameof(this.HeaderAlign));
|
||||||
|
set => AssistantComponentPropHelper.WriteString(this.Props, nameof(this.HeaderAlign), value);
|
||||||
|
}
|
||||||
|
|
||||||
|
public bool IsDisabled
|
||||||
|
{
|
||||||
|
get => AssistantComponentPropHelper.ReadBool(this.Props, nameof(this.IsDisabled), false);
|
||||||
|
set => AssistantComponentPropHelper.WriteBool(this.Props, nameof(this.IsDisabled), value);
|
||||||
|
}
|
||||||
|
|
||||||
|
public bool IsExpanded
|
||||||
|
{
|
||||||
|
get => AssistantComponentPropHelper.ReadBool(this.Props, nameof(this.IsExpanded), false);
|
||||||
|
set => AssistantComponentPropHelper.WriteBool(this.Props, nameof(this.IsExpanded), value);
|
||||||
|
}
|
||||||
|
|
||||||
|
public bool IsDense
|
||||||
|
{
|
||||||
|
get => AssistantComponentPropHelper.ReadBool(this.Props, nameof(this.IsDense), false);
|
||||||
|
set => AssistantComponentPropHelper.WriteBool(this.Props, nameof(this.IsDense), value);
|
||||||
|
}
|
||||||
|
|
||||||
|
public bool HasInnerPadding
|
||||||
|
{
|
||||||
|
get => AssistantComponentPropHelper.ReadBool(this.Props, nameof(this.HasInnerPadding), true);
|
||||||
|
set => AssistantComponentPropHelper.WriteBool(this.Props, nameof(this.HasInnerPadding), value);
|
||||||
|
}
|
||||||
|
|
||||||
|
public bool HideIcon
|
||||||
|
{
|
||||||
|
get => AssistantComponentPropHelper.ReadBool(this.Props, nameof(this.HideIcon), false);
|
||||||
|
set => AssistantComponentPropHelper.WriteBool(this.Props, nameof(this.HideIcon), value);
|
||||||
|
}
|
||||||
|
|
||||||
|
public int? MaxHeight
|
||||||
|
{
|
||||||
|
get => AssistantComponentPropHelper.ReadNullableInt(this.Props, nameof(this.MaxHeight));
|
||||||
|
set => AssistantComponentPropHelper.WriteNullableInt(this.Props, nameof(this.MaxHeight), value);
|
||||||
|
}
|
||||||
|
|
||||||
|
public string ExpandIcon
|
||||||
|
{
|
||||||
|
get => AssistantComponentPropHelper.ReadString(this.Props, nameof(this.ExpandIcon));
|
||||||
|
set => AssistantComponentPropHelper.WriteString(this.Props, nameof(this.ExpandIcon), value);
|
||||||
|
}
|
||||||
|
|
||||||
|
public string Class
|
||||||
|
{
|
||||||
|
get => AssistantComponentPropHelper.ReadString(this.Props, nameof(this.Class));
|
||||||
|
set => AssistantComponentPropHelper.WriteString(this.Props, nameof(this.Class), value);
|
||||||
|
}
|
||||||
|
|
||||||
|
public string Style
|
||||||
|
{
|
||||||
|
get => AssistantComponentPropHelper.ReadString(this.Props, nameof(this.Style));
|
||||||
|
set => AssistantComponentPropHelper.WriteString(this.Props, nameof(this.Style), value);
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -68,9 +68,9 @@ internal sealed class AssistantStack : AssistantComponentBase
|
|||||||
set => AssistantComponentPropHelper.WriteString(this.Props, nameof(this.Class), value);
|
set => AssistantComponentPropHelper.WriteString(this.Props, nameof(this.Class), value);
|
||||||
}
|
}
|
||||||
|
|
||||||
public int Style
|
public string Style
|
||||||
{
|
{
|
||||||
get => AssistantComponentPropHelper.ReadInt(this.Props, nameof(this.Style), 3);
|
get => AssistantComponentPropHelper.ReadString(this.Props, nameof(this.Style));
|
||||||
set => AssistantComponentPropHelper.WriteInt(this.Props, nameof(this.Style), value);
|
set => AssistantComponentPropHelper.WriteString(this.Props, nameof(this.Style), value);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user