@samatawy/diagrams
    Preparing search index...

    Class Toolbar

    A simple toolbar component that can be used to create a toolbar with buttons and separators. The toolbar can be customized with CSS classes and tooltip attributes. Buttons can be added with icons, labels, tooltips, and click event handlers. Buttons can also be toggled on/off and enabled/disabled.

    Hierarchy (View Summary)

    Index

    Constructors

    Properties

    host: HTMLElement
    config: Required<ToolbarConfig>
    buttons: Map<string, HTMLButtonElement> = ...

    Methods

    • Manually adds a button to the toolbar. This is useful for dynamically adding buttons after the toolbar has been created.

      Parameters

      Returns HTMLButtonElement

      The HTMLButtonElement that was created and added to the toolbar.

    • Manually adds a separator to the toolbar. This is useful for dynamically adding separators after the toolbar has been created.

      Returns HTMLDivElement

      The HTMLDivElement that was created and added to the toolbar.

    • Sets the active state of a button.

      Parameters

      • id: string

        The ID of the button.

      • active: boolean

        Whether the button should be active.

      Returns void

    • Sets the enabled state of a button.

      Parameters

      • id: string

        The ID of the button.

      • enabled: boolean

        Whether the button should be enabled.

      Returns void

    • Gets a button by its ID.

      Parameters

      • id: string

        The ID of the button.

      Returns HTMLButtonElement | undefined

      The HTMLButtonElement if found, otherwise undefined.

    • Creates a button DOM element from the given definition and wires its click handler.

      Parameters

      • def: ToolButtonDef

        The button definition including id, icon, label, and callbacks.

      Returns HTMLButtonElement

      The constructed HTMLButtonElement.

    • Resolves a string icon reference or Element into a DOM element suitable for button content.

      Parameters

      • Optionalicon: string | Element

        An SVG sprite reference (e.g. '#icon-undo'), an img URL, raw SVG markup, or an Element.

      Returns Element | null

      The icon element, or null when no icon is provided.