VaKeR CYBER ARMY
Logo of a company Server : Apache/2.4.41 (Ubuntu)
System : Linux absol.cf 5.4.0-198-generic #218-Ubuntu SMP Fri Sep 27 20:18:53 UTC 2024 x86_64
User : www-data ( 33)
PHP Version : 7.4.33
Disable Function : pcntl_alarm,pcntl_fork,pcntl_waitpid,pcntl_wait,pcntl_wifexited,pcntl_wifstopped,pcntl_wifsignaled,pcntl_wifcontinued,pcntl_wexitstatus,pcntl_wtermsig,pcntl_wstopsig,pcntl_signal,pcntl_signal_get_handler,pcntl_signal_dispatch,pcntl_get_last_error,pcntl_strerror,pcntl_sigprocmask,pcntl_sigwaitinfo,pcntl_sigtimedwait,pcntl_exec,pcntl_getpriority,pcntl_setpriority,pcntl_async_signals,pcntl_unshare,
Directory :  /var/www/html/libs/absol-full/dist/js/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Current File : /var/www/html/libs/absol-full/dist/js/mdls__absol-form__js__components__TableInput.js
/*** module: node_modules/absol-form/js/components/TableInput.js ***/
"use strict";

Object.defineProperty(exports, "__esModule", {
  value: true
});
exports.default = void 0;

var _ScalableComponent = _interopRequireDefault(require("../core/ScalableComponent"));

var _TableEditor = _interopRequireDefault(require("absol-sheet/js/fragment/TableEditor"));

var _FCore = require("../core/FCore");

var _DomSignal = _interopRequireDefault(require("absol/src/HTML5/DomSignal"));

var _inheritComponentClass = _interopRequireDefault(require("../core/inheritComponentClass"));

var _Assembler = require("../core/Assembler");

var _ResizeSystem = _interopRequireDefault(require("absol/src/HTML5/ResizeSystem"));

var _FormArrayEditor = _interopRequireDefault(require("absol-sheet/js/fragment/FormArrayEditor"));

var _utils = require("absol-acomp/js/utils");


/***
 * @extends ScalableComponent
 * @constructor
 */
function TableInput(opt) {
  var appearance = opt.layoutData && opt.layoutData.attributes && opt.layoutData.attributes.appearance;
  appearance = appearance || 'sheet';
  this.ctnElt = (0, _FCore._)('div.as-base-component');
  var clazz = appearance === 'sheet' ? _TableEditor.default : _FormArrayEditor.default;
  this.attributes = Object.assign({}, this.attributes, {
    appearance: appearance
  });
  this.editor = new clazz({
    elt: this.ctnElt
  });
  this.editor.getView();

  _ScalableComponent.default.call(this);
}

(0, _inheritComponentClass.default)(TableInput, _ScalableComponent.default);
TableInput.prototype.tag = 'TableInput';
TableInput.prototype.menuIcon = 'span.mdi.mdi-table-edit';
TableInput.prototype.style.vAlign = 'top';
TableInput.prototype.style.display = 'inline-block';
TableInput.prototype.attributes.appearance = 'sheet';

TableInput.prototype.render = function () {
  return this.ctnElt;
};

TableInput.prototype.focusIncompleteCell = function () {
  if (this._incompleteCell) this.editor.focusIncompleteCell();
};
/***
 *
 * @return {FmVerifyInfo}
 */


TableInput.prototype.verify = function () {
  /***
   *
   * @type {FmVerifyInfo}
   */
  var result = {
    comp: this,
    completed: true
  };

  if (this.editor.tableData) {
    this._incompleteCell = this.editor.tableData.findFirsIncompleteCell();

    if (this._incompleteCell) {
      result.completed = false;
      result.incompleteCell = this._incompleteCell;
      this.pinFire('incomplete');
    } else {}
  }

  return result;
};

TableInput.prototype.styleHandlers.maxHeight = {
  set: function (value) {
    if (!(value > 0 && value < Infinity)) value = null;

    if (value) {
      this.domElt.addStyle('max-height', value + 'px');
    } else {
      this.domElt.removeStyle('max-height');
    }

    return value;
  },
  export: function () {
    var ref = arguments[arguments.length - 1];
    var value = ref.get();
    if (value) return value;
    return undefined;
  },
  descriptor: {
    type: 'LengthInPixel'
  }
};
TableInput.prototype.styleHandlers.rowHeight = {
  set: function (value) {
    value = parseFloat(value + '');
    if (!(0, _utils.isRealNumber)(value)) value = 21;
    if (value <= 0) value = 21;
    if (this.editor.tableData && this.editor.tableData.config) this.editor.tableData.config.rowHeight = value;else {
      this.domElt.addStyle('--row-height', value + 'px');
    }
    var td = (0, _FCore.$)('tr td', this.elt);

    _ResizeSystem.default.updateUp(td || this.domElt);

    setTimeout(() => {
      _ResizeSystem.default.updateUp(td || this.domElt);
    }, 10);
    setTimeout(() => {
      _ResizeSystem.default.requestUpdateSignal();
    }, 20);
    return value;
  },
  get: function (ref) {
    var value = ref.get();
    if (!(0, _utils.isRealNumber)(value) || value <= 0) return 21;
    return value;
  },
  export: function () {
    var value = this.style.rowHeight;
    if (value === 21) return undefined;
    return value;
  },
  descriptor: {
    type: 'number',
    min: 21
  }
};

TableInput.prototype.getAcceptsStyleNames = function () {
  return _ScalableComponent.default.prototype.getAcceptsStyleNames.call(this).concat(['maxHeight']);
};

TableInput.prototype.attributeHandlers.propertyNames = {
  set: function (value) {
    this._dataFlushed = false;

    this._requestUpdateContent();

    return value;
  } // get: function () {
  //     var ref = arguments[arguments.length - 1];
  //     if (this._dataFlushed) {
  //         return this.editor.tableData.propertyNames;
  //     }
  //     else {
  //         return ref.get();
  //     }
  // }

};
TableInput.prototype.attributeHandlers.propertyDescriptors = {
  set: function (value) {
    this._dataFlushed = false;

    this._requestUpdateContent();

    return value;
  } // get: function () {
  //     var ref = arguments[arguments.length - 1];
  //     if (this._dataFlushed) {
  //         return this.editor.tableData.propertyDescriptors;
  //     }
  //     else {
  //         return ref.get();
  //     }
  // }

};
TableInput.prototype.attributeHandlers.config = {
  set: function (value) {
    this._dataFlushed = false;

    this._requestUpdateContent();

    return value;
  },
  get: function () {
    var ref = arguments[arguments.length - 1];

    if (this._dataFlushed && this.editor.tableData) {
      return this.editor.tableData.config;
    } else {
      return ref.get();
    }
  },
  export: function () {
    return Object.assign({}, this.attributes.config);
  }
};
TableInput.prototype.attributeHandlers.records = {
  set: function (value) {
    value = value || [];
    this._dataFlushed = false;

    this._requestUpdateContent();

    return value;
  },
  get: function () {
    var ref = arguments[arguments.length - 1];

    if (this.attributes.appearance !== 'form' && this._dataFlushed && this.editor.tableData && this.editor.tableData.export) {
      return this.editor.tableData.export().records;
    } else {
      return ref.get();
    }
  }
};
TableInput.prototype.pinHandlers.records = {
  receives: function (value) {
    this.attributes.records = value;
  },
  get: function () {
    return this.attributes.records;
  },
  descriptor: {
    type: 'object[]'
  }
};
TableInput.prototype.pinHandlers.verify = {
  /***
   * @this TableInput
   * @param value
   */
  receives: function (value) {
    if (value) this.verify();
  },
  descriptor: {
    type: 'bool'
  }
};
TableInput.prototype.pinHandlers.incomplete = {
  get: function () {
    return this._incompleteCell;
  },
  descriptor: {
    type: 'bool'
  }
};
TableInput.prototype.pinHandlers.focusIncompleteCell = {
  /***
   * @this TableInput
   * @param value
   */
  receives: function (value) {
    if (value) {
      this.editor.focusIncompleteCell();
    }
  },
  descriptor: {
    type: 'bool'
  }
};
TableInput.prototype.attributeHandlers.readOnly = {
  set: function (value) {
    this.editor.opt.readOnly = !!value;
  },
  get: function () {
    return this.editor.opt.readOnly;
  },
  export: function () {
    return this.editor.opt.readOnly ? true : undefined;
  },
  descriptor: {
    type: 'bool'
  }
};
TableInput.prototype.attributeHandlers.headless = {
  set: function (value) {
    this.editor.opt.headless = !!value;
  },
  get: function () {
    return this.editor.opt.headless;
  },
  export: function () {
    return this.editor.opt.headless ? true : undefined;
  },
  descriptor: {
    type: 'bool'
  }
};
TableInput.prototype.attributeHandlers.disabled = {
  set: function (value) {
    this.editor.opt.readOnly = !!value;
  },
  get: function () {
    return this.editor.opt.readOnly;
  },
  export: function () {
    return this.editor.opt.readOnly ? true : undefined;
  },
  descriptor: {
    type: 'bool',
    hidden: true
  }
};
TableInput.prototype.attributeHandlers.appearance = {
  set: function (value, ref) {
    if (['sheet', 'form'].indexOf(value) < 0) value = 'sheet';
    if (value === ref.get()) return value;
    var data;
    if (this._dataFlushed) data = this.editor.getData();
    this.ctnElt.clearChild();

    if (value === 'sheet') {
      this.editor = new _TableEditor.default({
        elt: this.ctnElt
      });
    } else {
      this.editor = new _FormArrayEditor.default({
        elt: this.ctnElt
      });
    }

    this.editor.getView();
    if (!data) data = {
      records: []
    };

    if (this._dataFlushed && this.attributes.propertyDescriptors && this.attributes.propertyNames) {
      this.editor.setData(Object.assign({}, data, {
        propertyDescriptors: this.attributes.propertyDescriptors,
        propertyNames: this.attributes.propertyNames
      }));
    }

    return value;
  },
  export: function (ref) {
    var value = ref.get();
    if (value === 'sheet') value = undefined;
    return value;
  },
  descriptor: {
    type: 'enum',
    values: ['sheet', 'form']
  }
};

TableInput.prototype.onCreated = function () {
  this.$domSignal = (0, _FCore._)('attachhook.as-dom-signal');
  this.view.appendChild(this.$domSignal);
  this.domSignal = new _DomSignal.default(this.$domSignal);
  this.domSignal.on('requestUpdateContent', this._updateContent.bind(this));
  this._dataFlushed = true;
  this.attributes.records = [];
  this.attributes.propertyDescriptors = {
    "done": {
      "type": "text",
      "text": "example"
    }
  };
  this.attributes.propertyNames = ['done'];
  this.editor.on('change', function () {
    this.pinFire('records');
    this.notifyChange();

    _ResizeSystem.default.updateUp(this.domElt);
  }.bind(this));
};

TableInput.prototype._verifyTableData = function () {
  if (!this.attributes.propertyNames || !(this.attributes.propertyNames instanceof Array) || !this.attributes.propertyDescriptors || !this.attributes.records || !this.attributes.records) return false;
  return true;
};

TableInput.prototype._updateContent = function () {
  var config;

  if (this._verifyTableData()) {
    var prevRecords = this.editor.records;
    this.editor.fragment = this.fragment;
    config = Object.assign({}, this.attributes.config);
    config.rowHeight = this.style.rowHeight;
    this.editor.setData({
      propertyNames: this.attributes.propertyNames,
      propertyDescriptors: this.attributes.propertyDescriptors,
      records: this.attributes.records,
      config: config
    });
    this._dataFlushed = true;

    if (prevRecords !== this.editor.records) {
      this.pinFire('records');
      this.notifyChange();
    }

    _ResizeSystem.default.updateUp(this.domElt);
  }
};

TableInput.prototype._requestUpdateContent = function () {
  this.domSignal.emit('requestUpdateContent');
};

TableInput.prototype.createDataBindingDescriptor = function () {
  var thisTI = this;
  var props = {};
  Object.defineProperties(props, {
    propertyNames: {
      enumerable: true,
      set: function (pnA) {
        thisTI.setAttribute('propertyNames', pnA);
      },
      get: function () {
        return thisTI.getAttribute('propertyNames');
      }
    },
    propertyDescriptors: {
      enumerable: true,
      set: function (pdO) {
        thisTI.setAttribute('propertyDescriptors', pdO);
      },
      get: function () {
        return thisTI.getAttribute('propertyDescriptors');
      }
    },
    records: {
      enumerable: true,
      set: function (records) {
        thisTI.setAttribute('records', records);
      },
      get: function () {
        return thisTI.getAttribute('records');
      }
    }
  });
  return {
    enumerable: true,
    set: function (value) {
      Object.assign(props, value);
    },
    get: function () {
      return props;
    }
  };
};

_Assembler.AssemblerInstance.addClass(TableInput);

var _default = TableInput;
exports.default = _default;

VaKeR 2022