import SynergyElement from '../../internal/synergy-element.js'; import SynIcon from '../icon/icon.component.js'; import SynDivider from '../divider/divider.component.js'; import type { CSSResultGroup } from 'lit'; import type { SynergyFormControl } from '../../internal/synergy-element.js'; import { type NumericStrategy } from './strategies.js'; /** * @summary Inputs collect data from the user. * @documentation https://synergy-design-system.github.io/?path=/docs/components-syn-input--docs * @status stable * @since 2.0 * * @dependency syn-icon * @dependency syn-divider * * @slot label - The input's label. Alternatively, you can use the `label` attribute. * @slot prefix - Used to prepend a presentational icon or similar element to the input. * @slot suffix - Used to append a presentational icon or similar element to the input. * @slot clear-icon - An icon to use in lieu of the default clear icon. * @slot show-password-icon - An icon to use in lieu of the default show password icon. * @slot hide-password-icon - An icon to use in lieu of the default hide password icon. * @slot help-text - Text that describes how to use the input. Alternatively, you can use the `help-text` attribute. * @slot increment-number-stepper - An icon to use in lieu of the default increment number stepper icon. * @slot decrement-number-stepper - An icon to use in lieu of the default decrement number stepper icon. * * @event syn-blur - Emitted when the control loses focus. * @event syn-change - Emitted when an alteration to the control's value is committed by the user. * @event syn-clear - Emitted when the clear button is activated. * @event syn-focus - Emitted when the control gains focus. * @event syn-input - Emitted when the control receives input. * @event syn-invalid - Emitted when the form control has been checked for validity and its constraints aren't satisfied. * @event syn-clamp - Emitted if the numeric strategy allows autoClamp and the value is clamped to the min or max attribute. * * @csspart form-control - The form control that wraps the label, input, and help text. * @csspart form-control-label - The label's wrapper. * @csspart form-control-input - The input's wrapper. * @csspart form-control-help-text - The help text's wrapper. * @csspart base - The component's base wrapper. * @csspart input - The internal `` control. * @csspart prefix - The container that wraps the prefix. * @csspart clear-button - The clear button. * @csspart password-toggle-button - The password toggle button. * @csspart suffix - The container that wraps the suffix. * @csspart stepper - The container that wraps the number stepper. * @csspart decrement-number-stepper - The decrement number stepper button. * @csspart increment-number-stepper - The increment number stepper button. * @csspart divider - The divider between the increment and decrement number stepper buttons. * * @cssproperty --syn-input-autofill-shadow - The shadow to apply when the input is autofilled. * @cssproperty --syn-input-autofill-readonly-shadow - The shadow to apply when the input is readonly and autofilled. * @cssproperty --syn-input-autofill-text-fill-color - The text fill color to apply when the input is autofilled. * @cssproperty --syn-input-autofill-caret-color - The caret color to apply when the input is autofilled. */ export default class SynInput extends SynergyElement implements SynergyFormControl { #private; static styles: CSSResultGroup; static dependencies: { 'syn-icon': typeof SynIcon; 'syn-divider': typeof SynDivider; }; private readonly formControlController; private readonly hasSlotController; private readonly localize; input: HTMLInputElement; private hasFocus; title: string; private __numberInput; private __dateInput; /** * The type of input. Works the same as a native `` element, but only a subset of types are supported. Defaults * to `text`. */ type: 'date' | 'datetime-local' | 'email' | 'number' | 'password' | 'search' | 'tel' | 'text' | 'time' | 'url'; /** The name of the input, submitted as a name/value pair with form data. */ name: string; /** The current value of the input, submitted as a name/value pair with form data. */ value: string; /** The default value of the form control. Primarily used for resetting the form control. */ defaultValue: string; /** The input's size. */ size: 'small' | 'medium' | 'large'; /** The input's label. If you need to display HTML, use the `label` slot instead. */ label: string; /** The input's help text. If you need to display HTML, use the `help-text` slot instead. */ helpText: string; /** Adds a clear button when the input is not empty. */ clearable: boolean; /** Disables the input. */ disabled: boolean; /** Placeholder text to show as a hint when the input is empty. */ placeholder: string; /** Makes the input readonly. */ readonly: boolean; /** Adds a button to toggle the password's visibility. Only applies to password types. */ passwordToggle: boolean; /** Determines whether or not the password is currently visible. Only applies to password input types. */ passwordVisible: boolean; /** Hides the increment/decrement spin buttons for number inputs. */ noSpinButtons: boolean; /** * By default, form controls are associated with the nearest containing `