import { t as SigveloTooltip } from "./tooltip-VyMg30Ew.js"; import { CSSResultGroup, PropertyValues } from "lit"; import { SigveloFormControlElement } from "@mcp-b/wc-support/base/sigvelo-element"; //#region src/components/slider/slider.d.ts /** * * * @summary Allows users to select numeric values within a given range by moving a thumb along a track. * @tag sigvelo-slider * @documentation https://design-system.sigvelo.com/docs/components/slider * @status stable * @since 1.0 * * @dependency sigvelo-tooltip * * @slot label - The slider's label. For plain-text labels, you can use the `label` attribute instead. * @slot description - The slider's description. For plain-text descriptions, you can use the `description` attribute * instead. * @slot reference - One or more reference labels to show visually below the slider. * * @event sigvelo-blur - Emitted when the slider loses focus. This event does not bubble. * @event sigvelo-change - Emitted when the user commits changes to the slider's value. * @event sigvelo-focus - Emitted when the slider receives focus. This event does not bubble. * @event sigvelo-input - Emitted when the slider receives input. * * @csspart label - The element that contains the sliders's label. * @csspart description - The element that contains the slider's description. * @csspart slider - The focusable element with `role="slider"`. Contains the track and reference slot. * @csspart track - The slider's track. * @csspart indicator - The colored indicator that shows from the start of the slider to the current value. * @csspart markers - The container that holds all the markers when `with-markers` is used. * @csspart marker - The individual markers that are shown when `with-markers` is used. * @csspart references - The container that holds references that get slotted in. * @csspart thumb - The slider's thumb. * @csspart thumb-min - The min value thumb in a range slider. * @csspart thumb-max - The max value thumb in a range slider. * @csspart tooltip - The tooltip, a `` element. * @csspart tooltip__tooltip - The tooltip's `tooltip` part. * @csspart tooltip__content - The tooltip's `content` part. * @csspart tooltip__arrow - The tooltip's `arrow` part. * * @cssstate disabled - Applied when the slider is disabled. * @cssstate dragging - Applied when the slider is being dragged. * @cssstate focused - Applied when the slider has focus. * @cssstate user-valid - Applied when the slider is valid and the user has sufficiently interacted with it. * @cssstate user-invalid - Applied when the slider is invalid and the user has sufficiently interacted with it. * * @cssproperty [--track-size=0.75em] - The height or width of the slider's track. * @cssproperty [--marker-width=0.1875em] - The width of each individual marker. * @cssproperty [--marker-height=0.1875em] - The height of each individual marker. * @cssproperty [--thumb-width=1.25em] - The width of the thumb. * @cssproperty [--thumb-height=1.25em] - The height of the thumb. * * @example Default * ```html * * Less * More * * ``` * * @example Showing tooltips * Add the `with-tooltip` attribute to show a tooltip when the slider has focus or is dragged. * * ```html * * ``` * * @example Setting min, max, and step * Use the `min` and `max` attributes to set a minimum and maximum value for the slider. Use the `step` attribute to change the granularity the value must adhere to. * * ```html * * ``` * * @example Showing markers * Add the `with-markers` attribute to show visual markers at each step. Markers work best with sliders that have shorter ranges. * * ```html * * ``` * * @example Adding references * Use the `reference` slot to add visual references below the slider. By default, references are positioned with `space-between`, making it easy to align them with starting, ending, and center markers. * * ```html * * Slow * Medium * Fast * * ``` * * **Note:** If you want to show a reference next to a specific marker, you can add `position: absolute` to it and set the `left`, `right`, `top`, or `bottom` property to a percentage that corresponds to the marker's position. * * @example Formatting the value * You can format the value that gets shown in tooltips and/or announced by screen readers with the `valueFormatter` property. Using JavaScript, set the property to a function that accepts a numeric value and returns a string. The `Intl.FormatNumber API` can be really useful here. * * ```html * *
* * * * *
* * * * *
* * * * * * * * ``` * * @example Range selection * Set `value` to a two-number array to create a slider with two thumbs for selecting a range of values. * * ```html * * $0 * $50 * $100 * * * * ``` * * For range sliders, the two entries in `value` represent the current thumb positions. When the form is submitted, both values will be included as separate entries with the same name. * * ```ts * const slider = document.querySelector('sigvelo-slider'); * * // Get the current values * console.log(`Min value: ${slider.value[0]}, Max value: ${slider.value[1]}`); * * // Set the values programmatically * slider.value = [30, 70]; * ``` * * @example Changing the orientation * To make a vertical slider, set the `orientation` attribute to `vertical`. Vertical sliders are centered and will span 100% of the available space by default. * * ```html *
* * * * * *
* ``` * * Range sliders can also be vertical. * * ```html *
* * *
* * * ``` * * @example Changing the size * Use the `size` attribute to change the slider's size. * * ```html *
*
*
*
* * ``` * * @example Changing the indicator's offset * To make the selection more obvious, a filled indicator representing the current value is drawn from the minimum value of the slider. To change the offset from which the indicator is drawn, set the `indicator-offset` attribute to another value along the slider. * * ```html * * Lazy * Zoomies * * ``` * * @example Disabling * Use the `disabled` attribute to disable the slider. * * ```html * * ``` * * @example Using custom validation * Sliders don't have built-in validation attributes like many other form controls. However, you can Use the `setCustomValidity()` method to make the slider invalid and show a custom error message on submit. To clear the error, remove the attribute or set it to an empty string. * * ```html *
* *
* Submit *
* * * ``` * * @example Styling validation * You can style valid and invalid sliders using the `:valid` and `:invalid` pseudo classes. * * ```html *
* *
* Submit * Reset *
* * * * * ``` * * However, these selectors will match even before the user has had a chance to fill out the form. More often than not, you'll want to use the `user-valid` and `user-invalid` custom states instead. This way, validation styles are only shown _after_ the user interacts with the form control or when the form is submitted. * * ```html *
* *
* Submit * Reset *
* * * * * ``` * * @example Styling sliders * Sliders come with a simple, minimal appearance. Feel free to customize them with your own styles. * * ```html *
*
* * * *
* *
* * *
*
* * * ``` * * ```html * * *
* * * * * * * ``` * * ```html * * Off * Slow * Fast * * * * ``` */ declare class SigveloSlider extends SigveloFormControlElement { static formAssociated: boolean; static observeSlots: boolean; static styles: CSSResultGroup; private draggableTrack?; private draggableThumbMin; private draggableThumbMax; private localize; private trackBoundingClientRect; private valueWhenDraggingStarted; private activeThumb; private lastTrackPosition; private defaultValue; protected get focusableAnchor(): HTMLElement; slider: HTMLElement; thumb: HTMLElement; thumbMin: HTMLElement; thumbMax: HTMLElement; track: HTMLElement; tooltip: SigveloTooltip; tooltipMin: SigveloTooltip; tooltipMax: SigveloTooltip; isInvalid: boolean; hadUserInteraction: boolean; wasSubmitted: boolean; /** * The slider's label. If you need to provide HTML in the label, use the `label` slot instead. */ label: string; /** * The slider's description. If you need to provide HTML in the description, use the `description` slot instead. */ description: string; /** The name of the slider. This will be submitted with the form as a name/value pair. */ name: string; /** The slider's value. Pass a two-number array to render a range slider. */ value: number | readonly number[]; /** Get if this is a range slider */ get isRange(): boolean; private get singleValue(); private set singleValue(value); private get rangeStart(); private set rangeStart(value); private get rangeEnd(); private set rangeEnd(value); /** Disables the slider. */ disabled: boolean; /** Makes the slider a read-only field. */ readonly: boolean; /** The orientation of the slider. */ orientation: "horizontal" | "vertical"; /** The slider's size. */ size: "xs" | "sm" | "md" | "lg" | "xl"; /** The starting value from which to draw the slider's fill, which is based on its current value. */ indicatorOffset: number; /** * The form to associate this control with. If omitted, the closest containing `
` will be used. The value of * this attribute must be an ID of a form in the same document or shadow root. */ form: string; /** The minimum value allowed. */ min: number; /** The maximum value allowed. */ max: number; /** The granularity the value must adhere to when incrementing and decrementing. */ step: number; /** Tells the browser to focus the slider when the page loads or a dialog is shown. */ autofocus: boolean; /** The distance of the tooltip from the slider's thumb. */ tooltipDistance: number; /** The placement of the tooltip in reference to the slider's thumb. */ tooltipPlacement: "top" | "right" | "bottom" | "left"; /** Draws markers at each step along the slider. */ withMarkers: boolean; /** Draws a tooltip above the thumb when the control has focus or is dragged. */ withTooltip: boolean; /** * A custom formatting function to apply to the value. This will be shown in the tooltip and announced by screen * readers. Must be set with JavaScript. Property only. */ valueFormatter: (value: number) => string; connectedCallback(): void; disconnectedCallback(): void; firstUpdated(): void; private stopDragging; private setupDragging; formDisabledCallback(): void; private updateDragging; updated(changedProperties: PropertyValues): void; /** @internal Called when the form is reset. */ formResetCallback(): void; /** Clamps a number to min/max while ensuring it's a valid step interval. */ private clampAndRoundToStep; /** Given a value, returns its percentage within a range of min/max. */ private getPercentageFromValue; /** Converts coordinates to slider value */ private getValueFromCoordinates; private handleBlur; private handleFocus; private handleKeyDown; private handleLabelPointerDown; private setValueFromCoordinates; private setThumbValueFromCoordinates; private showTooltip; private hideTooltip; private showRangeTooltips; private hideRangeTooltips; /** Updates the form value submission for range sliders */ private updateFormValue; /** Sets the form control's validity */ private updateValidity; /** Sets focus to the slider. */ focus(): void; /** Removes focus from the slider. */ blur(): void; /** * Decreases the slider's value by `step`. This is a programmatic change, so `input` and `change` events will not be * emitted when this is called. */ stepDown(): void; /** * Increases the slider's value by `step`. This is a programmatic change, so `input` and `change` events will not be * emitted when this is called. */ stepUp(): void; render(): import("lit-html").TemplateResult<1>; } declare global { interface HTMLElementTagNameMap { "sigvelo-slider": SigveloSlider; } } //#endregion export { SigveloSlider as t };