-
Notifications
You must be signed in to change notification settings - Fork 38
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(timepicker): component TimePicker (#42)
- Loading branch information
1 parent
e452e71
commit e23a9bd
Showing
15 changed files
with
1,208 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
import { | ||
Component, | ||
NgModule, | ||
ViewEncapsulation | ||
} from '@angular/core'; | ||
|
||
import { FormsModule } from '@angular/forms'; | ||
import { BrowserModule } from '@angular/platform-browser'; | ||
import { platformBrowserDynamic } from '@angular/platform-browser-dynamic'; | ||
import { McFormFieldModule } from '@ptsecurity/mosaic/form-field'; | ||
import { McTimepickerModule } from '@ptsecurity/mosaic/timepicker'; | ||
|
||
import { McButtonModule } from '../../lib/button'; | ||
import { McIconModule } from '../../lib/icon'; | ||
|
||
|
||
@Component({ | ||
selector: 'app', | ||
styleUrls: ['./styles.css'], | ||
template: require('./template.html'), | ||
encapsulation: ViewEncapsulation.None | ||
}) | ||
export class TimepickerDemoComponent { | ||
timeValue1: Date = new Date(); | ||
timeValue2: Date = new Date(); | ||
isDisabled: boolean = false; | ||
|
||
toggleDisable() { | ||
this.isDisabled = !this.isDisabled; | ||
} | ||
} | ||
|
||
@NgModule({ | ||
declarations: [ | ||
TimepickerDemoComponent | ||
], | ||
imports: [ | ||
BrowserModule, | ||
FormsModule, | ||
McTimepickerModule, | ||
McFormFieldModule, | ||
McButtonModule, | ||
McIconModule | ||
], | ||
bootstrap: [ | ||
TimepickerDemoComponent | ||
] | ||
}) | ||
export class TimepickerDemoModule {} | ||
|
||
|
||
platformBrowserDynamic() | ||
.bootstrapModule(TimepickerDemoModule) | ||
.catch((error) => console.error(error)); // tslint:disable-line no-console |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
@import '~@ptsecurity/mosaic-icons/dist/styles/mc-icons'; | ||
@import '../../lib/core/theming/prebuilt/default-theme'; | ||
|
||
.demo-timepicker_full { | ||
width: 150px; | ||
} | ||
|
||
.demo-timepicker_short { | ||
width: 120px; | ||
} | ||
|
||
header { | ||
$config: mc-typography-config(); | ||
|
||
@include mc-typography-level-to-styles($config, caption); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
<div class="mc-headline">Timepicker</div> | ||
<div class="mc-body"> | ||
<h3 class="mc-title">Example 1</h3> | ||
<p>Params:</p> | ||
<ul> | ||
<li><span class="mc-body_mono">min-time="10:00:00"</span><br> | ||
<li><span class="mc-body_mono">max-time="13:30:00"</span><br> | ||
<li><span class="mc-body_mono">format `HH:mm:ss`</span> | ||
</ul> | ||
|
||
|
||
<div> | ||
<button mc-button (click)="toggleDisable()">Toggle disabled state</button> | ||
<br> | ||
<span class="mc-small-text">current disable state === {{isDisabled}}</span> | ||
</div> | ||
<br> | ||
|
||
<section class="demo-timepicker_full"> | ||
<mc-form-field > | ||
<i mcPrefix mc-icon="mc-clock_16"></i> | ||
<input mcTimepicker | ||
[(ngModel)]="timeValue1" | ||
time-format="HH:mm:ss" | ||
min-time="10:00:00" | ||
max-time="13:30:00" | ||
[disabled]="isDisabled"> | ||
</mc-form-field> | ||
</section> | ||
|
||
<br> | ||
|
||
<p class="mc-caption_mono" *ngIf="timeValue1 !== null"> | ||
Current time value: | ||
{{timeValue1.getHours()}}: | ||
{{timeValue1.getMinutes()}}: | ||
{{timeValue1.getSeconds()}} | ||
</p> | ||
|
||
<p class="mc-caption_mono" *ngIf="timeValue1 === null"> Incorrect input - null result</p> | ||
|
||
<br> | ||
|
||
<!--<h4>No any validation, format `HH:mm`, no icon:</h4>--> | ||
<!--<mc-timepicker [(ngModel)]="timeValue2"--> | ||
<!--time-format="HH:mm">--> | ||
<!--</mc-timepicker>--> | ||
<!--<br>--> | ||
<!--<p>Current time value: {{timeValue2.getHours()}}:{{timeValue2.getMinutes()}}:{{timeValue2.getSeconds()}}</p>--> | ||
|
||
</div> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
export * from './public-api'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
export * from './timepicker.module'; | ||
export * from './timepicker.constants'; | ||
export * from './timepicker'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
export enum TimeParts { | ||
hours, | ||
minutes, | ||
seconds | ||
} | ||
|
||
export enum TimeFormats { | ||
HHmmss = 'HH:mm:ss', | ||
HHmm = 'HH:mm' | ||
} | ||
|
||
export const TIMEFORMAT_PLACEHOLDERS: { [timeFormat: string]: string } = { | ||
'hh:mm:ss': ' : : ', | ||
'hh:mm': ' : ' | ||
}; | ||
|
||
export const DEFAULT_TIME_FORMAT: TimeFormats = TimeFormats.HHmm; | ||
|
||
export const HOURS_MINUTES_SECONDS_REGEXP = | ||
new RegExp(/^([0-9]|0[0-9]|1[0-9]|2[0-3]):([0-5][0-9]|[0-9]):([0-5][0-9]|[0-9])?$/); | ||
export const HOURS_MINUTES_REGEXP = /^([0-9]|0[0-9]|1[0-9]|2[0-3]):([0-5][0-9]|[0-9])?$/; | ||
export const HOURS_ONLY_REGEXP = /^([0-9]|0[0-9]|1[0-9]|2[0-3]):?$/; | ||
|
||
export const SECONDS_PER_MINUTE: number = 59; | ||
export const MINUTES_PER_HOUR: number = 59; | ||
export const HOURS_PER_DAY: number = 23; | ||
|
||
// TODO Move it to common CDK | ||
export const ARROW_UP_KEYCODE: string = 'ArrowUp'; | ||
export const ARROW_DOWN_KEYCODE: string = 'ArrowDown'; | ||
export const ARROW_LEFT_KEYCODE: string = 'ArrowLeft'; | ||
export const ARROW_RIGHT_KEYCODE: string = 'ArrowRight'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
import { CommonModule } from '@angular/common'; | ||
import { NgModule } from '@angular/core'; | ||
import { FormsModule } from '@angular/forms'; | ||
|
||
import { A11yModule } from '@ptsecurity/cdk/a11y'; | ||
import { PlatformModule } from '@ptsecurity/cdk/platform'; | ||
|
||
import { McTimepicker } from './timepicker'; | ||
|
||
|
||
@NgModule({ | ||
imports: [ | ||
CommonModule, | ||
A11yModule, | ||
PlatformModule, | ||
FormsModule | ||
], | ||
declarations: [ | ||
McTimepicker | ||
], | ||
exports: [ | ||
McTimepicker | ||
] | ||
}) | ||
export class McTimepickerModule {} |
Oops, something went wrong.