You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

53 lines
2.1 KiB

4 years ago
  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 =
  8. /*#__PURE__*/
  9. function (_Declaration) {
  10. _inheritsLoose(GridArea, _Declaration);
  11. function GridArea() {
  12. return _Declaration.apply(this, arguments) || this;
  13. }
  14. var _proto = GridArea.prototype;
  15. /**
  16. * Translate grid-area to separate -ms- prefixed properties
  17. */
  18. _proto.insert = function insert(decl, prefix, prefixes, result) {
  19. if (prefix !== '-ms-') return _Declaration.prototype.insert.call(this, decl, prefix, prefixes);
  20. var values = utils.parse(decl);
  21. var _utils$translate = utils.translate(values, 0, 2),
  22. rowStart = _utils$translate[0],
  23. rowSpan = _utils$translate[1];
  24. var _utils$translate2 = utils.translate(values, 1, 3),
  25. columnStart = _utils$translate2[0],
  26. columnSpan = _utils$translate2[1];
  27. [['grid-row', rowStart], ['grid-row-span', rowSpan], ['grid-column', columnStart], ['grid-column-span', columnSpan]].forEach(function (_ref) {
  28. var prop = _ref[0],
  29. value = _ref[1];
  30. utils.insertDecl(decl, prop, value);
  31. });
  32. utils.warnTemplateSelectorNotFound(decl, result);
  33. utils.warnIfGridRowColumnExists(decl, result);
  34. return undefined;
  35. };
  36. return GridArea;
  37. }(Declaration);
  38. _defineProperty(GridArea, "names", ['grid-area']);
  39. module.exports = GridArea;