ng-zorro-antd-yj
Version:
An enterprise-class UI components based on Ant Design and Angular
122 lines • 9.28 kB
JavaScript
/**
* @fileoverview added by tsickle
* @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
*/
import * as tslib_1 from "tslib";
import { coerceBooleanProperty, coerceCssPixelValue, _isNumberValue } from '@angular/cdk/coercion';
/**
* @param {?} value
* @return {?}
*/
export function toBoolean(value) {
return coerceBooleanProperty(value);
}
/**
* @param {?} value
* @param {?=} fallbackValue
* @return {?}
*/
export function toNumber(value, fallbackValue) {
if (fallbackValue === void 0) { fallbackValue = 0; }
return _isNumberValue(value) ? Number(value) : fallbackValue;
}
/**
* @param {?} value
* @return {?}
*/
export function toCssPixel(value) {
return coerceCssPixelValue(value);
}
// Get the function-property type's value
/**
* @template T
* @param {?} prop
* @param {...?} args
* @return {?}
*/
export function valueFunctionProp(prop) {
var args = [];
for (var _i = 1; _i < arguments.length; _i++) {
args[_i - 1] = arguments[_i];
}
// tslint:disable-line: no-any
return typeof prop === 'function' ? prop.apply(void 0, tslib_1.__spread(args)) : prop;
}
// tslint:disable-next-line: no-any
/**
* @template T, D
* @param {?} name
* @param {?} fallback
* @return {?}
*/
function propDecoratorFactory(name, fallback) {
// tslint:disable-next-line: no-any
/**
* @param {?} target
* @param {?} propName
* @return {?}
*/
function propDecorator(target, propName) {
/** @type {?} */
var privatePropName = "$$__" + propName;
if (Object.prototype.hasOwnProperty.call(target, privatePropName)) {
console.warn("The prop \"" + privatePropName + "\" is already exist, it will be overrided by " + name + " decorator.");
}
Object.defineProperty(target, privatePropName, {
configurable: true,
writable: true
});
Object.defineProperty(target, propName, {
get: /**
* @return {?}
*/
function () {
return this[privatePropName]; // tslint:disable-line:no-invalid-this
},
set: /**
* @param {?} value
* @return {?}
*/
function (value) {
this[privatePropName] = fallback(value); // tslint:disable-line:no-invalid-this
}
});
}
return propDecorator;
}
/**
* Input decorator that handle a prop to do get/set automatically with toBoolean
*
* Why not using \@InputBoolean alone without \@Input? AOT needs \@Input to be visible
*
* \@howToUse
* ```
* \@Input() \@InputBoolean() visible: boolean = false;
*
* // Act as below:
* // \@Input()
* // get visible() { return this.__visibile; }
* // set visible(value) { this.__visible = value; }
* // __visible = false;
* ```
* @return {?}
*/
export function InputBoolean() {
// tslint:disable-line: no-any
return propDecoratorFactory('InputBoolean', toBoolean);
}
/**
* @return {?}
*/
export function InputCssPixel() {
// tslint:disable-line: no-any
return propDecoratorFactory('InputCssPixel', toCssPixel);
}
/**
* @return {?}
*/
export function InputNumber() {
// tslint:disable-line: no-any
return propDecoratorFactory('InputNumber', toNumber);
}
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiY29udmVydC5qcyIsInNvdXJjZVJvb3QiOiJuZzovL25nLXpvcnJvLWFudGQteWovIiwic291cmNlcyI6WyJjb3JlL3V0aWwvY29udmVydC50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiOzs7OztBQUFBLE9BQU8sRUFBRSxxQkFBcUIsRUFBRSxtQkFBbUIsRUFBRSxjQUFjLEVBQUUsTUFBTSx1QkFBdUIsQ0FBQzs7Ozs7QUFHbkcsTUFBTSxVQUFVLFNBQVMsQ0FBQyxLQUF1QjtJQUMvQyxPQUFPLHFCQUFxQixDQUFDLEtBQUssQ0FBQyxDQUFDO0FBQ3RDLENBQUM7Ozs7OztBQUlELE1BQU0sVUFBVSxRQUFRLENBQUMsS0FBc0IsRUFBRSxhQUF5QjtJQUF6Qiw4QkFBQSxFQUFBLGlCQUF5QjtJQUN4RSxPQUFPLGNBQWMsQ0FBQyxLQUFLLENBQUMsQ0FBQyxDQUFDLENBQUMsTUFBTSxDQUFDLEtBQUssQ0FBQyxDQUFDLENBQUMsQ0FBQyxhQUFhLENBQUM7QUFDL0QsQ0FBQzs7Ozs7QUFFRCxNQUFNLFVBQVUsVUFBVSxDQUFDLEtBQXNCO0lBQy9DLE9BQU8sbUJBQW1CLENBQUMsS0FBSy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