postcss-clampwind 0.0.11 → 0.0.12
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 +18 -6
- package/dist/clampwind.esm.js +18 -6
- package/package.json +1 -1
package/dist/clampwind.cjs.cjs
CHANGED
|
@@ -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
|
@@ -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);
|