@hug/ngx-time-picker 21.0.2 → 22.0.0-alpha.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +6 -0
- package/fesm2022/{hug-ngx-time-picker-testing.mjs → hug-ngx-time-picker-m2-testing.mjs} +1 -1
- package/fesm2022/hug-ngx-time-picker-m2-testing.mjs.map +1 -0
- package/fesm2022/hug-ngx-time-picker-m2.mjs +228 -0
- package/fesm2022/hug-ngx-time-picker-m2.mjs.map +1 -0
- package/fesm2022/hug-ngx-time-picker.mjs +2 -222
- package/fesm2022/hug-ngx-time-picker.mjs.map +1 -1
- package/package.json +11 -6
- package/types/hug-ngx-time-picker-m2.d.ts +66 -0
- package/types/hug-ngx-time-picker.d.ts +2 -65
- package/fesm2022/hug-ngx-time-picker-testing.mjs.map +0 -1
- /package/types/{hug-ngx-time-picker-testing.d.ts → hug-ngx-time-picker-m2-testing.d.ts} +0 -0
package/CHANGELOG.md
CHANGED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"hug-ngx-time-picker-m2-testing.mjs","sources":["../../../projects/time-picker/m2/testing/time-picker-harness.ts","../../../projects/time-picker/m2/testing/hug-ngx-time-picker-m2-testing.ts"],"sourcesContent":["import { HarnessPredicate, TestKey } from '@angular/cdk/testing';\nimport { MatFormFieldControlHarness } from '@angular/material/form-field/testing/control';\nimport { MatInputHarness } from '@angular/material/input/testing';\n\nimport { NgxTimePickerHarnessFilters } from './time-picker-harness-filters';\n\n/** Harness for interacting with a ngx time picker in tests. */\nexport class NgxTimePickerHarness extends MatFormFieldControlHarness {\n\n // eslint-disable-next-line @typescript-eslint/naming-convention\n public static hostSelector = 'ngx-time-picker';\n\n static with(options: NgxTimePickerHarnessFilters = {}): HarnessPredicate<NgxTimePickerHarness> {\n return new HarnessPredicate(NgxTimePickerHarness, options).addOption('value', options.value, (harness, value) => HarnessPredicate.stringMatches(harness.getValue(), value));\n }\n\n public async getHoursInput(): Promise<MatInputHarness> {\n return (await this.locatorFactory.harnessLoaderFor('.hours')).getHarness(MatInputHarness.with({ selector: '[matInput]' }));\n }\n\n public async getMinutesInput(): Promise<MatInputHarness> {\n return (await this.locatorFactory.harnessLoaderFor('.minutes')).getHarness(MatInputHarness.with({ selector: '[matInput]' }));\n }\n\n public async setValue(value: string): Promise<void> {\n const hoursMinutes = value.split(':');\n\n if (hoursMinutes[0].length) {\n await this.getHoursInput().then(async hoursInput => {\n await hoursInput.host().then(async hoursElement => {\n await hoursElement.clear();\n await hoursInput.setValue(hoursMinutes[0]);\n await hoursInput.blur();\n });\n });\n }\n\n if (hoursMinutes[1].length) {\n await this.getMinutesInput().then(async minutesInput => {\n await minutesInput.host().then(async minutesElement => {\n await minutesElement.clear();\n await minutesInput.setValue(hoursMinutes[1]);\n await minutesElement.blur();\n });\n });\n }\n }\n\n public async getValue(): Promise<string> {\n return this.getHoursValue().then(hoursValue => this.getMinutesValue().then(minutesValue => `${hoursValue}:${minutesValue}`));\n }\n\n public async getHoursValue(): Promise<string> {\n return this.getHoursInput().then(hoursInput => hoursInput.getValue());\n }\n\n public async getMinutesValue(): Promise<string> {\n return this.getMinutesInput().then(minutesInput => minutesInput.getValue());\n }\n\n public async sendKeysToHoursInput(...keys: readonly TestKey[]): Promise<void> {\n return this.getHoursInput().then(async hoursInput => {\n await hoursInput.host().then(async hoursElement => {\n await hoursElement.sendKeys(...keys);\n });\n });\n }\n\n public async sendKeysToMinutesInput(...keys: readonly TestKey[]): Promise<void> {\n return this.getMinutesInput().then(async minutesInput => {\n await minutesInput.host().then(async minutesElement => {\n await minutesElement.sendKeys(...keys);\n });\n });\n }\n}\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './index';\n"],"names":[],"mappings":";;;;AAMA;AACM,MAAO,oBAAqB,SAAQ,0BAA0B,CAAA;;AAGzD,IAAA,OAAO,YAAY,GAAG,iBAAiB;AAE9C,IAAA,OAAO,IAAI,CAAC,OAAA,GAAu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OAAO,IAAI,CAAC,eAAe,EAAE,CAAC,IAAI,CAAC,OAAM,YAAY,KAAG;YACpD,MAAM,YAAY,CAAC,IAAI,EAAE,CAAC,IAAI,CAAC,OAAM,cAAc,KAAG;AAClD,gBAAA,MAAM,cAAc,CAAC,QAAQ,CAAC,GAAG,IAAI,CAAC;AAC1C,YAAA,CAAC,CAAC;AACN,QAAA,CAAC,CAAC;IACN;;;AC1EJ;;AAEG;;;;"}
|
|
@@ -0,0 +1,228 @@
|
|
|
1
|
+
import { coerceBooleanProperty, coerceNumberProperty } from '@angular/cdk/coercion';
|
|
2
|
+
import { DecimalPipe } from '@angular/common';
|
|
3
|
+
import * as i0 from '@angular/core';
|
|
4
|
+
import { EventEmitter, inject, ChangeDetectorRef, Input, Output, ViewChild, ViewEncapsulation, ChangeDetectionStrategy, Component } from '@angular/core';
|
|
5
|
+
import { takeUntilDestroyed } from '@angular/core/rxjs-interop';
|
|
6
|
+
import * as i1 from '@angular/forms';
|
|
7
|
+
import { NgControl, FormsModule } from '@angular/forms';
|
|
8
|
+
import * as i2 from '@angular/material/form-field';
|
|
9
|
+
import { MatFormFieldModule } from '@angular/material/form-field';
|
|
10
|
+
import * as i3 from '@angular/material/input';
|
|
11
|
+
import { MatInputModule } from '@angular/material/input';
|
|
12
|
+
import { NgxNumericStepperComponent } from '@hug/ngx-numeric-stepper/m2';
|
|
13
|
+
import { set } from 'date-fns';
|
|
14
|
+
import { Subject, distinctUntilChanged, map, tap, debounceTime, switchMap, EMPTY, timer, mergeWith } from 'rxjs';
|
|
15
|
+
|
|
16
|
+
class NgxTimePickerComponent {
|
|
17
|
+
hours;
|
|
18
|
+
minutes;
|
|
19
|
+
timeChange = new EventEmitter();
|
|
20
|
+
/** Display mode for the time-picker */
|
|
21
|
+
mode = 'fullTime';
|
|
22
|
+
/**
|
|
23
|
+
* Force the hour or minute to be null (only if the other field is disabled)
|
|
24
|
+
*
|
|
25
|
+
* For instance, if set to true and the hours are disabled, the minutes input value will be null
|
|
26
|
+
* This is useful to force the user to provide a value
|
|
27
|
+
*/
|
|
28
|
+
forceNullValue = false;
|
|
29
|
+
appearance = 'outline';
|
|
30
|
+
set autoFocus(value) {
|
|
31
|
+
this._autoFocus = coerceBooleanProperty(value);
|
|
32
|
+
}
|
|
33
|
+
defaultPlaceholderHours = '_ _';
|
|
34
|
+
defaultPlaceholderMinutes = '_ _';
|
|
35
|
+
set time(value) {
|
|
36
|
+
this.writeValue(value);
|
|
37
|
+
}
|
|
38
|
+
get time() {
|
|
39
|
+
return this.value;
|
|
40
|
+
}
|
|
41
|
+
/** Step of the arrows */
|
|
42
|
+
set step(value) {
|
|
43
|
+
this._step = coerceNumberProperty(value);
|
|
44
|
+
this.changeDetectorRef.markForCheck();
|
|
45
|
+
}
|
|
46
|
+
/** To get the step of the minutes arrows */
|
|
47
|
+
get step() {
|
|
48
|
+
return this._step;
|
|
49
|
+
}
|
|
50
|
+
/** Disabled property setter. Can be string or empty so you can use it like : <time-picker disabled></time-picker> */
|
|
51
|
+
set disabled(value) {
|
|
52
|
+
this._disabled = coerceBooleanProperty(value);
|
|
53
|
+
this.changeDetectorRef.markForCheck();
|
|
54
|
+
}
|
|
55
|
+
/** To get disabled attribute. */
|
|
56
|
+
get disabled() {
|
|
57
|
+
return this._disabled;
|
|
58
|
+
}
|
|
59
|
+
hoursChange$ = new Subject();
|
|
60
|
+
minutesChange$ = new Subject();
|
|
61
|
+
hoursKeyDown$ = new Subject();
|
|
62
|
+
changeDetectorRef = inject(ChangeDetectorRef);
|
|
63
|
+
control = inject(NgControl, { optional: true, self: true });
|
|
64
|
+
_step = 1;
|
|
65
|
+
_disabled = false;
|
|
66
|
+
_value;
|
|
67
|
+
_autoFocus = true;
|
|
68
|
+
constructor() {
|
|
69
|
+
if (this.control) {
|
|
70
|
+
this.control.valueAccessor = this;
|
|
71
|
+
}
|
|
72
|
+
const hoursChange$ = this.hoursChange$.pipe(distinctUntilChanged(), map(hours => {
|
|
73
|
+
if (typeof hours === 'object') {
|
|
74
|
+
const value = hours.target.value;
|
|
75
|
+
return [value !== undefined ? parseInt(value, 10) : undefined, true];
|
|
76
|
+
}
|
|
77
|
+
return [!isNaN(hours) ? hours : 0, false];
|
|
78
|
+
}), tap(([hours, _isEvent]) => {
|
|
79
|
+
const newValue = this.value ? new Date(this.value.getTime()) : new Date();
|
|
80
|
+
if (hours !== undefined) {
|
|
81
|
+
newValue.setHours(hours);
|
|
82
|
+
}
|
|
83
|
+
if (this.mode === 'fullTime' || this.mode === 'fullTimeWithMinutesDisabled' || this.mode === 'hoursOnly') {
|
|
84
|
+
this.value = newValue;
|
|
85
|
+
}
|
|
86
|
+
this.changeDetectorRef.markForCheck();
|
|
87
|
+
}));
|
|
88
|
+
const minutesChange$ = this.minutesChange$.pipe(distinctUntilChanged(), map(event => {
|
|
89
|
+
let minutes;
|
|
90
|
+
if (typeof event === 'object') {
|
|
91
|
+
const value = event.target.value;
|
|
92
|
+
minutes = value !== undefined ? parseInt(value, 10) : undefined;
|
|
93
|
+
}
|
|
94
|
+
else {
|
|
95
|
+
minutes = event;
|
|
96
|
+
}
|
|
97
|
+
return minutes && !isNaN(minutes) && minutes || 0;
|
|
98
|
+
}), tap(minutes => {
|
|
99
|
+
const newValue = this.value ? new Date(this.value.getTime()) : new Date();
|
|
100
|
+
if (minutes < 0) {
|
|
101
|
+
minutes += 60;
|
|
102
|
+
}
|
|
103
|
+
else if (minutes >= 60) {
|
|
104
|
+
minutes -= 60;
|
|
105
|
+
}
|
|
106
|
+
newValue.setMinutes(minutes);
|
|
107
|
+
if (this.mode === 'fullTime' || this.mode === 'fullTimeWithHoursDisabled' || this.mode === 'minutesOnly') {
|
|
108
|
+
this.value = newValue;
|
|
109
|
+
}
|
|
110
|
+
this.changeDetectorRef.markForCheck();
|
|
111
|
+
}));
|
|
112
|
+
const setFocusToNextInput$ = this.hoursKeyDown$.pipe(debounceTime(200), switchMap(event => {
|
|
113
|
+
const inputElement = this.hours?.nativeElement;
|
|
114
|
+
if (!inputElement) {
|
|
115
|
+
return EMPTY;
|
|
116
|
+
}
|
|
117
|
+
if (event.key && !event.ctrlKey && !event.shiftKey && !event.altKey && !['ArrowUp', 'ArrowDown', 'ArrowLeft', 'ArrowRight', 'Backspace', 'Delete', 'Tab', 'Enter', 'Control', 'Shift'].includes(event.key)) {
|
|
118
|
+
const regex = /^(\d|[01]\d|2[0-3])$/;
|
|
119
|
+
const [selectionStart, selectionEnd] = [inputElement.selectionStart || 0, inputElement.selectionEnd || 0].sort((a, b) => a - b);
|
|
120
|
+
const inputValue = inputElement.value || '';
|
|
121
|
+
if (regex.test(inputValue) && this._autoFocus && inputValue.length === 2 && this.minutes?.nativeElement && inputElement === document.activeElement && selectionStart === 2 && selectionEnd === 2) {
|
|
122
|
+
this.minutes.nativeElement.focus();
|
|
123
|
+
return timer(0).pipe(tap(() => {
|
|
124
|
+
this.minutes?.nativeElement.select();
|
|
125
|
+
}));
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
return EMPTY;
|
|
129
|
+
}));
|
|
130
|
+
hoursChange$.pipe(mergeWith(minutesChange$, setFocusToNextInput$), takeUntilDestroyed()).subscribe();
|
|
131
|
+
}
|
|
132
|
+
// ************* ControlValueAccessor Implementation **************
|
|
133
|
+
/** set accessor including call the onchange callback */
|
|
134
|
+
set value(v) {
|
|
135
|
+
if (v !== this._value) {
|
|
136
|
+
this.writeValue(v);
|
|
137
|
+
this.onChangeCallback(v);
|
|
138
|
+
this.timeChange.emit(v);
|
|
139
|
+
}
|
|
140
|
+
}
|
|
141
|
+
/** get accessor */
|
|
142
|
+
get value() {
|
|
143
|
+
return this._value;
|
|
144
|
+
}
|
|
145
|
+
/** From ControlValueAccessor interface */
|
|
146
|
+
writeValue(value) {
|
|
147
|
+
if ((value ?? null) !== (this._value ?? null)) {
|
|
148
|
+
if (value instanceof Date) {
|
|
149
|
+
this._value = value ? new Date(value.getTime()) : set(new Date(), { hours: 0, minutes: 0, seconds: 0 });
|
|
150
|
+
}
|
|
151
|
+
else {
|
|
152
|
+
this._value = value;
|
|
153
|
+
}
|
|
154
|
+
this.changeDetectorRef.markForCheck();
|
|
155
|
+
}
|
|
156
|
+
}
|
|
157
|
+
/** From ControlValueAccessor interface */
|
|
158
|
+
registerOnChange(fn) {
|
|
159
|
+
this.onChangeCallback = fn;
|
|
160
|
+
}
|
|
161
|
+
/** From ControlValueAccessor interface */
|
|
162
|
+
registerOnTouched(fn) {
|
|
163
|
+
this.onTouchedCallback = fn;
|
|
164
|
+
}
|
|
165
|
+
setDisabledState(isDisabled) {
|
|
166
|
+
this.disabled = isDisabled;
|
|
167
|
+
}
|
|
168
|
+
// ************* End of ControlValueAccessor Implementation **************
|
|
169
|
+
get hoursValue() {
|
|
170
|
+
if (!this.value || (this.forceNullValue && this.mode === 'fullTimeWithMinutesDisabled' && !!this.control?.pristine)) {
|
|
171
|
+
return undefined;
|
|
172
|
+
}
|
|
173
|
+
return this.value.getHours();
|
|
174
|
+
}
|
|
175
|
+
get minutesValue() {
|
|
176
|
+
if (!this.value || (this.forceNullValue && this.mode === 'fullTimeWithHoursDisabled' && !!this.control?.pristine)) {
|
|
177
|
+
return undefined;
|
|
178
|
+
}
|
|
179
|
+
return this.value.getMinutes();
|
|
180
|
+
}
|
|
181
|
+
onChangeCallback = (_a) => undefined;
|
|
182
|
+
onTouchedCallback = () => undefined;
|
|
183
|
+
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.1.1", ngImport: i0, type: NgxTimePickerComponent, deps: [], target: i0.ɵɵFactoryTarget.Component });
|
|
184
|
+
static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "21.1.1", type: NgxTimePickerComponent, isStandalone: true, selector: "ngx-time-picker", inputs: { mode: "mode", forceNullValue: "forceNullValue", appearance: "appearance", autoFocus: "autoFocus", defaultPlaceholderHours: "defaultPlaceholderHours", defaultPlaceholderMinutes: "defaultPlaceholderMinutes", time: "time", step: "step", disabled: "disabled" }, outputs: { timeChange: "timeChange" }, viewQueries: [{ propertyName: "hours", first: true, predicate: ["hours"], descendants: true }, { propertyName: "minutes", first: true, predicate: ["minutes"], descendants: true }], ngImport: i0, template: "<!-- Hours -->\n<mat-form-field\n [appearance]=\"appearance\"\n class=\"hours\"\n [class.disabled]=\"disabled || mode === 'fullTimeWithHoursDisabled'\"\n [style.display]=\"mode === 'minutesOnly' ? 'none' : 'block'\">\n <input\n aria-label=\"hours\"\n #hours\n matInput\n [attr.hours]=\"hoursValue\"\n type=\"text\"\n [ngModel]=\"hoursValue | number: '2.'\"\n (ngModelChange)=\"hoursChange$.next($event)\"\n [ngModelOptions]=\"{ updateOn: 'blur' }\"\n (keydown)=\"hoursKeyDown$.next($event)\"\n [disabled]=\"disabled || mode === 'fullTimeWithHoursDisabled'\"\n [maxLength]=\"2\"\n autocomplete=\"off\"\n [placeholder]=\"defaultPlaceholderHours\"\n (click)=\"hours.select()\" />\n <ngx-numeric-stepper\n (increment)=\"hoursChange$.next((hoursValue || 0) + 1)\"\n (decrement)=\"hoursChange$.next((hoursValue || 0) - 1)\"></ngx-numeric-stepper>\n</mat-form-field>\n\n<!-- Separator -->\n<span class=\"time-separator\" [style.display]=\"mode === 'minutesOnly' || mode === 'hoursOnly' ? 'none' : 'block'\">\n :\n</span>\n\n<!-- Minutes -->\n<mat-form-field\n [appearance]=\"appearance\"\n class=\"minutes\"\n [class.disabled]=\"disabled || mode === 'fullTimeWithMinutesDisabled'\"\n [style.display]=\"mode === 'hoursOnly' ? 'none' : 'block'\">\n <input\n aria-label=\"minutes\"\n #minutes\n matInput\n [attr.minutes]=\"minutesValue\"\n type=\"text\"\n [ngModel]=\"minutesValue | number: '2.'\"\n (ngModelChange)=\"minutesChange$.next($event)\"\n [ngModelOptions]=\"{ updateOn: 'blur' }\"\n [disabled]=\"disabled || mode === 'fullTimeWithMinutesDisabled'\"\n [maxLength]=\"2\"\n autocomplete=\"off\"\n [placeholder]=\"defaultPlaceholderMinutes\"\n (click)=\"minutes.select()\" />\n <ngx-numeric-stepper\n (increment)=\"minutesChange$.next((minutesValue || 0) + _step)\"\n (decrement)=\"minutesChange$.next((minutesValue || 0) - _step)\"></ngx-numeric-stepper>\n</mat-form-field>\n", styles: ["ngx-time-picker{display:flex;flex-direction:row;align-items:baseline;justify-content:center}ngx-time-picker:not([inform]) .mat-form-field-appearance-outline .mat-mdc-form-field-wrapper{padding-bottom:0}ngx-time-picker:not([inform]) .mat-form-field-appearance-outline .mat-mdc-form-field-wrapper .mat-mdc-form-field-infix{border-bottom:.7em solid transparent}ngx-time-picker mat-form-field[ngx-numeric-stepper-form-field]{width:52px}ngx-time-picker .time-separator{width:4px;font-size:14.5px;line-height:17px;margin:0 8px}\n"], dependencies: [{ kind: "ngmodule", type: FormsModule }, { kind: "directive", type: i1.DefaultValueAccessor, selector: "input:not([type=checkbox])[formControlName],textarea[formControlName],input:not([type=checkbox])[formControl],textarea[formControl],input:not([type=checkbox])[ngModel],textarea[ngModel],[ngDefaultControl]" }, { kind: "directive", type: i1.NgControlStatus, selector: "[formControlName],[ngModel],[formControl]" }, { kind: "directive", type: i1.NgModel, selector: "[ngModel]:not([formControlName]):not([formControl])", inputs: ["name", "disabled", "ngModel", "ngModelOptions"], outputs: ["ngModelChange"], exportAs: ["ngModel"] }, { kind: "ngmodule", type: MatFormFieldModule }, { kind: "component", type: i2.MatFormField, selector: "mat-form-field", inputs: ["hideRequiredMarker", "color", "floatLabel", "appearance", "subscriptSizing", "hintLabel"], exportAs: ["matFormField"] }, { kind: "ngmodule", type: MatInputModule }, { kind: "directive", type: i3.MatInput, selector: "input[matInput], textarea[matInput], select[matNativeControl], input[matNativeControl], textarea[matNativeControl]", inputs: ["disabled", "id", "placeholder", "name", "required", "type", "errorStateMatcher", "aria-describedby", "value", "readonly", "disabledInteractive"], exportAs: ["matInput"] }, { kind: "component", type: NgxNumericStepperComponent, selector: "ngx-numeric-stepper", inputs: ["layout", "input", "arrowIcons", "showOnInit"], outputs: ["increment", "decrement"] }, { kind: "pipe", type: DecimalPipe, name: "number" }], changeDetection: i0.ChangeDetectionStrategy.OnPush, encapsulation: i0.ViewEncapsulation.None });
|
|
185
|
+
}
|
|
186
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.1.1", ngImport: i0, type: NgxTimePickerComponent, decorators: [{
|
|
187
|
+
type: Component,
|
|
188
|
+
args: [{ changeDetection: ChangeDetectionStrategy.OnPush, selector: 'ngx-time-picker', encapsulation: ViewEncapsulation.None, standalone: true, imports: [
|
|
189
|
+
DecimalPipe,
|
|
190
|
+
FormsModule,
|
|
191
|
+
MatFormFieldModule,
|
|
192
|
+
MatInputModule,
|
|
193
|
+
NgxNumericStepperComponent
|
|
194
|
+
], template: "<!-- Hours -->\n<mat-form-field\n [appearance]=\"appearance\"\n class=\"hours\"\n [class.disabled]=\"disabled || mode === 'fullTimeWithHoursDisabled'\"\n [style.display]=\"mode === 'minutesOnly' ? 'none' : 'block'\">\n <input\n aria-label=\"hours\"\n #hours\n matInput\n [attr.hours]=\"hoursValue\"\n type=\"text\"\n [ngModel]=\"hoursValue | number: '2.'\"\n (ngModelChange)=\"hoursChange$.next($event)\"\n [ngModelOptions]=\"{ updateOn: 'blur' }\"\n (keydown)=\"hoursKeyDown$.next($event)\"\n [disabled]=\"disabled || mode === 'fullTimeWithHoursDisabled'\"\n [maxLength]=\"2\"\n autocomplete=\"off\"\n [placeholder]=\"defaultPlaceholderHours\"\n (click)=\"hours.select()\" />\n <ngx-numeric-stepper\n (increment)=\"hoursChange$.next((hoursValue || 0) + 1)\"\n (decrement)=\"hoursChange$.next((hoursValue || 0) - 1)\"></ngx-numeric-stepper>\n</mat-form-field>\n\n<!-- Separator -->\n<span class=\"time-separator\" [style.display]=\"mode === 'minutesOnly' || mode === 'hoursOnly' ? 'none' : 'block'\">\n :\n</span>\n\n<!-- Minutes -->\n<mat-form-field\n [appearance]=\"appearance\"\n class=\"minutes\"\n [class.disabled]=\"disabled || mode === 'fullTimeWithMinutesDisabled'\"\n [style.display]=\"mode === 'hoursOnly' ? 'none' : 'block'\">\n <input\n aria-label=\"minutes\"\n #minutes\n matInput\n [attr.minutes]=\"minutesValue\"\n type=\"text\"\n [ngModel]=\"minutesValue | number: '2.'\"\n (ngModelChange)=\"minutesChange$.next($event)\"\n [ngModelOptions]=\"{ updateOn: 'blur' }\"\n [disabled]=\"disabled || mode === 'fullTimeWithMinutesDisabled'\"\n [maxLength]=\"2\"\n autocomplete=\"off\"\n [placeholder]=\"defaultPlaceholderMinutes\"\n (click)=\"minutes.select()\" />\n <ngx-numeric-stepper\n (increment)=\"minutesChange$.next((minutesValue || 0) + _step)\"\n (decrement)=\"minutesChange$.next((minutesValue || 0) - _step)\"></ngx-numeric-stepper>\n</mat-form-field>\n", styles: ["ngx-time-picker{display:flex;flex-direction:row;align-items:baseline;justify-content:center}ngx-time-picker:not([inform]) .mat-form-field-appearance-outline .mat-mdc-form-field-wrapper{padding-bottom:0}ngx-time-picker:not([inform]) .mat-form-field-appearance-outline .mat-mdc-form-field-wrapper .mat-mdc-form-field-infix{border-bottom:.7em solid transparent}ngx-time-picker mat-form-field[ngx-numeric-stepper-form-field]{width:52px}ngx-time-picker .time-separator{width:4px;font-size:14.5px;line-height:17px;margin:0 8px}\n"] }]
|
|
195
|
+
}], ctorParameters: () => [], propDecorators: { hours: [{
|
|
196
|
+
type: ViewChild,
|
|
197
|
+
args: ['hours']
|
|
198
|
+
}], minutes: [{
|
|
199
|
+
type: ViewChild,
|
|
200
|
+
args: ['minutes']
|
|
201
|
+
}], timeChange: [{
|
|
202
|
+
type: Output
|
|
203
|
+
}], mode: [{
|
|
204
|
+
type: Input
|
|
205
|
+
}], forceNullValue: [{
|
|
206
|
+
type: Input
|
|
207
|
+
}], appearance: [{
|
|
208
|
+
type: Input
|
|
209
|
+
}], autoFocus: [{
|
|
210
|
+
type: Input
|
|
211
|
+
}], defaultPlaceholderHours: [{
|
|
212
|
+
type: Input
|
|
213
|
+
}], defaultPlaceholderMinutes: [{
|
|
214
|
+
type: Input
|
|
215
|
+
}], time: [{
|
|
216
|
+
type: Input
|
|
217
|
+
}], step: [{
|
|
218
|
+
type: Input
|
|
219
|
+
}], disabled: [{
|
|
220
|
+
type: Input
|
|
221
|
+
}] } });
|
|
222
|
+
|
|
223
|
+
/**
|
|
224
|
+
* Generated bundle index. Do not edit.
|
|
225
|
+
*/
|
|
226
|
+
|
|
227
|
+
export { NgxTimePickerComponent };
|
|
228
|
+
//# sourceMappingURL=hug-ngx-time-picker-m2.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"hug-ngx-time-picker-m2.mjs","sources":["../../../projects/time-picker/m2/time-picker.component.ts","../../../projects/time-picker/m2/time-picker.component.html","../../../projects/time-picker/m2/hug-ngx-time-picker-m2.ts"],"sourcesContent":["import { BooleanInput, coerceBooleanProperty, coerceNumberProperty, NumberInput } from '@angular/cdk/coercion';\nimport { DecimalPipe } from '@angular/common';\nimport { ChangeDetectionStrategy, ChangeDetectorRef, Component, ElementRef, EventEmitter, inject, Input, Output, ViewChild, ViewEncapsulation } from '@angular/core';\nimport { takeUntilDestroyed } from '@angular/core/rxjs-interop';\nimport { ControlValueAccessor, FormsModule, NgControl } from '@angular/forms';\nimport { MatFormFieldAppearance, MatFormFieldModule } from '@angular/material/form-field';\nimport { MatInputModule } from '@angular/material/input';\nimport { NgxNumericStepperComponent } from '@hug/ngx-numeric-stepper/m2';\nimport { set } from 'date-fns';\nimport { debounceTime, distinctUntilChanged, EMPTY, map, mergeWith, Subject, switchMap, tap, timer } from 'rxjs';\n\nexport type NgxTimePickerDisplayMode = 'fullTime' | 'fullTimeWithHoursDisabled' | 'fullTimeWithMinutesDisabled' | 'hoursOnly' | 'minutesOnly';\n\n@Component({\n changeDetection: ChangeDetectionStrategy.OnPush,\n selector: 'ngx-time-picker',\n styleUrls: ['./time-picker.component.scss'],\n templateUrl: './time-picker.component.html',\n encapsulation: ViewEncapsulation.None,\n standalone: true,\n imports: [\n DecimalPipe,\n FormsModule,\n MatFormFieldModule,\n MatInputModule,\n NgxNumericStepperComponent\n ]\n})\nexport class NgxTimePickerComponent implements ControlValueAccessor {\n @ViewChild('hours') public hours?: ElementRef<HTMLInputElement>;\n @ViewChild('minutes') public minutes?: ElementRef<HTMLInputElement>;\n\n @Output() public readonly timeChange = new EventEmitter<Date>();\n\n /** Display mode for the time-picker */\n @Input() public mode: NgxTimePickerDisplayMode = 'fullTime';\n\n /**\n * Force the hour or minute to be null (only if the other field is disabled)\n *\n * For instance, if set to true and the hours are disabled, the minutes input value will be null\n * This is useful to force the user to provide a value\n */\n @Input() public forceNullValue = false;\n\n @Input() public appearance: MatFormFieldAppearance = 'outline';\n\n @Input()\n public set autoFocus(value: BooleanInput) {\n this._autoFocus = coerceBooleanProperty(value);\n }\n\n @Input() public defaultPlaceholderHours = '_ _';\n @Input() public defaultPlaceholderMinutes = '_ _';\n\n @Input()\n public set time(value: Date | undefined) {\n this.writeValue(value);\n }\n\n public get time(): Date | undefined {\n return this.value;\n }\n\n /** Step of the arrows */\n @Input()\n public set step(value: NumberInput) {\n this._step = coerceNumberProperty(value);\n this.changeDetectorRef.markForCheck();\n }\n\n /** To get the step of the minutes arrows */\n public get step(): NumberInput {\n return this._step;\n }\n\n /** Disabled property setter. Can be string or empty so you can use it like : <time-picker disabled></time-picker> */\n @Input()\n public set disabled(value: BooleanInput) {\n this._disabled = coerceBooleanProperty(value);\n this.changeDetectorRef.markForCheck();\n }\n\n /** To get disabled attribute. */\n public get disabled(): BooleanInput {\n return this._disabled;\n }\n\n public readonly hoursChange$ = new Subject<Event | number>();\n public readonly minutesChange$ = new Subject<Event | number>();\n public readonly hoursKeyDown$ = new Subject<KeyboardEvent>();\n\n protected changeDetectorRef = inject(ChangeDetectorRef);\n protected control = inject(NgControl, { optional: true, self: true });\n protected _step = 1;\n\n private _disabled = false;\n private _value?: Date;\n private _autoFocus = true;\n\n public constructor() {\n if (this.control) {\n this.control.valueAccessor = this;\n }\n\n const hoursChange$ = this.hoursChange$.pipe(\n distinctUntilChanged(),\n map(hours => {\n if (typeof hours === 'object') {\n const value = (hours.target as HTMLInputElement).value;\n return [value !== undefined ? parseInt(value, 10) : undefined, true] as const;\n }\n return [!isNaN(hours) ? hours : 0, false] as const;\n }),\n tap(([hours, _isEvent]) => {\n const newValue = this.value ? new Date(this.value.getTime()) : new Date();\n\n if (hours !== undefined) {\n newValue.setHours(hours);\n }\n\n if (this.mode === 'fullTime' || this.mode === 'fullTimeWithMinutesDisabled' || this.mode === 'hoursOnly') {\n this.value = newValue;\n }\n\n this.changeDetectorRef.markForCheck();\n })\n );\n\n const minutesChange$ = this.minutesChange$.pipe(\n distinctUntilChanged(),\n map(event => {\n let minutes: number | undefined;\n if (typeof event === 'object') {\n const value = (event.target as HTMLInputElement).value;\n minutes = value !== undefined ? parseInt(value, 10) : undefined;\n } else {\n minutes = event;\n }\n\n return minutes && !isNaN(minutes) && minutes || 0;\n }),\n tap(minutes => {\n const newValue = this.value ? new Date(this.value.getTime()) : new Date();\n\n if (minutes < 0) {\n minutes += 60;\n } else if (minutes >= 60) {\n minutes -= 60;\n }\n newValue.setMinutes(minutes);\n\n if (this.mode === 'fullTime' || this.mode === 'fullTimeWithHoursDisabled' || this.mode === 'minutesOnly') {\n this.value = newValue;\n }\n\n this.changeDetectorRef.markForCheck();\n })\n );\n\n const setFocusToNextInput$ = this.hoursKeyDown$.pipe(\n debounceTime(200),\n switchMap(event => {\n const inputElement = this.hours?.nativeElement;\n if (!inputElement) {\n return EMPTY;\n }\n\n if (event.key && !event.ctrlKey && !event.shiftKey && !event.altKey && !['ArrowUp', 'ArrowDown', 'ArrowLeft', 'ArrowRight', 'Backspace', 'Delete', 'Tab', 'Enter', 'Control', 'Shift'].includes(event.key)) {\n const regex = /^(\\d|[01]\\d|2[0-3])$/;\n const [selectionStart, selectionEnd] = [inputElement.selectionStart || 0, inputElement.selectionEnd || 0].sort((a, b) => a - b);\n const inputValue = inputElement.value || '';\n if (regex.test(inputValue) && this._autoFocus && inputValue.length === 2 && this.minutes?.nativeElement && inputElement === document.activeElement && selectionStart === 2 && selectionEnd === 2) {\n this.minutes.nativeElement.focus();\n return timer(0).pipe(\n tap(() => {\n this.minutes?.nativeElement.select();\n })\n );\n }\n }\n\n return EMPTY;\n })\n );\n\n hoursChange$.pipe(\n mergeWith(minutesChange$, setFocusToNextInput$),\n takeUntilDestroyed()\n ).subscribe();\n }\n\n // ************* ControlValueAccessor Implementation **************\n /** set accessor including call the onchange callback */\n public set value(v: Date | undefined) {\n if (v !== this._value) {\n this.writeValue(v);\n this.onChangeCallback(v);\n this.timeChange.emit(v);\n }\n }\n\n /** get accessor */\n public get value(): Date | undefined {\n return this._value;\n }\n\n /** From ControlValueAccessor interface */\n public writeValue(value: Date | undefined): void {\n if ((value ?? null) !== (this._value ?? null)) {\n if (value instanceof Date) {\n this._value = value ? new Date(value.getTime()) : set(new Date(), { hours: 0, minutes: 0, seconds: 0 });\n } else {\n this._value = value;\n }\n\n this.changeDetectorRef.markForCheck();\n }\n }\n\n /** From ControlValueAccessor interface */\n public registerOnChange(fn: (_a: unknown) => void): void {\n this.onChangeCallback = fn;\n }\n\n /** From ControlValueAccessor interface */\n public registerOnTouched(fn: () => void): void {\n this.onTouchedCallback = fn;\n }\n\n public setDisabledState(isDisabled: boolean): void {\n this.disabled = isDisabled;\n }\n // ************* End of ControlValueAccessor Implementation **************\n\n protected get hoursValue(): number | undefined {\n if (!this.value || (this.forceNullValue && this.mode === 'fullTimeWithMinutesDisabled' && !!this.control?.pristine)) {\n return undefined;\n }\n return this.value.getHours();\n }\n\n protected get minutesValue(): number | undefined {\n if (!this.value || (this.forceNullValue && this.mode === 'fullTimeWithHoursDisabled' && !!this.control?.pristine)) {\n return undefined;\n }\n return this.value.getMinutes();\n }\n\n protected onChangeCallback = (_a: unknown): void => undefined;\n protected onTouchedCallback = (): void => undefined;\n}\n","<!-- Hours -->\n<mat-form-field\n [appearance]=\"appearance\"\n class=\"hours\"\n [class.disabled]=\"disabled || mode === 'fullTimeWithHoursDisabled'\"\n [style.display]=\"mode === 'minutesOnly' ? 'none' : 'block'\">\n <input\n aria-label=\"hours\"\n #hours\n matInput\n [attr.hours]=\"hoursValue\"\n type=\"text\"\n [ngModel]=\"hoursValue | number: '2.'\"\n (ngModelChange)=\"hoursChange$.next($event)\"\n [ngModelOptions]=\"{ updateOn: 'blur' }\"\n (keydown)=\"hoursKeyDown$.next($event)\"\n [disabled]=\"disabled || mode === 'fullTimeWithHoursDisabled'\"\n [maxLength]=\"2\"\n autocomplete=\"off\"\n [placeholder]=\"defaultPlaceholderHours\"\n (click)=\"hours.select()\" />\n <ngx-numeric-stepper\n (increment)=\"hoursChange$.next((hoursValue || 0) + 1)\"\n (decrement)=\"hoursChange$.next((hoursValue || 0) - 1)\"></ngx-numeric-stepper>\n</mat-form-field>\n\n<!-- Separator -->\n<span class=\"time-separator\" [style.display]=\"mode === 'minutesOnly' || mode === 'hoursOnly' ? 'none' : 'block'\">\n :\n</span>\n\n<!-- Minutes -->\n<mat-form-field\n [appearance]=\"appearance\"\n class=\"minutes\"\n [class.disabled]=\"disabled || mode === 'fullTimeWithMinutesDisabled'\"\n [style.display]=\"mode === 'hoursOnly' ? 'none' : 'block'\">\n <input\n aria-label=\"minutes\"\n #minutes\n matInput\n [attr.minutes]=\"minutesValue\"\n type=\"text\"\n [ngModel]=\"minutesValue | number: '2.'\"\n (ngModelChange)=\"minutesChange$.next($event)\"\n [ngModelOptions]=\"{ updateOn: 'blur' }\"\n [disabled]=\"disabled || mode === 'fullTimeWithMinutesDisabled'\"\n [maxLength]=\"2\"\n autocomplete=\"off\"\n [placeholder]=\"defaultPlaceholderMinutes\"\n (click)=\"minutes.select()\" />\n <ngx-numeric-stepper\n (increment)=\"minutesChange$.next((minutesValue || 0) + _step)\"\n (decrement)=\"minutesChange$.next((minutesValue || 0) - _step)\"></ngx-numeric-stepper>\n</mat-form-field>\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './index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angular/common';
|
|
3
|
-
import * as i0 from '@angular/core';
|
|
4
|
-
import { EventEmitter, inject, ChangeDetectorRef, Input, Output, ViewChild, ViewEncapsulation, ChangeDetectionStrategy, Component } from '@angular/core';
|
|
5
|
-
import { takeUntilDestroyed } from '@angular/core/rxjs-interop';
|
|
6
|
-
import * as i1 from '@angular/forms';
|
|
7
|
-
import { NgControl, FormsModule } from '@angular/forms';
|
|
8
|
-
import * as i2 from '@angular/material/form-field';
|
|
9
|
-
import { MatFormFieldModule } from '@angular/material/form-field';
|
|
10
|
-
import * as i3 from '@angular/material/input';
|
|
11
|
-
import { MatInputModule } from '@angular/material/input';
|
|
12
|
-
import { NgxNumericStepperComponent } from '@hug/ngx-numeric-stepper';
|
|
13
|
-
import { set } from 'date-fns';
|
|
14
|
-
import { Subject, distinctUntilChanged, map, tap, debounceTime, switchMap, EMPTY, timer, mergeWith } from 'rxjs';
|
|
15
|
-
|
|
16
|
-
class NgxTimePickerComponent {
|
|
17
|
-
hours;
|
|
18
|
-
minutes;
|
|
19
|
-
timeChange = new EventEmitter();
|
|
20
|
-
/** Display mode for the time-picker */
|
|
21
|
-
mode = 'fullTime';
|
|
22
|
-
/**
|
|
23
|
-
* Force the hour or minute to be null (only if the other field is disabled)
|
|
24
|
-
*
|
|
25
|
-
* For instance, if set to true and the hours are disabled, the minutes input value will be null
|
|
26
|
-
* This is useful to force the user to provide a value
|
|
27
|
-
*/
|
|
28
|
-
forceNullValue = false;
|
|
29
|
-
appearance = 'outline';
|
|
30
|
-
set autoFocus(value) {
|
|
31
|
-
this._autoFocus = coerceBooleanProperty(value);
|
|
32
|
-
}
|
|
33
|
-
defaultPlaceholderHours = '_ _';
|
|
34
|
-
defaultPlaceholderMinutes = '_ _';
|
|
35
|
-
set time(value) {
|
|
36
|
-
this.writeValue(value);
|
|
37
|
-
}
|
|
38
|
-
get time() {
|
|
39
|
-
return this.value;
|
|
40
|
-
}
|
|
41
|
-
/** Step of the arrows */
|
|
42
|
-
set step(value) {
|
|
43
|
-
this._step = coerceNumberProperty(value);
|
|
44
|
-
this.changeDetectorRef.markForCheck();
|
|
45
|
-
}
|
|
46
|
-
/** To get the step of the minutes arrows */
|
|
47
|
-
get step() {
|
|
48
|
-
return this._step;
|
|
49
|
-
}
|
|
50
|
-
/** Disabled property setter. Can be string or empty so you can use it like : <time-picker disabled></time-picker> */
|
|
51
|
-
set disabled(value) {
|
|
52
|
-
this._disabled = coerceBooleanProperty(value);
|
|
53
|
-
this.changeDetectorRef.markForCheck();
|
|
54
|
-
}
|
|
55
|
-
/** To get disabled attribute. */
|
|
56
|
-
get disabled() {
|
|
57
|
-
return this._disabled;
|
|
58
|
-
}
|
|
59
|
-
hoursChange$ = new Subject();
|
|
60
|
-
minutesChange$ = new Subject();
|
|
61
|
-
hoursKeyDown$ = new Subject();
|
|
62
|
-
changeDetectorRef = inject(ChangeDetectorRef);
|
|
63
|
-
control = inject(NgControl, { optional: true, self: true });
|
|
64
|
-
_step = 1;
|
|
65
|
-
_disabled = false;
|
|
66
|
-
_value;
|
|
67
|
-
_autoFocus = true;
|
|
68
|
-
constructor() {
|
|
69
|
-
if (this.control) {
|
|
70
|
-
this.control.valueAccessor = this;
|
|
71
|
-
}
|
|
72
|
-
const hoursChange$ = this.hoursChange$.pipe(distinctUntilChanged(), map(hours => {
|
|
73
|
-
if (typeof hours === 'object') {
|
|
74
|
-
const value = hours.target.value;
|
|
75
|
-
return [value !== undefined ? parseInt(value, 10) : undefined, true];
|
|
76
|
-
}
|
|
77
|
-
return [!isNaN(hours) ? hours : 0, false];
|
|
78
|
-
}), tap(([hours, _isEvent]) => {
|
|
79
|
-
const newValue = this.value ? new Date(this.value.getTime()) : new Date();
|
|
80
|
-
if (hours !== undefined) {
|
|
81
|
-
newValue.setHours(hours);
|
|
82
|
-
}
|
|
83
|
-
if (this.mode === 'fullTime' || this.mode === 'fullTimeWithMinutesDisabled' || this.mode === 'hoursOnly') {
|
|
84
|
-
this.value = newValue;
|
|
85
|
-
}
|
|
86
|
-
this.changeDetectorRef.markForCheck();
|
|
87
|
-
}));
|
|
88
|
-
const minutesChange$ = this.minutesChange$.pipe(distinctUntilChanged(), map(event => {
|
|
89
|
-
let minutes;
|
|
90
|
-
if (typeof event === 'object') {
|
|
91
|
-
const value = event.target.value;
|
|
92
|
-
minutes = value !== undefined ? parseInt(value, 10) : undefined;
|
|
93
|
-
}
|
|
94
|
-
else {
|
|
95
|
-
minutes = event;
|
|
96
|
-
}
|
|
97
|
-
return minutes && !isNaN(minutes) && minutes || 0;
|
|
98
|
-
}), tap(minutes => {
|
|
99
|
-
const newValue = this.value ? new Date(this.value.getTime()) : new Date();
|
|
100
|
-
if (minutes < 0) {
|
|
101
|
-
minutes += 60;
|
|
102
|
-
}
|
|
103
|
-
else if (minutes >= 60) {
|
|
104
|
-
minutes -= 60;
|
|
105
|
-
}
|
|
106
|
-
newValue.setMinutes(minutes);
|
|
107
|
-
if (this.mode === 'fullTime' || this.mode === 'fullTimeWithHoursDisabled' || this.mode === 'minutesOnly') {
|
|
108
|
-
this.value = newValue;
|
|
109
|
-
}
|
|
110
|
-
this.changeDetectorRef.markForCheck();
|
|
111
|
-
}));
|
|
112
|
-
const setFocusToNextInput$ = this.hoursKeyDown$.pipe(debounceTime(200), switchMap(event => {
|
|
113
|
-
const inputElement = this.hours?.nativeElement;
|
|
114
|
-
if (!inputElement) {
|
|
115
|
-
return EMPTY;
|
|
116
|
-
}
|
|
117
|
-
if (event.key && !event.ctrlKey && !event.shiftKey && !event.altKey && !['ArrowUp', 'ArrowDown', 'ArrowLeft', 'ArrowRight', 'Backspace', 'Delete', 'Tab', 'Enter', 'Control', 'Shift'].includes(event.key)) {
|
|
118
|
-
const regex = /^(\d|[01]\d|2[0-3])$/;
|
|
119
|
-
const [selectionStart, selectionEnd] = [inputElement.selectionStart || 0, inputElement.selectionEnd || 0].sort((a, b) => a - b);
|
|
120
|
-
const inputValue = inputElement.value || '';
|
|
121
|
-
if (regex.test(inputValue) && this._autoFocus && inputValue.length === 2 && this.minutes?.nativeElement && inputElement === document.activeElement && selectionStart === 2 && selectionEnd === 2) {
|
|
122
|
-
this.minutes.nativeElement.focus();
|
|
123
|
-
return timer(0).pipe(tap(() => {
|
|
124
|
-
this.minutes?.nativeElement.select();
|
|
125
|
-
}));
|
|
126
|
-
}
|
|
127
|
-
}
|
|
128
|
-
return EMPTY;
|
|
129
|
-
}));
|
|
130
|
-
hoursChange$.pipe(mergeWith(minutesChange$, setFocusToNextInput$), takeUntilDestroyed()).subscribe();
|
|
131
|
-
}
|
|
132
|
-
// ************* ControlValueAccessor Implementation **************
|
|
133
|
-
/** set accessor including call the onchange callback */
|
|
134
|
-
set value(v) {
|
|
135
|
-
if (v !== this._value) {
|
|
136
|
-
this.writeValue(v);
|
|
137
|
-
this.onChangeCallback(v);
|
|
138
|
-
this.timeChange.emit(v);
|
|
139
|
-
}
|
|
140
|
-
}
|
|
141
|
-
/** get accessor */
|
|
142
|
-
get value() {
|
|
143
|
-
return this._value;
|
|
144
|
-
}
|
|
145
|
-
/** From ControlValueAccessor interface */
|
|
146
|
-
writeValue(value) {
|
|
147
|
-
if ((value ?? null) !== (this._value ?? null)) {
|
|
148
|
-
if (value instanceof Date) {
|
|
149
|
-
this._value = value ? new Date(value.getTime()) : set(new Date(), { hours: 0, minutes: 0, seconds: 0 });
|
|
150
|
-
}
|
|
151
|
-
else {
|
|
152
|
-
this._value = value;
|
|
153
|
-
}
|
|
154
|
-
this.changeDetectorRef.markForCheck();
|
|
155
|
-
}
|
|
156
|
-
}
|
|
157
|
-
/** From ControlValueAccessor interface */
|
|
158
|
-
registerOnChange(fn) {
|
|
159
|
-
this.onChangeCallback = fn;
|
|
160
|
-
}
|
|
161
|
-
/** From ControlValueAccessor interface */
|
|
162
|
-
registerOnTouched(fn) {
|
|
163
|
-
this.onTouchedCallback = fn;
|
|
164
|
-
}
|
|
165
|
-
setDisabledState(isDisabled) {
|
|
166
|
-
this.disabled = isDisabled;
|
|
167
|
-
}
|
|
168
|
-
// ************* End of ControlValueAccessor Implementation **************
|
|
169
|
-
get hoursValue() {
|
|
170
|
-
if (!this.value || (this.forceNullValue && this.mode === 'fullTimeWithMinutesDisabled' && !!this.control?.pristine)) {
|
|
171
|
-
return undefined;
|
|
172
|
-
}
|
|
173
|
-
return this.value.getHours();
|
|
174
|
-
}
|
|
175
|
-
get minutesValue() {
|
|
176
|
-
if (!this.value || (this.forceNullValue && this.mode === 'fullTimeWithHoursDisabled' && !!this.control?.pristine)) {
|
|
177
|
-
return undefined;
|
|
178
|
-
}
|
|
179
|
-
return this.value.getMinutes();
|
|
180
|
-
}
|
|
181
|
-
onChangeCallback = (_a) => undefined;
|
|
182
|
-
onTouchedCallback = () => undefined;
|
|
183
|
-
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.1.1", ngImport: i0, type: NgxTimePickerComponent, deps: [], target: i0.ɵɵFactoryTarget.Component });
|
|
184
|
-
static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "21.1.1", type: NgxTimePickerComponent, isStandalone: true, selector: "ngx-time-picker", inputs: { mode: "mode", forceNullValue: "forceNullValue", appearance: "appearance", autoFocus: "autoFocus", defaultPlaceholderHours: "defaultPlaceholderHours", defaultPlaceholderMinutes: "defaultPlaceholderMinutes", time: "time", step: "step", disabled: "disabled" }, outputs: { timeChange: "timeChange" }, viewQueries: [{ propertyName: "hours", first: true, predicate: ["hours"], descendants: true }, { propertyName: "minutes", first: true, predicate: ["minutes"], descendants: true }], ngImport: i0, template: "<!-- Hours -->\n<mat-form-field\n [appearance]=\"appearance\"\n class=\"hours\"\n [class.disabled]=\"disabled || mode === 'fullTimeWithHoursDisabled'\"\n [style.display]=\"mode === 'minutesOnly' ? 'none' : 'block'\">\n <input\n aria-label=\"hours\"\n #hours\n matInput\n [attr.hours]=\"hoursValue\"\n type=\"text\"\n [ngModel]=\"hoursValue | number: '2.'\"\n (ngModelChange)=\"hoursChange$.next($event)\"\n [ngModelOptions]=\"{ updateOn: 'blur' }\"\n (keydown)=\"hoursKeyDown$.next($event)\"\n [disabled]=\"disabled || mode === 'fullTimeWithHoursDisabled'\"\n [maxLength]=\"2\"\n autocomplete=\"off\"\n [placeholder]=\"defaultPlaceholderHours\"\n (click)=\"hours.select()\" />\n <ngx-numeric-stepper\n (increment)=\"hoursChange$.next((hoursValue || 0) + 1)\"\n (decrement)=\"hoursChange$.next((hoursValue || 0) - 1)\"></ngx-numeric-stepper>\n</mat-form-field>\n\n<!-- Separator -->\n<span class=\"time-separator\" [style.display]=\"mode === 'minutesOnly' || mode === 'hoursOnly' ? 'none' : 'block'\">\n :\n</span>\n\n<!-- Minutes -->\n<mat-form-field\n [appearance]=\"appearance\"\n class=\"minutes\"\n [class.disabled]=\"disabled || mode === 'fullTimeWithMinutesDisabled'\"\n [style.display]=\"mode === 'hoursOnly' ? 'none' : 'block'\">\n <input\n aria-label=\"minutes\"\n #minutes\n matInput\n [attr.minutes]=\"minutesValue\"\n type=\"text\"\n [ngModel]=\"minutesValue | number: '2.'\"\n (ngModelChange)=\"minutesChange$.next($event)\"\n [ngModelOptions]=\"{ updateOn: 'blur' }\"\n [disabled]=\"disabled || mode === 'fullTimeWithMinutesDisabled'\"\n [maxLength]=\"2\"\n autocomplete=\"off\"\n [placeholder]=\"defaultPlaceholderMinutes\"\n (click)=\"minutes.select()\" />\n <ngx-numeric-stepper\n (increment)=\"minutesChange$.next((minutesValue || 0) + _step)\"\n (decrement)=\"minutesChange$.next((minutesValue || 0) - _step)\"></ngx-numeric-stepper>\n</mat-form-field>\n", styles: ["ngx-time-picker{display:flex;flex-direction:row;align-items:baseline;justify-content:center}ngx-time-picker:not([inform]) .mat-form-field-appearance-outline .mat-mdc-form-field-wrapper{padding-bottom:0}ngx-time-picker:not([inform]) .mat-form-field-appearance-outline .mat-mdc-form-field-wrapper .mat-mdc-form-field-infix{border-bottom:.7em solid transparent}ngx-time-picker mat-form-field[ngx-numeric-stepper-form-field]{width:52px}ngx-time-picker .time-separator{width:4px;font-size:14.5px;line-height:17px;margin:0 8px}\n"], dependencies: [{ kind: "ngmodule", type: FormsModule }, { kind: "directive", type: i1.DefaultValueAccessor, selector: "input:not([type=checkbox])[formControlName],textarea[formControlName],input:not([type=checkbox])[formControl],textarea[formControl],input:not([type=checkbox])[ngModel],textarea[ngModel],[ngDefaultControl]" }, { kind: "directive", type: i1.NgControlStatus, selector: "[formControlName],[ngModel],[formControl]" }, { kind: "directive", type: i1.NgModel, selector: "[ngModel]:not([formControlName]):not([formControl])", inputs: ["name", "disabled", "ngModel", "ngModelOptions"], outputs: ["ngModelChange"], exportAs: ["ngModel"] }, { kind: "ngmodule", type: MatFormFieldModule }, { kind: "component", type: i2.MatFormField, selector: "mat-form-field", inputs: ["hideRequiredMarker", "color", "floatLabel", "appearance", "subscriptSizing", "hintLabel"], exportAs: ["matFormField"] }, { kind: "ngmodule", type: MatInputModule }, { kind: "directive", type: i3.MatInput, selector: "input[matInput], textarea[matInput], select[matNativeControl], input[matNativeControl], textarea[matNativeControl]", inputs: ["disabled", "id", "placeholder", "name", "required", "type", "errorStateMatcher", "aria-describedby", "value", "readonly", "disabledInteractive"], exportAs: ["matInput"] }, { kind: "component", type: NgxNumericStepperComponent, selector: "ngx-numeric-stepper", inputs: ["layout", "input", "arrowIcons", "showOnInit"], outputs: ["increment", "decrement"] }, { kind: "pipe", type: DecimalPipe, name: "number" }], changeDetection: i0.ChangeDetectionStrategy.OnPush, encapsulation: i0.ViewEncapsulation.None });
|
|
185
|
-
}
|
|
186
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.1.1", ngImport: i0, type: NgxTimePickerComponent, decorators: [{
|
|
187
|
-
type: Component,
|
|
188
|
-
args: [{ changeDetection: ChangeDetectionStrategy.OnPush, selector: 'ngx-time-picker', encapsulation: ViewEncapsulation.None, standalone: true, imports: [
|
|
189
|
-
DecimalPipe,
|
|
190
|
-
FormsModule,
|
|
191
|
-
MatFormFieldModule,
|
|
192
|
-
MatInputModule,
|
|
193
|
-
NgxNumericStepperComponent
|
|
194
|
-
], template: "<!-- Hours -->\n<mat-form-field\n [appearance]=\"appearance\"\n class=\"hours\"\n [class.disabled]=\"disabled || mode === 'fullTimeWithHoursDisabled'\"\n [style.display]=\"mode === 'minutesOnly' ? 'none' : 'block'\">\n <input\n aria-label=\"hours\"\n #hours\n matInput\n [attr.hours]=\"hoursValue\"\n type=\"text\"\n [ngModel]=\"hoursValue | number: '2.'\"\n (ngModelChange)=\"hoursChange$.next($event)\"\n [ngModelOptions]=\"{ updateOn: 'blur' }\"\n (keydown)=\"hoursKeyDown$.next($event)\"\n [disabled]=\"disabled || mode === 'fullTimeWithHoursDisabled'\"\n [maxLength]=\"2\"\n autocomplete=\"off\"\n [placeholder]=\"defaultPlaceholderHours\"\n (click)=\"hours.select()\" />\n <ngx-numeric-stepper\n (increment)=\"hoursChange$.next((hoursValue || 0) + 1)\"\n (decrement)=\"hoursChange$.next((hoursValue || 0) - 1)\"></ngx-numeric-stepper>\n</mat-form-field>\n\n<!-- Separator -->\n<span class=\"time-separator\" [style.display]=\"mode === 'minutesOnly' || mode === 'hoursOnly' ? 'none' : 'block'\">\n :\n</span>\n\n<!-- Minutes -->\n<mat-form-field\n [appearance]=\"appearance\"\n class=\"minutes\"\n [class.disabled]=\"disabled || mode === 'fullTimeWithMinutesDisabled'\"\n [style.display]=\"mode === 'hoursOnly' ? 'none' : 'block'\">\n <input\n aria-label=\"minutes\"\n #minutes\n matInput\n [attr.minutes]=\"minutesValue\"\n type=\"text\"\n [ngModel]=\"minutesValue | number: '2.'\"\n (ngModelChange)=\"minutesChange$.next($event)\"\n [ngModelOptions]=\"{ updateOn: 'blur' }\"\n [disabled]=\"disabled || mode === 'fullTimeWithMinutesDisabled'\"\n [maxLength]=\"2\"\n autocomplete=\"off\"\n [placeholder]=\"defaultPlaceholderMinutes\"\n (click)=\"minutes.select()\" />\n <ngx-numeric-stepper\n (increment)=\"minutesChange$.next((minutesValue || 0) + _step)\"\n (decrement)=\"minutesChange$.next((minutesValue || 0) - _step)\"></ngx-numeric-stepper>\n</mat-form-field>\n", styles: ["ngx-time-picker{display:flex;flex-direction:row;align-items:baseline;justify-content:center}ngx-time-picker:not([inform]) .mat-form-field-appearance-outline .mat-mdc-form-field-wrapper{padding-bottom:0}ngx-time-picker:not([inform]) .mat-form-field-appearance-outline .mat-mdc-form-field-wrapper .mat-mdc-form-field-infix{border-bottom:.7em solid transparent}ngx-time-picker mat-form-field[ngx-numeric-stepper-form-field]{width:52px}ngx-time-picker .time-separator{width:4px;font-size:14.5px;line-height:17px;margin:0 8px}\n"] }]
|
|
195
|
-
}], ctorParameters: () => [], propDecorators: { hours: [{
|
|
196
|
-
type: ViewChild,
|
|
197
|
-
args: ['hours']
|
|
198
|
-
}], minutes: [{
|
|
199
|
-
type: ViewChild,
|
|
200
|
-
args: ['minutes']
|
|
201
|
-
}], timeChange: [{
|
|
202
|
-
type: Output
|
|
203
|
-
}], mode: [{
|
|
204
|
-
type: Input
|
|
205
|
-
}], forceNullValue: [{
|
|
206
|
-
type: Input
|
|
207
|
-
}], appearance: [{
|
|
208
|
-
type: Input
|
|
209
|
-
}], autoFocus: [{
|
|
210
|
-
type: Input
|
|
211
|
-
}], defaultPlaceholderHours: [{
|
|
212
|
-
type: Input
|
|
213
|
-
}], defaultPlaceholderMinutes: [{
|
|
214
|
-
type: Input
|
|
215
|
-
}], time: [{
|
|
216
|
-
type: Input
|
|
217
|
-
}], step: [{
|
|
218
|
-
type: Input
|
|
219
|
-
}], disabled: [{
|
|
220
|
-
type: Input
|
|
221
|
-
}] } });
|
|
1
|
+
const m3 = 'M3';
|
|
222
2
|
|
|
223
3
|
/**
|
|
224
4
|
* Generated bundle index. Do not edit.
|
|
225
5
|
*/
|
|
226
6
|
|
|
227
|
-
export {
|
|
7
|
+
export { m3 };
|
|
228
8
|
//# sourceMappingURL=hug-ngx-time-picker.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"hug-ngx-time-picker.mjs","sources":["../../../projects/time-picker/src/time-picker.component.ts","../../../projects/time-picker/src/time-picker.component.html","../../../projects/time-picker/src/hug-ngx-time-picker.ts"],"sourcesContent":["import { BooleanInput, coerceBooleanProperty, coerceNumberProperty, NumberInput } from '@angular/cdk/coercion';\nimport { DecimalPipe } from '@angular/common';\nimport { ChangeDetectionStrategy, ChangeDetectorRef, Component, ElementRef, EventEmitter, inject, Input, Output, ViewChild, ViewEncapsulation } from '@angular/core';\nimport { takeUntilDestroyed } from '@angular/core/rxjs-interop';\nimport { ControlValueAccessor, FormsModule, NgControl } from '@angular/forms';\nimport { MatFormFieldAppearance, MatFormFieldModule } from '@angular/material/form-field';\nimport { MatInputModule } from '@angular/material/input';\nimport { NgxNumericStepperComponent } from '@hug/ngx-numeric-stepper';\nimport { set } from 'date-fns';\nimport { debounceTime, distinctUntilChanged, EMPTY, map, mergeWith, Subject, switchMap, tap, timer } from 'rxjs';\n\nexport type NgxTimePickerDisplayMode = 'fullTime' | 'fullTimeWithHoursDisabled' | 'fullTimeWithMinutesDisabled' | 'hoursOnly' | 'minutesOnly';\n\n@Component({\n changeDetection: ChangeDetectionStrategy.OnPush,\n selector: 'ngx-time-picker',\n styleUrls: ['./time-picker.component.scss'],\n templateUrl: './time-picker.component.html',\n encapsulation: ViewEncapsulation.None,\n standalone: true,\n imports: [\n DecimalPipe,\n FormsModule,\n MatFormFieldModule,\n MatInputModule,\n NgxNumericStepperComponent\n ]\n})\nexport class NgxTimePickerComponent implements ControlValueAccessor {\n @ViewChild('hours') public hours?: ElementRef<HTMLInputElement>;\n @ViewChild('minutes') public minutes?: ElementRef<HTMLInputElement>;\n\n @Output() public readonly timeChange = new EventEmitter<Date>();\n\n /** Display mode for the time-picker */\n @Input() public mode: NgxTimePickerDisplayMode = 'fullTime';\n\n /**\n * Force the hour or minute to be null (only if the other field is disabled)\n *\n * For instance, if set to true and the hours are disabled, the minutes input value will be null\n * This is useful to force the user to provide a value\n */\n @Input() public forceNullValue = false;\n\n @Input() public appearance: MatFormFieldAppearance = 'outline';\n\n @Input()\n public set autoFocus(value: BooleanInput) {\n this._autoFocus = coerceBooleanProperty(value);\n }\n\n @Input() public defaultPlaceholderHours = '_ _';\n @Input() public defaultPlaceholderMinutes = '_ _';\n\n @Input()\n public set time(value: Date | undefined) {\n this.writeValue(value);\n }\n\n public get time(): Date | undefined {\n return this.value;\n }\n\n /** Step of the arrows */\n @Input()\n public set step(value: NumberInput) {\n this._step = coerceNumberProperty(value);\n this.changeDetectorRef.markForCheck();\n }\n\n /** To get the step of the minutes arrows */\n public get step(): NumberInput {\n return this._step;\n }\n\n /** Disabled property setter. Can be string or empty so you can use it like : <time-picker disabled></time-picker> */\n @Input()\n public set disabled(value: BooleanInput) {\n this._disabled = coerceBooleanProperty(value);\n this.changeDetectorRef.markForCheck();\n }\n\n /** To get disabled attribute. */\n public get disabled(): BooleanInput {\n return this._disabled;\n }\n\n public readonly hoursChange$ = new Subject<Event | number>();\n public readonly minutesChange$ = new Subject<Event | number>();\n public readonly hoursKeyDown$ = new Subject<KeyboardEvent>();\n\n protected changeDetectorRef = inject(ChangeDetectorRef);\n protected control = inject(NgControl, { optional: true, self: true });\n protected _step = 1;\n\n private _disabled = false;\n private _value?: Date;\n private _autoFocus = true;\n\n public constructor() {\n if (this.control) {\n this.control.valueAccessor = this;\n }\n\n const hoursChange$ = this.hoursChange$.pipe(\n distinctUntilChanged(),\n map(hours => {\n if (typeof hours === 'object') {\n const value = (hours.target as HTMLInputElement).value;\n return [value !== undefined ? parseInt(value, 10) : undefined, true] as const;\n }\n return [!isNaN(hours) ? hours : 0, false] as const;\n }),\n tap(([hours, _isEvent]) => {\n const newValue = this.value ? new Date(this.value.getTime()) : new Date();\n\n if (hours !== undefined) {\n newValue.setHours(hours);\n }\n\n if (this.mode === 'fullTime' || this.mode === 'fullTimeWithMinutesDisabled' || this.mode === 'hoursOnly') {\n this.value = newValue;\n }\n\n this.changeDetectorRef.markForCheck();\n })\n );\n\n const minutesChange$ = this.minutesChange$.pipe(\n distinctUntilChanged(),\n map(event => {\n let minutes: number | undefined;\n if (typeof event === 'object') {\n const value = (event.target as HTMLInputElement).value;\n minutes = value !== undefined ? parseInt(value, 10) : undefined;\n } else {\n minutes = event;\n }\n\n return minutes && !isNaN(minutes) && minutes || 0;\n }),\n tap(minutes => {\n const newValue = this.value ? new Date(this.value.getTime()) : new Date();\n\n if (minutes < 0) {\n minutes += 60;\n } else if (minutes >= 60) {\n minutes -= 60;\n }\n newValue.setMinutes(minutes);\n\n if (this.mode === 'fullTime' || this.mode === 'fullTimeWithHoursDisabled' || this.mode === 'minutesOnly') {\n this.value = newValue;\n }\n\n this.changeDetectorRef.markForCheck();\n })\n );\n\n const setFocusToNextInput$ = this.hoursKeyDown$.pipe(\n debounceTime(200),\n switchMap(event => {\n const inputElement = this.hours?.nativeElement;\n if (!inputElement) {\n return EMPTY;\n }\n\n if (event.key && !event.ctrlKey && !event.shiftKey && !event.altKey && !['ArrowUp', 'ArrowDown', 'ArrowLeft', 'ArrowRight', 'Backspace', 'Delete', 'Tab', 'Enter', 'Control', 'Shift'].includes(event.key)) {\n const regex = /^(\\d|[01]\\d|2[0-3])$/;\n const [selectionStart, selectionEnd] = [inputElement.selectionStart || 0, inputElement.selectionEnd || 0].sort((a, b) => a - b);\n const inputValue = inputElement.value || '';\n if (regex.test(inputValue) && this._autoFocus && inputValue.length === 2 && this.minutes?.nativeElement && inputElement === document.activeElement && selectionStart === 2 && selectionEnd === 2) {\n this.minutes.nativeElement.focus();\n return timer(0).pipe(\n tap(() => {\n this.minutes?.nativeElement.select();\n })\n );\n }\n }\n\n return EMPTY;\n })\n );\n\n hoursChange$.pipe(\n mergeWith(minutesChange$, setFocusToNextInput$),\n takeUntilDestroyed()\n ).subscribe();\n }\n\n // ************* ControlValueAccessor Implementation **************\n /** set accessor including call the onchange callback */\n public set value(v: Date | undefined) {\n if (v !== this._value) {\n this.writeValue(v);\n this.onChangeCallback(v);\n this.timeChange.emit(v);\n }\n }\n\n /** get accessor */\n public get value(): Date | undefined {\n return this._value;\n }\n\n /** From ControlValueAccessor interface */\n public writeValue(value: Date | undefined): void {\n if ((value ?? null) !== (this._value ?? null)) {\n if (value instanceof Date) {\n this._value = value ? new Date(value.getTime()) : set(new Date(), { hours: 0, minutes: 0, seconds: 0 });\n } else {\n this._value = value;\n }\n\n this.changeDetectorRef.markForCheck();\n }\n }\n\n /** From ControlValueAccessor interface */\n public registerOnChange(fn: (_a: unknown) => void): void {\n this.onChangeCallback = fn;\n }\n\n /** From ControlValueAccessor interface */\n public registerOnTouched(fn: () => void): void {\n this.onTouchedCallback = fn;\n }\n\n public setDisabledState(isDisabled: boolean): void {\n this.disabled = isDisabled;\n }\n // ************* End of ControlValueAccessor Implementation **************\n\n protected get hoursValue(): number | undefined {\n if (!this.value || (this.forceNullValue && this.mode === 'fullTimeWithMinutesDisabled' && !!this.control?.pristine)) {\n return undefined;\n }\n return this.value.getHours();\n }\n\n protected get minutesValue(): number | undefined {\n if (!this.value || (this.forceNullValue && this.mode === 'fullTimeWithHoursDisabled' && !!this.control?.pristine)) {\n return undefined;\n }\n return this.value.getMinutes();\n }\n\n protected onChangeCallback = (_a: unknown): void => undefined;\n protected onTouchedCallback = (): void => undefined;\n}\n","<!-- Hours -->\n<mat-form-field\n [appearance]=\"appearance\"\n class=\"hours\"\n [class.disabled]=\"disabled || mode === 'fullTimeWithHoursDisabled'\"\n [style.display]=\"mode === 'minutesOnly' ? 'none' : 'block'\">\n <input\n aria-label=\"hours\"\n #hours\n matInput\n [attr.hours]=\"hoursValue\"\n type=\"text\"\n [ngModel]=\"hoursValue | number: '2.'\"\n (ngModelChange)=\"hoursChange$.next($event)\"\n [ngModelOptions]=\"{ updateOn: 'blur' }\"\n (keydown)=\"hoursKeyDown$.next($event)\"\n [disabled]=\"disabled || mode === 'fullTimeWithHoursDisabled'\"\n [maxLength]=\"2\"\n autocomplete=\"off\"\n [placeholder]=\"defaultPlaceholderHours\"\n (click)=\"hours.select()\" />\n <ngx-numeric-stepper\n (increment)=\"hoursChange$.next((hoursValue || 0) + 1)\"\n (decrement)=\"hoursChange$.next((hoursValue || 0) - 1)\"></ngx-numeric-stepper>\n</mat-form-field>\n\n<!-- Separator -->\n<span class=\"time-separator\" [style.display]=\"mode === 'minutesOnly' || mode === 'hoursOnly' ? 'none' : 'block'\">\n :\n</span>\n\n<!-- Minutes -->\n<mat-form-field\n [appearance]=\"appearance\"\n class=\"minutes\"\n [class.disabled]=\"disabled || mode === 'fullTimeWithMinutesDisabled'\"\n [style.display]=\"mode === 'hoursOnly' ? 'none' : 'block'\">\n <input\n aria-label=\"minutes\"\n #minutes\n matInput\n [attr.minutes]=\"minutesValue\"\n type=\"text\"\n [ngModel]=\"minutesValue | number: '2.'\"\n (ngModelChange)=\"minutesChange$.next($event)\"\n [ngModelOptions]=\"{ updateOn: 'blur' }\"\n [disabled]=\"disabled || mode === 'fullTimeWithMinutesDisabled'\"\n [maxLength]=\"2\"\n autocomplete=\"off\"\n [placeholder]=\"defaultPlaceholderMinutes\"\n (click)=\"minutes.select()\" />\n <ngx-numeric-stepper\n (increment)=\"minutesChange$.next((minutesValue || 0) + _step)\"\n (decrement)=\"minutesChange$.next((minutesValue || 0) - _step)\"></ngx-numeric-stepper>\n</mat-form-field>\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './index';\n"],"names":[],"mappings":";;;;;;;;;;;;;;;MA4Ba,sBAAsB,CAAA;AACJ,IAAA,KAAK;AACH,IAAA,OAAO;AAEV,IAAA,UAAU,GAAG,IAAI,YAAY,EAAQ;;IAG/C,IAAI,GAA6B,UAAU;AAE3D;;;;;AAKG;IACa,cAAc,GAAG,KAAK;IAEtB,UAAU,GAA2B,SAAS;IAE9D,IACW,SAAS,CAAC,KAAmB,EAAA;AACpC,QAAA,IAAI,CAAC,UAAU,GAAG,qBAAqB,CAAC,KAAK,CAAC;IAClD;IAEgB,uBAAuB,GAAG,KAAK;IAC/B,yBAAyB,GA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AA,EAAA,YAAA,EAAA,YAAA,CAAA,EAAA,OAAA,EAAA,CAAA,WAAA,EAAA,WAAA,CAAA,EAAA,EAAA,EAAA,IAAA,EAAA,MAAA,EAAA,IAAA,EAJ1B,WAAW,EAAA,IAAA,EAAA,QAAA,EAAA,CAAA,EAAA,eAAA,EAAA,EAAA,CAAA,uBAAA,CAAA,MAAA,EAAA,aAAA,EAAA,EAAA,CAAA,iBAAA,CAAA,IAAA,EAAA,CAAA;;2FAON,sBAAsB,EAAA,UAAA,EAAA,CAAA;kBAflC,SAAS;sCACW,uBAAuB,CAAC,MAAM,EAAA,QAAA,EACrC,iBAAiB,EAAA,aAAA,EAGZ,iBAAiB,CAAC,IAAI,EAAA,UAAA,EACzB,IAAI,EAAA,OAAA,EACP;wBACL,WAAW;wBACX,WAAW;wBACX,kBAAkB;wBAClB,cAAc;wBACd;AACH,qBAAA,EAAA,QAAA,EAAA,mlEAAA,EAAA,MAAA,EAAA,CAAA,6gBAAA,CAAA,EAAA;;sBAGA,SAAS;uBAAC,OAAO;;sBACjB,SAAS;uBAAC,SAAS;;sBAEnB;;sBAGA;;sBAQA;;sBAEA;;sBAEA;;sBAKA;;sBACA;;sBAEA;;sBAUA;;sBAYA;;;AE7EL;;AAEG;;;;"}
|
|
1
|
+
{"version":3,"file":"hug-ngx-time-picker.mjs","sources":["../../../projects/time-picker/src/index.ts","../../../projects/time-picker/src/hug-ngx-time-picker.ts"],"sourcesContent":["export const m3 = 'M3';\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './index';\n"],"names":[],"mappings":"AAAO,MAAM,EAAE,GAAG;;ACAlB;;AAEG;;;;"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@hug/ngx-time-picker",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "22.0.0-alpha.1",
|
|
4
4
|
"description": "HUG Angular - time picker component",
|
|
5
5
|
"homepage": "https://github.com/dsi-hug/ngx-components",
|
|
6
6
|
"license": "GPL-3.0-only",
|
|
@@ -26,7 +26,7 @@
|
|
|
26
26
|
"@angular/core": ">=21 <22",
|
|
27
27
|
"@angular/forms": ">=21 <22",
|
|
28
28
|
"@angular/material": ">=21 <22",
|
|
29
|
-
"@hug/ngx-numeric-stepper": "^
|
|
29
|
+
"@hug/ngx-numeric-stepper": "^22.0.0-alpha.1",
|
|
30
30
|
"date-fns": "^2.30.0",
|
|
31
31
|
"rxjs": "^7.8.2",
|
|
32
32
|
"zone.js": "^0.16.0"
|
|
@@ -35,7 +35,8 @@
|
|
|
35
35
|
"tslib": "^2.8.1"
|
|
36
36
|
},
|
|
37
37
|
"publishConfig": {
|
|
38
|
-
"access": "public"
|
|
38
|
+
"access": "public",
|
|
39
|
+
"tag": "alpha"
|
|
39
40
|
},
|
|
40
41
|
"module": "fesm2022/hug-ngx-time-picker.mjs",
|
|
41
42
|
"typings": "types/hug-ngx-time-picker.d.ts",
|
|
@@ -47,9 +48,13 @@
|
|
|
47
48
|
"types": "./types/hug-ngx-time-picker.d.ts",
|
|
48
49
|
"default": "./fesm2022/hug-ngx-time-picker.mjs"
|
|
49
50
|
},
|
|
50
|
-
"./
|
|
51
|
-
"types": "./types/hug-ngx-time-picker-
|
|
52
|
-
"default": "./fesm2022/hug-ngx-time-picker-
|
|
51
|
+
"./m2": {
|
|
52
|
+
"types": "./types/hug-ngx-time-picker-m2.d.ts",
|
|
53
|
+
"default": "./fesm2022/hug-ngx-time-picker-m2.mjs"
|
|
54
|
+
},
|
|
55
|
+
"./m2/testing": {
|
|
56
|
+
"types": "./types/hug-ngx-time-picker-m2-testing.d.ts",
|
|
57
|
+
"default": "./fesm2022/hug-ngx-time-picker-m2-testing.mjs"
|
|
53
58
|
}
|
|
54
59
|
}
|
|
55
60
|
}
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
import { BooleanInput, NumberInput } from '@angular/cdk/coercion';
|
|
2
|
+
import * as i0 from '@angular/core';
|
|
3
|
+
import { ElementRef, EventEmitter, ChangeDetectorRef } from '@angular/core';
|
|
4
|
+
import { ControlValueAccessor, NgControl } from '@angular/forms';
|
|
5
|
+
import { MatFormFieldAppearance } from '@angular/material/form-field';
|
|
6
|
+
import { Subject } from 'rxjs';
|
|
7
|
+
|
|
8
|
+
type NgxTimePickerDisplayMode = 'fullTime' | 'fullTimeWithHoursDisabled' | 'fullTimeWithMinutesDisabled' | 'hoursOnly' | 'minutesOnly';
|
|
9
|
+
declare class NgxTimePickerComponent implements ControlValueAccessor {
|
|
10
|
+
hours?: ElementRef<HTMLInputElement>;
|
|
11
|
+
minutes?: ElementRef<HTMLInputElement>;
|
|
12
|
+
readonly timeChange: EventEmitter<Date>;
|
|
13
|
+
/** Display mode for the time-picker */
|
|
14
|
+
mode: NgxTimePickerDisplayMode;
|
|
15
|
+
/**
|
|
16
|
+
* Force the hour or minute to be null (only if the other field is disabled)
|
|
17
|
+
*
|
|
18
|
+
* For instance, if set to true and the hours are disabled, the minutes input value will be null
|
|
19
|
+
* This is useful to force the user to provide a value
|
|
20
|
+
*/
|
|
21
|
+
forceNullValue: boolean;
|
|
22
|
+
appearance: MatFormFieldAppearance;
|
|
23
|
+
set autoFocus(value: BooleanInput);
|
|
24
|
+
defaultPlaceholderHours: string;
|
|
25
|
+
defaultPlaceholderMinutes: string;
|
|
26
|
+
set time(value: Date | undefined);
|
|
27
|
+
get time(): Date | undefined;
|
|
28
|
+
/** Step of the arrows */
|
|
29
|
+
set step(value: NumberInput);
|
|
30
|
+
/** To get the step of the minutes arrows */
|
|
31
|
+
get step(): NumberInput;
|
|
32
|
+
/** Disabled property setter. Can be string or empty so you can use it like : <time-picker disabled></time-picker> */
|
|
33
|
+
set disabled(value: BooleanInput);
|
|
34
|
+
/** To get disabled attribute. */
|
|
35
|
+
get disabled(): BooleanInput;
|
|
36
|
+
readonly hoursChange$: Subject<number | Event>;
|
|
37
|
+
readonly minutesChange$: Subject<number | Event>;
|
|
38
|
+
readonly hoursKeyDown$: Subject<KeyboardEvent>;
|
|
39
|
+
protected changeDetectorRef: ChangeDetectorRef;
|
|
40
|
+
protected control: NgControl | null;
|
|
41
|
+
protected _step: number;
|
|
42
|
+
private _disabled;
|
|
43
|
+
private _value?;
|
|
44
|
+
private _autoFocus;
|
|
45
|
+
constructor();
|
|
46
|
+
/** set accessor including call the onchange callback */
|
|
47
|
+
set value(v: Date | undefined);
|
|
48
|
+
/** get accessor */
|
|
49
|
+
get value(): Date | undefined;
|
|
50
|
+
/** From ControlValueAccessor interface */
|
|
51
|
+
writeValue(value: Date | undefined): void;
|
|
52
|
+
/** From ControlValueAccessor interface */
|
|
53
|
+
registerOnChange(fn: (_a: unknown) => void): void;
|
|
54
|
+
/** From ControlValueAccessor interface */
|
|
55
|
+
registerOnTouched(fn: () => void): void;
|
|
56
|
+
setDisabledState(isDisabled: boolean): void;
|
|
57
|
+
protected get hoursValue(): number | undefined;
|
|
58
|
+
protected get minutesValue(): number | undefined;
|
|
59
|
+
protected onChangeCallback: (_a: unknown) => void;
|
|
60
|
+
protected onTouchedCallback: () => void;
|
|
61
|
+
static ɵfac: i0.ɵɵFactoryDeclaration<NgxTimePickerComponent, never>;
|
|
62
|
+
static ɵcmp: i0.ɵɵComponentDeclaration<NgxTimePickerComponent, "ngx-time-picker", never, { "mode": { "alias": "mode"; "required": false; }; "forceNullValue": { "alias": "forceNullValue"; "required": false; }; "appearance": { "alias": "appearance"; "required": false; }; "autoFocus": { "alias": "autoFocus"; "required": false; }; "defaultPlaceholderHours": { "alias": "defaultPlaceholderHours"; "required": false; }; "defaultPlaceholderMinutes": { "alias": "defaultPlaceholderMinutes"; "required": false; }; "time": { "alias": "time"; "required": false; }; "step": { "alias": "step"; "required": false; }; "disabled": { "alias": "disabled"; "required": false; }; }, { "timeChange": "timeChange"; }, never, never, true, never>;
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
export { NgxTimePickerComponent };
|
|
66
|
+
export type { NgxTimePickerDisplayMode };
|
|
@@ -1,66 +1,3 @@
|
|
|
1
|
-
|
|
2
|
-
import * as i0 from '@angular/core';
|
|
3
|
-
import { ElementRef, EventEmitter, ChangeDetectorRef } from '@angular/core';
|
|
4
|
-
import { ControlValueAccessor, NgControl } from '@angular/forms';
|
|
5
|
-
import { MatFormFieldAppearance } from '@angular/material/form-field';
|
|
6
|
-
import { Subject } from 'rxjs';
|
|
1
|
+
declare const m3 = "M3";
|
|
7
2
|
|
|
8
|
-
|
|
9
|
-
declare class NgxTimePickerComponent implements ControlValueAccessor {
|
|
10
|
-
hours?: ElementRef<HTMLInputElement>;
|
|
11
|
-
minutes?: ElementRef<HTMLInputElement>;
|
|
12
|
-
readonly timeChange: EventEmitter<Date>;
|
|
13
|
-
/** Display mode for the time-picker */
|
|
14
|
-
mode: NgxTimePickerDisplayMode;
|
|
15
|
-
/**
|
|
16
|
-
* Force the hour or minute to be null (only if the other field is disabled)
|
|
17
|
-
*
|
|
18
|
-
* For instance, if set to true and the hours are disabled, the minutes input value will be null
|
|
19
|
-
* This is useful to force the user to provide a value
|
|
20
|
-
*/
|
|
21
|
-
forceNullValue: boolean;
|
|
22
|
-
appearance: MatFormFieldAppearance;
|
|
23
|
-
set autoFocus(value: BooleanInput);
|
|
24
|
-
defaultPlaceholderHours: string;
|
|
25
|
-
defaultPlaceholderMinutes: string;
|
|
26
|
-
set time(value: Date | undefined);
|
|
27
|
-
get time(): Date | undefined;
|
|
28
|
-
/** Step of the arrows */
|
|
29
|
-
set step(value: NumberInput);
|
|
30
|
-
/** To get the step of the minutes arrows */
|
|
31
|
-
get step(): NumberInput;
|
|
32
|
-
/** Disabled property setter. Can be string or empty so you can use it like : <time-picker disabled></time-picker> */
|
|
33
|
-
set disabled(value: BooleanInput);
|
|
34
|
-
/** To get disabled attribute. */
|
|
35
|
-
get disabled(): BooleanInput;
|
|
36
|
-
readonly hoursChange$: Subject<number | Event>;
|
|
37
|
-
readonly minutesChange$: Subject<number | Event>;
|
|
38
|
-
readonly hoursKeyDown$: Subject<KeyboardEvent>;
|
|
39
|
-
protected changeDetectorRef: ChangeDetectorRef;
|
|
40
|
-
protected control: NgControl | null;
|
|
41
|
-
protected _step: number;
|
|
42
|
-
private _disabled;
|
|
43
|
-
private _value?;
|
|
44
|
-
private _autoFocus;
|
|
45
|
-
constructor();
|
|
46
|
-
/** set accessor including call the onchange callback */
|
|
47
|
-
set value(v: Date | undefined);
|
|
48
|
-
/** get accessor */
|
|
49
|
-
get value(): Date | undefined;
|
|
50
|
-
/** From ControlValueAccessor interface */
|
|
51
|
-
writeValue(value: Date | undefined): void;
|
|
52
|
-
/** From ControlValueAccessor interface */
|
|
53
|
-
registerOnChange(fn: (_a: unknown) => void): void;
|
|
54
|
-
/** From ControlValueAccessor interface */
|
|
55
|
-
registerOnTouched(fn: () => void): void;
|
|
56
|
-
setDisabledState(isDisabled: boolean): void;
|
|
57
|
-
protected get hoursValue(): number | undefined;
|
|
58
|
-
protected get minutesValue(): number | undefined;
|
|
59
|
-
protected onChangeCallback: (_a: unknown) => void;
|
|
60
|
-
protected onTouchedCallback: () => void;
|
|
61
|
-
static ɵfac: i0.ɵɵFactoryDeclaration<NgxTimePickerComponent, never>;
|
|
62
|
-
static ɵcmp: i0.ɵɵComponentDeclaration<NgxTimePickerComponent, "ngx-time-picker", never, { "mode": { "alias": "mode"; "required": false; }; "forceNullValue": { "alias": "forceNullValue"; "required": false; }; "appearance": { "alias": "appearance"; "required": false; }; "autoFocus": { "alias": "autoFocus"; "required": false; }; "defaultPlaceholderHours": { "alias": "defaultPlaceholderHours"; "required": false; }; "defaultPlaceholderMinutes": { "alias": "defaultPlaceholderMinutes"; "required": false; }; "time": { "alias": "time"; "required": false; }; "step": { "alias": "step"; "required": false; }; "disabled": { "alias": "disabled"; "required": false; }; }, { "timeChange": "timeChange"; }, never, never, true, never>;
|
|
63
|
-
}
|
|
64
|
-
|
|
65
|
-
export { NgxTimePickerComponent };
|
|
66
|
-
export type { NgxTimePickerDisplayMode };
|
|
3
|
+
export { m3 };
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"hug-ngx-time-picker-testing.mjs","sources":["../../../projects/time-picker/testing/time-picker-harness.ts","../../../projects/time-picker/testing/hug-ngx-time-picker-testing.ts"],"sourcesContent":["import { HarnessPredicate, TestKey } from '@angular/cdk/testing';\nimport { MatFormFieldControlHarness } from '@angular/material/form-field/testing/control';\nimport { MatInputHarness } from '@angular/material/input/testing';\n\nimport { NgxTimePickerHarnessFilters } from './time-picker-harness-filters';\n\n/** Harness for interacting with a ngx time picker in tests. */\nexport class NgxTimePickerHarness extends MatFormFieldControlHarness {\n\n // eslint-disable-next-line @typescript-eslint/naming-convention\n public static hostSelector = 'ngx-time-picker';\n\n static with(options: NgxTimePickerHarnessFilters = {}): HarnessPredicate<NgxTimePickerHarness> {\n return new HarnessPredicate(NgxTimePickerHarness, options).addOption('value', options.value, (harness, value) => HarnessPredicate.stringMatches(harness.getValue(), value));\n }\n\n public async getHoursInput(): Promise<MatInputHarness> {\n return (await this.locatorFactory.harnessLoaderFor('.hours')).getHarness(MatInputHarness.with({ selector: '[matInput]' }));\n }\n\n public async getMinutesInput(): Promise<MatInputHarness> {\n return (await this.locatorFactory.harnessLoaderFor('.minutes')).getHarness(MatInputHarness.with({ selector: '[matInput]' }));\n }\n\n public async setValue(value: string): Promise<void> {\n const hoursMinutes = value.split(':');\n\n if (hoursMinutes[0].length) {\n await this.getHoursInput().then(async hoursInput => {\n await hoursInput.host().then(async hoursElement => {\n await hoursElement.clear();\n await hoursInput.setValue(hoursMinutes[0]);\n await hoursInput.blur();\n });\n });\n }\n\n if (hoursMinutes[1].length) {\n await this.getMinutesInput().then(async minutesInput => {\n await minutesInput.host().then(async minutesElement => {\n await minutesElement.clear();\n await minutesInput.setValue(hoursMinutes[1]);\n await minutesElement.blur();\n });\n });\n }\n }\n\n public async getValue(): Promise<string> {\n return this.getHoursValue().then(hoursValue => this.getMinutesValue().then(minutesValue => `${hoursValue}:${minutesValue}`));\n }\n\n public async getHoursValue(): Promise<string> {\n return this.getHoursInput().then(hoursInput => hoursInput.getValue());\n }\n\n public async getMinutesValue(): Promise<string> {\n return this.getMinutesInput().then(minutesInput => minutesInput.getValue());\n }\n\n public async sendKeysToHoursInput(...keys: readonly TestKey[]): Promise<void> {\n return this.getHoursInput().then(async hoursInput => {\n await hoursInput.host().then(async hoursElement => {\n await hoursElement.sendKeys(...keys);\n });\n });\n }\n\n public async sendKeysToMinutesInput(...keys: readonly TestKey[]): Promise<void> {\n return this.getMinutesInput().then(async minutesInput => {\n await minutesInput.host().then(async minutesElement => {\n await minutesElement.sendKeys(...keys);\n });\n });\n }\n}\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './index';\n"],"names":[],"mappings":";;;;AAMA;AACM,MAAO,oBAAqB,SAAQ,0BAA0B,CAAA;;AAGzD,IAAA,OAAO,YAAY,GAAG,iBAAiB;AAE9C,IAAA,OAAO,IAAI,CAAC,OAAA,GAAuC,EAAE,EAAA;AACjD,QAAA,OAAO,IAAI,gBAAgB,CAAC,oBAAoB,EAAE,OAAO,CAAC,CAAC,SAAS,CAAC,OAAO,EAAE,OAAO,CAAC,KAAK,EAAE,CAAC,OAAO,EAAE,KAAK,KAAK,gBAAgB,CAAC,aAAa,CAAC,OAAO,CAAC,QAAQ,EAAE,EAAE,KAAK,CAAC,CAAC;IAC/K;AAEO,IAAA,MAAM,aAAa,GAAA;QACtB,OAAO,CAAC,MAAM,IAAI,CAAC,cAAc,CAAC,gBAAgB,CAAC,QAAQ,CAAC,EAAE,UAAU,CAAC,eAAe,CAAC,IAAI,CAAC,EAAE,QAAQ,EAAE,YAAY,EAAE,CAAC,CAAC;IAC9H;AAEO,IAAA,MAAM,eAAe,GAAA;QACxB,OAAO,CAAC,MAAM,IAAI,CAAC,cAAc,CAAC,gBAAgB,CAAC,UAAU,CAAC,EAAE,UAAU,CAAC,eAAe,CAAC,IAAI,CAAC,EAAE,QAAQ,EAAE,YAAY,EAAE,CAAC,CAAC;IAChI;IAEO,MA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