import { CSSResultGroup, PropertyValues } from "lit"; import { SigveloFormControlElement } from "@mcp-b/wc-support/base/sigvelo-element"; //#region src/components/rating/rating.d.ts /** * * * @summary Allows users to provide feedback based on their satisfaction with a product or service. * @tag sigvelo-rating * @documentation https://design-system.sigvelo.com/docs/components/rating * @status stable * @since 1.0 * * @slot label - The rating's label. For plain-text labels, you can use the `label` attribute instead. * @slot description - The rating's description. For plain-text descriptions, you can use the `description` attribute * instead. * * @event sigvelo-blur - Emitted when the rating loses focus. This event does not bubble. * @event sigvelo-change - Emitted when the user commits changes to the rating's value. * @event sigvelo-focus - Emitted when the rating receives focus. This event does not bubble. * @event sigvelo-input - Emitted when the rating receives input. * * @csspart label - The element that contains the ratings's label. * @csspart description - The element that contains the rating's description. * @csspart rating - The element that wraps all of the rating's symbols. * @csspart symbol - The container that holds the selected and unselected version of each symbol. * * @cssstate disabled - Applied when the rating is disabled. * @cssstate focused - Applied when the rating has focus. * @cssstate user-valid - Applied when the rating is valid and the user has sufficiently interacted with it. * @cssstate user-invalid - Applied when the rating is invalid and the user has sufficiently interacted with it. * * @example Default * ```html * * * ``` * * @example Labels and descriptions * You can use the `label` and `description` attributes to provide plain text labels and descriptions for the rating. If you want to provide HTML, use the `label` and `description` slots instead. * * ```html * * * For details, please visit our website. * * * ``` * * @example Providing an initial value * Use the `value` attribute to provide an initial value for the rating. * * ```html * * ``` * * @example Changing the scale * Ratings use a scale of 1–5 by default. You can change this by setting the `max` attribute. * * ```html * * ``` * * @example Fractional values * You can enable fractional values by setting the `step` attribute. For example, `0.5` will allow half-star ratings. * * ```html * * ``` * * @example Changing the size * Use the `size` attribute to change the rating's size. * * ```html *
*
*
*
* * ``` * * @example Using custom symbols * To customize the symbols shown, use JavaScript to set the `symbolFormatter` property to a function that returns the HTML for each symbol. The function will receive the `value` and `isSelected` arguments that you can use to customize the symbol based on specific values or whether the symbol is in the selected state. * * ```html * * * * ``` * * ```html * * * * ``` * * ```html * * * * ``` * * **Warning:** You should only return trusted HTML from the `symbolFormatter()` function, otherwise you may become vulnerable to XSS exploits. * * @example Readonly ratings * Use the `readonly` attribute to make the rating read-only. * * ```html * * ``` * * @example Disabling * Use the `disabled` attribute to disable the rating. * * ```html * * ``` * * @example Validation * The `required` attribute can be applied to enable validation using the Constraint Validation API. This will prevent form submission until a non-zero value is selected. * * * ```html *
*
* Submit * Reset *
* ``` * * @example Using custom validation * Use the `setCustomValidity()` method to make the rating invalid and show a custom error message on submit. This will override all other validation parameters. 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 ratings 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 *
* * * ``` */ declare class SigveloRating extends SigveloFormControlElement { static formAssociated: boolean; static observeSlots: boolean; static styles: CSSResultGroup; private didDragOverOthers; private draggableRating; private localize; private ratingBoundingClientRect; private valueWhenDraggingStarted; protected get focusableAnchor(): HTMLElement; rating: HTMLElement; isInvalid: boolean; hadUserInteraction: boolean; wasSubmitted: boolean; /** * The rating's label. If you need to provide HTML in the label, use the `label` slot instead. */ label: string; /** * The rating's description. If you need to provide HTML in the description, use the `description` slot instead. */ description: string; /** The name of the rating. This will be submitted with the form as a name/value pair. */ name: string; /** The rating's value. */ value: number; /** Disables the rating. */ disabled: boolean; /** Makes the rating a read-only field. */ readonly: boolean; /** The rating's size. */ size: "xs" | "sm" | "md" | "lg" | "xl"; /** * 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; /** Makes the rating required. Form submission will not be allowed when this is set and the rating is empty. */ required: boolean; /** 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 rating when the page loads or a dialog is shown. */ autofocus: boolean; /** * A function that returns the HTML for each symbol. The function will receive the `value` and `isSelected` arguments * that you can use to customize the symbol based on specific values or whether the symbol is in the selected state. * You should only return trusted HTML from this function, otherwise you may become vulnerable to XSS exploits. */ symbolFormatter: (step: number, isSelected: boolean) => string; connectedCallback(): void; disconnectedCallback(): void; firstUpdated(): void; updated(changedProperties: PropertyValues): void; formDisabledCallback(): 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 clampAndCeilToStep; private handleBlur; private handleFocus; private handleKeyDown; private handleLabelPointerDown; private setValueFromCoordinates; /** Sets the form control's validity */ private updateValidity; /** Sets focus to the rating. */ focus(): void; /** Removes focus from the rating. */ blur(): void; /** * Decreases the rating'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 rating'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-rating": SigveloRating; } } //#endregion export { SigveloRating as t };