grid-area.js 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. "use strict";
  2. function _defaults(obj, defaults) { var keys = Object.getOwnPropertyNames(defaults); for (var i = 0; i < keys.length; i++) { var key = keys[i]; var value = Object.getOwnPropertyDescriptor(defaults, key); if (value && value.configurable && obj[key] === undefined) { Object.defineProperty(obj, key, value); } } return obj; }
  3. function _inheritsLoose(subClass, superClass) { subClass.prototype = Object.create(superClass.prototype); subClass.prototype.constructor = subClass; _defaults(subClass, superClass); }
  4. function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
  5. var Declaration = require('../declaration');
  6. var utils = require('./grid-utils');
  7. var GridArea = /*#__PURE__*/function (_Declaration) {
  8. _inheritsLoose(GridArea, _Declaration);
  9. function GridArea() {
  10. return _Declaration.apply(this, arguments) || this;
  11. }
  12. var _proto = GridArea.prototype;
  13. /**
  14. * Translate grid-area to separate -ms- prefixed properties
  15. */
  16. _proto.insert = function insert(decl, prefix, prefixes, result) {
  17. if (prefix !== '-ms-') return _Declaration.prototype.insert.call(this, decl, prefix, prefixes);
  18. var values = utils.parse(decl);
  19. var _utils$translate = utils.translate(values, 0, 2),
  20. rowStart = _utils$translate[0],
  21. rowSpan = _utils$translate[1];
  22. var _utils$translate2 = utils.translate(values, 1, 3),
  23. columnStart = _utils$translate2[0],
  24. columnSpan = _utils$translate2[1];
  25. [['grid-row', rowStart], ['grid-row-span', rowSpan], ['grid-column', columnStart], ['grid-column-span', columnSpan]].forEach(function (_ref) {
  26. var prop = _ref[0],
  27. value = _ref[1];
  28. utils.insertDecl(decl, prop, value);
  29. });
  30. utils.warnTemplateSelectorNotFound(decl, result);
  31. utils.warnIfGridRowColumnExists(decl, result);
  32. return undefined;
  33. };
  34. return GridArea;
  35. }(Declaration);
  36. _defineProperty(GridArea, "names", ['grid-area']);
  37. module.exports = GridArea;