1 | "use strict";
|
2 |
|
3 | 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); }
|
4 |
|
5 | function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
6 |
|
7 | 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); } }
|
8 |
|
9 | function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
|
10 |
|
11 |
|
12 | var Arbitrary, DeclarationBlock, declarationClasses;
|
13 |
|
14 | module.exports = DeclarationBlock = function () {
|
15 | var self;
|
16 |
|
17 | var DeclarationBlock = function () {
|
18 | function DeclarationBlock() {
|
19 | _classCallCheck(this, DeclarationBlock);
|
20 |
|
21 | this._declarations = {};
|
22 | }
|
23 |
|
24 | _createClass(DeclarationBlock, [{
|
25 | key: "set",
|
26 | value: function set(prop, value) {
|
27 | var key, val;
|
28 |
|
29 | if (_typeof(prop) === 'object') {
|
30 | for (key in prop) {
|
31 | val = prop[key];
|
32 | this.set(key, val);
|
33 | }
|
34 |
|
35 | return this;
|
36 | }
|
37 |
|
38 | prop = self.sanitizeProp(prop);
|
39 |
|
40 | this._getDeclarationClass(prop).setOnto(this._declarations, prop, value);
|
41 |
|
42 | return this;
|
43 | }
|
44 | }, {
|
45 | key: "_getDeclarationClass",
|
46 | value: function _getDeclarationClass(prop) {
|
47 | var cls;
|
48 |
|
49 | if (prop[0] === '_') {
|
50 | return Arbitrary;
|
51 | }
|
52 |
|
53 | if (!(cls = declarationClasses[prop])) {
|
54 | throw Error("Unknown property `".concat(prop, "`. Write it as `_").concat(prop, "` if you're defining a custom property"));
|
55 | }
|
56 |
|
57 | return cls;
|
58 | }
|
59 | }], [{
|
60 | key: "sanitizeProp",
|
61 | value: function sanitizeProp(prop) {
|
62 | return String(prop).trim();
|
63 | }
|
64 | }]);
|
65 |
|
66 | return DeclarationBlock;
|
67 | }();
|
68 |
|
69 | ;
|
70 | self = DeclarationBlock;
|
71 | return DeclarationBlock;
|
72 | }.call(void 0);
|
73 |
|
74 | Arbitrary = require('./declarationBlock/Arbitrary');
|
75 | declarationClasses = {
|
76 | color: require('./declarationBlock/Color'),
|
77 | background: require('./declarationBlock/Background'),
|
78 | width: require('./declarationBlock/Width'),
|
79 | height: require('./declarationBlock/Height'),
|
80 | bullet: require('./declarationBlock/Bullet'),
|
81 | display: require('./declarationBlock/Display'),
|
82 | margin: require('./declarationBlock/Margin'),
|
83 | marginTop: require('./declarationBlock/MarginTop'),
|
84 | marginLeft: require('./declarationBlock/MarginLeft'),
|
85 | marginRight: require('./declarationBlock/MarginRight'),
|
86 | marginBottom: require('./declarationBlock/MarginBottom'),
|
87 | padding: require('./declarationBlock/Padding'),
|
88 | paddingTop: require('./declarationBlock/PaddingTop'),
|
89 | paddingLeft: require('./declarationBlock/PaddingLeft'),
|
90 | paddingRight: require('./declarationBlock/PaddingRight'),
|
91 | paddingBottom: require('./declarationBlock/PaddingBottom')
|
92 | }; |
\ | No newline at end of file |