@agile-ts/multieditor
Version:
Simple Form Manager for UI-Frameworks
36 lines (33 loc) • 1.01 kB
JavaScript
import { State } from '@agile-ts/core';
import { defineConfig, copy } from '@agile-ts/utils';
import { StatusTracker } from './status.tracker.js';
class Status extends State {
constructor(item, config = {}) {
super(item.agileInstance(), null, { key: `status_${item._key}` });
this.lastTrackedValues = [];
config = defineConfig(config, {
display: false
});
this.item = item;
this.statusTracker = new StatusTracker();
this.config = {
display: config.display
};
}
get value() {
return this.config.display ? copy(this._value) : null;
}
set(value, config = {}) {
config = defineConfig(config, {
waitForTracking: false,
background: this.config != null ? !this.config.display : void 0
});
if (value != null)
this.statusTracker.tracked(value);
if (config.waitForTracking && this.statusTracker.isTracking)
return this;
this.observers["value"].ingestValue(value, config);
return this;
}
}
export { Status };