grid-row-column.js 1.9 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 GridRowColumn = /*#__PURE__*/function (_Declaration) {
  8. _inheritsLoose(GridRowColumn, _Declaration);
  9. function GridRowColumn() {
  10. return _Declaration.apply(this, arguments) || this;
  11. }
  12. var _proto = GridRowColumn.prototype;
  13. /**
  14. * Translate grid-row / grid-column to separate -ms- prefixed properties
  15. */
  16. _proto.insert = function insert(decl, prefix, prefixes) {
  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, 1),
  20. start = _utils$translate[0],
  21. span = _utils$translate[1];
  22. var hasStartValueSpan = values[0] && values[0].includes('span');
  23. if (hasStartValueSpan) {
  24. span = values[0].join('').replace(/\D/g, '');
  25. }
  26. [[decl.prop, start], [decl.prop + "-span", span]].forEach(function (_ref) {
  27. var prop = _ref[0],
  28. value = _ref[1];
  29. utils.insertDecl(decl, prop, value);
  30. });
  31. return undefined;
  32. };
  33. return GridRowColumn;
  34. }(Declaration);
  35. _defineProperty(GridRowColumn, "names", ['grid-row', 'grid-column']);
  36. module.exports = GridRowColumn;