See #474.
Time is present almost everywhere in the online world, scheduling appointments, looking for public transport, reminders, deadlines, entity timestamps, etc.
This component should make it easy for users to quickly select a time on any device (PC, mobile, SR).
Same as the date-picker, this is a wrapped form control. (container gets added if not provided by the user).
<input type="time" clrTime>
<clr-time-container>
<input type="time" clrTime>
</clr-time-container>
Typical situation showcase - scheduling an appointment during the working hours (only start time shown). Initial value might be used for editing an existing appointment for example.
<form clrForm>
<clr-time-container [clrView]="TimepickerViewEnum.DIGITAL">
<label>Start time</label>
<input type="time" name="start_time" [clrTime]="initialValue"
clrMinuteStep="5" min="8:30" max="17:00">
</clr-time-container>
</form>
It might be worth to at least partly merge time-picker and date-picker since they are similar components. In the future they will also be used together in a date-time-picker.
This is a new module (but documentation and dev demo pages are of course affected).
Will you introduce new services, components or directives?
Can you describe the basic flow of information between classes?
Very similar to the date-picker. Time input uses the TimeIOService to parse, validate and format user input. When the time-picker popover is open, it uses the TimeNavigationService to change the currently selected time, that gets in turn sent to the input componentand finally the value of the input field is changed too.
No (if I understood it correctly)
Only if it is decided to partly merge date & time pickers.
No
The input component needs to access the native element of its input field to change its value.
I am expecting to finish the first draft within ~10 days of finalizing the design/proposal discussions. Other than a few pointers during the design process, I should not need much help with the actual development. I however have a few gaps in a11y knowledge.
Hey @martinbrom - thanks for starting this component and taking this on. Here is some quick feedback on the initial directive/component design that you have put together. Most of this is re-stating what you proposed but I'm trying to break it down a bit by component or directive and add my preferences / opinions. I also fleshed out the demo templates in order to think through the inputs/outpus and services.
@ Inputs:@ Outputs@ InputI didn't go deep into services yet but it might make sense to share a similar approach that is impleented in the datepicker. e.g
yes, this seems good
If possible we should reuse or extend whats in the datepicker version of this service. May need to extract it / reorganize the files / folders but POC could import it from the datepicker location.
tbd - enhancements
tbd - enhancements
If possible we should reuse or extend whats in the datepicker version of this service. May need to extract it / reorganize the files / folders but POC could import it from the datepicker location. This may mean a small refacotring / renaming of the exiting service
yes, if possible re-use datepicker serivce but may need to rename/refactor a bit.
Yes
<form clrForm>
<clr-time-container>
<label>Basic Time Demo</label>
<input type="time" clrTime name="demo" [(ngModel)]="demo">
</clr-time-container>
</form>
<form clrForm #timeForm="ngForm">
<h4>Template Driven Timepicker</h4>
<clr-time-container>
<label>Enter Time</label>
<input type="time" name="date" [(ngModel)]="date" clrTime>
</clr-time-container>
</form>
<form clrForm [formGroup]="timeForm">
<h4>Reactive Form Demo</h4>
<clr-time-container>
<label>Date</label>
<input type="time" clrTime formControlName="time"/>
</clr-time-container>
</form>
<form clrForm>
<clr-time-container>
<label>Min/Max times: </label>
<input type="time" clrTime name="demo" [(ngModel)]="demo" min="09:00" max="18:00">
</clr-time-container>
</form>
<form clrForm>
<clr-time-container clrPosition="smartPosition">
<label>Position Demo</label>
<input type="time" clrTime name="demo" [(ngModel)]="demo">
</clr-date-container>
</form>
public smartPosition: ClrPopoverPositionsInterface = {
axis: ClrAxis = ClrAxis.VERTICAL;
side: ClrSide = ClrSide.AFTER;
anchor: ClrAlignment.END;
content: ClrAlignment.START;
}
md5-44e43f69e2c05553aef1a027c66787aa
```typescript
public customDateTimeObject = new Date();
@ InputsQuickpicker
Lets use / extend as much as possible from the datepicker for the initial MVP/POC They do need to me merged at some point but I don't want that to get in the way of starting this. Structure is likely to be somethig like
I'm going to try to get one or two other team members to take a look and see if Imissed anything. Feel free to continue the discussion if you have questions or comments on my feedback. Thanks again!
I have a few comments/amendments to the above.
1) I don't want to support Date objects. The biggest reason is timezones, but also that the input[type="time"] format is always in 24h hh:mm or hh:mm:ss format. https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input/time. This means the 'consumer supplied date object' API is not to be supported. It also means you're always dealing with a standard format.
2) I think seconds have to be considered, because HTML spec supports it when using step. Again, follow the HTML input spec tightly.
3) The input should conform to standard HTML attributes like step and min.
4) We don't need a timeChange output, Angular already provides change event handlers for inputs.
5) There should be fewer services (like the view manager service) as compared with the date picker. The date picker has many views to manage, but time is much simpler. Don't force services that don't have a purpose.
Why not use native HTML attribute value as initialValue?
<input type="time" clrTime value="08:15">
@belyan Angular forms track their values using Template Driven or Reactive form approaches. If you aren't using Angular controls, then you can't use clrTime so it's unnecessary to include. The values should always be set in the controller model.
Is this still being worked on?
The feature request here has been captured into our list and we鈥檙e going to take it into consideration as we develop Clarity Core capabilities. In an effort to clean up our backlog and focus our attention, I鈥檓 going to close this as captured in our feature requests. Please follow our development and releases to see when we release relevant components to make this possible. Future feature requests can be made in our GitHub Discussions.
Most helpful comment
Hey @martinbrom - thanks for starting this component and taking this on. Here is some quick feedback on the initial directive/component design that you have put together. Most of this is re-stating what you proposed but I'm trying to break it down a bit by component or directive and add my preferences / opinions. I also fleshed out the demo templates in order to think through the inputs/outpus and services.
ClrTimepicker v1
@ Inputs:2.1 Leave room to add SS (or milliseconds as enhancements later)
2.2 should only take a date object (I need to confirm with the team on this, we initially took both a string and a Date obj for datepicker and it caused a lot of issues. I _think_ we only want to take dates for this input but i'm not 馃挴 on that.
ClrTimepicker v1
@ OutputsClrTimeContainer v1
@ InputServices
I didn't go deep into services yet but it might make sense to share a similar approach that is impleented in the datepicker. e.g
DateIOService (TimeIOService)
yes, this seems good
LocaleHelperService
If possible we should reuse or extend whats in the datepicker version of this service. May need to extract it / reorganize the files / folders but POC could import it from the datepicker location.
TimeNavigationService
tbd - enhancements
ViewManagerService
tbd - enhancements
TimepickerEnabledService
If possible we should reuse or extend whats in the datepicker version of this service. May need to extract it / reorganize the files / folders but POC could import it from the datepicker location. This may mean a small refacotring / renaming of the exiting service
TimepickerFocusService
yes, if possible re-use datepicker serivce but may need to rename/refactor a bit.
TimeFormControlService
Yes
Demos / Example usages
Basic Usage (recomendation should be to use inside the container)
Template drive form
Reactive form
min/max
Consumer supplied position
Future enhancements:
@ Inputs1.1 Input clrView (name pending) - digital, analog (can be done in another iteration)
1.2 I would change clrView to clrTimeMode = ClrTimeView.DIGITAL || ClrTimeView.ANALOG
3.1 - ClrDigitalTime (view / component)
3.2 - ClrAnalogTime (view / component)
Quickpicker
Notes
Lets use / extend as much as possible from the datepicker for the initial MVP/POC They do need to me merged at some point but I don't want that to get in the way of starting this. Structure is likely to be somethig like
I'm going to try to get one or two other team members to take a look and see if Imissed anything. Feel free to continue the discussion if you have questions or comments on my feedback. Thanks again!