UNPKG

@lxlib/seed

Version:

This library was generated with [Angular CLI](https://github.com/angular/angular-cli) version 9.1.1.

16 lines (14 loc) 11.9 kB
!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports,require("@angular/core"),require("@lxlib/util"),require("@angular/forms"),require("@lxlib/theme"),require("ng-zorro-antd/core/animation"),require("@angular/common"),require("ng-zorro-antd/core/outlet"),require("ng-zorro-antd/icon"),require("ng-zorro-antd/tooltip")):"function"==typeof define&&define.amd?define("@lxlib/seed/se",["exports","@angular/core","@lxlib/util","@angular/forms","@lxlib/theme","ng-zorro-antd/core/animation","@angular/common","ng-zorro-antd/core/outlet","ng-zorro-antd/icon","ng-zorro-antd/tooltip"],e):e(((t=t||self).lxlib=t.lxlib||{},t.lxlib.seed=t.lxlib.seed||{},t.lxlib.seed.se={}),t.ng.core,t.lxlib.util,t.ng.forms,t.lxlib.theme,t.animation,t.ng.common,t["ng-zorro-antd/core/outlet"],t["ng-zorro-antd/icon"],t["ng-zorro-antd/tooltip"])}(this,(function(t,e,n,o,r,i,l,a,s,p){"use strict"; /*! ***************************************************************************** Copyright (c) Microsoft Corporation. All rights reserved. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 THIS CODE IS PROVIDED ON AN *AS IS* BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION ANY IMPLIED WARRANTIES OR CONDITIONS OF TITLE, FITNESS FOR A PARTICULAR PURPOSE, MERCHANTABLITY OR NON-INFRINGEMENT. See the Apache Version 2.0 License for specific language governing permissions and limitations under the License. ***************************************************************************** */var u=function(){return(u=Object.assign||function(t){for(var e,n=1,o=arguments.length;n<o;n++)for(var r in e=arguments[n])Object.prototype.hasOwnProperty.call(e,r)&&(t[r]=e[r]);return t}).apply(this,arguments)};function c(t,e,n,o){var r,i=arguments.length,l=i<3?e:null===o?o=Object.getOwnPropertyDescriptor(e,n):o;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)l=Reflect.decorate(t,e,n,o);else for(var a=t.length-1;a>=0;a--)(r=t[a])&&(l=(i<3?r(l):i>3?r(e,n,l):r(e,n))||l);return i>3&&l&&Object.defineProperty(e,n,l),l}function d(t,e){if("object"==typeof Reflect&&"function"==typeof Reflect.metadata)return Reflect.metadata(t,e)}function h(t,e){var n="function"==typeof Symbol&&t[Symbol.iterator];if(!n)return t;var o,r,i=n.call(t),l=[];try{for(;(void 0===e||e-- >0)&&!(o=i.next()).done;)l.push(o.value)}catch(t){r={error:t}}finally{try{o&&!o.done&&(n=i.return)&&n.call(i)}finally{if(r)throw r.error}}return l}function g(){for(var t=[],e=0;e<arguments.length;e++)t=t.concat(h(arguments[e]));return t}var f=function(){function t(){this.size="default",this.nzLayout="horizontal",this.gutter=32,this.col=2,this.labelWidth=150,this.firstVisual=!1}return t.decorators=[{type:e.Injectable,args:[{providedIn:"root"}]}],t.ɵprov=e.ɵɵdefineInjectable({factory:function(){return new t},token:t,providedIn:"root"}),t}();var y=function(){function t(t){this.line=!1,Object.assign(this,u(u({},new f),t))}return Object.defineProperty(t.prototype,"gutter",{get:function(){return"horizontal"===this.nzLayout?this._gutter:0},set:function(t){this._gutter=n.toNumber(t)},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"nzLayout",{get:function(){return this._nzLayout},set:function(t){this._nzLayout=t,"inline"===t&&(this.size="compact")},enumerable:!0,configurable:!0}),t.decorators=[{type:e.Component,args:[{selector:"se-container, [se-container]",exportAs:"seContainer",template:'<div class="ant-row se__container se__{{nzLayout}} se__{{size}}"\n [ngStyle]="{\'margin-left.px\': -(gutter / 2), \'margin-right.px\': -(gutter / 2)}">\n <se-title *ngIf="title">\n <ng-container *nzStringTemplateOutlet="title">{{ title }}</ng-container>\n </se-title>\n <ng-content></ng-content>\n</div>\n',preserveWhitespaces:!1,changeDetection:e.ChangeDetectionStrategy.OnPush,encapsulation:e.ViewEncapsulation.None}]}],t.ctorParameters=function(){return[{type:f}]},t.propDecorators={colInCon:[{type:e.Input,args:["se-container"]}],col:[{type:e.Input}],labelWidth:[{type:e.Input}],title:[{type:e.Input}],gutter:[{type:e.Input}],nzLayout:[{type:e.Input}],size:[{type:e.Input}],firstVisual:[{type:e.Input}],line:[{type:e.Input}]},c([n.InputNumber(null),d("design:type",Number)],t.prototype,"colInCon",void 0),c([n.InputNumber(null),d("design:type",Number)],t.prototype,"col",void 0),c([n.InputNumber(null),d("design:type",Number)],t.prototype,"labelWidth",void 0),c([n.InputBoolean(),d("design:type",Boolean)],t.prototype,"firstVisual",void 0),c([n.InputBoolean(),d("design:type",Object)],t.prototype,"line",void 0),t}();var m=function(){function t(t,e,n){if(this.parent=t,this.ren=n,null==t)throw new Error("[se-title] must include 'se-container' component");this.el=e.nativeElement}return t.prototype.setClass=function(){var t=this.parent.gutter,e=this.el;this.ren.setStyle(e,"padding-left",t/2+"px"),this.ren.setStyle(e,"padding-right",t/2+"px")},t.prototype.ngOnInit=function(){this.setClass()},t.decorators=[{type:e.Component,args:[{selector:"se-title, [se-title]",exportAs:"seTitle",template:"<ng-content></ng-content>",host:{"[class.se__title]":"true"},preserveWhitespaces:!1,changeDetection:e.ChangeDetectionStrategy.OnPush,encapsulation:e.ViewEncapsulation.None}]}],t.ctorParameters=function(){return[{type:y,decorators:[{type:e.Host},{type:e.Optional}]},{type:e.ElementRef},{type:e.Renderer2}]},t}();var b=0,v=function(){function t(t,e,n,o,r){if(this.parent=e,this.rep=n,this.ren=o,this.cdr=r,this.clsMap=[],this.inited=!1,this.onceFlag=!1,this.errorData={},this.invalid=!1,this._labelWidth=null,this.required=!1,this.controlClass="",this._id="_se-"+b++,this._autoId=!0,null==e)throw new Error("[se] must include 'se-container' component");this.el=t.nativeElement}return Object.defineProperty(t.prototype,"error",{set:function(t){this.errorData="string"==typeof t||t instanceof e.TemplateRef?{"":t}:t},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"id",{set:function(t){this._id=t,this._autoId=!1},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"paddingValue",{get:function(){return this.parent.gutter/2},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"showErr",{get:function(){return this.invalid&&!!this._error},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"compact",{get:function(){return"compact"===this.parent.size},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"ngControl",{get:function(){return this.ngModel||this.formControlName},enumerable:!0,configurable:!0}),t.prototype.setClass=function(){var t=this,e=t.el,n=t.ren,o=t.clsMap,r=t.col,i=t.parent,l=t.cdr,a=t.line,s=t.labelWidth,p=t.rep;this._labelWidth="horizontal"===i.nzLayout?null!=s?s:i.labelWidth:null,o.forEach((function(t){return n.removeClass(e,t)})),o.length=0;var u="horizontal"===i.nzLayout?p.genCls(null!=r?r:i.colInCon||i.col):[];return o.push.apply(o,g(["ant-form-item"],u,["se__item"])),(a||i.line)&&o.push("se__line"),o.forEach((function(t){return n.addClass(e,t)})),l.detectChanges(),this},t.prototype.bindModel=function(){var t,e,n,r=this;if(this.ngControl&&!this.status$){if(this.status$=this.ngControl.statusChanges.subscribe((function(t){return r.updateStatus("INVALID"===t)})),this._autoId){var i=null===(e=null===(t=this.ngControl.valueAccessor)||void 0===t?void 0:t._elementRef)||void 0===e?void 0:e.nativeElement;i&&(i.id=this._id)}if(!0!==this.required){var l=null===(n=this.ngControl)||void 0===n?void 0:n._rawValidators;this.required=null!=l.find((function(t){return t instanceof o.RequiredValidator})),this.cdr.detectChanges()}}},t.prototype.updateStatus=function(t){if(!this.ngControl.disabled&&!this.ngControl.isDisabled){this.invalid=t&&this.onceFlag||this.ngControl.dirty&&t;var e=this.ngControl.errors;if(null!=e&&Object.keys(e).length>0){var n=Object.keys(e)[0]||"",o=this.errorData[n];this._error=null!=o?o:this.errorData[""]||""}this.cdr.detectChanges()}},t.prototype.checkContent=function(){var t=this.contentElement.nativeElement,e="se__item-empty";n.isEmpty(t)?this.ren.addClass(t,e):this.ren.removeClass(t,e)},t.prototype.ngAfterContentInit=function(){this.checkContent()},t.prototype.ngOnChanges=function(){this.onceFlag=this.parent.firstVisual,this.inited&&this.setClass().bindModel()},t.prototype.ngAfterViewInit=function(){var t=this;this.setClass().bindModel(),this.inited=!0,this.onceFlag&&Promise.resolve().then((function(){t.updateStatus(t.ngControl.invalid),t.onceFlag=!1}))},t.prototype.ngOnDestroy=function(){this.status$&&this.status$.unsubscribe()},t.decorators=[{type:e.Component,args:[{selector:"se",exportAs:"se",template:'<div class="ant-form-item-label" [class.se__nolabel]="!label" [style.width.px]="_labelWidth">\n <label *ngIf="label" [attr.for]="_id" class="se__label" [ngClass]="{\'ant-form-item-required\': required}">\n <span class="se__label-text">\n <ng-container *nzStringTemplateOutlet="label">{{ label }}</ng-container>\n </span>\n <span *ngIf="optional || optionalHelp" class="se__label-optional" [class.se__label-optional-no-text]="!optional">\n <ng-container *nzStringTemplateOutlet="optional">{{ optional }}</ng-container>\n <i *ngIf="optionalHelp" nz-tooltip [nzTooltipTitle]="optionalHelp" nz-icon nzType="question-circle"></i>\n </span>\n </label>\n</div>\n<div class="ant-form-item-control se__control">\n <div class="ant-form-item-control-input {{controlClass}}">\n <div class="ant-form-item-control-input-content" (cdkObserveContent)="checkContent()" #contentElement>\n <ng-content></ng-content>\n </div>\n </div>\n <div class="ant-form-item-explain" *ngIf="showErr && !compact">\n <div @helpMotion>\n <ng-container *nzStringTemplateOutlet="_error">{{ _error }}</ng-container>\n </div>\n </div>\n <div *ngIf="extra && !compact" class="ant-form-item-extra">\n <ng-container *nzStringTemplateOutlet="extra">{{ extra }}</ng-container>\n </div>\n</div>\n',host:{"[style.padding-left.px]":"paddingValue","[style.padding-right.px]":"paddingValue","[class.ant-form-item-has-error]":"showErr","[class.ant-form-item-with-help]":"showErr && !compact"},preserveWhitespaces:!1,animations:[i.helpMotion],changeDetection:e.ChangeDetectionStrategy.OnPush,encapsulation:e.ViewEncapsulation.None}]}],t.ctorParameters=function(){return[{type:e.ElementRef},{type:y,decorators:[{type:e.Optional},{type:e.Host}]},{type:r.ResponsiveService},{type:e.Renderer2},{type:e.ChangeDetectorRef}]},t.propDecorators={ngModel:[{type:e.ContentChild,args:[o.NgModel,{static:!0}]}],formControlName:[{type:e.ContentChild,args:[o.FormControlName,{static:!0}]}],contentElement:[{type:e.ViewChild,args:["contentElement",{static:!0}]}],optional:[{type:e.Input}],optionalHelp:[{type:e.Input}],error:[{type:e.Input}],extra:[{type:e.Input}],label:[{type:e.Input}],col:[{type:e.Input}],required:[{type:e.Input}],controlClass:[{type:e.Input}],line:[{type:e.Input}],labelWidth:[{type:e.Input}],id:[{type:e.Input}]},c([n.InputNumber(null),d("design:type",Number)],t.prototype,"col",void 0),c([n.InputBoolean(),d("design:type",Object)],t.prototype,"required",void 0),c([n.InputBoolean(null),d("design:type",Boolean)],t.prototype,"line",void 0),c([n.InputNumber(null),d("design:type",Number)],t.prototype,"labelWidth",void 0),t}();var C=[y,v,m],I=function(){function t(){}return t.decorators=[{type:e.NgModule,args:[{imports:[l.CommonModule,n.LxlibUtilModule,p.NzToolTipModule,s.NzIconModule,a.NzOutletModule],declarations:g(C),exports:g(C)}]}],t}();t.SEComponent=v,t.SEConfig=f,t.SEContainerComponent=y,t.SEModule=I,t.SETitleComponent=m,Object.defineProperty(t,"__esModule",{value:!0})})); //# sourceMappingURL=edit.umd.min.js.map