Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

v17.1.0 #109

Merged
merged 2 commits into from
Mar 12, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
266 changes: 137 additions & 129 deletions README.md

Large diffs are not rendered by default.

6 changes: 6 additions & 0 deletions changelog.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
#17.1.0
* Add option `dottedMinutesInGap`
* Fix mini-fab appearance (closes [#105](https://github.com/tonysamperi/ngx-mat-timepicker/issues/105))
* Fix hours init (closes [#108](https://github.com/tonysamperi/ngx-mat-timepicker/issues/108))
* Fixed README

#17.0.3
* Remove ripple

Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "ngx-mat-timepicker-repo",
"version": "17.0.3",
"version": "17.1.0",
"build": 0,
"license": "MIT",
"private": true,
Expand Down
8 changes: 3 additions & 5 deletions projects/ngx-mat-timepicker-repo/src/app/app.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,18 +13,16 @@ import {MatFormFieldModule} from "@angular/material/form-field";
import {MatIconModule} from "@angular/material/icon";
import {MatInputModule} from "@angular/material/input";
import {MatMenuModule} from "@angular/material/menu";
import { MatSelectModule} from "@angular/material/select";
import {MatSelectModule} from "@angular/material/select";
import {MatToolbarModule} from "@angular/material/toolbar";
import {MatTooltipModule} from "@angular/material/tooltip";
//
import {NgxMatTimepickerModule, NgxMatTimepickerLocaleService} from "ngx-mat-timepicker";
import {NgxMatTimepickerModule} from "ngx-mat-timepicker";
//
import {NgxMatTimepickerAppComponent} from "./app.component";
import {NgxMatTimepickerTestComponent, NgxMatTimepickerTestDialogComponent} from "./components/test/test.component";
import {NgxMatTimepickerDemoComponent} from "./components/demo/demo.component";
import {CodeViewerComponent} from "./components/code-viewer/code-viewer.component";
//
import {NgxMatTimepickerLocaleOverrideService} from "./locale-override.service";

@NgModule({
declarations: [NgxMatTimepickerAppComponent],
Expand Down Expand Up @@ -55,7 +53,7 @@ import {NgxMatTimepickerLocaleOverrideService} from "./locale-override.service";
NgxMatTimepickerTestDialogComponent
],
providers: [
// {provide: NgxMatTimepickerLocaleService, useClass: NgxMatTimepickerLocaleOverrideService}
// {provide: NgxMatTimepickerLocaleService, useClass: NgxMatTimepickerLocaleOverrideService}
],
bootstrap: [NgxMatTimepickerAppComponent]
})
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ <h2 class="mat-h2">
</div>
<form class="demo-form">
<div>
<h2>Picker with 12h format</h2>
<h2>Picker with 12h format and "dottedMinutesInGap"</h2>
<p>using <span class="mat-color-primary">default</span> palette (primary)</p>
<code-viewer>
<div class="example ngx-mtp-d-flex ngx-mtp-align-center ngx-mtp-flex-column">
Expand All @@ -155,6 +155,7 @@ <h2>Picker with 12h format</h2>
(click)="selectedTimes.A = undefined">clear
</button>
<ngx-mat-timepicker #pickerA
dottedMinutesInGap
enableKeyboardInput
(timeSet)="onTimeSet($event)"></ngx-mat-timepicker>
</div>
Expand All @@ -172,7 +173,10 @@ <h2>Picker with 12h format</h2>
watch_later
&lt;/mat-icon&gt;
&lt;/mat-form-field&gt;
&lt;ngx-mat-timepicker #pickerA>&lt;/ngx-mat-timepicker&gt;
&lt;ngx-mat-timepicker #pickerA
dottedMinutesInGap
enableKeyboardInput
(timeSet)="onTimeSet($event)"&gt;&lt;/ngx-mat-timepicker&gt;
</code>
</pre>
</code-viewer>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@
<ng-container *ngFor="let locale of myLocaleKeys; let last=last">
<span class="locale"
[class.active]="locale === currentLocaleKey"
(click)="updateLocale(locale)">{{locale}}</span><span class="separator"
*ngIf="!last"> | </span>
(click)="updateLocale(locale)">{{ locale }}</span><span class="separator"
*ngIf="!last"> | </span>
</ng-container>
</p>
<button mat-raised-button
Expand Down Expand Up @@ -62,18 +62,19 @@ <h2>Picker with 12h format</h2>
<!-- <ngx-mat-timepicker-->
<!-- #timepicker-->
<!-- [enableKeyboardInput]="true"></ngx-mat-timepicker>-->
<button (click)="openDialog()"
mat-button
color="primary">OPEN DIALOG</button>
<!-- <button (click)="openDialog()"-->
<!-- mat-button-->
<!-- color="primary">OPEN DIALOG-->
<!-- </button>-->

<ngx-mat-timepicker-field
color="warn"
[format]="24"
[defaultTime]="time"
(timeChanged)="time = $event"
[controlOnly]="true"
[min]="minTime"
></ngx-mat-timepicker-field>
<p>{{time}}</p>
<p>{{ time }}</p>

</div>
<pre class="language-markup">
Expand All @@ -91,5 +92,5 @@ <h2>Picker with 12h format</h2>
target="_blank">Tony
Samperi</a>
</p>
<p>© <span>{{year}}</span> MIT License</p>
<p>© <span>{{ year }}</span> MIT License</p>
</footer>
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import {Component, ViewChild} from "@angular/core";
import {FormControl, Validators, FormsModule} from "@angular/forms";
import {FormControl, Validators, FormsModule, ReactiveFormsModule} from "@angular/forms";
import {MatDialog, MatDialogModule} from "@angular/material/dialog";
import {MatInputModule} from "@angular/material/input";
import {MatInputModule, MatLabel} from "@angular/material/input";
import {MatFormFieldModule} from "@angular/material/form-field";
import {CodeViewerComponent} from "../code-viewer/code-viewer.component";
import {MatButtonModule} from "@angular/material/button";
Expand Down Expand Up @@ -37,13 +37,21 @@ import {NgxMatTimepickerDemoComponent} from "../demo/demo.component";
(click)="pickerA.open()">watch_later
</mat-icon>
</mat-form-field>
<p>FIELD FOCUSED: {{foo.focused}}</p>
<p>FIELD FOCUSED: {{ foo.focused }}</p>
<ngx-mat-timepicker appendToInput="true"
#pickerA></ngx-mat-timepicker>
</div>
`,
standalone: true,
imports: [MatDialogModule, MatFormFieldModule, MatInputModule, FormsModule, NgxMatTimepickerDirective, MatIconModule, NgxMatTimepickerComponent]
imports: [
FormsModule,
MatDialogModule,
MatFormFieldModule,
MatIconModule,
MatInputModule,
NgxMatTimepickerComponent,
NgxMatTimepickerDirective
]
})
export class NgxMatTimepickerTestDialogComponent {
date: string = "2:00";
Expand All @@ -55,13 +63,29 @@ export class NgxMatTimepickerTestDialogComponent {
templateUrl: "test.component.html",
styleUrls: ["test.component.scss"],
standalone: true,
imports: [MatToolbarModule, NgFor, NgIf, MatButtonModule, FormsModule, CodeViewerComponent, NgxMatTimepickerFieldComponent]
imports: [
CodeViewerComponent,
FormsModule,
MatButtonModule,
MatFormFieldModule,
MatIconModule,
MatInputModule,
MatLabel,
MatToolbarModule,
NgFor,
NgIf,
NgxMatTimepickerComponent,
NgxMatTimepickerDirective,
NgxMatTimepickerFieldComponent,
ReactiveFormsModule
]
})
export class NgxMatTimepickerTestComponent extends NgxMatTimepickerDemoComponent {

formControlItem: FormControl = new FormControl("", [Validators.pattern(/([0-9]|[1-2]\d):[0-5]\d/)]);
time: string = "00:00";
@ViewChild("timepicker") timepicker: NgxMatTimepickerComponent;
@ViewChild("timepicker")
private _timepicker: NgxMatTimepickerComponent;

constructor(private _matDialog: MatDialog, localeOverrideSrv: NgxMatTimepickerLocaleService) {
super(localeOverrideSrv);
Expand Down
2 changes: 1 addition & 1 deletion projects/ngx-mat-timepicker/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "ngx-mat-timepicker",
"version": "17.0.3",
"version": "17.1.0",
"license": "MIT",
"description": "ngx-mat-timepicker is an Angular material 9+ extension to add time pickers!",
"homepage": "https://tonysamperi.github.io/ngx-mat-timepicker",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
import {ChangeDetectionStrategy, Component, EventEmitter, Input, OnChanges, Output, SimpleChanges} from "@angular/core";
import { NgClass } from "@angular/common";
import { FormsModule } from "@angular/forms";
import { MatInputModule } from "@angular/material/input";
import {NgClass} from "@angular/common";
import {FormsModule} from "@angular/forms";
import {MatInputModule} from "@angular/material/input";
import {ThemePalette} from "@angular/material/core";
import { FloatLabelType, MatFormFieldModule } from "@angular/material/form-field";
import {FloatLabelType, MatFormFieldModule} from "@angular/material/form-field";
//
import {NgxMatTimepickerUnits} from "../../models/ngx-mat-timepicker-units.enum";
import {NgxMatTimepickerParserPipe} from "../../pipes/ngx-mat-timepicker-parser.pipe";
import {NgxMatTimepickerClockFace} from "../../models/ngx-mat-timepicker-clock-face.interface";
import {NgxMatTimepickerUtils} from "../../utils/ngx-mat-timepicker.utils";
import { NgxMatTimepickerTimeLocalizerPipe } from "../../pipes/ngx-mat-timepicker-time-localizer.pipe";
import {NgxMatTimepickerTimeLocalizerPipe} from "../../pipes/ngx-mat-timepicker-time-localizer.pipe";

function concatTime(currentTime: string, nextTime: string): number | undefined {
const isNumber = /\d/.test(nextTime);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,84 +1,85 @@
<ng-template #cancelBtnDefault>
<button mat-button
[color]="color">CANCEL
</button>
<button mat-button
[color]="color">CANCEL
</button>
</ng-template>
<ng-template #confirmBtnDefault>
<button mat-button
[color]="color">OK
</button>
<button mat-button
[color]="color">OK
</button>
</ng-template>
<div mat-dialog-content>
<ngx-mat-timepicker-content [appendToInput]="data.appendToInput"
[inputElement]="data.inputElement">
<div class="timepicker"
[ngClass]="data.timepickerClass">
<mat-toolbar [color]="color"
[class.is-editable]="data.enableKeyboardInput"
class="timepicker-header">
<ngx-mat-timepicker-dial [color]="color"
[format]="data.format"
[hour]="(selectedHour | async)?.time"
[minute]="(selectedMinute | async)?.time"
[period]="selectedPeriod | async"
[activeTimeUnit]="activeTimeUnit"
[minTime]="data.minTime"
[maxTime]="data.maxTime"
[isEditable]="data.enableKeyboardInput"
[editableHintTmpl]="data.editableHintTmpl"
[minutesGap]="data.minutesGap"
[hoursOnly]="data.hoursOnly"
(periodChanged)="changePeriod($event)"
(timeUnitChanged)="changeTimeUnit($event)"
(hourChanged)="onHourChange($event)"
(minuteChanged)="onMinuteChange($event)"
></ngx-mat-timepicker-dial>
</mat-toolbar>
<div class="timepicker__main-content">
<div class="timepicker__body"
[ngSwitch]="activeTimeUnit">
<div *ngSwitchCase="timeUnit.HOUR">
<ngx-mat-timepicker-24-hours-face *ngIf="data.format === 24;else ampmHours"
[color]="color"
(hourChange)="onHourChange($event)"
[selectedHour]="selectedHour | async"
[minTime]="data.minTime"
[maxTime]="data.maxTime"
[format]="data.format"
(hourSelected)="onHourSelected($event)"></ngx-mat-timepicker-24-hours-face>
<ng-template #ampmHours>
<ngx-mat-timepicker-12-hours-face
[color]="color"
(hourChange)="onHourChange($event)"
[selectedHour]="selectedHour | async"
[period]="selectedPeriod | async"
[minTime]="data.minTime"
[maxTime]="data.maxTime"
(hourSelected)="onHourSelected($event)"></ngx-mat-timepicker-12-hours-face>
</ng-template>
</div>
<ngx-mat-timepicker-minutes-face *ngSwitchCase="timeUnit.MINUTE"
[color]="color"
[selectedMinute]="selectedMinute | async"
[selectedHour]="(selectedHour | async)?.time"
[minTime]="data.minTime"
[maxTime]="data.maxTime"
[format]="data.format"
[period]="selectedPeriod | async"
[minutesGap]="data.minutesGap"
(minuteChange)="onMinuteChange($event)"></ngx-mat-timepicker-minutes-face>
</div>
</div>
</div>
</ngx-mat-timepicker-content>
<ngx-mat-timepicker-content [appendToInput]="data.appendToInput"
[inputElement]="data.inputElement">
<div class="timepicker"
[ngClass]="data.timepickerClass">
<mat-toolbar [color]="color"
[class.is-editable]="data.enableKeyboardInput"
class="timepicker-header">
<ngx-mat-timepicker-dial [color]="color"
[format]="data.format"
[hour]="(selectedHour | async)?.time"
[minute]="(selectedMinute | async)?.time"
[period]="selectedPeriod | async"
[activeTimeUnit]="activeTimeUnit"
[minTime]="data.minTime"
[maxTime]="data.maxTime"
[isEditable]="data.enableKeyboardInput"
[editableHintTmpl]="data.editableHintTmpl"
[minutesGap]="data.minutesGap"
[hoursOnly]="data.hoursOnly"
(periodChanged)="changePeriod($event)"
(timeUnitChanged)="changeTimeUnit($event)"
(hourChanged)="onHourChange($event)"
(minuteChanged)="onMinuteChange($event)"
></ngx-mat-timepicker-dial>
</mat-toolbar>
<div class="timepicker__main-content">
<div class="timepicker__body"
[ngSwitch]="activeTimeUnit">
<div *ngSwitchCase="timeUnit.HOUR">
<ngx-mat-timepicker-24-hours-face *ngIf="data.format === 24;else ampmHours"
[color]="color"
(hourChange)="onHourChange($event)"
[selectedHour]="selectedHour | async"
[minTime]="data.minTime"
[maxTime]="data.maxTime"
[format]="data.format"
(hourSelected)="onHourSelected($event)"></ngx-mat-timepicker-24-hours-face>
<ng-template #ampmHours>
<ngx-mat-timepicker-12-hours-face
[color]="color"
(hourChange)="onHourChange($event)"
[selectedHour]="selectedHour | async"
[period]="selectedPeriod | async"
[minTime]="data.minTime"
[maxTime]="data.maxTime"
(hourSelected)="onHourSelected($event)"></ngx-mat-timepicker-12-hours-face>
</ng-template>
</div>
<ngx-mat-timepicker-minutes-face *ngSwitchCase="timeUnit.MINUTE"
[color]="color"
[dottedMinutesInGap]="data.dottedMinutesInGap"
[selectedMinute]="selectedMinute | async"
[selectedHour]="(selectedHour | async)?.time"
[minTime]="data.minTime"
[maxTime]="data.maxTime"
[format]="data.format"
[period]="selectedPeriod | async"
[minutesGap]="data.minutesGap"
(minuteChange)="onMinuteChange($event)"></ngx-mat-timepicker-minutes-face>
</div>
</div>
</div>
</ngx-mat-timepicker-content>
</div>
<div mat-dialog-actions>
<div (click)="close()">
<ng-container
*ngTemplateOutlet="data.cancelBtnTmpl ? data.cancelBtnTmpl : cancelBtnDefault"></ng-container>
</div>
<div (click)="setTime()">
<ng-container
*ngTemplateOutlet="data.confirmBtnTmpl ? data.confirmBtnTmpl : confirmBtnDefault"></ng-container>
</div>
<div (click)="close()">
<ng-container
*ngTemplateOutlet="data.cancelBtnTmpl ? data.cancelBtnTmpl : cancelBtnDefault"></ng-container>
</div>
<div (click)="setTime()">
<ng-container
*ngTemplateOutlet="data.confirmBtnTmpl ? data.confirmBtnTmpl : confirmBtnDefault"></ng-container>
</div>
</div>
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,17 @@
<div class="clock-face__number clock-face__number--outer"
[ngStyle]="{'transform': 'rotateZ('+ time.angle +'deg)'}"
*ngFor="let time of faceTime; trackBy: trackByTime">
<input #current
type="hidden"
[value]="time.time | minutesFormatter: minutesGap | timeLocalizer: timeUnit.MINUTE" />
<button mat-mini-fab
disableRipple
class="mat-elevation-z0"
[class.dot]="dottedMinutesInGap && current.value === '' && !(time.time | activeMinute: selectedTime?.time:1:isClockFaceDisabled)"
[color]="(time.time | activeMinute: selectedTime?.time:minutesGap:isClockFaceDisabled) ? color : undefined"
[ngStyle]="{'transform': 'rotateZ(-'+ time.angle +'deg)'}"
[disabled]="time.disabled">
{{time.time | minutesFormatter: minutesGap | timeLocalizer: timeUnit.MINUTE}}
{{current.value}}
</button>
</div>
</div>
Expand Down
Loading
Loading