blob: 154765364dac0c57d0222eb628ddb05600bf07a6 [file] [log] [blame]
/**
* @fileoverview added by tsickle
* @suppress {checkTypes,extraRequire,missingReturn,uselessCode} checked by tsc
*/
import { Component, Input, HostBinding, ChangeDetectionStrategy, ViewChild, ElementRef } from '@angular/core';
/** @enum {string} */
var TdNotificationCountPositionY = {
Top: 'top',
Bottom: 'bottom',
Center: 'center',
};
export { TdNotificationCountPositionY };
/** @enum {string} */
var TdNotificationCountPositionX = {
Before: 'before',
After: 'after',
Center: 'center',
};
export { TdNotificationCountPositionX };
/** @type {?} */
export var DEFAULT_NOTIFICATION_LIMIT = 99;
var TdNotificationCountComponent = /** @class */ (function () {
function TdNotificationCountComponent() {
this._notifications = 0;
this._limit = DEFAULT_NOTIFICATION_LIMIT;
/**
* color?: "primary" | "accent" | "warn"
* Sets the theme color of the notification tip. Defaults to "warn"
*/
this.color = 'warn';
}
Object.defineProperty(TdNotificationCountComponent.prototype, "positionX", {
get: /**
* @return {?}
*/
function () {
return this._positionX;
},
/**
* positionX?: TdNotificationCountPositionX or "before" | "after" | "center"
* Sets the X position of the notification tip.
* Defaults to "after" if it has content, else 'center'.
*/
set: /**
* positionX?: TdNotificationCountPositionX or "before" | "after" | "center"
* Sets the X position of the notification tip.
* Defaults to "after" if it has content, else 'center'.
* @param {?} positionX
* @return {?}
*/
function (positionX) {
this._positionX = positionX;
},
enumerable: true,
configurable: true
});
Object.defineProperty(TdNotificationCountComponent.prototype, "positionY", {
get: /**
* @return {?}
*/
function () {
return this._positionY;
},
/**
* positionY?: TdNotificationCountPositionY or "top" | "bottom" | "center"
* Sets the Y position of the notification tip.
* Defaults to "top" if it has content, else 'center'.
*/
set: /**
* positionY?: TdNotificationCountPositionY or "top" | "bottom" | "center"
* Sets the Y position of the notification tip.
* Defaults to "top" if it has content, else 'center'.
* @param {?} positionY
* @return {?}
*/
function (positionY) {
this._positionY = positionY;
},
enumerable: true,
configurable: true
});
Object.defineProperty(TdNotificationCountComponent.prototype, "notifications", {
/**
* notifications?: number | boolean
* Number for the notification count. Shows component only if the input is a positive number or 'true'
*/
set: /**
* notifications?: number | boolean
* Number for the notification count. Shows component only if the input is a positive number or 'true'
* @param {?} notifications
* @return {?}
*/
function (notifications) {
this._notifications = notifications;
},
enumerable: true,
configurable: true
});
Object.defineProperty(TdNotificationCountComponent.prototype, "limit", {
/**
* limit?: number
* Limit for notification count. If the number of notifications is greater than limit, then + will be added. Defaults to 99.
*/
set: /**
* limit?: number
* Limit for notification count. If the number of notifications is greater than limit, then + will be added. Defaults to 99.
* @param {?} limit
* @return {?}
*/
function (limit) {
this._limit = limit;
},
enumerable: true,
configurable: true
});
Object.defineProperty(TdNotificationCountComponent.prototype, "hideHost", {
get: /**
* @return {?}
*/
function () {
return !this.show && !this._hasContent();
},
enumerable: true,
configurable: true
});
Object.defineProperty(TdNotificationCountComponent.prototype, "noCount", {
/**
* Sets the component in its 'noCount' state if [notifications] is a boolean 'true'.
* Makes the notification tip show without a count.
*/
get: /**
* Sets the component in its 'noCount' state if [notifications] is a boolean 'true'.
* Makes the notification tip show without a count.
* @return {?}
*/
function () {
return this._notifications === true;
},
enumerable: true,
configurable: true
});
Object.defineProperty(TdNotificationCountComponent.prototype, "notificationsDisplay", {
/**
* Notification display string when a count is available.
* Anything over 99 gets set as 99+
*/
get: /**
* Notification display string when a count is available.
* Anything over 99 gets set as 99+
* @return {?}
*/
function () {
if (this._notifications > this._limit) {
return this._limit + "+";
}
return this._notifications.toString();
},
enumerable: true,
configurable: true
});
Object.defineProperty(TdNotificationCountComponent.prototype, "show", {
/**
* Shows notification tip only when [notifications] is true or a positive integer.
*/
get: /**
* Shows notification tip only when [notifications] is true or a positive integer.
* @return {?}
*/
function () {
return this._notifications === true || (!isNaN((/** @type {?} */ (this._notifications))) && this._notifications > 0);
},
enumerable: true,
configurable: true
});
/**
* Check if [positionX] and [positionY] have been set as inputs, else use defaults depending on component content.
*/
/**
* Check if [positionX] and [positionY] have been set as inputs, else use defaults depending on component content.
* @return {?}
*/
TdNotificationCountComponent.prototype.ngAfterContentInit = /**
* Check if [positionX] and [positionY] have been set as inputs, else use defaults depending on component content.
* @return {?}
*/
function () {
if (!this._positionX) {
this.positionX = this._hasContent() ? TdNotificationCountPositionX.After : TdNotificationCountPositionX.Center;
}
if (!this._positionY) {
this.positionY = this._hasContent() ? TdNotificationCountPositionY.Top : TdNotificationCountPositionY.Center;
}
};
/**
* Method to check if element has any kind of content (elements or text)
*/
/**
* Method to check if element has any kind of content (elements or text)
* @return {?}
*/
TdNotificationCountComponent.prototype._hasContent = /**
* Method to check if element has any kind of content (elements or text)
* @return {?}
*/
function () {
if (this.content) {
/** @type {?} */
var contentElement = this.content.nativeElement;
return contentElement && (contentElement.children.length > 0 || !!contentElement.textContent.trim());
}
return false;
};
TdNotificationCountComponent.decorators = [
{ type: Component, args: [{
selector: 'td-notification-count',
template: "<div #content class=\"td-notification-content\">\n <ng-content></ng-content>\n</div>\n<div *ngIf=\"show\"\n class=\"td-notification-count mat-{{color}}\"\n [class.td-notification-top]=\"positionY === 'top'\"\n [class.td-notification-bottom]=\"positionY === 'bottom'\"\n [class.td-notification-before]=\"positionX === 'before'\"\n [class.td-notification-after]=\"positionX === 'after'\"\n [class.td-notification-center-y]=\"positionY === 'center'\"\n [class.td-notification-center-x]=\"positionX === 'center'\"\n [class.td-notification-no-count]=\"noCount\">\n {{noCount ? '' : notificationsDisplay}}\n</div>",
changeDetection: ChangeDetectionStrategy.OnPush,
styles: [":host{position:relative;display:block;text-align:center;min-width:40px;height:40px}:host.td-notification-hidden{min-width:0}.td-notification-count{line-height:21px;width:20px;height:20px;position:absolute;font-size:10px;font-weight:600;border-radius:50%;z-index:1}.td-notification-count.td-notification-center-x{margin-left:auto;margin-right:auto;left:0;right:0}.td-notification-count.td-notification-center-y{margin-top:auto;margin-bottom:auto;top:0;bottom:0}.td-notification-count.td-notification-top{top:0}.td-notification-count.td-notification-bottom{bottom:0}.td-notification-count.td-notification-before{left:0}.td-notification-count.td-notification-after{right:0}.td-notification-count.td-notification-no-count{width:8px;height:8px}.td-notification-count.td-notification-no-count.td-notification-top{top:8px}.td-notification-count.td-notification-no-count.td-notification-bottom{bottom:8px}.td-notification-count.td-notification-no-count.td-notification-before{left:8px}.td-notification-count.td-notification-no-count.td-notification-after{right:8px}::ng-deep [dir=rtl] .td-notification-count.td-notification-before{right:0;left:auto}::ng-deep [dir=rtl] .td-notification-count.td-notification-after{left:0;right:auto}::ng-deep [dir=rtl] .td-notification-count.td-notification-no-count.td-notification-before{right:8px;left:auto}::ng-deep [dir=rtl] .td-notification-count.td-notification-no-count.td-notification-after{left:8px;right:auto}.td-notification-content,.td-notification-content ::ng-deep>*{line-height:40px}"]
}] }
];
TdNotificationCountComponent.propDecorators = {
content: [{ type: ViewChild, args: ['content',] }],
color: [{ type: Input }],
positionX: [{ type: Input }],
positionY: [{ type: Input }],
notifications: [{ type: Input }],
limit: [{ type: Input }],
hideHost: [{ type: HostBinding, args: ['class.td-notification-hidden',] }]
};
return TdNotificationCountComponent;
}());
export { TdNotificationCountComponent };
if (false) {
/** @type {?} */
TdNotificationCountComponent.prototype._notifications;
/** @type {?} */
TdNotificationCountComponent.prototype._positionY;
/** @type {?} */
TdNotificationCountComponent.prototype._positionX;
/** @type {?} */
TdNotificationCountComponent.prototype._limit;
/**
* Div content wrapper of `ng-content`.
* @type {?}
*/
TdNotificationCountComponent.prototype.content;
/**
* color?: "primary" | "accent" | "warn"
* Sets the theme color of the notification tip. Defaults to "warn"
* @type {?}
*/
TdNotificationCountComponent.prototype.color;
}
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoibm90aWZpY2F0aW9uLWNvdW50LmNvbXBvbmVudC5qcyIsInNvdXJjZVJvb3QiOiJuZzovL0Bjb3ZhbGVudC9jb3JlLyIsInNvdXJjZXMiOlsibm90aWZpY2F0aW9ucy9ub3RpZmljYXRpb24tY291bnQuY29tcG9uZW50LnRzIl0sIm5hbWVzIjpbXSwibWFwcGlu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