From c3e453dd6186bf1b228464e56944823e35c88af0 Mon Sep 17 00:00:00 2001 From: didimmova Date: Tue, 21 Oct 2025 14:26:06 +0300 Subject: [PATCH] feat(timepicker): update timepicker sample with properties panel --- src/app/time-picker/time-picker.sample.html | 52 +++++++- src/app/time-picker/time-picker.sample.scss | 12 ++ src/app/time-picker/time-picker.sample.ts | 124 +++++++++++++++++++- 3 files changed, 180 insertions(+), 8 deletions(-) diff --git a/src/app/time-picker/time-picker.sample.html b/src/app/time-picker/time-picker.sample.html index 7da22ba5546..8cce0135198 100644 --- a/src/app/time-picker/time-picker.sample.html +++ b/src/app/time-picker/time-picker.sample.html @@ -2,10 +2,34 @@

Time Picker with Date value binding

{{showDate(date)}}

-
- +
+ + @if (hasLabel) { + + } @if (hasPrefix) { + face + } @if (hasSuffix) { + face + } @if (hasHint) { + It's a hint + }
@@ -77,4 +101,24 @@

Time Picker with custom spin buttons

+ + +
+ + + + + + + + + + + + + + + +
+
diff --git a/src/app/time-picker/time-picker.sample.scss b/src/app/time-picker/time-picker.sample.scss index 7d984d7219f..a3231aaec7b 100644 --- a/src/app/time-picker/time-picker.sample.scss +++ b/src/app/time-picker/time-picker.sample.scss @@ -14,3 +14,15 @@ justify-content: center; padding: 8px; } + +.custom-controls { + igx-switch { + display: flex; + align-items: center; + margin-bottom: 16px; + + label { + margin: 0; + } + } +} diff --git a/src/app/time-picker/time-picker.sample.ts b/src/app/time-picker/time-picker.sample.ts index 8f94c56d4f8..04d6673bbb6 100644 --- a/src/app/time-picker/time-picker.sample.ts +++ b/src/app/time-picker/time-picker.sample.ts @@ -1,4 +1,4 @@ -import { Component, ViewChild } from '@angular/core'; +import { Component, DestroyRef, inject, TemplateRef, ViewChild, OnInit } from '@angular/core'; import { FormsModule } from '@angular/forms'; import { IgxTimePickerComponent, @@ -13,22 +13,53 @@ import { IgxPrefixDirective, IgxIconComponent, IgxPickerClearComponent, - IgxSuffixDirective + IgxSuffixDirective, + IgxLabelDirective, + IgSizeDirective, + PickerInteractionMode, + IgxSwitchComponent } from 'igniteui-angular'; +import { + PropertyPanelConfig, + PropertyChangeService, + Properties, +} from '../properties-panel/property-change.service'; @Component({ selector: 'app-time-picker-sample', styleUrls: ['time-picker.sample.scss'], templateUrl: 'time-picker.sample.html', - imports: [IgxTimePickerComponent, FormsModule, IgxHintDirective, IgxButtonDirective, IgxPickerActionsDirective, IgxPickerToggleComponent, IgxPrefixDirective, IgxIconComponent, IgxPickerClearComponent, IgxSuffixDirective] + imports: [ + IgxTimePickerComponent, + FormsModule, + IgxHintDirective, + IgxButtonDirective, + IgxPickerActionsDirective, + IgxPickerToggleComponent, + IgxPrefixDirective, + IgxIconComponent, + IgxPickerClearComponent, + IgxSuffixDirective, + IgxLabelDirective, + IgSizeDirective, + IgxSwitchComponent + ] }) -export class TimePickerSampleComponent { +export class TimePickerSampleComponent implements OnInit { @ViewChild('tp', { read: IgxTimePickerComponent, static: true }) public tp: IgxTimePickerComponent; @ViewChild('target') public target: IgxInputDirective; + @ViewChild('customControls', { static: true }) + public customControlsTemplate!: TemplateRef; + + public hasSuffix = false; + public hasPrefix = false; + public hasLabel = false; + public hasHint = false; + public itemsDelta = { hours: 1, minutes: 15, seconds: 20 }; public format = 'hh:mm:ss:SS a'; public spinLoop = true; @@ -49,6 +80,91 @@ export class TimePickerSampleComponent { positionStrategy: new AutoPositionStrategy() }; + public panelConfig: PropertyPanelConfig = { + size: { + control: { + type: 'button-group', + options: ['small', 'medium', 'large'], + defaultValue: 'medium', + } + }, + mode: { + control: { + type: 'button-group', + options: [ + { label: 'dialog', value: PickerInteractionMode.Dialog}, + { label: 'dropdown', value: PickerInteractionMode.DropDown} + ], + defaultValue: 'dropdown' + } + }, + type: { + control: { + type: 'button-group', + options: ['box', 'border', 'line'], + defaultValue: 'box' + } + }, + readonly: { + control: { + type: 'boolean', + defaultValue: false + } + }, + disabled: { + control: { + type: 'boolean', + defaultValue: false + } + }, + value: { + control: { + type: 'time' + } + }, + placeholder: { + control: { + type: 'text', + defaultValue: 'hh:mm' + } + }, + displayFormat: { + label: 'Display Format', + control: { + type: 'text' + } + }, + inputFormat: { + label: 'Input Format', + control: { + type: 'text' + } + } + } + + public properties: Properties; + private propertyChangeService = inject(PropertyChangeService); + private destroyRef = inject(DestroyRef); + + constructor() { + this.propertyChangeService.setPanelConfig(this.panelConfig); + + const propertyChange = + this.propertyChangeService.propertyChanges.subscribe( + (properties) => { + this.properties = properties; + } + ); + + this.destroyRef.onDestroy(() => propertyChange.unsubscribe()); + } + + public ngOnInit() { + this.propertyChangeService.setCustomControls( + this.customControlsTemplate + ); + } + public change() { this.isRequired = !this.isRequired; }