SelectLink

Synchronizes the selected values of two select controls.

Import
the javascript logo
import { SelectLink } from "@schukai/monster/source/components/form/select-link.mjs";
Source
the git logo
Package
Since
1.0.0

Purpose and scope

Synchronizes the selected values of two select controls.

This page documents the <monster-select-link> custom element. Use the Usage examples for a working starting point and the API tab for the complete public contract.

When to use it

Use this module when its focused responsibility matches the surrounding workflow. Prefer its public options, properties, methods and events over reaching into rendered internals.

Linked Selects

Links two real Select controls and forwards the source value into the target filter parameters.

Javascript

import "@schukai/monster/source/components/form/select.mjs";
import "@schukai/monster/source/components/form/select-link.mjs";

const country = document.getElementById("country-select");
const city = document.getElementById("city-select");
const status = document.getElementById("select-link-basic-status");
country.importOptions([{value: "de", label: "Germany"}, {value: "fr", label: "France"}]);
city.importOptions([{value: "berlin", label: "Berlin"}, {value: "paris", label: "Paris"}]);
country.addEventListener("monster-changed", () => {
  status.textContent = `Target parameter: ${city.getOption("filter.params.country", "")}`;
});

HTML

<section style="display:grid;gap:var(--monster-space-3)">
  <monster-select id="country-select"></monster-select>
  <monster-select id="city-select"></monster-select>
  <monster-select-link data-monster-option-source="#country-select" data-monster-option-target="#city-select" data-monster-option-param="country" data-monster-option-auto-fetch="false"></monster-select-link>
  <output id="select-link-basic-status"></output>
</section>

Stylesheet

/** no additional stylesheet is defined **/
Open in playground

Cascading Remote Parameters

Demonstrates empty-state handling, target enabling and cascading filter parameters.

Javascript

import "@schukai/monster/source/components/form/select.mjs";
import "@schukai/monster/source/components/form/select-link.mjs";

const region = document.getElementById("region-select");
region.importOptions([{value: "eu", label: "Europe"}, {value: "na", label: "North America"}]);

document.getElementById("region-select-europe").addEventListener("click", () => {
  region.value = "eu";
  region.dispatchEvent(new CustomEvent("monster-changed", {detail: {value: "eu"}}));
});

HTML

<section style="display:grid;gap:var(--monster-space-3)">
  <monster-select id="region-select"></monster-select>
  <monster-select id="office-select"></monster-select>
  <monster-select-link data-monster-option-source="#region-select" data-monster-option-target="#office-select" data-monster-option-param="region" data-monster-option-empty-message="Choose a region first" data-monster-option-auto-fetch="false"></monster-select-link>
  <button id="region-select-europe" type="button">Choose Europe</button>
</section>

Stylesheet

/** no additional stylesheet is defined **/
Open in playground

Component Design

monster-select-link coordinates dependent Monster Select controls and forwards values from an upstream selection into downstream request parameters.

Composition

The coordinator is non-visual. Style the linked Select elements through their own documented parts and keep selectors and parameter mappings explicit.

HTML Structure

<monster-select-link></monster-select-link>

JavaScript Initialization

const element = document.createElement('monster-select-link');
document.body.appendChild(element);

Exported

SelectLink

Derived from

CustomElement

Options

The Options listed in this section are defined directly within the class. This class is derived from several parent classes, including the CustomElement class. Therefore, it inherits Options from these parent classes. If you cannot find a specific Options in this list, we recommend consulting the documentation of the CustomElement.

Option
Type
Default
Description
-/-

  • since
  • deprecated

Properties and Attributes

The Properties and Attributes listed in this section are defined directly within the class. This class is derived from several parent classes, including the CustomElement class and ultimately from HTMLElement. Therefore, it inherits Properties and Attributes from these parent classes. If you cannot find a specific Properties and Attributes in this list, we recommend consulting the documentation of the CustomElement.

  • data-monster-options: Sets the configuration options for the collapse component when used as an HTML attribute.
  • data-monster-option-[name]: Sets the value of the configuration option [name] for the collapse component when used as an HTML attribute.

Methods

The methods listed in this section are defined directly within the class. This class is derived from several parent classes, including the CustomElement class and ultimately from HTMLElement. Therefore, it inherits methods from these parent classes. If you cannot find a specific method in this list, we recommend consulting the documentation of the CustomElement.

Static methods

[instanceSymbol]()
No description available.
getTag()
No description available.

Lifecycle methods

Lifecycle methods are called by the environment and are usually not intended to be called directly.

[assembleMethodSymbol]()
No description available.
connectedCallback()
Binding belongs to the connect lifecycle, not to assembly: disconnecting unbinds, so a reconnect has to bind again. bindSelects() is idempotent.
disconnectedCallback()
No description available.

Events

This component does not fire any public events. It may fire events that are inherited from its parent classes.

The current width of the area is too small to display the content correctly.