UNPKG

@sd-angular/core

Version:

Sd Angular Core Lib

2 lines 10.4 kB
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports,require("@sd-angular/core/common"),require("@angular/core"),require("@angular/common"),require("@angular/forms"),require("@angular/material/form-field"),require("@angular/material/datepicker"),require("@angular/material-moment-adapter"),require("@angular/material/core"),require("ngx-device-detector"),require("moment"),require("uuid"),require("object-hash"),require("rxjs"),require("@angular/material/icon"),require("@sd-angular/core/translate")):"function"==typeof define&&define.amd?define("@sd-angular/core/date-range",["exports","@sd-angular/core/common","@angular/core","@angular/common","@angular/forms","@angular/material/form-field","@angular/material/datepicker","@angular/material-moment-adapter","@angular/material/core","ngx-device-detector","moment","uuid","object-hash","rxjs","@angular/material/icon","@sd-angular/core/translate"],t):t(((e="undefined"!=typeof globalThis?globalThis:e||self)["sd-angular"]=e["sd-angular"]||{},e["sd-angular"].core=e["sd-angular"].core||{},e["sd-angular"].core["date-range"]={}),e["sd-angular"].core.common,e.ng.core,e.ng.common,e.ng.forms,e.ng.material.formField,e.ng.material.datepicker,e.ng.materialMomentAdapter,e.ng.material.core,e["ngx-device-detector"],e.moment,e.uuid,e.hash,e.rxjs,e.ng.material.icon,e["sd-angular"].core.translate)}(this,(function(e,t,a,r,o,n,i,l,s,d,u,c,m,p,f,h){"use strict";function g(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}var b=g(u),y=g(m);Object.create;var v,M,C,D,w,k,I,q,E;Object.create;function O(e,t,a,r){if("a"===a&&!r)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!r:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===a?r:"a"===a?r.call(e):r?r.value:t.get(e)}function Y(e,t,a,r,o){if("m"===r)throw new TypeError("Private method is not writable");if("a"===r&&!o)throw new TypeError("Private accessor was defined without a setter");if("function"==typeof t?e!==t||!o:!t.has(e))throw new TypeError("Cannot write private member to an object whose class did not declare it");return"a"===r?o.call(e,a):o?o.value=a:t.set(e,a),a}var j={parse:{dateInput:"DD/MM/YYYY"},display:{dateInput:"DD/MM/YYYY",monthYearLabel:"MMM YYYY",dateA11yLabel:"LL",monthYearA11yLabel:"MMMM YYYY"}},x=function(){function e(e,t,r){var n=this;this.cdRef=e,this.detectorService=t,this.formConfig=r,this.id1="I"+c.v4(),this.id2="I"+c.v4(),v.set(this,null),M.set(this,null),this.isMobileOrTablet=!1,C.set(this,c.v4()),D.set(this,void 0),this.formControl=new o.FormControl,this.required=!1,this.disableErrorMessage=!1,this.sdChange=new a.EventEmitter,this.fromChange=new a.EventEmitter,this.toChange=new a.EventEmitter,this.control1=new o.FormControl,w.set(this,c.v4()),this.control2=new o.FormControl,k.set(this,c.v4()),I.set(this,new p.Subscription),q.set(this,(function(){var e=Date.isDate(O(n,v))?b.default(Date.toFormat(O(n,v),"MM/dd/yyyy HH:mm:ss"),"MM/DD/YYYY HH:mm:ss"):null,t=Date.isDate(O(n,M))?b.default(Date.toFormat(O(n,M),"MM/dd/yyyy HH:mm:ss"),"MM/DD/YYYY HH:mm:ss"):null;n.control1.setValue(e,{emitEvent:!1}),n.control2.setValue(t,{emitEvent:!1}),n.formControl.setValue({from:e,to:t},{emitEvent:!1}),n.cdRef.markForCheck()})),this.onStartChange=function(e){var t,a,r=(null===(t=e.value)||void 0===t?void 0:t.toDate())||null,o=Date.toFormat(null===(a=e.value)||void 0===a?void 0:a.toDate(),"MM/dd/yyyy HH:mm:ss");Date.toFormat(O(n,v),"MM/dd/yyyy HH:mm:ss")!==o&&(Y(n,v,r),n.fromChange.emit(r),O(n,E).call(n))},this.onEndChange=function(e){var t,a,r=(null===(t=e.value)||void 0===t?void 0:t.toDate())||null,o=Date.toFormat(null===(a=e.value)||void 0===a?void 0:a.toDate(),"MM/dd/yyyy HH:mm:ss");Date.toFormat(O(n,M),"MM/dd/yyyy HH:mm:ss")!==o&&(Y(n,M,r),n.toChange.emit(r),O(n,E).call(n))},E.set(this,(function(){var e,t,a=(null===(e=n.control1.value)||void 0===e?void 0:e.toDate())||null,r=(null===(t=n.control2.value)||void 0===t?void 0:t.toDate())||null;n.formControl.setValue({from:a,to:r},{emitEvent:!1}),n.sdChange.emit(n.formControl.value),n.cdRef.markForCheck()})),this.clear=function(){n.control1.setValue(null,{emitEvent:!1}),n.control2.setValue(null,{emitEvent:!1}),n.formControl.setValue({from:null,to:null},{emitEvent:!1}),Y(n,v,n.control1.value),Y(n,M,n.control2.value),n.fromChange.emit(O(n,v)),n.toChange.emit(O(n,M)),n.sdChange.emit(n.formControl.value),n.cdRef.markForCheck()},this.isMobileOrTablet=!this.detectorService.isDesktop(),this.cdRef.markForCheck()}return Object.defineProperty(e.prototype,"name",{set:function(e){e&&Y(this,C,e)},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"form",{set:function(e){e&&(e instanceof o.NgForm?Y(this,D,e.form):Y(this,D,e))},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"disabled",{set:function(e){(e=""===e||e)?this.formControl.disable():this.formControl.enable()},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"_required",{set:function(e){this.required=""===e||e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"_label",{set:function(e){this.label=e,this.qcId=y.default({selector:"sd-date-range",label:e})},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"_disableErrorMessage",{set:function(e){this.disableErrorMessage=""===e||e,e=""===e||e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"_min",{set:function(e){Date.isDate(e)?this.min=new Date(e):this.min=null},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"_max",{set:function(e){Date.isDate(e)?this.max=new Date(e):this.max=null},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"from",{set:function(e){Date.isDate(e)||(e=null),O(this,v)!==e&&(Y(this,v,e),O(this,q).call(this))},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"to",{set:function(e){Date.isDate(e)||(e=null),O(this,M)!==e&&(Y(this,M,e),O(this,q).call(this))},enumerable:!1,configurable:!0}),e.prototype.ngOnDestroy=function(){var e,t,a;null===(e=O(this,D))||void 0===e||e.removeControl(O(this,w)),null===(t=O(this,D))||void 0===t||t.removeControl(O(this,k)),null===(a=O(this,D))||void 0===a||a.removeControl(O(this,C)),O(this,I).unsubscribe()},e.prototype.ngOnInit=function(){var e,t,a,r;this.appearance=this.appearance||(null===(e=this.formConfig)||void 0===e?void 0:e.appearance),null===(t=O(this,D))||void 0===t||t.addControl(O(this,w),this.control1),null===(a=O(this,D))||void 0===a||a.addControl(O(this,k),this.control2),null===(r=O(this,D))||void 0===r||r.addControl(O(this,C),this.formControl)},e.prototype.ngAfterViewInit=function(){O(this,q).call(this)},e}();v=new WeakMap,M=new WeakMap,C=new WeakMap,D=new WeakMap,w=new WeakMap,k=new WeakMap,I=new WeakMap,q=new WeakMap,E=new WeakMap,x.decorators=[{type:a.Component,args:[{selector:"sd-date-range",template:'<ng-container *ngIf="!appearance && sdLabelDef?.templateRef">\r\n <ng-container *ngTemplateOutlet="sdLabelDef.templateRef">\r\n </ng-container>\r\n</ng-container>\r\n<label *ngIf="!appearance && label &&!sdLabelDef?.templateRef" class="d-block mb-0 T14M">{{label}} <span class="text-danger mb-2"\r\n *ngIf="required">*</span></label>\r\n<mat-form-field class="sd-md" [ngClass]="{\'sd-sm\': size === \'sm\', \'no-padding-wrapper\': disableErrorMessage}"\r\n [appearance]="appearance || \'outline\'">\r\n <mat-label *ngIf="appearance && label">{{label}}</mat-label>\r\n <mat-date-range-input [max]="max" [min]="min" [rangePicker]="picker" [disabled]="formControl.disabled">\r\n <input aria-hidden="true" [id]="id1" autocomplete="off" autocorrect="off" matStartDate [formControl]="control1"\r\n (dateInput)="onStartChange($event)" [placeholder]="formControl.disabled ? \'\' : (\'Start\' | sdTranslate)"\r\n [attr.data-qclabel]="label" [attr.data-qcid]="qcId + \'input1\'">\r\n <input aria-hidden="true" [id]="id2" [autocomplete]="id2" autocorrect="off" matEndDate [formControl]="control2"\r\n (dateInput)="onEndChange($event)" [placeholder]="formControl.disabled ? \'\' : (\'End\' | sdTranslate)"\r\n [attr.data-qclabel]="label" [attr.data-qcid]="qcId + \'input2\'">\r\n </mat-date-range-input>\r\n <mat-icon *ngIf="control1?.value || control2?.value" class="pointer sd-suffix-icon" (click)="clear()" matSuffix>cancel\r\n </mat-icon>\r\n <mat-icon class="pointer sd-suffix-icon" (click)="!formControl.disabled && picker.open()" matSuffix>today\r\n </mat-icon>\r\n <mat-date-range-picker [touchUi]="isMobileOrTablet" #picker></mat-date-range-picker>\r\n</mat-form-field>',providers:[{provide:s.MAT_DATE_FORMATS,useValue:j}],changeDetection:a.ChangeDetectionStrategy.OnPush,styles:[":host{display:block;padding-top:5px}:host ::ng-deep .mat-form-field.no-padding-wrapper .mat-form-field-wrapper{padding-bottom:0}:host ::ng-deep .mat-form-field.mat-form-field-appearance-outline.mat-form-field-disabled .mat-form-field-outline{background:#f6f6f6;color:#e9e9e9}:host ::ng-deep .mat-form-field input.mat-end-date:disabled,:host ::ng-deep .mat-form-field input.mat-start-date:disabled{color:#4d4d4d!important}:host ::ng-deep .mat-form-field .mat-placeholder-required{color:#f82c13}"]}]}],x.ctorParameters=function(){return[{type:a.ChangeDetectorRef},{type:d.DeviceDetectorService},{type:void 0,decorators:[{type:a.Inject,args:[t.FORM_CONFIG]},{type:a.Optional}]}]},x.propDecorators={name:[{type:a.Input}],appearance:[{type:a.Input}],size:[{type:a.Input}],form:[{type:a.Input}],disabled:[{type:a.Input}],_required:[{type:a.Input,args:["required"]}],_label:[{type:a.Input,args:["label"]}],_disableErrorMessage:[{type:a.Input,args:["disableErrorMessage"]}],_min:[{type:a.Input,args:["min"]}],_max:[{type:a.Input,args:["max"]}],from:[{type:a.Input}],to:[{type:a.Input}],sdChange:[{type:a.Output}],fromChange:[{type:a.Output}],toChange:[{type:a.Output}],sdLabelDef:[{type:a.ContentChild,args:[t.SdLabelDefDirective]}]};var F=function(){};F.decorators=[{type:a.NgModule,args:[{imports:[r.CommonModule,o.FormsModule,o.ReactiveFormsModule,n.MatFormFieldModule,f.MatIconModule,i.MatDatepickerModule,l.MatMomentDateModule,h.SdTranslateModule],declarations:[x],exports:[x],providers:[]}]}],e.SdDateRange=x,e.SdDateRangeModule=F,e.ɵ0=j,Object.defineProperty(e,"__esModule",{value:!0})})); //# sourceMappingURL=sd-angular-core-date-range.umd.min.js.map