Time Duration Input
The TimeDurationInputComponent is an Angular component designed for handling time duration inputs in a user-friendly way. It allows users to specify a time duration along with a unit (e.g., minutes or hours). This component emits changes to the selected duration and unit, making it suitable for applications that require precise time input and flexibility in time units.
How to use the component in your app :
import the component :
import {TimeDurationInputComponent} from '@tradinos/cms-frontend-form';The selector for component , like it :
<lib-cms-time-duration-input></lib-cms-time-duration-input>Features
Time Unit Selection:
Users can choose between predefined time units (e.g., minutes, hours).
Dynamic Value Binding:
Accepts a
TimeDurationobject as input and updates the component dynamically.
Event-Driven Updates:
Emits changes via the
valueChangeoutput whenever the time duration or unit is updated.
Validation States:
Handles
disabledandinvalidstates for seamless integration with forms.
Translation Support:
Time unit labels are translated dynamically using PrimeNG's translation service.
Inputs
Input
Type
Description
Default Value
value
TimeDuration
The initial time duration object containing the unit (key) and value.
-
disabled
boolean | null
Disables the input when set to true.
null
invalid
boolean
Marks the component as invalid when set to true.
false
This is the TimeDuration type:
For example:
Outputs
Output
Type
Description
valueChange
EventEmitter<TimeDuration>
Emits the updated time duration whenever the user modifies the input or changes the unit.
Methods
1. setValue(timeDuration: TimeDuration): void
Description:
Updates the component's state based on the provided
TimeDurationobject.Ensures that the selected unit (
key) and value are synchronized with the input.
Parameters:
timeDuration: An object containingkey(unit) andvalue(time duration).
2. onValueChanged(): void
Description:
Emits the updated time duration through the
valueChangeoutput whenever the user modifies the input or unit.
Parameters: None.
Key Properties
Property
Type
Description
options
Array<{ key, label }>
The available time units (e.g., minutes and hours) with their translated labels.
option
any
The currently selected time unit.
duration
any
The currently entered time duration.
Last updated