1 | import { AfterViewInit, ChangeDetectorRef, ComponentRef, ElementRef, Renderer2 } from '@angular/core';
|
2 | import { Subject, Subscription } from 'rxjs';
|
3 | import { ControlValueAccessor } from '@angular/forms';
|
4 | import { NbTimePickerComponent } from './timepicker.component';
|
5 | import { NbOverlayRef, NbScrollStrategy } from '../cdk/overlay/mapping';
|
6 | import { NbAdjustableConnectedPositionStrategy, NbPositionBuilderService } from '../cdk/overlay/overlay-position';
|
7 | import { NbOverlayService } from '../cdk/overlay/overlay-service';
|
8 | import { NbTriggerStrategy, NbTriggerStrategyBuilderService } from '../cdk/overlay/overlay-trigger';
|
9 | import { NbDateService } from '../calendar-kit/services/date.service';
|
10 | import { NbCalendarTimeModelService } from '../calendar-kit/services/calendar-time-model.service';
|
11 | import * as i0 from "@angular/core";
|
12 | /**
|
13 | * The `NbTimePickerDirective` is form control that gives you ability to select a time. The timepicker
|
14 | * is shown when input receives a `focus` event.
|
15 | * ```html
|
16 | * <input [nbTimepicker]="timepicker">
|
17 | * <nb-timepicker #timepicker></nb-timepicker>
|
18 | * ```
|
19 | *
|
20 | * @stacked-example(Showcase, timepicker/timepicker-showcase.component)
|
21 | *
|
22 | * ### Installation
|
23 | *
|
24 | * Import `NbTimepickerModule.forRoot()` to your root module.
|
25 | * ```ts
|
26 | * @NgModule({
|
27 | * imports: [
|
28 | * // ...
|
29 | * NbTimepickerModule.forRoot(),
|
30 | * ],
|
31 | * })
|
32 | * export class AppModule { }
|
33 | * ```
|
34 | * And `NbTimepickerModule` to your feature module.
|
35 | * ```ts
|
36 | * @NgModule({
|
37 | * imports: [
|
38 | * // ...
|
39 | * NbTimepickerModule,
|
40 | * ],
|
41 | * })
|
42 | * export class PageModule { }
|
43 | *
|
44 | * ```
|
45 | * <div id="native-parse-issue" class="note note-warning">
|
46 | * <div class="note-title">Note</div>
|
47 | * <div class="note-body">
|
48 | * Timepicker uses native Date object by default, which doesn't support parsing by custom format.
|
49 | * According to the ECMAScript specification, the only supported format is a format described by ISO 8061 standard.
|
50 | * This standard requires date part to be included in the date string,
|
51 | * meaning you have to type a date+time in the input.
|
52 | * We highly recommend you to use NbDateFnsDateModule or NbMomentDateModule to be able to support time only strings in
|
53 | * the timepicker inputs. These modules use date-fns and moment date libraries, which provide capabilities
|
54 | * to parse time only strings.
|
55 | * See "Formatting Issue" at
|
56 | * <a href="https://akveo.github.io/nebular/docs/components/datepicker/overview#formatting-issue">Date picker docs</a>
|
57 | * for installation instructions.
|
58 | * </div>
|
59 | * </div>
|
60 | * <hr>
|
61 | *
|
62 | * ### Usage
|
63 | *
|
64 | * To show seconds column along with hours and minutes use `withSeconds` input
|
65 | *
|
66 | * ```html
|
67 | * <input [nbTimepicker]="timepicker">
|
68 | * <nb-timepicker #timepicker withSeconds></nb-timepicker>
|
69 | * ```
|
70 | * @stacked-example(Time picker with seconds, timepicker/timepicker-with-seconds.component)
|
71 | *
|
72 | * To force timepicker work in 12 hours format, use `twelveHoursFormat` input.
|
73 | * By default, timepicker choose 12 or 24 formats based on application locale standards
|
74 | *
|
75 | * ```html
|
76 | * <input [nbTimepicker]="timepicker" twelveHoursFormat>
|
77 | * <nb-timepicker #timepicker></nb-timepicker>
|
78 | * ```
|
79 | *
|
80 | * @stacked-example(Twelve hours format showcase, timepicker/timepicker-twelve-hours-format.component)
|
81 | *
|
82 | * A single column picker with options value as time and minute, so users won’t be able to pick
|
83 | * hours and minutes individually.
|
84 | * You can control options minutes offset via `step` input, e.g.: 11:00, 11:20, 11:40...'
|
85 | *
|
86 | * @stacked-example(Single column, timepicker/timepicker-single-column.component)
|
87 | *
|
88 | * Timepicker support forms and reactive forms API so you can provide value using `formControl` and `ngModel` directives
|
89 | * @stacked-example(Form control, timepicker/timepicker-form-control.component)
|
90 | *
|
91 | * <input [nbTimepicker]="timepicker" twelveHoursFormat>
|
92 | * <nb-timepicker #timepicke [formControl]="formControl"></nb-timepicker>
|
93 | *
|
94 | * @stacked-example(NgModel, timepicker/timepicker-ng-model.component)
|
95 | *
|
96 | * <input [nbTimepicker]="timepicker" twelveHoursFormat>
|
97 | * <nb-timepicker #timepicke [ngModel]="date"></nb-timepicker>
|
98 | *
|
99 | * You can provide localized versions of the timepicker text via the `localization` property of the config
|
100 | * object passed to the `forRoot` or `forChild` methods of the `NbTimepickerModule`:
|
101 | * ```ts
|
102 | * @NgModule({
|
103 | * imports: [
|
104 | * // ...
|
105 | * NbTimepickerModule.forRoot({
|
106 | * localization: {
|
107 | * hoursText: 'Hr',
|
108 | * minutesText: 'Min',
|
109 | * secondsText: 'Sec',
|
110 | * ampmText: 'Am/Pm',
|
111 | * }
|
112 | * }),
|
113 | * ],
|
114 | * })
|
115 | * export class AppModule { }
|
116 | * ```
|
117 | *
|
118 | * @styles
|
119 | *
|
120 | * timepicker-cell-text-color:
|
121 | * timepicker-cell-hover-background-color:
|
122 | * timepicker-cell-hover-text-color:
|
123 | * timepicker-cell-focus-background-color:
|
124 | * timepicker-cell-focus-text-color:
|
125 | * timepicker-cell-active-background-color:
|
126 | * timepicker-cell-active-text-color:
|
127 | * timepicker-cell-text-font-size:
|
128 | * timepicker-cell-text-font-family:
|
129 | * timepicker-cell-text-line-height:
|
130 | * timepicker-cell-text-font-weight:
|
131 | * timepicker-cell-height:
|
132 | * timepicker-header-cell-text-color:
|
133 | * timepicker-header-cell-text-font-size:
|
134 | * timepicker-header-cell-text-font-family:
|
135 | * timepicker-header-cell-height:
|
136 | * timepicker-header-cell-text-line-height:
|
137 | * timepicker-header-cell-text-font-weight:
|
138 | * timepicker-border-color:
|
139 | * timepicker-border-style:
|
140 | * timepicker-border-width:
|
141 | * timepicker-scrollbar-color:
|
142 | * timepicker-scrollbar-background-color:
|
143 | * timepicker-scrollbar-width:
|
144 | * timepicker-single-column-width:
|
145 | * timepicker-multiple-column-width:
|
146 | * timepicker-title-height:
|
147 | * timepicker-title-padding:
|
148 | * timepicker-container-width:
|
149 | * timepicker-container-height:
|
150 | * */
|
151 | export declare class NbTimePickerDirective<D> implements AfterViewInit, ControlValueAccessor {
|
152 | protected document: any;
|
153 | protected positionBuilder: NbPositionBuilderService;
|
154 | protected hostRef: ElementRef;
|
155 | protected triggerStrategyBuilder: NbTriggerStrategyBuilderService;
|
156 | protected overlay: NbOverlayService;
|
157 | protected cd: ChangeDetectorRef;
|
158 | protected calendarTimeModelService: NbCalendarTimeModelService<D>;
|
159 | protected dateService: NbDateService<D>;
|
160 | protected renderer: Renderer2;
|
161 | protected placeholder: string;
|
162 | /**
|
163 | * Provides timepicker component.
|
164 | * */
|
165 | get timepicker(): NbTimePickerComponent<D>;
|
166 | set timepicker(timePicker: NbTimePickerComponent<D>);
|
167 | protected _timePickerComponent: NbTimePickerComponent<D>;
|
168 | protected pickerInputsChangedSubscription: Subscription | undefined;
|
169 | /**
|
170 | * Time picker overlay offset.
|
171 | * */
|
172 | overlayOffset: number;
|
173 | /**
|
174 | * String representation of latest selected date.
|
175 | * Updated when value is updated programmatically (writeValue), via timepicker (subscribeOnApplyClick)
|
176 | * or via input field (handleInputChange)
|
177 | * @docs-private
|
178 | */
|
179 | protected lastInputValue: string;
|
180 | /**
|
181 | * Positioning strategy used by overlay.
|
182 | * @docs-private
|
183 | * */
|
184 | protected positionStrategy: NbAdjustableConnectedPositionStrategy;
|
185 | protected overlayRef: NbOverlayRef;
|
186 | protected destroy$: Subject<void>;
|
187 | protected onChange: (value: D) => void;
|
188 | protected onTouched: () => void;
|
189 | /**
|
190 | * Trigger strategy used by overlay.
|
191 | * @docs-private
|
192 | * */
|
193 | protected triggerStrategy: NbTriggerStrategy;
|
194 | /**
|
195 | * Returns html input element.
|
196 | * @docs-private
|
197 | * */
|
198 | get input(): HTMLInputElement;
|
199 | /**
|
200 | * Determines is timepicker overlay opened.
|
201 | * @docs-private
|
202 | * */
|
203 | get isOpen(): boolean;
|
204 | /**
|
205 | * Determines is timepicker overlay closed.
|
206 | * @docs-private
|
207 | * */
|
208 | get isClosed(): boolean;
|
209 | constructor(document: any, positionBuilder: NbPositionBuilderService, hostRef: ElementRef, triggerStrategyBuilder: NbTriggerStrategyBuilderService, overlay: NbOverlayService, cd: ChangeDetectorRef, calendarTimeModelService: NbCalendarTimeModelService<D>, dateService: NbDateService<D>, renderer: Renderer2, placeholder: string);
|
210 | /**
|
211 | * Returns host input value.
|
212 | * @docs-private
|
213 | * */
|
214 | get inputValue(): string;
|
215 | set inputValue(value: string);
|
216 | ngAfterViewInit(): void;
|
217 | show(): void;
|
218 | hide(): void;
|
219 | /**
|
220 | * Attaches picker to the timepicker portal.
|
221 | * @docs-private
|
222 | * */
|
223 | protected attachToOverlay(): void;
|
224 | setupTimepicker(): void;
|
225 | protected initOverlay(): void;
|
226 | protected subscribeOnApplyClick(): void;
|
227 | protected createOverlay(): void;
|
228 | protected subscribeOnTriggers(): void;
|
229 | protected createTriggerStrategy(): NbTriggerStrategy;
|
230 | protected createPositionStrategy(): NbAdjustableConnectedPositionStrategy;
|
231 | protected getContainer(): ComponentRef<any>;
|
232 | protected createScrollStrategy(): NbScrollStrategy;
|
233 | protected subscribeOnInputChange(): void;
|
234 | protected subscribeToBlur(): void;
|
235 | /**
|
236 | * Parses input value and write if it isn't null.
|
237 | * @docs-private
|
238 | * */
|
239 | protected handleInputChange(value: string): void;
|
240 | protected updateValue(value: D): void;
|
241 | writeValue(value: D): void;
|
242 | registerOnChange(fn: (value: any) => {}): void;
|
243 | registerOnTouched(fn: any): void;
|
244 | setDisabledState(isDisabled: boolean): void;
|
245 | protected parseNativeDateString(value: string): string;
|
246 | static ɵfac: i0.ɵɵFactoryDeclaration<NbTimePickerDirective<any>, [null, null, null, null, null, null, null, null, null, { attribute: "placeholder"; }]>;
|
247 | static ɵdir: i0.ɵɵDirectiveDeclaration<NbTimePickerDirective<any>, "input[nbTimepicker]", never, { "timepicker": { "alias": "nbTimepicker"; "required": false; }; "overlayOffset": { "alias": "overlayOffset"; "required": false; }; }, {}, never, never, false, never>;
|
248 | }
|