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

+3 -12
View File
@@ -19,25 +19,16 @@ type CollapsibleOptions struct {
Disabled bool
}
// CollapsibleView is a built Collapsible and what happened to it in this frame.
type CollapsibleView struct {
*ui.Element
changed bool
}
// Changed reports that the trigger opened or closed the content.
func (v CollapsibleView) Changed() bool { return v.changed }
// Collapsible shows content below a trigger while *open; closed content is not built.
func Collapsible(c *ui.Context, open *bool, opts CollapsibleOptions, content func()) CollapsibleView {
func Collapsible(c *ui.Context, open *bool, opts CollapsibleOptions, content func()) ChoiceResult {
if opts.Title == "" && opts.Trigger == nil {
panic("mujica: Collapsible needs Title or Trigger")
}
k := Tokens(c)
u := Density(c).Unit()
var v CollapsibleView
var v ChoiceResult
v.Element = ui.Column(c).Shrink(0)
v.Children(func() {
v.Element.Children(func() {
was := *open
p := ui.CollapsibleBase(c, open)
tr := p.Trigger