diff --git a/README.md b/README.md index 8abad2e..dfdef51 100644 --- a/README.md +++ b/README.md @@ -103,6 +103,7 @@ layout: | type | string | **Required** | `custom:time-picker-card` | | | entity | string | **Required** | [Input Datetime](https://www.home-assistant.io/integrations/input_datetime/) entity with `has_time: true` | | | name | string | **Optional** | Card name | Entity's `friendly_name` | +| link_values | boolean | **Optional** | If enabled, will change hour when minutes overflow. E.g. will go from 11:55 to 12:00, instead of 11:00 | `false` | | hour_mode | `12` or `24` | **Optional** | Hour format. If `12`, card will show AM/PM picker | `24` | | hour_step | number | **Optional** | Hour change when clicking arrows | `1` | | minute_step | number | **Optional** | Minute change when clicking arrows | `5` | diff --git a/src/components/time-unit.component.ts b/src/components/time-unit.component.ts index e867c05..fb40003 100644 --- a/src/components/time-unit.component.ts +++ b/src/components/time-unit.component.ts @@ -16,6 +16,7 @@ import { Direction } from '../types'; @customElement('time-unit') export class TimeUnitComponent extends LitElement { static readonly EVENT_UPDATE = 'update'; + static readonly EVENT_STEP_CHANGE = 'stepChange'; @property() private unit!: TimeUnit; @@ -39,16 +40,12 @@ export class TimeUnitComponent extends LitElement { onInputChange({ target: { value } }: { target: HTMLInputElement }): void { this.unit.setStringValue(value); - this.emitUpdate(); + const event = new CustomEvent(TimeUnitComponent.EVENT_UPDATE); + this.dispatchEvent(event); } onStepChangerClick(direction: Direction): void { - this.unit.stepUpdate(direction); - this.emitUpdate(); - } - - private emitUpdate(): void { - const event = new CustomEvent(TimeUnitComponent.EVENT_UPDATE); + const event = new CustomEvent(TimeUnitComponent.EVENT_STEP_CHANGE, { detail: { direction } }); this.dispatchEvent(event); } diff --git a/src/editor.ts b/src/editor.ts index 7e5a74b..bcbc13f 100644 --- a/src/editor.ts +++ b/src/editor.ts @@ -61,14 +61,15 @@ export class TimePickerCardEditor extends LitElement implements LovelaceCardEdit @value-changed=${this.onValueChange} >