{"name":"@csstools/postcss-cascade-layers","description":"Use cascade layers in CSS","version":"1.0.4","contributors":[{"name":"Olu Niyi-Awosusi","email":"o.niyiawosusi@gmail.com"},{"name":"Sana Javed","email":"sanajaved7@gmail.com"},{"name":"Antonio Laguna","email":"antonio@laguna.es","url":"https://antonio.laguna.es"},{"name":"Romain Menke","email":"romainmenke@gmail.com"}],"license":"CC0-1.0","funding":{"type":"opencollective","url":"https://opencollective.com/csstools"},"engines":{"node":"^12 || ^14 || >=16"},"main":"dist/index.cjs","module":"dist/index.mjs","types":"dist/index.d.ts","exports":{".":{"import":"./dist/index.mjs","require":"./dist/index.cjs","default":"./dist/index.mjs"}},"dependencies":{"@csstools/selector-specificity":"^2.0.0","postcss-selector-parser":"^6.0.10"},"peerDependencies":{"postcss":"^8.2"},"devDependencies":{"postcss-import":"^14.1.0","puppeteer":"^13.6.0"},"scripts":{"build":"rollup -c ../../rollup/default.js","clean":"node -e \"fs.rmSync('./dist', { recursive: true, force: true });\"","docs":"node ../../.github/bin/generate-docs/install.mjs && node ../../.github/bin/generate-docs/readme.mjs","lint":"npm run lint:eslint && npm run lint:package-json","lint:eslint":"eslint ./src --ext .js --ext .ts --ext .mjs --no-error-on-unmatched-pattern","lint:package-json":"node ../../.github/bin/format-package-json.mjs","prepublishOnly":"npm run clean && npm run build && npm run test","test":"node .tape.mjs && npm run test:exports","test:browser":"node ./test/_browser.mjs","test:exports":"node ./test/_import.mjs && node ./test/_require.cjs","test:rewrite-expects":"REWRITE_EXPECTS=true node .tape.mjs"},"homepage":"https://github.com/csstools/postcss-plugins/tree/main/plugins/postcss-cascade-layers#readme","repository":{"type":"git","url":"git+https://github.com/csstools/postcss-plugins.git","directory":"plugins/postcss-cascade-layers"},"bugs":{"url":"https://github.com/csstools/postcss-plugins/issues"},"keywords":["cascade","css","layers","postcss","postcss-plugin","selectors","specificity"],"csstools":{"cssdbId":"cascade-layers","exportName":"postcssCascadeLayers","humanReadableName":"PostCSS Cascade Layers","specUrl":"https://www.w3.org/TR/css-cascade-5/#layering"},"volta":{"extends":"../../package.json"},"gitHead":"e0e5709d631adb1e43ed44d7c43485e219fc465a","_id":"@csstools/postcss-cascade-layers@1.0.4","_nodeVersion":"16.13.1","_npmVersion":"8.1.2","dist":{"integrity":"sha512-zP2tQIFu4C3HueOT+G4Pkla7f2Z6pfXphc1Y9wDE5jS2Ss6dk/asQ7FFEFWKgy3EkYc7E1FSjzhfeZVGg5sjXQ==","shasum":"9086bd2e71b43a947ae61bb735b0a83ab1549a68","tarball":"http://registry-npm.ywwl.com/@csstools/postcss-cascade-layers/download/@csstools/postcss-cascade-layers-1.0.4.tgz","fileCount":20,"unpackedSize":36327,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIQDYqble/sLcQdZmo9YzKerKgC8e1K/iDJaHM0Fe2cSVbQIgRX8YbM9PK6OX68MQx+WDOYZc7SuyLtE2FMaGSE9qVww="}],"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v4.10.10\r\nComment: https://openpgpjs.org\r\n\r\nwsFzBAEBCAAGBQJitGU7ACEJED1NWxICdlZqFiEECWMYAoorWMhJKdjhPU1b\r\nEgJ2VmrPKRAAkrDPFXJ3ozfHDwliJ+IWlybnFNkys0OfVOsCxlFtRQXhCDCE\r\nSbNX62AFzJmHxJ4SbHqHuWhX1z3Wkkox0SeLA7kG2boFiBj9gb7hYm54Ai7B\r\nIdDEOV0CtZSGMv8ueg4Arw/8DdkPF5+1LbTeEM9VEAIt1AY2T6TglQgS1AnM\r\ndZUJuj5hywia9y1ZUboFqDwP3c0YrAOfvbE/b3fF8cliU8XRuqpJC2z4fI4t\r\nmLjzie6OWrh8DQ+D84qX8KASsU7iOSJL+Jkye61zFkCvqP1HC2s9yoUkmYzc\r\nRjXmnYUaMqTv8kohMYKeDoKkSNyTJDvlz7ZlS+JqW0Pp5VGs8+OPpZP989VW\r\nZ/H33mtO4oxhaOWXDUDtdg/u0QOVfN3kUfYnNxTzOAqg4DkCsfqn5vwP+T+q\r\nBJyO2UGXgo7yUtoflTEO9L0qSeRwz3MtZMFov6hlRuNB3cGAoumTG/Qbc9Va\r\nFIgdurIvNyvVt3nb7v3NWVuekctNYTQ5GnxwdW/PEwrSYlzlMmDdhD7TQHyM\r\ngmmyn9MVpykFVXqZTH8Rs6PhKOlESf81gxcLyJw+JDt1mKM/gYtjeqRK6jQG\r\n2MroifZjhx7CxIhUkty2mVmtnsRDiGyXj25Njk3C496yvuvFexqHU/qaeKcd\r\n3EuMVDPBZ99HCl746++jVsR6MQOyAebDmFI=\r\n=s5Pg\r\n-----END PGP SIGNATURE-----\r\n","size":10394,"noattachment":false,"key":"/@csstools/postcss-cascade-layers/-/@csstools/postcss-cascade-layers-1.0.4.tgz"},"_npmUser":{"name":"alaguna","email":"sombragriselros@gmail.com"},"directories":{},"maintainers":[{"name":"alaguna","email":"sombragriselros@gmail.com"},{"name":"jonathantneal","email":"jonathantneal@hotmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/postcss-cascade-layers_1.0.4_1655989563098_0.13070659285583486"},"_hasShrinkwrap":false,"readme":"# PostCSS Cascade Layers [<img src=\"https://postcss.github.io/postcss/logo.svg\" alt=\"PostCSS Logo\" width=\"90\" height=\"90\" align=\"right\">][PostCSS]\n\n[<img alt=\"npm version\" src=\"https://img.shields.io/npm/v/@csstools/postcss-cascade-layers.svg\" height=\"20\">][npm-url] [<img alt=\"Build Status\" src=\"https://github.com/csstools/postcss-plugins/workflows/test/badge.svg\" height=\"20\">][cli-url] [<img alt=\"Discord\" src=\"https://shields.io/badge/Discord-5865F2?logo=discord&logoColor=white\">][discord]<br><br>[<img alt=\"Baseline Status\" src=\"https://cssdb.org/images/badges-baseline/cascade-layers.svg\" height=\"20\">][css-url] [<img alt=\"CSS Standard Status\" src=\"https://cssdb.org/images/badges/cascade-layers.svg\" height=\"20\">][css-url] \n\n```bash\nnpm install @csstools/postcss-cascade-layers --save-dev\n```\n\n[PostCSS Cascade Layers] lets you use `@layer` following the [Cascade Layers Specification]. For more information on layers, checkout [A Complete Guide to CSS Cascade Layers] by Miriam Suzanne.\n\n```pcss\n\ntarget {\n\tcolor: purple;\n}\n\n@layer {\n\ttarget {\n\t\tcolor: green;\n\t}\n}\n\n\n/* becomes */\n\n\ntarget:not(#\\#) {\n\tcolor: purple;\n}\n\ntarget {\n\t\tcolor: green;\n\t}\n\n```\n\n## How it works\n\n[PostCSS Cascade Layers] creates \"layers\" of specificity.\n\nIt applies extra specificity on all your styles based on :\n- the most specific selector found\n- the order in which layers are defined\n\n```css\n@layer A, B;\n\n@layer B {\n\t.a-less-specific-selector {\n\t\t/* styles */\n\t}\n}\n\n@layer A {\n\t#something #very-specific {\n\t\t/* styles */\n\t}\n}\n\n@layer C {\n\t.a-less-specific-selector {\n\t\t/* styles */\n\t}\n}\n```\n\nmost specific selector :\n- `#something #very-specific`\n- `[2, 0, 0]`\n- `2 + 1` -> `3` to ensure there is no overlap\n\nthe order in which layers are defined :\n- `A`\n- `B`\n- `C`\n\n| layer | previous adjustment | specificity adjustment | selector |\n| ------ | ------ | ----------- | --- |\n| `A` | `0` | `0 + 0 = 0` | N/A |\n| `B` | `0` | `0 + 3 = 3` | `:not(#\\#):not(#\\#):not(#\\#)` |\n| `C` | `3` | `3 + 3 = 6` | `:not(#\\#):not(#\\#):not(#\\#):not(#\\#):not(#\\#):not(#\\#)` |\n\nThis approach lets more important (later) layers always override less important (earlier) layers.<br>\nAnd layers have enough room internally so that each selector works and overrides as expected.\n\nMore layers with more specificity will cause longer `:not(...)` selectors to be generated.\n\n> [!IMPORTANT]\n> [PostCSS Cascade Layers] assumes to process your complete CSS bundle.<br>If your build tool processes files individually or processes files in parallel the output will be incorrect.<br>Using [`@csstools/postcss-bundler`](https://github.com/csstools/postcss-plugins/tree/main/plugin-packs/postcss-bundler) and `@import` statements is one way to make sure your CSS is bundled before it is processed by this plugin.\n\n\n## Usage\n\nAdd [PostCSS Cascade Layers] to your project:\n\n```bash\nnpm install postcss @csstools/postcss-cascade-layers --save-dev\n```\n\nUse it as a [PostCSS] plugin:\n\n```js\nconst postcss = require('postcss');\nconst postcssCascadeLayers = require('@csstools/postcss-cascade-layers');\n\npostcss([\n\tpostcssCascadeLayers(/* pluginOptions */)\n]).process(YOUR_CSS /*, processOptions */);\n```\n\n[PostCSS Cascade Layers] runs in all Node environments, with special\ninstructions for:\n\n- [Node](INSTALL.md#node)\n- [PostCSS CLI](INSTALL.md#postcss-cli)\n- [PostCSS Load Config](INSTALL.md#postcss-load-config)\n- [Webpack](INSTALL.md#webpack)\n- [Next.js](INSTALL.md#nextjs)\n- [Gulp](INSTALL.md#gulp)\n- [Grunt](INSTALL.md#grunt)\n\n## Options\n\n### onRevertLayerKeyword\n\nThe `onRevertLayerKeyword` option enables warnings if `revert-layer` is used.\nTransforming `revert-layer` for older browsers is not possible in this plugin.\n\nDefaults to `warn`\n\n```js\npostcssCascadeLayers({ onRevertLayerKeyword: 'warn' }) // 'warn' | false\n```\n\n```pcss\n/* [postcss-cascade-layers]: handling \"revert-layer\" is unsupported by this plugin and will cause style differences between browser versions. */\n@layer {\n\t.foo {\n\t\tcolor: revert-layer;\n\t}\n}\n```\n\n### onConditionalRulesChangingLayerOrder\n\nThe `onConditionalRulesChangingLayerOrder` option enables warnings if layers are declared in multiple different orders in conditional rules.\nTransforming these layers correctly for older browsers is not possible in this plugin.\n\nDefaults to `warn`\n\n```js\npostcssCascadeLayers({ onConditionalRulesChangingLayerOrder: 'warn' }) // 'warn' | false\n```\n\n```pcss\n/* [postcss-cascade-layers]: handling different layer orders in conditional rules is unsupported by this plugin and will cause style differences between browser versions. */\n@media (min-width: 10px) {\n\t@layer B {\n\t\t.foo {\n\t\t\tcolor: red;\n\t\t}\n\t}\n}\n\n@layer A {\n\t.foo {\n\t\tcolor: pink;\n\t}\n}\n\n@layer B {\n\t.foo {\n\t\tcolor: red;\n\t}\n}\n```\n\n### onImportLayerRule\n\nThe `@import` at-rule can also be used with cascade layers, specifically to create a new layer like so: \n```css\n@import 'theme.css' layer(utilities);\n```\nIf your CSS uses `@import` with layers, you will also need the [postcss-import] plugin. This plugin alone will not handle the `@import` at-rule.  \n\nThis plugin will warn you when it detects that [postcss-import] did not transform`@import` at-rules.\n\n```js\npostcssCascadeLayers({ onImportLayerRule: 'warn' }) // 'warn' | false\n```\n\n### Contributors\nThe contributors to this plugin were [Olu Niyi-Awosusi] and [Sana Javed] from [Oddbird] and Romain Menke.\n\n[cli-url]: https://github.com/csstools/postcss-plugins/actions/workflows/test.yml?query=workflow/test\n[css-url]: https://cssdb.org/#cascade-layers\n[discord]: https://discord.gg/bUadyRwkJS\n[npm-url]: https://www.npmjs.com/package/@csstools/postcss-cascade-layers\n\n[PostCSS]: https://github.com/postcss/postcss\n[PostCSS Cascade Layers]: https://github.com/csstools/postcss-plugins/tree/main/plugins/postcss-cascade-layers\n[Cascade Layers Specification]: https://www.w3.org/TR/css-cascade-5/#layering\n[A Complete Guide to CSS Cascade Layers]: https://css-tricks.com/css-cascade-layers/\n[Olu Niyi-Awosusi]: https://github.com/oluoluoxenfree\n[Sana Javed]: https://github.com/sanajaved7\n[Oddbird]: https://github.com/oddbird\n[postcss-import]: https://github.com/postcss/postcss-import\n","publish_time":1655989563336,"_cnpm_publish_time":1655989563336,"dist-tags":{"latest":"6.0.2"}}