1- import { Component , ViewChild } from '@angular/core' ;
1+ import { Component , CUSTOM_ELEMENTS_SCHEMA , DestroyRef , ViewChild } from '@angular/core' ;
22import { JsonPipe } from '@angular/common' ;
33import { UntypedFormGroup , UntypedFormBuilder , Validators , UntypedFormControl , ValidatorFn , AbstractControl , FormsModule , ReactiveFormsModule } from '@angular/forms' ;
4+ import { DateRange , IgxButtonDirective , IgxDateRangePickerComponent , IgxDateTimeEditorDirective , IgxInputDirective , IgxLabelDirective , IgxRadioComponent , IgxRippleDirective , IGX_INPUT_GROUP_TYPE , IChangeCheckboxEventArgs , IGX_DATE_RANGE_PICKER_DIRECTIVES , IgxIconComponent , IgSizeDirective } from 'igniteui-angular' ;
45import { DateRangeType } from 'igniteui-angular/src/lib/calendar/common/types' ;
6+ import { defineComponents , IgcButtonComponent , IgcDateRangePickerComponent , IgcDateTimeInputComponent , IgcIconComponent } from 'igniteui-webcomponents' ;
7+ import { Properties , PropertyChangeService , PropertyPanelConfig } from '../properties-panel/property-change.service' ;
58
9+ defineComponents ( IgcDateRangePickerComponent , IgcButtonComponent , IgcIconComponent , IgcDateTimeInputComponent ) ;
610
711@Component ( {
812 selector : 'app-date-range' ,
913 templateUrl : './date-range.sample.html' ,
1014 styleUrls : [ './date-range.sample.scss' ] ,
15+ schemas : [ CUSTOM_ELEMENTS_SCHEMA ] ,
1116 providers : [
1217 {
1318 provide : IGX_INPUT_GROUP_TYPE ,
1419 useValue : 'border'
1520 }
1621 ] ,
17- imports : [ IgxButtonDirective , IgxRippleDirective , IgxDateRangePickerComponent , IgxPickerToggleComponent , IgxSuffixDirective , IgxIconComponent , IgxDateRangeStartComponent , IgxInputDirective , IgxDateTimeEditorDirective , IgxPrefixDirective , IgxDateRangeEndComponent , FormsModule , IgxLabelDirective , IgxRadioComponent , ReactiveFormsModule , JsonPipe ]
22+ imports : [
23+ IgxButtonDirective ,
24+ IgxRippleDirective ,
25+ FormsModule ,
26+ IgxLabelDirective ,
27+ IgxRadioComponent ,
28+ ReactiveFormsModule ,
29+ JsonPipe ,
30+ IGX_DATE_RANGE_PICKER_DIRECTIVES ,
31+ IgxInputDirective ,
32+ IgxDateTimeEditorDirective ,
33+ IgxIconComponent ,
34+ IgSizeDirective
35+ ]
1836} )
1937export class DateRangeSampleComponent {
2038 @ViewChild ( 'dr1' , { static : true } )
@@ -29,22 +47,155 @@ export class DateRangeSampleComponent {
2947 public range6Start = null ;
3048 public range6End = null ;
3149 public range6 : DateRange = { start : this . range6Start , end : this . range6End } ;
32- public minDate : Date = new Date ( ) ;
50+ public minDate : Date = new Date ( new Date ( ) . setDate ( new Date ( ) . getDate ( ) - 20 ) ) ;
3351 public maxDate : Date = new Date ( new Date ( ) . setDate ( new Date ( ) . getDate ( ) + 25 ) ) ;
3452
3553 public reactiveForm : UntypedFormGroup ;
54+ public DateRangeType = DateRangeType ;
3655
3756 public updateOnOptions : string [ ] = [ 'change' , 'blur' , 'submit' ] ;
3857 public updateOn = 'blur' ;
3958
59+
60+ public specialDates = [ {
61+ type : DateRangeType . Between , dateRange : [
62+ new Date ( new Date ( ) . getFullYear ( ) , new Date ( ) . getMonth ( ) , 3 ) ,
63+ new Date ( new Date ( ) . getFullYear ( ) , new Date ( ) . getMonth ( ) , 8 )
64+ ]
65+ } ] ;
66+
4067 public disabledDates = [ {
4168 type : DateRangeType . Between , dateRange : [
4269 new Date ( new Date ( ) . getFullYear ( ) , new Date ( ) . getMonth ( ) , 20 ) ,
4370 new Date ( new Date ( ) . getFullYear ( ) , new Date ( ) . getMonth ( ) , 25 )
4471 ]
4572 } ] ;
4673
47- constructor ( fb : UntypedFormBuilder ) {
74+ public panelConfig : PropertyPanelConfig = {
75+ size : {
76+ control : {
77+ type : 'button-group' ,
78+ options : [ 'small' , 'medium' , 'large' ] ,
79+ defaultValue : 'medium' ,
80+ }
81+ } ,
82+ mode : {
83+ control : {
84+ type : 'button-group' ,
85+ options : [ 'dropdown' , 'dialog' ] ,
86+ defaultValue : 'dropdown'
87+ }
88+ } ,
89+ value : {
90+ control : {
91+ type : 'date-range' ,
92+ defaultValue : this . range3
93+ }
94+ } ,
95+ minValue : {
96+ label : 'Min Value' ,
97+ control : {
98+ type : 'date' ,
99+ defaultValue : this . minDate
100+ }
101+ } ,
102+ maxValue : {
103+ label : 'Max Value' ,
104+ control : {
105+ type : 'date' ,
106+ defaultValue : this . maxDate
107+ }
108+ } ,
109+ required : {
110+ control : {
111+ type : 'boolean' ,
112+ defaultValue : false
113+ }
114+ } ,
115+ disabled : {
116+ control : {
117+ type : 'boolean' ,
118+ defaultValue : false
119+ }
120+ } ,
121+ placeholder : {
122+ control : {
123+ type : 'text' ,
124+ defaultValue : 'MM/dd/yyyy'
125+ }
126+ } ,
127+ displayFormat : {
128+ label : 'Display Format' ,
129+ control : {
130+ type : 'text'
131+ }
132+ } ,
133+ inputFormat : {
134+ label : 'Input Format' ,
135+ control : {
136+ type : 'text'
137+ }
138+ } ,
139+ hasHeader : {
140+ label : 'Has Header (for dialog mode)' ,
141+ control : {
142+ type : 'boolean' ,
143+ defaultValue : true
144+ }
145+ } ,
146+ orientation : {
147+ label : 'Orientation' ,
148+ control : {
149+ type : 'button-group' ,
150+ options : [ 'horizontal' , 'vertical' ] ,
151+ defaultValue : 'horizontal'
152+ }
153+ } ,
154+ headerOrientation : {
155+ label : 'Header Orientation (dialog mode)' ,
156+ control : {
157+ type : 'button-group' ,
158+ options : [ 'horizontal' , 'vertical' ] ,
159+ defaultValue : 'horizontal'
160+ }
161+ } ,
162+ headerTemplate : {
163+ label : 'Show Header Template (dialog)' ,
164+ control : {
165+ type : 'boolean' ,
166+ defaultValue : false
167+ }
168+ } ,
169+ calendarTitle : {
170+ label : 'Show Calendar Title (dialog)' ,
171+ control : {
172+ type : 'boolean' ,
173+ defaultValue : false
174+ }
175+ } ,
176+ separator : {
177+ label : 'Separator text' ,
178+ control : {
179+ type : 'text' ,
180+ defaultValue : 'to'
181+ }
182+ } ,
183+ visibleMonths : {
184+ label : 'Visible Months' ,
185+ control : {
186+ type : 'number' ,
187+ defaultValue : 2 ,
188+ }
189+ } ,
190+ } ;
191+
192+ public properties : Properties ;
193+
194+ constructor (
195+ fb : UntypedFormBuilder ,
196+ private propertyChangeService : PropertyChangeService ,
197+ private destroyRef : DestroyRef
198+ ) {
48199 const today = new Date ( ) ;
49200 const in5days = new Date ( ) ;
50201 in5days . setDate ( today . getDate ( ) + 5 ) ;
@@ -60,6 +211,17 @@ export class DateRangeSampleComponent {
60211 start6 : [ '' , { validators : Validators . required , updateOn : this . updateOn } ] ,
61212 end6 : [ '' , { validators : Validators . required , updateOn : this . updateOn } ] ,
62213 } ) ;
214+
215+ this . propertyChangeService . setPanelConfig ( this . panelConfig ) ;
216+
217+ const propertyChange =
218+ this . propertyChangeService . propertyChanges . subscribe (
219+ ( properties ) => {
220+ this . properties = properties ;
221+ }
222+ ) ;
223+
224+ this . destroyRef . onDestroy ( ( ) => propertyChange . unsubscribe ( ) ) ;
63225 }
64226
65227 public updateOnChange ( e : IChangeCheckboxEventArgs ) {
0 commit comments