carbon-components-svelte/types/Slider/Slider.svelte.d.ts
mmamedel 90dbd1562b
fix(slider): dispatch on:input event (#1906)
Fixes #1643

The dispatched `on:change` event in `Slider` only fires when the slider thumb is released. `on:input` fires when actively dragging the thumb, and should fire on every increment (e.g., 1, 2, 3).
2024-02-10 20:44:39 -08:00

137 lines
2.4 KiB
TypeScript

import type { SvelteComponentTyped } from "svelte";
import type { SvelteHTMLElements } from "svelte/elements";
type RestProps = SvelteHTMLElements["div"];
export interface SliderProps extends RestProps {
/**
* Specify the value of the slider
* @default 0
*/
value?: number;
/**
* Set the maximum slider value
* @default 100
*/
max?: number;
/**
* Specify the label for the max value
* @default ""
*/
maxLabel?: string;
/**
* Set the minimum slider value
* @default 0
*/
min?: number;
/**
* Specify the label for the min value
* @default ""
*/
minLabel?: string;
/**
* Set the step value
* @default 1
*/
step?: number;
/**
* Set the step multiplier value
* @default 4
*/
stepMultiplier?: number;
/**
* Set to `true` to require a value
* @default false
*/
required?: boolean;
/**
* Specify the input type
* @default "number"
*/
inputType?: string;
/**
* Set to `true` to disable the slider
* @default false
*/
disabled?: boolean;
/**
* Set to `true` to enable the light variant
* @default false
*/
light?: boolean;
/**
* Set to `true` to hide the text input
* @default false
*/
hideTextInput?: boolean;
/**
* Set to `true` for the slider to span
* the full width of its containing element.
* @default false
*/
fullWidth?: boolean;
/**
* Set an id for the slider div element
* @default "ccs-" + Math.random().toString(36)
*/
id?: string;
/**
* Set to `true` to indicate an invalid state
* @default false
*/
invalid?: boolean;
/**
* Specify the label text.
* Alternatively, use the "labelText" slot (e.g., `<span slot="labelText">...</span>`)
* @default ""
*/
labelText?: string;
/**
* Set to `true` to visually hide the label text
* @default false
*/
hideLabel?: boolean;
/**
* Set a name for the slider element
* @default ""
*/
name?: string;
/**
* Obtain a reference to the HTML element
* @default null
*/
ref?: null | HTMLDivElement;
[key: `data-${string}`]: any;
}
export default class Slider extends SvelteComponentTyped<
SliderProps,
{
change: CustomEvent<number>;
input: CustomEvent<number>;
click: WindowEventMap["click"];
mouseover: WindowEventMap["mouseover"];
mouseenter: WindowEventMap["mouseenter"];
mouseleave: WindowEventMap["mouseleave"];
},
{ labelText: {} }
> {}