@samatawy/diagrams
    Preparing search index...

    Class SizeSelect

    A dropdown control for selecting sizes (e.g., font sizes, line widths). Emits a 'sizechange' event when the selected size changes. Example usage: const sizeSelect = new SizeSelect(document.getElementById('size-select'), { sizes: [8, 10, 12, 14, 16, 18, 20], unit: 'px', showLabel: true, });

    Index

    Constructors

    Properties

    host: HTMLElement
    config: Required<Omit<SizeSelectConfig, "sizes">> & { sizes: number[] }
    selected: number
    trigger: HTMLButtonElement
    triggerPreview: HTMLSpanElement
    menu: HTMLDivElement

    Accessors

    Methods

    • Sets the available size options and optionally selects a size.

      Parameters

      • sizes: number[]

        An array of sizes.

      • OptionalselectedSize: number

        The size to select. Defaults to the first size in the array.

      Returns void

    • Handles the click event on the trigger button. Toggles the open/closed state of the dropdown menu.

      Returns void

    • Handles the click event on the document. Closes the dropdown menu if the click is outside the host element.

      Parameters

      • event: Event

        The click event.

      Returns void

    • Handles the click event on an option. Selects the clicked size and closes the dropdown menu.

      Parameters

      • event: Event

        The click event.

      Returns void

    • Replaces the current option list with a new set of size values.

      Parameters

      • sizes: number[]

        The numeric size values to render.

      Returns void

    • Builds a single option button with a size preview and optional unit label.

      Parameters

      • size: number

        The numeric size value for this option.

      Returns HTMLButtonElement

      The constructed option button element.

    • Updates the internal selection state, syncs the trigger and option list, and optionally emits 'sizechange'.

      Parameters

      • size: number

        The new size value to select.

      • emit: boolean = true

        Whether to dispatch the change event. Defaults to true.

      Returns void