source: trip-planner-front/node_modules/autoprefixer/lib/hacks/grid-rows-columns.js@ 6fe77af

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

initial commit

  • Property mode set to 100644
File size: 4.4 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 prefixTrackProp = _require.prefixTrackProp,
13 prefixTrackValue = _require.prefixTrackValue,
14 autoplaceGridItems = _require.autoplaceGridItems,
15 getGridGap = _require.getGridGap,
16 inheritGridGap = _require.inheritGridGap;
17
18var Processor = require('../processor');
19
20var GridRowsColumns = /*#__PURE__*/function (_Declaration) {
21 _inheritsLoose(GridRowsColumns, _Declaration);
22
23 function GridRowsColumns() {
24 return _Declaration.apply(this, arguments) || this;
25 }
26
27 var _proto = GridRowsColumns.prototype;
28
29 /**
30 * Change property name for IE
31 */
32 _proto.prefixed = function prefixed(prop, prefix) {
33 if (prefix === '-ms-') {
34 return prefixTrackProp({
35 prop: prop,
36 prefix: prefix
37 });
38 }
39
40 return _Declaration.prototype.prefixed.call(this, prop, prefix);
41 }
42 /**
43 * Change IE property back
44 */
45 ;
46
47 _proto.normalize = function normalize(prop) {
48 return prop.replace(/^grid-(rows|columns)/, 'grid-template-$1');
49 };
50
51 _proto.insert = function insert(decl, prefix, prefixes, result) {
52 if (prefix !== '-ms-') return _Declaration.prototype.insert.call(this, decl, prefix, prefixes);
53 var parent = decl.parent,
54 prop = decl.prop,
55 value = decl.value;
56 var isRowProp = prop.includes('rows');
57 var isColumnProp = prop.includes('columns');
58 var hasGridTemplate = parent.some(function (i) {
59 return i.prop === 'grid-template' || i.prop === 'grid-template-areas';
60 });
61 /**
62 * Not to prefix rows declaration if grid-template(-areas) is present
63 */
64
65 if (hasGridTemplate && isRowProp) {
66 return false;
67 }
68
69 var processor = new Processor({
70 options: {}
71 });
72 var status = processor.gridStatus(parent, result);
73 var gap = getGridGap(decl);
74 gap = inheritGridGap(decl, gap) || gap;
75 var gapValue = isRowProp ? gap.row : gap.column;
76
77 if ((status === 'no-autoplace' || status === true) && !hasGridTemplate) {
78 gapValue = null;
79 }
80
81 var prefixValue = prefixTrackValue({
82 value: value,
83 gap: gapValue
84 });
85 /**
86 * Insert prefixes
87 */
88
89 decl.cloneBefore({
90 prop: prefixTrackProp({
91 prop: prop,
92 prefix: prefix
93 }),
94 value: prefixValue
95 });
96 var autoflow = parent.nodes.find(function (i) {
97 return i.prop === 'grid-auto-flow';
98 });
99 var autoflowValue = 'row';
100
101 if (autoflow && !processor.disabled(autoflow, result)) {
102 autoflowValue = autoflow.value.trim();
103 }
104
105 if (status === 'autoplace') {
106 /**
107 * Show warning if grid-template-rows decl is not found
108 */
109 var rowDecl = parent.nodes.find(function (i) {
110 return i.prop === 'grid-template-rows';
111 });
112
113 if (!rowDecl && hasGridTemplate) {
114 return undefined;
115 } else if (!rowDecl && !hasGridTemplate) {
116 decl.warn(result, 'Autoplacement does not work without grid-template-rows property');
117 return undefined;
118 }
119 /**
120 * Show warning if grid-template-columns decl is not found
121 */
122
123
124 var columnDecl = parent.nodes.find(function (i) {
125 return i.prop === 'grid-template-columns';
126 });
127
128 if (!columnDecl && !hasGridTemplate) {
129 decl.warn(result, 'Autoplacement does not work without grid-template-columns property');
130 }
131 /**
132 * Autoplace grid items
133 */
134
135
136 if (isColumnProp && !hasGridTemplate) {
137 autoplaceGridItems(decl, result, gap, autoflowValue);
138 }
139 }
140
141 return undefined;
142 };
143
144 return GridRowsColumns;
145}(Declaration);
146
147_defineProperty(GridRowsColumns, "names", ['grid-template-rows', 'grid-template-columns', 'grid-rows', 'grid-columns']);
148
149module.exports = GridRowsColumns;
Note: See TracBrowser for help on using the repository browser.