SortableStack
Description
SortableStack is a stack-based container whose child items can be reordered with drag and drop. It wraps a standard Stack internally, tracks a stable identifier for each item, and reports the updated ordering when the user finishes sorting.
Use it when the visual order matters and you need to persist or react to that order, such as dashboards, pinned lists, or configurable layouts.
Usage
Create a SortableStack through the SortableStack(...), VSortableStack(), or HSortableStack() helpers. Add items with stable identifiers, then listen for sorting changes.
SortableStackItem
Each draggable entry is represented by SortableStackItem.
Identifieris the unique key used for ordering.Componentis the rendered child component.
API reference
public class SortableStack : IComponent, IHasBackgroundColor, IHasMarginPadding, ISpecialCaseStyling, ICanWrapA Stack component that allows its children to be reordered via drag and drop.
- Namespace
- Tesserae
- Implements
- IComponent, IHasBackgroundColor, IHasMarginPadding, ISpecialCaseStyling, ICanWrap
Constructors
| Name | Description |
|---|---|
| SortableStack | Initializes a new instance of the SortableStack class. |
Properties
| Name | Description |
|---|---|
| Background | Gets or sets the background color. |
| Margin | Gets or sets the margin. |
| Padding | Gets or sets the padding. |
| StylingContainer | Gets the styling container. |
| PropagateToStackItemParent | Gets whether styling should propagate to the stack item parent. |
| CanWrap | Gets or sets whether the stack can wrap its items. |
public string Background { get ; set ; }Gets or sets the background color.
public dom.HTMLElement StylingContainerGets the styling container.
public bool PropagateToStackItemParentGets whether styling should propagate to the stack item parent.
Methods
| Name | Description |
|---|---|
| Add | Adds a component to the sortable stack. |
| Children | Sets the children of the sortable stack. |
| Render | Renders the sortable stack. |
| AlignItemsCenter | Aligns items in the center. |
| LoadSorting | Loads the sorting order of the items. Should be called after all items have been added. |
| OnSortingChanged | Adds a sorting change event handler. |
| NoWrap | Disables wrapping of items. |
| Wrap | Enables wrapping of items. |
| AlignItems | Sets the alignment of items. |
| Relative | Sets the stack to use relative positioning. |
| AlignContent | Sets the content alignment. |
| JustifyContent | Sets the content justification. |
| JustifyItems | Sets the item justification. |
| RemovePropagation | Removes event propagation. |
| OnMouseOver | Adds a mouse over event handler. |
| OnMouseOut | Adds a mouse out event handler. |
| Clear | Clears all items from the sortable stack. |
| NoDefaultMargin | Removes the default margin from the stack. |
| Remove | Removes an item from the sortable stack. |
| Overload | |
|---|---|
| Add(string, IComponent) | Adds a component to the sortable stack. |
| Add(SortableStackItem) | Adds a SortableStackItem to the stack. |
public SortableStack Children(params SortableStackItem[] children)Sets the children of the sortable stack.
Parameters
- children
- The children items.
Returns
The current instance of the type.
public dom.HTMLElement Render()Renders the sortable stack.
Returns
The rendered HTMLElement.
public SortableStack AlignItemsCenter()Aligns items in the center.
Returns
The current instance of the type.
public void LoadSorting(string[] itemOrder)Loads the sorting order of the items. Should be called after all items have been added.
Parameters
- itemOrder
- An array of identifiers in the desired order.
public void OnSortingChanged(Action<string[]> onSortingChanged)Adds a sorting change event handler.
Parameters
- onSortingChanged
- The event handler action.
public SortableStack NoWrap()Disables wrapping of items.
Returns
The current instance of the type.
public SortableStack Wrap()Enables wrapping of items.
Returns
The current instance of the type.
public SortableStack AlignItems(ItemAlign align)Sets the alignment of items.
Parameters
- align
- The alignment.
Returns
The current instance of the type.
public SortableStack Relative()Sets the stack to use relative positioning.
Returns
The current instance of the type.
public SortableStack AlignContent(ItemAlign align)Sets the content alignment.
Parameters
- align
- The alignment.
Returns
The current instance of the type.
public SortableStack JustifyContent(ItemJustify justify)Sets the content justification.
Parameters
- justify
- The justification.
Returns
The current instance of the type.
public SortableStack JustifyItems(ItemJustify justify)Sets the item justification.
Parameters
- justify
- The justification.
Returns
The current instance of the type.
public SortableStack RemovePropagation()Removes event propagation.
Returns
The current instance of the type.
public SortableStack OnMouseOver(ComponentEventHandler<Stack, Event> onMouseOver)Adds a mouse over event handler.
public SortableStack OnMouseOut(ComponentEventHandler<Stack, Event> onMouseOut)Adds a mouse out event handler.
public SortableStack NoDefaultMargin()Removes the default margin from the stack.
Returns
The current instance of the type.
public class SortableStackItemRepresents an item within a SortableStack.
- Namespace
- Tesserae
Properties
| Name | Description |
|---|---|
| Component | Gets or sets the component. |
| Identifier | Gets or sets the unique identifier. |
public IComponent Component { get; set; }Gets or sets the component.