ngx-modialog-11
Version:
Modal / Dialog for Angular
110 lines (109 loc) • 4.68 kB
TypeScript
export declare function privateKey(name: string): string;
/**
* Create a function for setting a value for a property on a given object.
* @param obj The object to apply the key & setter on.
* @param propertyName The name of the property on the object
* @param writeOnce If true will allow writing once (default: false)
*
* Example:
* let obj = new FluentAssign<any>;
* setAssignMethod(obj, 'myProp');
* obj.myProp('someValue');
* const result = obj.toJSON();
* console.log(result); //{ myProp: 'someValue' }
*
*
* let obj = new FluentAssign<any>;
* setAssignMethod(obj, 'myProp', true); // applying writeOnce
* obj.myProp('someValue');
* obj.myProp('someValue'); // ERROR: Overriding config property 'myProp' is not allowed.
*/
export declare function setAssignMethod<T>(obj: T, propertyName: string, writeOnce?: boolean): void;
/**
* Create a function for setting a value that is an alias to an other setter function.
* @param obj The object to apply the key & setter on.
* @param propertyName The name of the property on the object
* @param srcPropertyName The name of the property on the object this alias points to
* @param hard If true, will set a readonly property on the object that returns
* the value of the source property. Default: false
*
* Example:
* let obj = new FluentAssign<any> ;
* setAssignMethod(obj, 'myProp');
* setAssignAlias(obj, 'myPropAlias', 'myProp');
* obj.myPropAlias('someValue');
* const result = obj.toJSON();
* console.log(result); //{ myProp: 'someValue' }
* result.myPropAlias // undefined
*
*
* let obj = new FluentAssign<any> ;
* setAssignMethod(obj, 'myProp');
* setAssignAlias(obj, 'myPropAlias', 'myProp', true); // setting a hard alias.
* obj.myPropAlias('someValue');
* const result = obj.toJSON();
* console.log(result); //{ myProp: 'someValue' }
* result.myPropAlias // someValue
*/
export declare function setAssignAlias<T>(obj: T, propertyName: string, srcPropertyName: string, hard?: boolean): void;
/**
* Describes a fluent assign method.
* A function that gets a value and returns the instance it works on.
*/
export declare type FluentAssignMethod<T, Z> = (value: T) => Z;
export interface IFluentAssignFactory<Z> {
fluentAssign: Z;
setMethod(name: string, defaultValue?: any): IFluentAssignFactory<Z>;
}
/**
* Represent a fluent API factory wrapper for defining FluentAssign instances.
*/
export declare class FluentAssignFactory<T> {
private _fluentAssign;
constructor(fluentAssign?: FluentAssign<T>);
/**
* Create a setter method on the FluentAssign instance.
* @param name The name of the setter function.
* @param defaultValue If set (not undefined) set's the value on the instance immediately.
*/
setMethod(name: string, defaultValue?: any): FluentAssignFactory<T>;
/**
* The FluentAssign instance.
*/
get fluentAssign(): FluentAssign<T>;
}
/**
* Represent an object where every property is a function representing an assignment function.
* Calling each function with a value will assign the value to the object and return the object.
* Calling 'toJSON' returns an object with the same properties but this time representing the
* assigned values.
*
* This allows setting an object in a fluent API manner.
* Example:
let fluent = new FluentAssign<any>(undefined, ['some', 'went']);
fluent.some('thing').went('wrong').toJSON();
// { some: 'thing', went: 'wrong' }
*/
export declare class FluentAssign<T> {
private __fluent$base__;
/**
* Returns a FluentAssignFactory<FluentAssign<T>> ready to define a FluentAssign type.
* @param defaultValues An object representing default values for the instance.
* @param initialSetters A list of initial setters for the instance.
*/
static compose<T>(defaultValues?: T, initialSetters?: string[]): FluentAssignFactory<T>;
/**
* Returns a FluentAssignFactory<Z> where Z is an instance of FluentAssign<?> or a derived
* class of it.
* @param fluentAssign An instance of FluentAssign<?> or a derived class of FluentAssign<?>.
*/
static composeWith<Z>(fluentAssign: Z): IFluentAssignFactory<Z>;
/**
*
* @param defaultValues An object representing default values for the underlying object.
* @param initialSetters A list of initial setters for this FluentAssign.
* @param baseType the class/type to create a new base. optional, {} is used if not supplied.
*/
constructor(defaultValues?: T | T[], initialSetters?: string[], baseType?: new () => T);
toJSON(): T;
}