UNPKG

@ohayojp.com/components

Version:

Common business components of ohayojp.

400 lines (392 loc) 12.9 kB
import { __decorate, __metadata } from 'tslib'; import { Component, ChangeDetectionStrategy, ViewEncapsulation, Input, ElementRef, Host, Optional, Renderer2, ViewChild, NgModule } from '@angular/core'; import { OhayoConfigService, InputNumber, isEmpty, InputBoolean, OhayoUtilModule } from '@ohayojp.com/util'; import { ResponsiveService } from '@ohayojp.com/theme'; import { ObserversModule } from '@angular/cdk/observers'; import { CommonModule } from '@angular/common'; import { NzOutletModule } from 'ng-zorro-antd/core/outlet'; import { NzIconModule } from 'ng-zorro-antd/icon'; import { NzToolTipModule } from 'ng-zorro-antd/tooltip'; /** * @fileoverview added by tsickle * Generated from: sv-container.component.ts * @suppress {checkTypes,constantProperty,extraRequire,missingOverride,missingRequire,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc */ class SVContainerComponent { /** * @param {?} configSrv */ constructor(configSrv) { configSrv.attach(this, 'sv', { size: 'large', gutter: 32, layout: 'horizontal', col: 3, default: true, }); } } SVContainerComponent.decorators = [ { type: Component, args: [{ selector: 'sv-container, [sv-container]', exportAs: 'svContainer', template: "<div class=\"ant-row\" [ngStyle]=\"{ 'margin-left.px': -(gutter / 2), 'margin-right.px': -(gutter / 2) }\">\n <sv-title *ngIf=\"title\">\n <ng-container *nzStringTemplateOutlet=\"title\">{{ title }}</ng-container>\n </sv-title>\n <ng-content></ng-content>\n</div>\n", host: { '[class.sv__container]': 'true', '[class.sv__horizontal]': `layout === 'horizontal'`, '[class.sv__vertical]': `layout === 'vertical'`, '[class.sv__small]': `size === 'small'`, '[class.sv__large]': `size === 'large'`, '[class.clearfix]': `true`, }, preserveWhitespaces: false, changeDetection: ChangeDetectionStrategy.OnPush, encapsulation: ViewEncapsulation.None }] } ]; /** @nocollapse */ SVContainerComponent.ctorParameters = () => [ { type: OhayoConfigService } ]; SVContainerComponent.propDecorators = { title: [{ type: Input }], size: [{ type: Input }], gutter: [{ type: Input }], layout: [{ type: Input }], labelWidth: [{ type: Input }], col: [{ type: Input }], default: [{ type: Input }] }; __decorate([ InputNumber(), __metadata("design:type", Number) ], SVContainerComponent.prototype, "gutter", void 0); __decorate([ InputNumber(), __metadata("design:type", Number) ], SVContainerComponent.prototype, "labelWidth", void 0); __decorate([ InputNumber(), __metadata("design:type", Number) ], SVContainerComponent.prototype, "col", void 0); if (false) { /** @type {?} */ SVContainerComponent.ngAcceptInputType_gutter; /** @type {?} */ SVContainerComponent.ngAcceptInputType_labelWidth; /** @type {?} */ SVContainerComponent.ngAcceptInputType_col; /** @type {?} */ SVContainerComponent.prototype.title; /** @type {?} */ SVContainerComponent.prototype.size; /** * 列表项间距,单位为 `px` * @type {?} */ SVContainerComponent.prototype.gutter; /** @type {?} */ SVContainerComponent.prototype.layout; /** @type {?} */ SVContainerComponent.prototype.labelWidth; /** * 指定信息最多分几列展示,最终一行几列由 col 配置结合响应式规则决定 * @type {?} */ SVContainerComponent.prototype.col; /** @type {?} */ SVContainerComponent.prototype.default; } /** * @fileoverview added by tsickle * Generated from: sv-title.component.ts * @suppress {checkTypes,constantProperty,extraRequire,missingOverride,missingRequire,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc */ class SVTitleComponent { /** * @param {?} el * @param {?} parent * @param {?} ren */ constructor(el, parent, ren) { this.parent = parent; this.ren = ren; if (parent == null) { throw new Error(`[sv-title] must include 'sv-container' component`); } this.el = el.nativeElement; } /** * @private * @return {?} */ setClass() { const { gutter } = this.parent; const { el } = this; this.ren.setStyle(el, 'padding-left', `${gutter / 2}px`); this.ren.setStyle(el, 'padding-right', `${gutter / 2}px`); } /** * @return {?} */ ngOnInit() { this.setClass(); } } SVTitleComponent.decorators = [ { type: Component, args: [{ selector: 'sv-title, [sv-title]', exportAs: 'svTitle', template: '<ng-content></ng-content>', host: { '[class.sv__title]': 'true', }, preserveWhitespaces: false, changeDetection: ChangeDetectionStrategy.OnPush, encapsulation: ViewEncapsulation.None }] } ]; /** @nocollapse */ SVTitleComponent.ctorParameters = () => [ { type: ElementRef }, { type: SVContainerComponent, decorators: [{ type: Host }, { type: Optional }] }, { type: Renderer2 } ]; if (false) { /** * @type {?} * @private */ SVTitleComponent.prototype.el; /** * @type {?} * @private */ SVTitleComponent.prototype.parent; /** * @type {?} * @private */ SVTitleComponent.prototype.ren; } /** * @fileoverview added by tsickle * Generated from: sv.component.ts * @suppress {checkTypes,constantProperty,extraRequire,missingOverride,missingRequire,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc */ /** @type {?} */ const prefixCls = `sv`; class SVComponent { /** * @param {?} el * @param {?} parent * @param {?} rep * @param {?} ren */ constructor(el, parent, rep, ren) { this.parent = parent; this.rep = rep; this.ren = ren; this.clsMap = []; if (parent == null) { throw new Error(`[sv] must include 'sv-container' component`); } this.el = el.nativeElement; } // #endregion /** * @return {?} */ get paddingValue() { return this.parent && this.parent.gutter / 2; } /** * @return {?} */ get labelWidth() { const { labelWidth, layout } = this.parent; return layout === 'horizontal' ? labelWidth : null; } /** * @private * @return {?} */ setClass() { const { el, ren, col, clsMap, type, rep } = this; clsMap.forEach((/** * @param {?} cls * @return {?} */ cls => ren.removeClass(el, cls))); clsMap.length = 0; clsMap.push(...rep.genCls(col != null ? col : this.parent.col)); clsMap.push(`${prefixCls}__item`); if (this.parent.labelWidth) clsMap.push(`${prefixCls}__item-fixed`); if (type) clsMap.push(`${prefixCls}__type-${type}`); clsMap.forEach((/** * @param {?} cls * @return {?} */ cls => ren.addClass(el, cls))); } /** * @return {?} */ ngAfterViewInit() { this.setClass(); this.checkContent(); } /** * @return {?} */ ngOnChanges() { this.setClass(); } /** * @return {?} */ checkContent() { const { conEl } = this; /** @type {?} */ const def = this.default; if (!(def != null ? def : this.parent.default)) return; /** @type {?} */ const el = (/** @type {?} */ (conEl.nativeElement)); /** @type {?} */ const cls = `sv__default`; if (el.classList.contains(cls)) { el.classList.remove(cls); } if (isEmpty(el)) { el.classList.add(cls); } } } SVComponent.decorators = [ { type: Component, args: [{ selector: 'sv, [sv]', exportAs: 'sv', template: "<div class=\"sv__label\" [class.sv__label-empty]=\"!label\" [class.sv__label-width]=\"labelWidth != null\" [style.width.px]=\"labelWidth\">\n <span class=\"sv__label-text\">\n <ng-container *nzStringTemplateOutlet=\"label\">{{ label }}</ng-container>\n </span>\n <span *ngIf=\"optional || optionalHelp\" class=\"sv__label-optional\" [class.sv__label-optional-no-text]=\"!optional\">\n <ng-container *nzStringTemplateOutlet=\"optional\">{{ optional }}</ng-container>\n <i *ngIf=\"optionalHelp\" nz-tooltip [nzTooltipTitle]=\"optionalHelp\" [nzTooltipColor]=\"optionalHelpColor\" nz-icon nzType=\"question-circle\"></i>\n </span>\n</div>\n<div class=\"sv__detail\">\n <span (cdkObserveContent)=\"checkContent()\" #conEl>\n <ng-content></ng-content>\n </span>\n <ng-container *ngIf=\"!!unit\">\n <span class=\"sv__unit\" *nzStringTemplateOutlet=\"unit\">{{ unit }}</span>\n </ng-container>\n</div>\n", host: { '[style.padding-left.px]': 'paddingValue', '[style.padding-right.px]': 'paddingValue', }, preserveWhitespaces: false, changeDetection: ChangeDetectionStrategy.OnPush, encapsulation: ViewEncapsulation.None }] } ]; /** @nocollapse */ SVComponent.ctorParameters = () => [ { type: ElementRef }, { type: SVContainerComponent, decorators: [{ type: Host }, { type: Optional }] }, { type: ResponsiveService }, { type: Renderer2 } ]; SVComponent.propDecorators = { conEl: [{ type: ViewChild, args: ['conEl', { static: false },] }], optional: [{ type: Input }], optionalHelp: [{ type: Input }], optionalHelpColor: [{ type: Input }], label: [{ type: Input }], unit: [{ type: Input }], col: [{ type: Input }], default: [{ type: Input }], type: [{ type: Input }] }; __decorate([ InputNumber(null), __metadata("design:type", Number) ], SVComponent.prototype, "col", void 0); __decorate([ InputBoolean(null), __metadata("design:type", Boolean) ], SVComponent.prototype, "default", void 0); if (false) { /** @type {?} */ SVComponent.ngAcceptInputType_col; /** @type {?} */ SVComponent.ngAcceptInputType_default; /** * @type {?} * @private */ SVComponent.prototype.conEl; /** * @type {?} * @private */ SVComponent.prototype.el; /** * @type {?} * @private */ SVComponent.prototype.clsMap; /** @type {?} */ SVComponent.prototype.optional; /** @type {?} */ SVComponent.prototype.optionalHelp; /** @type {?} */ SVComponent.prototype.optionalHelpColor; /** @type {?} */ SVComponent.prototype.label; /** @type {?} */ SVComponent.prototype.unit; /** @type {?} */ SVComponent.prototype.col; /** @type {?} */ SVComponent.prototype.default; /** @type {?} */ SVComponent.prototype.type; /** @type {?} */ SVComponent.prototype.parent; /** * @type {?} * @private */ SVComponent.prototype.rep; /** * @type {?} * @private */ SVComponent.prototype.ren; } /** * @fileoverview added by tsickle * Generated from: sv.module.ts * @suppress {checkTypes,constantProperty,extraRequire,missingOverride,missingRequire,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc */ /** @type {?} */ const COMPONENTS = [SVContainerComponent, SVComponent, SVTitleComponent]; class SVModule { } SVModule.decorators = [ { type: NgModule, args: [{ imports: [CommonModule, ObserversModule, OhayoUtilModule, NzToolTipModule, NzIconModule, NzOutletModule], declarations: [...COMPONENTS], exports: [...COMPONENTS], },] } ]; /** * @fileoverview added by tsickle * Generated from: public_api.ts * @suppress {checkTypes,constantProperty,extraRequire,missingOverride,missingRequire,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc */ /** * @fileoverview added by tsickle * Generated from: view.ts * @suppress {checkTypes,constantProperty,extraRequire,missingOverride,missingRequire,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc */ export { SVComponent, SVContainerComponent, SVModule, SVTitleComponent }; //# sourceMappingURL=view.js.map