postcss-clampwind 0.0.11 → 0.0.13
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/dist/clampwind.cjs.cjs +22 -10
- package/dist/clampwind.esm.js +22 -10
- package/package.json +1 -1
package/dist/clampwind.cjs.cjs
CHANGED
|
@@ -158,10 +158,10 @@ var extractMaxValue = (params) => {
|
|
|
158
158
|
if (!params) return null;
|
|
159
159
|
let match = params.match(/<\s*([^),\s]+)/);
|
|
160
160
|
if (match) return match[1].trim();
|
|
161
|
-
if (params.match(/not\s+all\s+and\s
|
|
161
|
+
if (params.match(/not\s+(?:all\s+and\s*)?\(\s*max-width:/)) return null;
|
|
162
162
|
match = params.match(/max-width:\s*([^),\s]+)/);
|
|
163
163
|
if (match) return match[1].trim();
|
|
164
|
-
match = params.match(/not\s+all\s+and\s
|
|
164
|
+
match = params.match(/not\s+(?:all\s+and\s*)?\(\s*min-width:\s*([^),\s]+)\s*\)/);
|
|
165
165
|
if (match) return match[1].trim();
|
|
166
166
|
return null;
|
|
167
167
|
};
|
|
@@ -169,10 +169,10 @@ var extractMinValue = (params) => {
|
|
|
169
169
|
if (!params) return null;
|
|
170
170
|
let match = params.match(/>=?\s*([^),\s]+)/);
|
|
171
171
|
if (match) return match[1].trim();
|
|
172
|
-
if (params.match(/not\s+all\s+and\s
|
|
172
|
+
if (params.match(/not\s+(?:all\s+and\s*)?\(\s*min-width:/)) return null;
|
|
173
173
|
match = params.match(/min-width:\s*([^),\s]+)/);
|
|
174
174
|
if (match) return match[1].trim();
|
|
175
|
-
match = params.match(/not\s+all\s+and\s
|
|
175
|
+
match = params.match(/not\s+(?:all\s+and\s*)?\(\s*max-width:\s*([^),\s]+)\s*\)/);
|
|
176
176
|
if (match) {
|
|
177
177
|
return match[1].trim();
|
|
178
178
|
}
|
|
@@ -369,17 +369,26 @@ var clampwind = (opts = {}) => {
|
|
|
369
369
|
decl.value = clamp;
|
|
370
370
|
return true;
|
|
371
371
|
};
|
|
372
|
-
const getNestedStructure = (atRule) => {
|
|
373
|
-
const isNested = atRule.parent?.type === "atrule" && atRule.parent?.name ===
|
|
372
|
+
const getNestedStructure = (atRule, ruleName = "media") => {
|
|
373
|
+
const isNested = atRule.parent?.type === "atrule" && atRule.parent?.name === ruleName;
|
|
374
374
|
const hasNestedMedia = atRule.nodes?.some(
|
|
375
|
-
(node) => node.type === "atrule" && node.name ===
|
|
375
|
+
(node) => node.type === "atrule" && node.name === ruleName
|
|
376
376
|
);
|
|
377
377
|
return { isNested, hasNestedMedia };
|
|
378
378
|
};
|
|
379
|
-
const
|
|
379
|
+
const isDeclInsideNestedAtRule = (decl, boundaryAtRule, ruleName) => {
|
|
380
|
+
let parent = decl.parent;
|
|
381
|
+
while (parent && parent !== boundaryAtRule) {
|
|
382
|
+
if (parent.type === "atrule" && parent.name === ruleName) return true;
|
|
383
|
+
parent = parent.parent;
|
|
384
|
+
}
|
|
385
|
+
return false;
|
|
386
|
+
};
|
|
387
|
+
const processMediaQuery = (atRule, parentAtRule = null, skipNestedAtRuleName = null) => {
|
|
380
388
|
const clampDecls = [];
|
|
381
389
|
atRule.walkDecls((decl) => {
|
|
382
390
|
if (extractTwoValidClampArgs(decl.value)) {
|
|
391
|
+
if (skipNestedAtRuleName && isDeclInsideNestedAtRule(decl, atRule, skipNestedAtRuleName)) return;
|
|
383
392
|
clampDecls.push(decl);
|
|
384
393
|
}
|
|
385
394
|
});
|
|
@@ -418,10 +427,11 @@ var clampwind = (opts = {}) => {
|
|
|
418
427
|
}
|
|
419
428
|
}
|
|
420
429
|
};
|
|
421
|
-
const processContainerQuery = (atRule, parentAtRule = null) => {
|
|
430
|
+
const processContainerQuery = (atRule, parentAtRule = null, skipNestedAtRuleName = null) => {
|
|
422
431
|
const clampDecls = [];
|
|
423
432
|
atRule.walkDecls((decl) => {
|
|
424
433
|
if (extractTwoValidClampArgs(decl.value)) {
|
|
434
|
+
if (skipNestedAtRuleName && isDeclInsideNestedAtRule(decl, atRule, skipNestedAtRuleName)) return;
|
|
425
435
|
clampDecls.push(decl);
|
|
426
436
|
}
|
|
427
437
|
});
|
|
@@ -470,6 +480,7 @@ var clampwind = (opts = {}) => {
|
|
|
470
480
|
if (processedAtRules.has(atRule)) return;
|
|
471
481
|
const { isNested, hasNestedMedia } = getNestedStructure(atRule);
|
|
472
482
|
if (hasNestedMedia) {
|
|
483
|
+
processMediaQuery(atRule, null, "media");
|
|
473
484
|
atRule.walkAtRules("media", (nestedAtRule) => {
|
|
474
485
|
processedAtRules.add(nestedAtRule);
|
|
475
486
|
processMediaQuery(nestedAtRule, atRule);
|
|
@@ -482,8 +493,9 @@ var clampwind = (opts = {}) => {
|
|
|
482
493
|
});
|
|
483
494
|
root.walkAtRules("container", (atRule) => {
|
|
484
495
|
if (processedAtRules.has(atRule)) return;
|
|
485
|
-
const { isNested, hasNestedMedia } = getNestedStructure(atRule);
|
|
496
|
+
const { isNested, hasNestedMedia } = getNestedStructure(atRule, "container");
|
|
486
497
|
if (hasNestedMedia) {
|
|
498
|
+
processContainerQuery(atRule, null, "container");
|
|
487
499
|
atRule.walkAtRules("container", (nestedAtRule) => {
|
|
488
500
|
processedAtRules.add(nestedAtRule);
|
|
489
501
|
processContainerQuery(nestedAtRule, atRule);
|
package/dist/clampwind.esm.js
CHANGED
|
@@ -133,10 +133,10 @@ var extractMaxValue = (params) => {
|
|
|
133
133
|
if (!params) return null;
|
|
134
134
|
let match = params.match(/<\s*([^),\s]+)/);
|
|
135
135
|
if (match) return match[1].trim();
|
|
136
|
-
if (params.match(/not\s+all\s+and\s
|
|
136
|
+
if (params.match(/not\s+(?:all\s+and\s*)?\(\s*max-width:/)) return null;
|
|
137
137
|
match = params.match(/max-width:\s*([^),\s]+)/);
|
|
138
138
|
if (match) return match[1].trim();
|
|
139
|
-
match = params.match(/not\s+all\s+and\s
|
|
139
|
+
match = params.match(/not\s+(?:all\s+and\s*)?\(\s*min-width:\s*([^),\s]+)\s*\)/);
|
|
140
140
|
if (match) return match[1].trim();
|
|
141
141
|
return null;
|
|
142
142
|
};
|
|
@@ -144,10 +144,10 @@ var extractMinValue = (params) => {
|
|
|
144
144
|
if (!params) return null;
|
|
145
145
|
let match = params.match(/>=?\s*([^),\s]+)/);
|
|
146
146
|
if (match) return match[1].trim();
|
|
147
|
-
if (params.match(/not\s+all\s+and\s
|
|
147
|
+
if (params.match(/not\s+(?:all\s+and\s*)?\(\s*min-width:/)) return null;
|
|
148
148
|
match = params.match(/min-width:\s*([^),\s]+)/);
|
|
149
149
|
if (match) return match[1].trim();
|
|
150
|
-
match = params.match(/not\s+all\s+and\s
|
|
150
|
+
match = params.match(/not\s+(?:all\s+and\s*)?\(\s*max-width:\s*([^),\s]+)\s*\)/);
|
|
151
151
|
if (match) {
|
|
152
152
|
return match[1].trim();
|
|
153
153
|
}
|
|
@@ -344,17 +344,26 @@ var clampwind = (opts = {}) => {
|
|
|
344
344
|
decl.value = clamp;
|
|
345
345
|
return true;
|
|
346
346
|
};
|
|
347
|
-
const getNestedStructure = (atRule) => {
|
|
348
|
-
const isNested = atRule.parent?.type === "atrule" && atRule.parent?.name ===
|
|
347
|
+
const getNestedStructure = (atRule, ruleName = "media") => {
|
|
348
|
+
const isNested = atRule.parent?.type === "atrule" && atRule.parent?.name === ruleName;
|
|
349
349
|
const hasNestedMedia = atRule.nodes?.some(
|
|
350
|
-
(node) => node.type === "atrule" && node.name ===
|
|
350
|
+
(node) => node.type === "atrule" && node.name === ruleName
|
|
351
351
|
);
|
|
352
352
|
return { isNested, hasNestedMedia };
|
|
353
353
|
};
|
|
354
|
-
const
|
|
354
|
+
const isDeclInsideNestedAtRule = (decl, boundaryAtRule, ruleName) => {
|
|
355
|
+
let parent = decl.parent;
|
|
356
|
+
while (parent && parent !== boundaryAtRule) {
|
|
357
|
+
if (parent.type === "atrule" && parent.name === ruleName) return true;
|
|
358
|
+
parent = parent.parent;
|
|
359
|
+
}
|
|
360
|
+
return false;
|
|
361
|
+
};
|
|
362
|
+
const processMediaQuery = (atRule, parentAtRule = null, skipNestedAtRuleName = null) => {
|
|
355
363
|
const clampDecls = [];
|
|
356
364
|
atRule.walkDecls((decl) => {
|
|
357
365
|
if (extractTwoValidClampArgs(decl.value)) {
|
|
366
|
+
if (skipNestedAtRuleName && isDeclInsideNestedAtRule(decl, atRule, skipNestedAtRuleName)) return;
|
|
358
367
|
clampDecls.push(decl);
|
|
359
368
|
}
|
|
360
369
|
});
|
|
@@ -393,10 +402,11 @@ var clampwind = (opts = {}) => {
|
|
|
393
402
|
}
|
|
394
403
|
}
|
|
395
404
|
};
|
|
396
|
-
const processContainerQuery = (atRule, parentAtRule = null) => {
|
|
405
|
+
const processContainerQuery = (atRule, parentAtRule = null, skipNestedAtRuleName = null) => {
|
|
397
406
|
const clampDecls = [];
|
|
398
407
|
atRule.walkDecls((decl) => {
|
|
399
408
|
if (extractTwoValidClampArgs(decl.value)) {
|
|
409
|
+
if (skipNestedAtRuleName && isDeclInsideNestedAtRule(decl, atRule, skipNestedAtRuleName)) return;
|
|
400
410
|
clampDecls.push(decl);
|
|
401
411
|
}
|
|
402
412
|
});
|
|
@@ -445,6 +455,7 @@ var clampwind = (opts = {}) => {
|
|
|
445
455
|
if (processedAtRules.has(atRule)) return;
|
|
446
456
|
const { isNested, hasNestedMedia } = getNestedStructure(atRule);
|
|
447
457
|
if (hasNestedMedia) {
|
|
458
|
+
processMediaQuery(atRule, null, "media");
|
|
448
459
|
atRule.walkAtRules("media", (nestedAtRule) => {
|
|
449
460
|
processedAtRules.add(nestedAtRule);
|
|
450
461
|
processMediaQuery(nestedAtRule, atRule);
|
|
@@ -457,8 +468,9 @@ var clampwind = (opts = {}) => {
|
|
|
457
468
|
});
|
|
458
469
|
root.walkAtRules("container", (atRule) => {
|
|
459
470
|
if (processedAtRules.has(atRule)) return;
|
|
460
|
-
const { isNested, hasNestedMedia } = getNestedStructure(atRule);
|
|
471
|
+
const { isNested, hasNestedMedia } = getNestedStructure(atRule, "container");
|
|
461
472
|
if (hasNestedMedia) {
|
|
473
|
+
processContainerQuery(atRule, null, "container");
|
|
462
474
|
atRule.walkAtRules("container", (nestedAtRule) => {
|
|
463
475
|
processedAtRules.add(nestedAtRule);
|
|
464
476
|
processContainerQuery(nestedAtRule, atRule);
|