@pilotlab/lux-attributes
Version:
A luxurious user experience framework, developed by your friends at Pilot.
90 lines (61 loc) • 2.25 kB
text/typescript
import { INode } from '@pilotlab/lux-nodes';
import { IPromise } from '@pilotlab/lux-result';
import { AttributeChangeActions, DataType } from '../attributeEnums';
import IAttributeChangeOptions from './iAttributeChangeOptions';
import IAttributeSetReturn from './iAttributeSetReturn';
import IAttributeFactory from './iAttributeFactory';
import IAttributes from './iAttributes';
export interface IAttribute extends INode {
/*====================================================================*
START: Properties
*====================================================================*/
create:IAttributeFactory;
/**
* The value of the associated data.
*/
value:any;
valueTarget:any;
valuePrevious:any;
dataType:DataType;
readonly attributes:IAttributes;
/**
* Attributes will be considered empty if no key or value has been set.
*/
isEmpty:boolean;
/**
* If this function returns true, the attribute will be omitted from
* data transfer objects when saving data to the data store.
*/
omit:(value:any) => boolean;
/**
* This can hold a function that will operate on the supplied value to
* validate it and return an updated value as necessary.
*/
validate:(value:any) => any;
copy:IAttribute;
/**
* An automatically generated unique ID that is used when animating attribute values.
*/
animationKey:string;
/*====================================================================*
START: Public Methods
*====================================================================*/
/**
* Set the attribute value.
*/
set(
value:any,
changeOptions?:IAttributeChangeOptions,
):IPromise<IAttributeSetReturn>;
/**
* Interrupt any animated value transitions that are in effect.
*/
interrupt():void;
/**
* Manually trigger a dispatch on the 'changed' and/or saveTriggered signals.
*/
doChanged(changeAction:AttributeChangeActions):void;
toObject(isSaveDataTypes?:boolean, appendToObject?:any, isForceInclude?:boolean):any;
toJson(isSaveDataTypes?:boolean):string;
} // End interface
export default IAttribute;