18b75383382fe073d2d45cea0ffacf221a7462251d21d5c94571bac0ebb754c79bd78a09b7048a3b9a9a8b9c2725608dda4285a069fc60aeb9931ef8095f68 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114
  1. 'use strict';
  2. exports.__esModule = true;
  3. exports.getRegisteredCellTypes = exports.getRegisteredCellTypeNames = exports.hasCellType = exports.getCellType = exports.registerCellType = undefined;
  4. var _staticRegister2 = require('./../utils/staticRegister');
  5. var _staticRegister3 = _interopRequireDefault(_staticRegister2);
  6. var _editors = require('./../editors');
  7. var _renderers = require('./../renderers');
  8. var _validators = require('./../validators');
  9. var _autocompleteType = require('./autocompleteType');
  10. var _autocompleteType2 = _interopRequireDefault(_autocompleteType);
  11. var _checkboxType = require('./checkboxType');
  12. var _checkboxType2 = _interopRequireDefault(_checkboxType);
  13. var _dateType = require('./dateType');
  14. var _dateType2 = _interopRequireDefault(_dateType);
  15. var _dropdownType = require('./dropdownType');
  16. var _dropdownType2 = _interopRequireDefault(_dropdownType);
  17. var _handsontableType = require('./handsontableType');
  18. var _handsontableType2 = _interopRequireDefault(_handsontableType);
  19. var _numericType = require('./numericType');
  20. var _numericType2 = _interopRequireDefault(_numericType);
  21. var _passwordType = require('./passwordType');
  22. var _passwordType2 = _interopRequireDefault(_passwordType);
  23. var _textType = require('./textType');
  24. var _textType2 = _interopRequireDefault(_textType);
  25. var _timeType = require('./timeType');
  26. var _timeType2 = _interopRequireDefault(_timeType);
  27. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  28. var _staticRegister = (0, _staticRegister3.default)('cellTypes'),
  29. register = _staticRegister.register,
  30. getItem = _staticRegister.getItem,
  31. hasItem = _staticRegister.hasItem,
  32. getNames = _staticRegister.getNames,
  33. getValues = _staticRegister.getValues;
  34. _register('autocomplete', _autocompleteType2.default);
  35. _register('checkbox', _checkboxType2.default);
  36. _register('date', _dateType2.default);
  37. _register('dropdown', _dropdownType2.default);
  38. _register('handsontable', _handsontableType2.default);
  39. _register('numeric', _numericType2.default);
  40. _register('password', _passwordType2.default);
  41. _register('text', _textType2.default);
  42. _register('time', _timeType2.default);
  43. /**
  44. * Retrieve cell type object.
  45. *
  46. * @param {String} name Cell type identification.
  47. * @returns {Object} Returns cell type object.
  48. */
  49. function _getItem(name) {
  50. if (!hasItem(name)) {
  51. throw Error('You declared cell type "' + name + '" as a string that is not mapped to a known object.\n Cell type must be an object or a string mapped to an object registered by "Handsontable.cellTypes.registerCellType" method');
  52. }
  53. return getItem(name);
  54. }
  55. /**
  56. * Register cell type under specified name.
  57. *
  58. * @param {String} name Cell type identification.
  59. * @param {Object} type An object with contains keys (eq: `editor`, `renderer`, `validator`) which describes specified behaviour of the cell.
  60. */
  61. function _register(name, type) {
  62. var editor = type.editor,
  63. renderer = type.renderer,
  64. validator = type.validator;
  65. if (editor) {
  66. (0, _editors.registerEditor)(name, editor);
  67. }
  68. if (renderer) {
  69. (0, _renderers.registerRenderer)(name, renderer);
  70. }
  71. if (validator) {
  72. (0, _validators.registerValidator)(name, validator);
  73. }
  74. register(name, type);
  75. }
  76. exports.registerCellType = _register;
  77. exports.getCellType = _getItem;
  78. exports.hasCellType = hasItem;
  79. exports.getRegisteredCellTypeNames = getNames;
  80. exports.getRegisteredCellTypes = getValues;