import { LitElement, html } from 'lit'; import { customElement, property, state, query } from 'lit/decorators.js'; import { ifDefined } from 'lit/directives/if-defined.js'; import { classMap } from 'lit/directives/class-map.js'; import '@kyndryl-design-system/shidoka-foundation/components/icon'; import TimePickerScss from './timepicker.scss'; /** * Time picker. * @fires on-input - Captures the input event and emits the selected value and original event details. * @prop {string} minTime - Minimum Time in hh:mm format. * @prop {string} maxTime - Maximum Time hh:mm format. * @slot unnamed - Slot for label text. */ @customElement('kyn-time-picker') export class TimePicker extends LitElement { static override styles = [TimePickerScss]; /** @ignore */ static override shadowRootOptions = { ...LitElement.shadowRootOptions, delegatesFocus: true, }; /** * Associate the component with forms. * @ignore */ static formAssociated = true; /** * Attached internals for form association. * @ignore */ @state() internals = this.attachInternals(); /** Input size. "sm", "md", or "lg". */ @property({ type: String }) size = 'md'; /** Optional text beneath the input. */ @property({ type: String }) caption = ''; /** The value of the time input is always in 24-hour format that includes leading zeros: hh:mm, * regardless of the input format, which is likely to be selected based on the user's locale (or by the user agent). * If the time includes seconds (by step attribute), the format is always hh:mm:ss */ @property({ type: String }) value = ''; /** Time input name. */ @property({ type: String }) name = ''; /** Makes the input required. */ @property({ type: Boolean }) required = false; /** Input disabled state. */ @property({ type: Boolean }) disabled = false; /** Time input invalid text. */ @property({ type: String }) invalidText = ''; /** Time input warn text. */ @property({ type: String }) warnText = ''; /** Maximum time in hh:mm or hh:mm:ss format * only must always greater than minTime. */ @property({ type: String }) maxTime!: string; /** Minimum time in hh:mm or hh:mm:ss format * only & must always lesser than maxTime. */ @property({ type: String }) minTime!: string; /** Specifies the granularity that the value must adhere to, or the special value any, * It takes value that equates to the number of seconds you want to increment by; * the default (60 sec.). If you specify a value of less than 60 sec., the time input will show a seconds input area alongside the hours and minutes */ @property({ type: String }) step!: string; /** * Queries the DOM element. * @ignore */ @query('input') inputEl!: HTMLInputElement; /** * Internal validation message. * @ignore */ @state() internalValidationMsg = ''; /** * isInvalid when internalValidationMsg or invalidText is non-empty. * @ignore */ @state() isInvalid = false; override render() { return html`