@synergy-design-system/components
Version:
This package provides the base of the Synergy Design System as native web components. It uses [lit](https://www.lit.dev) and parts of [shoelace](https://shoelace.style/). Synergy officially supports the latest two versions of all major browsers (as define
70 lines (69 loc) • 2.98 kB
TypeScript
import { type TemplateResult } from 'lit';
import type SynOptGroup from '../optgroup/optgroup.js';
import type SynOption from '../option/option.component.js';
/**
* Get a list of all assigned elements for a given slot
* @param slot The slot to query
* @returns Flattened list of assigned elements
*/
export declare const getAssignedElementsForSlot: (slot: HTMLSlotElement) => HTMLElement[];
/**
* Retrieves the option or nested options from the provided HTMLElement.
*
* @param item - The HTMLElement representing the option or containing nested options.
* @returns The found syn-option(s)
*/
export declare const getOptionOrNestedOptions: (item: HTMLElement) => SynOption | SynOption[];
/**
* Check if an item is a syn-optgroup
* @param item The item to check for
* @returns True if the item is a SynOptgroup, false otherwise
*/
export declare const isOptgroup: (item: HTMLElement) => item is SynOptGroup;
/**
* Get a list of only Option elements
* @param items List of items to check for
* @returns New array of all found syn-nav-items
*/
export declare const getAllOptions: (items: HTMLElement[]) => (SynOption | SynOption[])[];
/**
* Get a list of only Optgroup elements
* @param items List of items to check for
* @returns New array of all found syn-optgroup's
*/
export declare const filterOnlyOptgroups: (items: HTMLElement[]) => SynOptGroup[];
/**
* Normalize a string by removing accents and converting to lowercase
* @param str The string to normalize
* @returns The normalized string
*/
export declare const normalizeString: (str: string) => string;
/**
* Creates a `SynOption` element from a given `TemplateResult`.
* We assume that the given `TemplateResult` is a <syn-option>.
*
* @param template - The `TemplateResult` to be rendered into a `SynOption`.
* @returns The created SynOption element
*/
export declare const createElementFromTemplateResult: (template: TemplateResult) => HTMLElement;
/**
* This function takes an input of type `TemplateResult`, `string`, or `HTMLElement`
* and creates an SynOption from it.
*
* @param option - The option which can be of type `TemplateResult`, `string` or `HTMLElement`.
* @returns The created SynOption or undefined if the option was not a valid type.
*/
export declare const createOptionFromDifferentTypes: (option: TemplateResult | string | HTMLElement) => SynOption | undefined;
/**
* Gets the value from an option. If an option has no value, it will use the text label.
* @param option The syn-option to get the value from
* @returns The value of the option
*/
export declare const getValueFromOption: (option: SynOption) => string | number;
/**
* Check if a value belongs to the value or text label of an option.
* @param value The value to check
* @param option The option to check against
* @returns True if the value belongs to the option, false otherwise
*/
export declare const checkValueBelongsToOption: (value: string, option: SynOption | undefined) => boolean;