@zohodesk/react-cli 0.0.1-exp.168.2 → 0.0.1-exp.168.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.eslintignore +7 -7
- package/.eslintrc.js +179 -179
- package/README.md +925 -918
- package/bin/cli.js +492 -492
- package/cert/Tsicsezwild-22-23.crt +37 -37
- package/cert/Tsicsezwild-22-23.key +27 -27
- package/docs/CustomChunks.md +26 -26
- package/docs/DevStart.md +18 -18
- package/docs/InstallNode.md +28 -28
- package/docs/TODOS.md +10 -10
- package/docs/ValueReplacer.md +60 -60
- package/docs/warnings_while_install.txt +35 -35
- package/files/eslintrc.js +62 -62
- package/files/prettierrc.js +3 -3
- package/lib/configs/webpack.css.umd.config.js +4 -4
- package/lib/configs/webpack.prod.config.js +1 -1
- package/lib/loaderUtils/configsAssetsLoaders.js +33 -33
- package/lib/loaders/workerLoader.js +9 -9
- package/lib/pluginUtils/getDevPlugins.js +5 -5
- package/lib/pluginUtils/getProdPlugins.js +5 -5
- package/lib/plugins/EFCPlugin.md +6 -6
- package/lib/plugins/I18NInjectIntoIndexPlugin.js +4 -4
- package/lib/plugins/I18nSplitPlugin/I18nDownlodLogic.js +38 -38
- package/lib/plugins/I18nSplitPlugin/I18nFilesEmitter.js +30 -30
- package/lib/plugins/I18nSplitPlugin/I18nKeysIdentifer.js +8 -8
- package/lib/plugins/I18nSplitPlugin/I18nSplit.md +86 -86
- package/lib/plugins/I18nSplitPlugin/README.md +25 -25
- package/lib/plugins/I18nSplitPlugin/index.js +57 -57
- package/lib/plugins/ResourceHintsPlugin.js +17 -17
- package/lib/plugins/RtlSplitPlugin/RtlCssPlugin.js +6 -6
- package/lib/plugins/RtlSplitPlugin/RtrSplit.md +30 -30
- package/lib/plugins/ServiceWorkerPlugin.js +9 -9
- package/lib/plugins/TPHashMappingPlugin.js +4 -4
- package/lib/postcss-plugins/RTLSplitPlugin.js +10 -10
- package/lib/postcss-plugins/hoverActivePlugin.js +324 -231
- package/lib/postcss-plugins/keyframesPlugin.js +20 -20
- package/lib/sh/pre-commit.sh +34 -34
- package/lib/sh/reportPublish.sh +45 -45
- package/lib/utils/buildstats.html +148 -148
- package/lib/utils/resultSchema.json +73 -73
- package/npm8.md +9 -9
- package/package.json +148 -148
- package/postpublish.js +6 -6
- package/templates/app/.eslintrc.js +140 -140
- package/templates/app/README.md +12 -12
- package/templates/app/app/index.html +24 -24
- package/templates/app/app/properties/ApplicationResources_en_US.properties +1 -1
- package/templates/app/app/properties/i18nkeys.json +3 -3
- package/templates/app/docs/all.html +69 -69
- package/templates/app/mockapi/index.js +18 -18
- package/templates/app/package.json +37 -37
- package/templates/app/src/actions/SampleActions/index.js +37 -37
- package/templates/app/src/actions/index.js +65 -65
- package/templates/app/src/appUrls.js +19 -19
- package/templates/app/src/components/Alert/Alert.js +134 -134
- package/templates/app/src/components/Alert/Alert.module.css +79 -79
- package/templates/app/src/components/FreezeLayer/FreezeLayer.css +37 -37
- package/templates/app/src/components/FreezeLayer/FreezeLayer.js +84 -84
- package/templates/app/src/components/Sample/Sample.module.css +11 -11
- package/templates/app/src/components/Sample/SampleList.js +61 -61
- package/templates/app/src/components/Slider/Slider.css +41 -41
- package/templates/app/src/components/Slider/Slider.js +55 -55
- package/templates/app/src/containers/AlertContainer/index.js +15 -15
- package/templates/app/src/containers/AppContainer/index.js +96 -96
- package/templates/app/src/containers/AppContainer/index.module.css +27 -27
- package/templates/app/src/containers/CustomMatch/index.js +65 -65
- package/templates/app/src/containers/DevTools/index.js +10 -10
- package/templates/app/src/containers/Header/index.js +67 -67
- package/templates/app/src/containers/Header/index.module.css +43 -43
- package/templates/app/src/containers/Redirect/index.js +63 -63
- package/templates/app/src/containers/Redirector/index.js +47 -47
- package/templates/app/src/containers/SampleListContainer/ListContainer.js +42 -42
- package/templates/app/src/containers/SampleListContainer/ListContainer.module.css +3 -3
- package/templates/app/src/historyChange.js +5 -5
- package/templates/app/src/index.html +10 -10
- package/templates/app/src/index.js +24 -24
- package/templates/app/src/middleware/PromiseMiddleware.js +59 -59
- package/templates/app/src/reducers/alertData.js +11 -11
- package/templates/app/src/reducers/index.js +6 -6
- package/templates/app/src/reducers/samples.js +19 -19
- package/templates/app/src/store/configureStore.dev.js +51 -51
- package/templates/app/src/store/configureStore.js +5 -5
- package/templates/app/src/store/configureStore.prod.js +26 -26
- package/templates/app/src/util/Common.js +5 -5
- package/templates/app/src/util/RequestAPI.js +132 -132
- package/templates/docs/all.html +249 -249
- package/templates/docs/component.html +178 -178
- package/templates/docs/components.html +221 -221
- package/templates/docs/css/b.min.css +6 -6
- package/templates/docs/css/component.css +42 -42
- package/templates/docs/css/componentTest.css +6 -6
- package/templates/docs/css/hopscotch.css +585 -585
- package/templates/docs/css/style.css +1022 -1022
- package/templates/docs/impactReportTemplate.html +154 -154
- package/templates/docs/index.html +1493 -1493
- package/templates/docs/js/active-line.js +72 -72
- package/templates/docs/js/b.min.js +7 -7
- package/templates/docs/js/codemirror.js +9680 -9680
- package/templates/docs/js/designTokens.js +334 -334
- package/templates/docs/js/j.min.js +4 -4
- package/templates/docs/js/javascript.js +874 -874
- package/templates/docs/js/matchbrackets.js +145 -145
|
@@ -4,261 +4,354 @@ var _postcss = _interopRequireDefault(require("postcss"));
|
|
|
4
4
|
|
|
5
5
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
6
6
|
|
|
7
|
-
|
|
8
|
-
return
|
|
9
|
-
|
|
10
|
-
|
|
7
|
+
function previousNodeCheck(nodes, index) {
|
|
8
|
+
return nodes !== undefined && nodes[index - 1] !== undefined && nodes[index - 1] && nodes[index - 1].text !== undefined;
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
function isComment(node) {
|
|
12
|
+
return node !== undefined && node.type === 'comment';
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
function isHoverPresent(atrule) {
|
|
16
|
+
let hoverPresent = false;
|
|
17
|
+
atrule.walkRules(rule => {
|
|
18
|
+
if (rule.selector.includes('hover')) {
|
|
19
|
+
hoverPresent = true;
|
|
11
20
|
}
|
|
21
|
+
});
|
|
22
|
+
return hoverPresent;
|
|
23
|
+
}
|
|
12
24
|
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
25
|
+
module.exports = _postcss.default.plugin('postcss-mobile-hover', () => rootOriginal => {
|
|
26
|
+
const hoverRules = [];
|
|
27
|
+
let positionsObj = {};
|
|
28
|
+
const hoverIgnoreQuery = 'Hover:ignore',
|
|
29
|
+
activeIgnoreQuery = 'Active:ignore',
|
|
30
|
+
hoverActiveIgnoreQuery = 'HoverActive:ignore';
|
|
31
|
+
const medHoverIgnoreQuery = 'MedHover:ignore',
|
|
32
|
+
medActiveIgnoreQuery = 'MedActive:ignore',
|
|
33
|
+
medHoverActiveIgnoreQuery = 'MedHoverActive:ignore';
|
|
34
|
+
|
|
35
|
+
function QueryIgnoreCheck(index, type) {
|
|
36
|
+
if (previousNodeCheck(rootOriginal.nodes, index)) {
|
|
37
|
+
return rootOriginal.nodes[index - 1].text === type;
|
|
23
38
|
}
|
|
24
39
|
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
posn = index;
|
|
32
|
-
}
|
|
33
|
-
});
|
|
34
|
-
return posn;
|
|
40
|
+
return false;
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
function mediaQueryIgnoreCheck(node, type) {
|
|
44
|
+
if (isComment(node)) {
|
|
45
|
+
return node.text === type;
|
|
35
46
|
}
|
|
36
47
|
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
48
|
+
return false;
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
function handleIgnore({
|
|
52
|
+
index,
|
|
53
|
+
atrule,
|
|
54
|
+
type
|
|
55
|
+
}) {
|
|
56
|
+
if (type.match(/(Hover:ignore|Active:ignore|HoverActive:ignore)/g)) {
|
|
57
|
+
return QueryIgnoreCheck(index, type);
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
if (type.match(/(MedHover:ignore|MedActive:ignore|MedHoverActive:ignore)/g)) {
|
|
61
|
+
return mediaQueryIgnoreCheck(atrule.nodes[index - 1], type.slice(3));
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
function returnPositions(parent) {
|
|
66
|
+
let positions = {
|
|
67
|
+
hovMed: rootOriginal.nodes[positionsObj[`${parent.params} and all and (min--moz-device-pixel-ratio:0) and (hover: hover), (hover: hover)`] - 1],
|
|
68
|
+
actMed: rootOriginal.nodes[positionsObj[`${parent.params} and (hover: none)`] - 1]
|
|
69
|
+
};
|
|
70
|
+
return positions;
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
function handleMedHoverAndHoverActiveIgnore(atrule, index) {
|
|
74
|
+
return !handleIgnore({
|
|
75
|
+
atrule,
|
|
76
|
+
index,
|
|
77
|
+
type: medHoverIgnoreQuery
|
|
78
|
+
}) && !handleIgnore({
|
|
79
|
+
atrule,
|
|
80
|
+
index,
|
|
81
|
+
type: medHoverActiveIgnoreQuery
|
|
82
|
+
});
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
function handleMedActiveAndHoverActiveIgnore(atrule, index) {
|
|
86
|
+
return !handleIgnore({
|
|
87
|
+
atrule,
|
|
88
|
+
index,
|
|
89
|
+
type: medActiveIgnoreQuery
|
|
90
|
+
}) && !handleIgnore({
|
|
91
|
+
atrule,
|
|
92
|
+
index,
|
|
93
|
+
type: medHoverActiveIgnoreQuery
|
|
94
|
+
});
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
function handleHoverAndHoverActiveIgnore(index) {
|
|
98
|
+
return !handleIgnore({
|
|
99
|
+
index,
|
|
100
|
+
type: hoverIgnoreQuery
|
|
101
|
+
}) && !handleIgnore({
|
|
102
|
+
index,
|
|
103
|
+
type: hoverActiveIgnoreQuery
|
|
104
|
+
});
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
function handleActiveAndHoverActiveIgnore(index) {
|
|
108
|
+
return !handleIgnore({
|
|
109
|
+
index,
|
|
110
|
+
type: activeIgnoreQuery
|
|
111
|
+
}) && !handleIgnore({
|
|
112
|
+
index,
|
|
113
|
+
type: hoverActiveIgnoreQuery
|
|
114
|
+
});
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
function handleAllIgnoreCases(index) {
|
|
118
|
+
return !handleIgnore({
|
|
119
|
+
index,
|
|
120
|
+
type: activeIgnoreQuery
|
|
121
|
+
}) && !handleIgnore({
|
|
122
|
+
index,
|
|
123
|
+
type: hoverIgnoreQuery
|
|
124
|
+
}) && !handleIgnore({
|
|
125
|
+
index,
|
|
126
|
+
type: hoverActiveIgnoreQuery
|
|
127
|
+
});
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
function mediaCommaQuery(rule, index) {
|
|
131
|
+
if (rule.parent.params !== undefined && !rule.parent.params.includes('hover')) {
|
|
132
|
+
//console.log(hovMed, actMed);
|
|
133
|
+
let newSelector = '';
|
|
134
|
+
let {
|
|
135
|
+
hovMed,
|
|
136
|
+
actMed
|
|
137
|
+
} = returnPositions(rule.parent);
|
|
138
|
+
let hovQueries = [];
|
|
139
|
+
let actQueries = [];
|
|
140
|
+
rule.selector.split(/\s*,\s*/).forEach(_subrule => {
|
|
141
|
+
let subrule = _subrule.trim();
|
|
142
|
+
|
|
143
|
+
let clone = rule.clone();
|
|
144
|
+
|
|
145
|
+
if (subrule.includes('hover')) {
|
|
146
|
+
clone.selector = subrule;
|
|
147
|
+
|
|
148
|
+
if (handleMedHoverAndHoverActiveIgnore(rule.parent, index)) {
|
|
149
|
+
hovQueries.push(subrule);
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
if (handleMedActiveAndHoverActiveIgnore(rule.parent, index)) {
|
|
153
|
+
actQueries.push(subrule);
|
|
154
|
+
}
|
|
155
|
+
} else {
|
|
156
|
+
newSelector += `${subrule}, `;
|
|
42
157
|
}
|
|
43
158
|
});
|
|
44
|
-
|
|
159
|
+
|
|
160
|
+
if (hovQueries.length > 0) {
|
|
161
|
+
let clone = rule.clone();
|
|
162
|
+
clone.selector = hovQueries.join(',');
|
|
163
|
+
hovMed.append(clone);
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
if (actQueries.length > 0) {
|
|
167
|
+
let clone = rule.clone();
|
|
168
|
+
clone.selector = actQueries.join(',');
|
|
169
|
+
actMed.append(clone.clone({
|
|
170
|
+
selector: clone.selector.replace(/:hover/gi, ':active')
|
|
171
|
+
}));
|
|
172
|
+
}
|
|
173
|
+
|
|
174
|
+
if (handleMedHoverAndHoverActiveIgnore(rule.parent, index)) {
|
|
175
|
+
rule.selector = newSelector.substring(0, newSelector.length - 2);
|
|
176
|
+
}
|
|
177
|
+
|
|
178
|
+
if (rule.selector === '') {
|
|
179
|
+
rule.remove();
|
|
180
|
+
}
|
|
45
181
|
}
|
|
182
|
+
}
|
|
46
183
|
|
|
47
|
-
|
|
184
|
+
function mediaQuery(rule, index) {
|
|
185
|
+
// console.log(rule.parent.params + " and all and (min--moz-device-pixel-ratio:0) and (hover: hover), (hover: hover)");
|
|
186
|
+
if (rule.parent.params !== undefined && !rule.parent.params.includes('hover')) {
|
|
187
|
+
let {
|
|
188
|
+
hovMed,
|
|
189
|
+
actMed
|
|
190
|
+
} = returnPositions(rule.parent);
|
|
48
191
|
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
if (rule.selector.includes("hover")) {
|
|
53
|
-
hoverPresent = true;
|
|
192
|
+
if (rule.selector.includes('hover') && hovMed !== undefined && rule.parent.type === 'atrule') {
|
|
193
|
+
if (handleMedHoverAndHoverActiveIgnore(rule.parent, index)) {
|
|
194
|
+
hovMed.append(rule);
|
|
54
195
|
}
|
|
196
|
+
|
|
197
|
+
if (handleMedActiveAndHoverActiveIgnore(rule.parent, index)) {
|
|
198
|
+
actMed.append(rule.clone({
|
|
199
|
+
selector: rule.selector.replace(/:hover/gi, ':active')
|
|
200
|
+
}));
|
|
201
|
+
}
|
|
202
|
+
}
|
|
203
|
+
}
|
|
204
|
+
}
|
|
205
|
+
|
|
206
|
+
function commaQuery(rule, index) {
|
|
207
|
+
//console.log("comma" , rule.selector.split('\n'));
|
|
208
|
+
let newSelector = '';
|
|
209
|
+
let hovQueries = [];
|
|
210
|
+
rule.selector.split(/\s*,\s*/).forEach(_subrule => {
|
|
211
|
+
let subrule = _subrule.trim();
|
|
212
|
+
|
|
213
|
+
if (subrule.includes('hover')) {
|
|
214
|
+
// hoverRules.push({ rule: clone, index });
|
|
215
|
+
hovQueries.push(subrule);
|
|
216
|
+
} else {
|
|
217
|
+
newSelector += `${subrule}, `;
|
|
218
|
+
}
|
|
219
|
+
});
|
|
220
|
+
|
|
221
|
+
if (hovQueries.length > 0) {
|
|
222
|
+
let clone = rule.clone();
|
|
223
|
+
clone.selector = hovQueries.join(',');
|
|
224
|
+
hoverRules.push({
|
|
225
|
+
rule: clone,
|
|
226
|
+
index
|
|
55
227
|
});
|
|
228
|
+
}
|
|
56
229
|
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
230
|
+
if (handleHoverAndHoverActiveIgnore(index)) {
|
|
231
|
+
rule.selector = newSelector.substring(0, newSelector.length - 2).trim();
|
|
232
|
+
}
|
|
233
|
+
|
|
234
|
+
if (rule.selector === '') {
|
|
235
|
+
rule.remove();
|
|
236
|
+
}
|
|
237
|
+
} // Start by identifying all :hover rules
|
|
238
|
+
|
|
239
|
+
|
|
240
|
+
rootOriginal.walkAtRules(atrule => {
|
|
241
|
+
//console.log(positions[`${atrule.params} and all and (min--moz-device-pixel-ratio:0) and (hover: hover), (hover: hover)`])
|
|
242
|
+
const hoverQuery = `${atrule.params} and all and (min--moz-device-pixel-ratio:0) and (hover: hover), (hover: hover)`;
|
|
243
|
+
const activeQuery = `${atrule.params} and (hover: none)`;
|
|
244
|
+
|
|
245
|
+
if (isHoverPresent(atrule)) {
|
|
246
|
+
if (!positionsObj[hoverQuery] && !positionsObj[activeQuery]) {
|
|
247
|
+
rootOriginal.append({
|
|
248
|
+
name: 'media',
|
|
249
|
+
params: hoverQuery
|
|
65
250
|
});
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
251
|
+
positionsObj[hoverQuery] = rootOriginal.nodes.length - 1;
|
|
252
|
+
rootOriginal.append({
|
|
253
|
+
name: 'media',
|
|
254
|
+
params: activeQuery
|
|
69
255
|
});
|
|
256
|
+
positionsObj[activeQuery] = rootOriginal.nodes.length - 1;
|
|
70
257
|
}
|
|
71
|
-
}
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
}));
|
|
106
|
-
} else {
|
|
107
|
-
clone.selector = subrule;
|
|
108
|
-
root.append(clone);
|
|
109
|
-
}
|
|
110
|
-
});
|
|
111
|
-
rule.remove();
|
|
112
|
-
}
|
|
113
|
-
} else if (rule.selector.includes(" ") && rule.selector.includes("+") || !rule.selector.includes(" ") && rule.selector.includes("+")) {
|
|
114
|
-
//console.log("media plus", rule.selector)
|
|
115
|
-
if (rule.parent.params != undefined && !rule.parent.params.includes("hover")) {
|
|
116
|
-
//console.log("not hovered")
|
|
117
|
-
var posHov = checkPositionNodeHov(rule.parent);
|
|
118
|
-
var actHov = checkPositionNodeAct(rule.parent);
|
|
119
|
-
var firHov = checkPositionNodeFireFox(rule.parent);
|
|
120
|
-
var hovMed = root.nodes[posHov];
|
|
121
|
-
var actMed = root.nodes[actHov];
|
|
122
|
-
var firMed = root.nodes[firHov]; // console.log(hovMed, actMed);
|
|
123
|
-
|
|
124
|
-
if (rule.selector.includes("hover")) {
|
|
125
|
-
console.log(rule.selector);
|
|
126
|
-
firMed.append(rule);
|
|
127
|
-
hovMed.append(rule);
|
|
128
|
-
actMed.append(rule.clone({
|
|
129
|
-
selector: rule.selector.replace(/:hover/gi, ":active")
|
|
130
|
-
}));
|
|
131
|
-
} else {
|
|
132
|
-
root.append(rule);
|
|
133
|
-
}
|
|
134
|
-
} else {// console.log(rule.selector)
|
|
135
|
-
}
|
|
136
|
-
} else if (rule.selector.includes(" ")) {
|
|
137
|
-
//console.log("media space", rule.selector)
|
|
138
|
-
if (rule.parent.params != undefined && !rule.parent.params.includes("hover")) {
|
|
139
|
-
//console.log("not hovered")
|
|
140
|
-
var posHov = checkPositionNodeHov(rule.parent);
|
|
141
|
-
var actHov = checkPositionNodeAct(rule.parent);
|
|
142
|
-
var firHov = checkPositionNodeFireFox(rule.parent);
|
|
143
|
-
var hovMed = root.nodes[posHov];
|
|
144
|
-
var actMed = root.nodes[actHov];
|
|
145
|
-
var firMed = root.nodes[firMed]; //console.log(hovMed, actMed);
|
|
146
|
-
|
|
147
|
-
if (rule.selector.includes("hover")) {
|
|
148
|
-
hovMed.append(rule);
|
|
149
|
-
actMed.append(rule.clone({
|
|
150
|
-
selector: rule.selector.replace(/:hover/gi, ":active")
|
|
151
|
-
}));
|
|
152
|
-
} else {
|
|
153
|
-
root.append(rule);
|
|
154
|
-
}
|
|
155
|
-
}
|
|
156
|
-
}
|
|
157
|
-
} //usual hover query with ',' ' ' '+'
|
|
158
|
-
else if ((rule.selector.includes(",") || rule.selector.includes(" ") || rule.selector.includes("+")) && rule.parent.name == undefined) {
|
|
159
|
-
if (rule.selector.includes(" ") && rule.selector.includes(",") || !rule.selector.includes(" ") && rule.selector.includes(",")) {
|
|
160
|
-
//console.log("comma" , rule.selector.split('\n'));
|
|
161
|
-
rule.selector.split(",\n").map(subrule => {
|
|
162
|
-
subrule = subrule.trim();
|
|
163
|
-
let clone = rule.clone();
|
|
164
|
-
|
|
165
|
-
if (subrule.includes("hover")) {
|
|
166
|
-
clone.selector = subrule;
|
|
167
|
-
hoverRules.push(clone);
|
|
168
|
-
} else {
|
|
169
|
-
clone.selector = subrule;
|
|
170
|
-
root.append(clone);
|
|
171
|
-
}
|
|
172
|
-
});
|
|
173
|
-
rule.remove();
|
|
174
|
-
} else if (rule.selector.includes(" ") && rule.selector.includes("+") || !rule.selector.includes(" ") && rule.selector.includes("+")) {
|
|
175
|
-
//console.log("plus" , rule.selector);
|
|
176
|
-
if (rule.selector.includes("hover")) {
|
|
177
|
-
//console.log("plus:", rule.selector);
|
|
178
|
-
hoverRules.push(rule);
|
|
179
|
-
rule.remove();
|
|
180
|
-
}
|
|
181
|
-
} else if (rule.selector.includes(" ")) {
|
|
182
|
-
//console.log("space", rule.selector);
|
|
183
|
-
hoverRules.push(rule);
|
|
184
|
-
rule.remove();
|
|
185
|
-
}
|
|
186
|
-
} // usual hover query
|
|
187
|
-
else {
|
|
188
|
-
//console.log(rule);
|
|
189
|
-
if (rule.selector.includes("hover")) {
|
|
190
|
-
hoverRules.push(rule);
|
|
191
|
-
}
|
|
258
|
+
}
|
|
259
|
+
});
|
|
260
|
+
rootOriginal.walkRules(/:hover/i, (rule, index) => {
|
|
261
|
+
// console.log({ rule, index });
|
|
262
|
+
// media hover query with ',' ' ' '+'
|
|
263
|
+
// console.log("media query" , rule.selector)
|
|
264
|
+
if (rule.parent.type === 'atrule' && rule.selector.includes(',')) {
|
|
265
|
+
//console.log("media comma", rule.selector)
|
|
266
|
+
mediaCommaQuery(rule, index);
|
|
267
|
+
} else {
|
|
268
|
+
// plus, space and other media queries
|
|
269
|
+
//console.log("media", rule.selector)
|
|
270
|
+
mediaQuery(rule, index);
|
|
271
|
+
} // usual hover query
|
|
272
|
+
|
|
273
|
+
|
|
274
|
+
if (!rule.selector.match(/,+| +|\++/g) && rule.parent !== undefined && rule.parent.name === undefined) {
|
|
275
|
+
hoverRules.push({
|
|
276
|
+
rule,
|
|
277
|
+
index
|
|
278
|
+
});
|
|
279
|
+
} //usual hover query with ',' ' ' '+'
|
|
280
|
+
|
|
281
|
+
|
|
282
|
+
if (rule.selector.match(/,+| +|\++/g) && rule.parent.name === undefined) {
|
|
283
|
+
if (rule.selector.includes(',')) {
|
|
284
|
+
commaQuery(rule, index);
|
|
285
|
+
} else if (rule.selector.match(/ +|\++/g)) {
|
|
286
|
+
//console.log("plus or space" , rule.selector);
|
|
287
|
+
if (rule.selector.includes('hover')) {
|
|
288
|
+
hoverRules.push({
|
|
289
|
+
rule,
|
|
290
|
+
index
|
|
291
|
+
}); //rule.remove();
|
|
192
292
|
}
|
|
193
293
|
}
|
|
194
|
-
}
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
if (hoverRules.length > 0) {
|
|
198
|
-
//console.log(hoverRules)
|
|
199
|
-
// Create a media query targetting ie10 + 11, as these browsers
|
|
200
|
-
// wont support @media (hover: hover) - but we know that this
|
|
201
|
-
// browser never runs on mobile devices, so we'll just push the
|
|
202
|
-
// hover rules there
|
|
203
|
-
// const ieQuery = root.append({
|
|
204
|
-
// name: 'media',
|
|
205
|
-
// params:
|
|
206
|
-
// 'all and ' +
|
|
207
|
-
// '(-ms-high-contrast: none), ' +
|
|
208
|
-
// '(-ms-high-contrast: active)'
|
|
209
|
-
// }).last;
|
|
210
|
-
// Create a media query targetting firefox, as this browser doesn't
|
|
211
|
-
// support @media (hover: hover)... Technically this browser could
|
|
212
|
-
// run on both desktop and mobile devices, but we're going to be
|
|
213
|
-
// applying :hover and hope for the best
|
|
214
|
-
const firefoxQuery = root.append({
|
|
215
|
-
name: "media",
|
|
216
|
-
params: "all and (min--moz-device-pixel-ratio:0)"
|
|
217
|
-
}).last; // Create a media query targetting devices that actually support
|
|
218
|
-
// hover
|
|
219
|
-
|
|
220
|
-
const hoverQuery = root.append({
|
|
221
|
-
name: "media",
|
|
222
|
-
params: "(hover: hover)"
|
|
223
|
-
}).last; // Create a media query targetting devices that don't support hover
|
|
224
|
-
// (ie. devices where we should fall back to :active instead)
|
|
225
|
-
|
|
226
|
-
const activeQuery = root.append({
|
|
227
|
-
name: "media",
|
|
228
|
-
params: "(hover: none)"
|
|
229
|
-
}).last; // Loop through the hover rules and apply them to each of the media
|
|
230
|
-
// queries
|
|
231
|
-
// eslint-disable-next-line no-labels
|
|
232
|
-
|
|
233
|
-
outerLoop: for (const hoverRule of hoverRules) {
|
|
234
|
-
// determine if the rule has been nested inside another media
|
|
235
|
-
// query; in that case bail out as we have no way of reliably
|
|
236
|
-
// nesting these queries
|
|
237
|
-
let parentRule = hoverRule.parent;
|
|
238
|
-
|
|
239
|
-
while (parentRule) {
|
|
240
|
-
if (parentRule.type === "atrule" && parentRule.name === "media") {
|
|
241
|
-
// eslint-disable-next-line no-labels
|
|
242
|
-
continue outerLoop;
|
|
243
|
-
}
|
|
294
|
+
}
|
|
295
|
+
}); // If there are any :hover rules in the input, then create media queries
|
|
296
|
+
// to automatically translate it into :active on touch-based devices
|
|
244
297
|
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
298
|
+
if (hoverRules.length > 0) {
|
|
299
|
+
// Create a media query targetting devices that actually support
|
|
300
|
+
// hover
|
|
301
|
+
const hoverQuery = rootOriginal.append({
|
|
302
|
+
name: 'media',
|
|
303
|
+
params: 'all and (min--moz-device-pixel-ratio:0) and (hover: hover), (hover: hover)'
|
|
304
|
+
}).last; // Create a media query targetting devices that don't support hover
|
|
305
|
+
// (ie. devices where we should fall back to :active instead)
|
|
249
306
|
|
|
307
|
+
const activeQuery = rootOriginal.append({
|
|
308
|
+
name: 'media',
|
|
309
|
+
params: '(hover: none)'
|
|
310
|
+
}).last; // Loop through the hover rules and apply them to each of the media
|
|
311
|
+
// queries
|
|
312
|
+
// eslint-disable-next-line no-labels
|
|
250
313
|
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
314
|
+
outerLoop: for (const hoverRule of hoverRules) {
|
|
315
|
+
// determine if the rule has been nested inside another media
|
|
316
|
+
// query; in that case bail out as we have no way of reliably
|
|
317
|
+
// nesting these queries
|
|
318
|
+
let parentRule = hoverRule.rule.parent;
|
|
319
|
+
|
|
320
|
+
while (parentRule) {
|
|
321
|
+
if (parentRule.type === 'atrule' && parentRule.name === 'media') {
|
|
322
|
+
// eslint-disable-next-line no-labels
|
|
323
|
+
continue outerLoop;
|
|
324
|
+
}
|
|
325
|
+
|
|
326
|
+
parentRule = parentRule.parent;
|
|
327
|
+
} // Push a clone of the :hover rule 'as is' to queries where we
|
|
328
|
+
// expect the user's device to support hover
|
|
329
|
+
// ieQuery.append(hoverRule.clone());
|
|
330
|
+
|
|
331
|
+
|
|
332
|
+
if (handleHoverAndHoverActiveIgnore(hoverRule.index)) {
|
|
333
|
+
hoverQuery.append(hoverRule.rule.clone());
|
|
334
|
+
} // Push a clone of the :hover rule, where we transform the
|
|
335
|
+
// selector to :active to the query targetting devices that
|
|
336
|
+
// don't support hover
|
|
255
337
|
|
|
256
|
-
activeQuery.append(hoverRule.clone({
|
|
257
|
-
selector: hoverRule.selector.replace(/:hover/gi, ":active")
|
|
258
|
-
})); // remove legacy rule from output
|
|
259
338
|
|
|
260
|
-
|
|
339
|
+
if (handleActiveAndHoverActiveIgnore(hoverRule.index)) {
|
|
340
|
+
activeQuery.append(hoverRule.rule.clone({
|
|
341
|
+
selector: hoverRule.rule.selector.replace(/:hover/gi, ':active')
|
|
342
|
+
}));
|
|
343
|
+
} // remove legacy rule from output
|
|
344
|
+
|
|
345
|
+
|
|
346
|
+
if (handleAllIgnoreCases(hoverRule.index)) {
|
|
347
|
+
hoverRule.rule.remove();
|
|
261
348
|
}
|
|
262
349
|
}
|
|
263
|
-
}
|
|
350
|
+
}
|
|
351
|
+
|
|
352
|
+
rootOriginal.walkAtRules(atrule => {
|
|
353
|
+
if (atrule !== undefined && atrule.nodes !== undefined && atrule.nodes.length === 0 || atrule.nodes === undefined) {
|
|
354
|
+
atrule.remove();
|
|
355
|
+
}
|
|
356
|
+
});
|
|
264
357
|
});
|