@lxlib/seed
Version:
This library was generated with [Angular CLI](https://github.com/angular/angular-cli) version 9.1.1.
422 lines (414 loc) • 12.2 kB
JavaScript
import { __decorate, __metadata, __spread } from 'tslib';
import { DOCUMENT, CommonModule } from '@angular/common';
import { Injectable, ɵɵdefineInjectable, EventEmitter, Component, ChangeDetectionStrategy, ViewEncapsulation, ElementRef, ChangeDetectorRef, Inject, Input, Output, Directive, NgModule } from '@angular/core';
import { ActivationStart, ActivationEnd, Router } from '@angular/router';
import { InputBoolean, InputNumber, LxlibUtilModule } from '@lxlib/util';
import { BehaviorSubject, fromEvent } from 'rxjs';
import { share, debounceTime, filter } from 'rxjs/operators';
/**
* @fileoverview added by tsickle
* Generated from: full-content.service.ts
* @suppress {checkTypes,constantProperty,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
*/
var FullContentService = /** @class */ (function () {
function FullContentService() {
this._change = new BehaviorSubject(null);
}
/** 切换全屏工作区状态 */
/**
* 切换全屏工作区状态
* @return {?}
*/
FullContentService.prototype.toggle = /**
* 切换全屏工作区状态
* @return {?}
*/
function () {
this._change.next(true);
};
Object.defineProperty(FullContentService.prototype, "change", {
get: /**
* @return {?}
*/
function () {
return this._change.pipe(share());
},
enumerable: true,
configurable: true
});
FullContentService.decorators = [
{ type: Injectable, args: [{ providedIn: 'root' },] }
];
/** @nocollapse */ FullContentService.ɵprov = ɵɵdefineInjectable({ factory: function FullContentService_Factory() { return new FullContentService(); }, token: FullContentService, providedIn: "root" });
return FullContentService;
}());
if (false) {
/**
* @type {?}
* @private
*/
FullContentService.prototype._change;
}
/**
* @fileoverview added by tsickle
* Generated from: full-content.component.ts
* @suppress {checkTypes,constantProperty,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
*/
/** @type {?} */
var wrapCls = "full-content__body";
/** @type {?} */
var openedCls = "full-content__opened";
/** @type {?} */
var hideTitleCls = "full-content__hidden-title";
var FullContentComponent = /** @class */ (function () {
// #endregion
function FullContentComponent(el, cdr, srv, router, doc) {
this.el = el;
this.cdr = cdr;
this.srv = srv;
this.router = router;
this.doc = doc;
this.inited = false;
this.id = "_full-content-" + Math.random().toString(36).substring(2);
this.scroll$ = null;
this._height = 0;
this.hideTitle = true;
this.padding = 24;
this.fullscreenChange = new EventEmitter();
}
/**
* @private
* @return {?}
*/
FullContentComponent.prototype.updateCls = /**
* @private
* @return {?}
*/
function () {
/** @type {?} */
var clss = this.bodyEl.classList;
if (this.fullscreen) {
clss.add(openedCls);
if (this.hideTitle) {
clss.add(hideTitleCls);
}
}
else {
clss.remove(openedCls);
if (this.hideTitle) {
clss.remove(hideTitleCls);
}
}
};
/**
* @private
* @return {?}
*/
FullContentComponent.prototype.update = /**
* @private
* @return {?}
*/
function () {
this.updateCls();
this.updateHeight();
this.fullscreenChange.emit(this.fullscreen);
};
/**
* @private
* @return {?}
*/
FullContentComponent.prototype.updateHeight = /**
* @private
* @return {?}
*/
function () {
this._height =
this.bodyEl.getBoundingClientRect().height - ((/** @type {?} */ (this.el.nativeElement))).getBoundingClientRect().top - this.padding;
this.cdr.detectChanges();
};
/**
* @private
* @return {?}
*/
FullContentComponent.prototype.removeInBody = /**
* @private
* @return {?}
*/
function () {
this.bodyEl.classList.remove(wrapCls, openedCls, hideTitleCls);
};
/**
* @return {?}
*/
FullContentComponent.prototype.ngOnInit = /**
* @return {?}
*/
function () {
var _this = this;
this.inited = true;
this.bodyEl = this.doc.querySelector('body');
this.bodyEl.classList.add(wrapCls);
((/** @type {?} */ (this.el.nativeElement))).id = this.id;
this.updateCls();
// when window resize
this.scroll$ = fromEvent(window, 'resize')
.pipe(debounceTime(200))
.subscribe((/**
* @return {?}
*/
function () { return _this.updateHeight(); }));
// when servier changed
this.srv$ = this.srv.change.pipe(filter((/**
* @param {?} res
* @return {?}
*/
function (res) { return res !== null; }))).subscribe((/**
* @return {?}
*/
function () { return _this.toggle(); }));
// when router changed
this.route$ = this.router.events
.pipe(filter((/**
* @param {?} e
* @return {?}
*/
function (e) { return e instanceof ActivationStart || e instanceof ActivationEnd; })), debounceTime(200))
.subscribe((/**
* @return {?}
*/
function () {
if (!!_this.doc.querySelector('#' + _this.id)) {
_this.bodyEl.classList.add(wrapCls);
_this.updateCls();
}
else {
_this.removeInBody();
}
}));
};
/**
* @return {?}
*/
FullContentComponent.prototype.toggle = /**
* @return {?}
*/
function () {
this.fullscreen = !this.fullscreen;
this.update();
this.updateHeight();
};
/**
* @return {?}
*/
FullContentComponent.prototype.ngAfterViewInit = /**
* @return {?}
*/
function () {
var _this = this;
setTimeout((/**
* @return {?}
*/
function () { return _this.updateHeight(); }));
};
/**
* @return {?}
*/
FullContentComponent.prototype.ngOnChanges = /**
* @return {?}
*/
function () {
if (this.inited)
this.update();
};
/**
* @return {?}
*/
FullContentComponent.prototype.ngOnDestroy = /**
* @return {?}
*/
function () {
this.removeInBody();
(/** @type {?} */ (this.scroll$)).unsubscribe();
this.srv$.unsubscribe();
this.route$.unsubscribe();
};
FullContentComponent.decorators = [
{ type: Component, args: [{
selector: 'full-content',
exportAs: 'fullContent',
template: " <ng-content></ng-content> ",
host: {
'[class.full-content]': 'true',
'[style.height.px]': '_height',
},
preserveWhitespaces: false,
changeDetection: ChangeDetectionStrategy.OnPush,
encapsulation: ViewEncapsulation.None
}] }
];
/** @nocollapse */
FullContentComponent.ctorParameters = function () { return [
{ type: ElementRef },
{ type: ChangeDetectorRef },
{ type: FullContentService },
{ type: Router },
{ type: undefined, decorators: [{ type: Inject, args: [DOCUMENT,] }] }
]; };
FullContentComponent.propDecorators = {
fullscreen: [{ type: Input }],
hideTitle: [{ type: Input }],
padding: [{ type: Input }],
fullscreenChange: [{ type: Output }]
};
__decorate([
InputBoolean(),
__metadata("design:type", Boolean)
], FullContentComponent.prototype, "fullscreen", void 0);
__decorate([
InputBoolean(),
__metadata("design:type", Object)
], FullContentComponent.prototype, "hideTitle", void 0);
__decorate([
InputNumber(),
__metadata("design:type", Object)
], FullContentComponent.prototype, "padding", void 0);
return FullContentComponent;
}());
if (false) {
/**
* @type {?}
* @private
*/
FullContentComponent.prototype.bodyEl;
/**
* @type {?}
* @private
*/
FullContentComponent.prototype.inited;
/**
* @type {?}
* @private
*/
FullContentComponent.prototype.srv$;
/**
* @type {?}
* @private
*/
FullContentComponent.prototype.route$;
/**
* @type {?}
* @private
*/
FullContentComponent.prototype.id;
/**
* @type {?}
* @private
*/
FullContentComponent.prototype.scroll$;
/** @type {?} */
FullContentComponent.prototype._height;
/** @type {?} */
FullContentComponent.prototype.fullscreen;
/** @type {?} */
FullContentComponent.prototype.hideTitle;
/** @type {?} */
FullContentComponent.prototype.padding;
/** @type {?} */
FullContentComponent.prototype.fullscreenChange;
/**
* @type {?}
* @private
*/
FullContentComponent.prototype.el;
/**
* @type {?}
* @private
*/
FullContentComponent.prototype.cdr;
/**
* @type {?}
* @private
*/
FullContentComponent.prototype.srv;
/**
* @type {?}
* @private
*/
FullContentComponent.prototype.router;
/**
* @type {?}
* @private
*/
FullContentComponent.prototype.doc;
}
/**
* @fileoverview added by tsickle
* Generated from: full-content-toggle.directive.ts
* @suppress {checkTypes,constantProperty,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
*/
var FullContentToggleDirective = /** @class */ (function () {
function FullContentToggleDirective(parent) {
this.parent = parent;
}
/**
* @return {?}
*/
FullContentToggleDirective.prototype._click = /**
* @return {?}
*/
function () {
this.parent.toggle();
};
FullContentToggleDirective.decorators = [
{ type: Directive, args: [{
selector: '[full-toggle]',
exportAs: 'fullToggle',
host: {
'(click)': '_click()',
},
},] }
];
/** @nocollapse */
FullContentToggleDirective.ctorParameters = function () { return [
{ type: FullContentComponent }
]; };
return FullContentToggleDirective;
}());
if (false) {
/**
* @type {?}
* @private
*/
FullContentToggleDirective.prototype.parent;
}
/**
* @fileoverview added by tsickle
* Generated from: full-content.module.ts
* @suppress {checkTypes,constantProperty,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
*/
/** @type {?} */
var COMPONENTS = [FullContentComponent, FullContentToggleDirective];
var FullContentModule = /** @class */ (function () {
function FullContentModule() {
}
FullContentModule.decorators = [
{ type: NgModule, args: [{
imports: [CommonModule, LxlibUtilModule],
declarations: __spread(COMPONENTS),
exports: __spread(COMPONENTS),
},] }
];
return FullContentModule;
}());
/**
* @fileoverview added by tsickle
* Generated from: public_api.ts
* @suppress {checkTypes,constantProperty,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
*/
/**
* @fileoverview added by tsickle
* Generated from: fullContent.ts
* @suppress {checkTypes,constantProperty,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
*/
export { FullContentComponent, FullContentModule, FullContentService, FullContentToggleDirective };
//# sourceMappingURL=fullContent.js.map