Refactor: results expose Element as a named field

Every component result type now names its element Element instead of
embedding *ui.Element. The eleven element-plus-changed results
(AccordionView, CarouselView, CollapsibleView, ImageViewerView,
PaginationResult, StepsResult, SidebarResult, TabsResult, RatingParts,
FileDropZoneParts, TransferParts) fold into ChoiceResult.

Fixes four Gallery demos where .Width(...).Changed() read the element's
flag instead of the component's: Accordion, MultiSelect, Cascader,
TreeSelect. TestDataAccordionDemoLogsChange covers the Accordion.
This commit is contained in:
ZacharyZhang-NY committed 2026-10-05 13:35:53 -04:00
1 parent 078dcab8b4
commit 8880865021
73 files changed
+163 -245

No files matched your search

+2 -11
View File
@@ -27,17 +27,8 @@ type TabsOptions struct {
Label string
}
// TabsResult is the built Tabs: the element holding tabs and panel.
type TabsResult struct {
*ui.Element
changed bool
}
// Changed reports a new choice made by the user in this frame.
func (r TabsResult) Changed() bool { return r.changed }
// Tabs shows tabs choosing *selected and the chosen tab's panel. Disabled tabs are skipped by the arrows.
func Tabs(c *ui.Context, selected *int, tabs []Tab, opts TabsOptions) TabsResult {
func Tabs(c *ui.Context, selected *int, tabs []Tab, opts TabsOptions) ChoiceResult {
if len(tabs) == 0 {
panic("mujica: Tabs needs at least one tab")
}
@@ -66,7 +57,7 @@ func Tabs(c *ui.Context, selected *int, tabs []Tab, opts TabsOptions) TabsResult
if opts.Vertical {
root.Row()
}
res := TabsResult{Element: root}
res := ChoiceResult{Element: root}
root.Children(func() {
var strip *ui.Element
if opts.Vertical {