DeclarationBlock.js 3.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192
  1. "use strict";
  2. function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
  3. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  4. function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
  5. function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
  6. // Generated by CoffeeScript 2.5.1
  7. var Arbitrary, DeclarationBlock, declarationClasses;
  8. module.exports = DeclarationBlock = function () {
  9. var self;
  10. var DeclarationBlock = /*#__PURE__*/function () {
  11. function DeclarationBlock() {
  12. _classCallCheck(this, DeclarationBlock);
  13. this._declarations = {};
  14. }
  15. _createClass(DeclarationBlock, [{
  16. key: "set",
  17. value: function set(prop, value) {
  18. var key, val;
  19. if (_typeof(prop) === 'object') {
  20. for (key in prop) {
  21. val = prop[key];
  22. this.set(key, val);
  23. }
  24. return this;
  25. }
  26. prop = self.sanitizeProp(prop);
  27. this._getDeclarationClass(prop).setOnto(this._declarations, prop, value);
  28. return this;
  29. }
  30. }, {
  31. key: "_getDeclarationClass",
  32. value: function _getDeclarationClass(prop) {
  33. var cls;
  34. if (prop[0] === '_') {
  35. return Arbitrary;
  36. }
  37. if (!(cls = declarationClasses[prop])) {
  38. throw Error("Unknown property `".concat(prop, "`. Write it as `_").concat(prop, "` if you're defining a custom property"));
  39. }
  40. return cls;
  41. }
  42. }], [{
  43. key: "sanitizeProp",
  44. value: function sanitizeProp(prop) {
  45. return String(prop).trim();
  46. }
  47. }]);
  48. return DeclarationBlock;
  49. }();
  50. ;
  51. self = DeclarationBlock;
  52. return DeclarationBlock;
  53. }.call(void 0);
  54. Arbitrary = require('./declarationBlock/Arbitrary');
  55. declarationClasses = {
  56. color: require('./declarationBlock/Color'),
  57. background: require('./declarationBlock/Background'),
  58. width: require('./declarationBlock/Width'),
  59. height: require('./declarationBlock/Height'),
  60. bullet: require('./declarationBlock/Bullet'),
  61. display: require('./declarationBlock/Display'),
  62. margin: require('./declarationBlock/Margin'),
  63. marginTop: require('./declarationBlock/MarginTop'),
  64. marginLeft: require('./declarationBlock/MarginLeft'),
  65. marginRight: require('./declarationBlock/MarginRight'),
  66. marginBottom: require('./declarationBlock/MarginBottom'),
  67. padding: require('./declarationBlock/Padding'),
  68. paddingTop: require('./declarationBlock/PaddingTop'),
  69. paddingLeft: require('./declarationBlock/PaddingLeft'),
  70. paddingRight: require('./declarationBlock/PaddingRight'),
  71. paddingBottom: require('./declarationBlock/PaddingBottom')
  72. };