source: trip-planner-front/node_modules/autoprefixer/lib/hacks/grid-template-areas.js@ 6a3a178

Last change on this file since 6a3a178 was 6a3a178, checked in by Ema <ema_spirova@…>, 3 years ago

initial commit

  • Property mode set to 100644
File size: 3.3 KB
Line 
1"use strict";
2
3function _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; }
4
5function _inheritsLoose(subClass, superClass) { subClass.prototype = Object.create(superClass.prototype); subClass.prototype.constructor = subClass; _defaults(subClass, superClass); }
6
7function _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; }
8
9var Declaration = require('../declaration');
10
11var _require = require('./grid-utils'),
12 parseGridAreas = _require.parseGridAreas,
13 warnMissedAreas = _require.warnMissedAreas,
14 prefixTrackProp = _require.prefixTrackProp,
15 prefixTrackValue = _require.prefixTrackValue,
16 getGridGap = _require.getGridGap,
17 warnGridGap = _require.warnGridGap,
18 inheritGridGap = _require.inheritGridGap;
19
20function getGridRows(tpl) {
21 return tpl.trim().slice(1, -1).split(/["']\s*["']?/g);
22}
23
24var GridTemplateAreas = /*#__PURE__*/function (_Declaration) {
25 _inheritsLoose(GridTemplateAreas, _Declaration);
26
27 function GridTemplateAreas() {
28 return _Declaration.apply(this, arguments) || this;
29 }
30
31 var _proto = GridTemplateAreas.prototype;
32
33 /**
34 * Translate grid-template-areas to separate -ms- prefixed properties
35 */
36 _proto.insert = function insert(decl, prefix, prefixes, result) {
37 if (prefix !== '-ms-') return _Declaration.prototype.insert.call(this, decl, prefix, prefixes);
38 var hasColumns = false;
39 var hasRows = false;
40 var parent = decl.parent;
41 var gap = getGridGap(decl);
42 gap = inheritGridGap(decl, gap) || gap; // remove already prefixed rows
43 // to prevent doubling prefixes
44
45 parent.walkDecls(/-ms-grid-rows/, function (i) {
46 return i.remove();
47 }); // add empty tracks to rows
48
49 parent.walkDecls(/grid-template-(rows|columns)/, function (trackDecl) {
50 if (trackDecl.prop === 'grid-template-rows') {
51 hasRows = true;
52 var prop = trackDecl.prop,
53 value = trackDecl.value;
54 trackDecl.cloneBefore({
55 prop: prefixTrackProp({
56 prop: prop,
57 prefix: prefix
58 }),
59 value: prefixTrackValue({
60 value: value,
61 gap: gap.row
62 })
63 });
64 } else {
65 hasColumns = true;
66 }
67 });
68 var gridRows = getGridRows(decl.value);
69
70 if (hasColumns && !hasRows && gap.row && gridRows.length > 1) {
71 decl.cloneBefore({
72 prop: '-ms-grid-rows',
73 value: prefixTrackValue({
74 value: "repeat(" + gridRows.length + ", auto)",
75 gap: gap.row
76 }),
77 raws: {}
78 });
79 } // warnings
80
81
82 warnGridGap({
83 gap: gap,
84 hasColumns: hasColumns,
85 decl: decl,
86 result: result
87 });
88 var areas = parseGridAreas({
89 rows: gridRows,
90 gap: gap
91 });
92 warnMissedAreas(areas, decl, result);
93 return decl;
94 };
95
96 return GridTemplateAreas;
97}(Declaration);
98
99_defineProperty(GridTemplateAreas, "names", ['grid-template-areas']);
100
101module.exports = GridTemplateAreas;
Note: See TracBrowser for help on using the repository browser.