{"name":"postcss-focus-within","version":"1.0.0","description":"[![NPM Version][npm-img]][npm-url] [![Build Status][cli-img]][cli-url] [![Windows Build Status][win-img]][win-url] [![Gitter Chat][git-img]][git-url]","author":{"name":"Jonathan Neal","email":"jonathantneal@hotmail.com"},"license":"CC0-1.0","repository":{"type":"git","url":"git+https://github.com/jonathantneal/postcss-focus-within.git"},"homepage":"https://github.com/jonathantneal/postcss-focus-within#readme","bugs":{"url":"https://github.com/jonathantneal/postcss-focus-within/issues"},"main":"index.bundle.js","module":"index.js","files":["index.js","index.bundle.js"],"scripts":{"prepublishOnly":"npm test","pretest":"rollup -c .rollup.js --silent","test":"echo 'Running tests...'; npm run test:ec && npm run test:js && npm run test:tape","test:ec":"echint --ignore index.bundle.js test","test:js":"eslint *.js --cache --ignore-path .gitignore --quiet","test:tape":"postcss-tape"},"engines":{"node":">=4.0.0"},"dependencies":{"postcss":"^6.0"},"devDependencies":{"babel-core":"^6.26","babel-eslint":"^8.2","babel-preset-env":"^1.6","echint":"^4.0","eslint":"^4.18","eslint-config-dev":"2.0","postcss-tape":"2.2","pre-commit":"^1.2","rollup":"^0.56","rollup-plugin-babel":"^3.0"},"eslintConfig":{"extends":"dev","parser":"babel-eslint"},"keywords":["postcss","css","postcss-plugin","focus","within","polyfill","pseudos","selectors","accessibility","a11y","descendants","ancestors"],"gitHead":"ee63ee4246a8107b64f65afa4e13d047839c2593","_id":"postcss-focus-within@1.0.0","_npmVersion":"5.6.0","_nodeVersion":"9.5.0","_npmUser":{"name":"jonathantneal","email":"jonathantneal@hotmail.com"},"dist":{"integrity":"sha512-iGLg941dX/e8zVCr6V6OhF+K23/KxgENwDlIYd6w9mcO26AKgvEUZs4kYB2b6ku7G93KI9p14SuCdez5tWKP+g==","shasum":"dbaa2e5c2f599cce6384d4afc0073414f2203546","tarball":"http://registry-npm.ywwl.com/postcss-focus-within/download/postcss-focus-within-1.0.0.tgz","fileCount":6,"unpackedSize":13354,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEYCIQChvoWoAabLlTnnpMyJNcY5P8BtYWUcXD4EFgHJNHCNuAIhALxLfmJ7M//ElnjgRHPdq3OyQUIAqJRy4b5gq4uJVPTz"}],"size":5018,"noattachment":false,"key":"/postcss-focus-within/-/postcss-focus-within-1.0.0.tgz"},"maintainers":[{"name":"jonathantneal","email":"jonathantneal@hotmail.com"}],"directories":{},"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/postcss-focus-within_1.0.0_1518910058056_0.7729713731156693"},"_hasShrinkwrap":false,"readme":"# PostCSS Focus Within [<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/postcss-focus-within.svg\" height=\"20\">][npm-url] [<img alt=\"CSS Standard Status\" src=\"https://cssdb.org/images/badges/focus-within-pseudo-class.svg\" height=\"20\">][css-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]\n\n```bash\nnpm install postcss-focus-within --save-dev\n```\n\n[PostCSS Focus Within] lets you use the `:focus-within` pseudo-class in CSS, \nfollowing the [Selectors Level 4 specification].\n\nTo use this feature you need to do two things :\n- add the [PostCSS plugin](#usage) that transforms the selector into a class or attribute\n- add the [browser polyfill](#browser) that sets the attribute or class on elements in a browser\n\n```pcss\n.my-form-field:focus-within label {\n\tbackground-color: yellow;\n}\n\n/* becomes */\n\n.my-form-field[focus-within].js-focus-within label, .js-focus-within .my-form-field[focus-within] label {\n\tbackground-color: yellow;\n}\n.my-form-field:focus-within label {\n\tbackground-color: yellow;\n}\n```\n\n[PostCSS Focus Within] duplicates rules using the `:focus-within` pseudo-class\nwith a `[focus-within]` attribute selector, the same selector used by the\nfocus-within polyfill. This replacement selector can be changed using the\n`replaceWith` option. Also, the preservation of the original `:focus-within`\nrule can be disabled using the `preserve` option.\n\n## Usage\n\nAdd [PostCSS Focus Within] to your project:\n\n```bash\nnpm install postcss postcss-focus-within --save-dev\n```\n\nUse it as a [PostCSS] plugin:\n\n```js\nconst postcss = require('postcss');\nconst postcssFocusWithin = require('postcss-focus-within');\n\npostcss([\n\tpostcssFocusWithin(/* pluginOptions */)\n]).process(YOUR_CSS /*, processOptions */);\n```\n\n[PostCSS Focus Within] 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### preserve\n\nThe `preserve` option determines whether the original notation\nis preserved. By default, it is preserved.\n\n```js\npostcssFocusWithin({ preserve: false })\n```\n\n```pcss\n.my-form-field:focus-within label {\n\tbackground-color: yellow;\n}\n\n/* becomes */\n\n.my-form-field[focus-within].js-focus-within label, .js-focus-within .my-form-field[focus-within] label {\n\tbackground-color: yellow;\n}\n```\n\n### replaceWith\n\nThe `replaceWith` option defines the selector to replace `:focus-within`. By\ndefault, the replacement selector is `[focus-within]`.\nPlease note that using a class, leverages `classList` under the hood which\nmight  not be supported on some old browsers such as IE9, so you may need\nto polyfill `classList` in those cases.\n\n```js\npostcssFocusWithin({ replaceWith: '.focus-within' });\n```\n\n```pcss\n.my-form-field:focus-within label {\n\tbackground-color: yellow;\n}\n\n/* becomes */\n\n.my-form-field.focus-within.js-focus-within label, .js-focus-within .my-form-field.focus-within label {\n\tbackground-color: yellow;\n}\n.my-form-field:focus-within label {\n\tbackground-color: yellow;\n}\n```\n\nNote that changing this option implies that it needs to be passed to the\nbrowser polyfill as well.\n\n### disablePolyfillReadyClass\n\nThe `disablePolyfillReadyClass` option determines if selectors are prefixed with an indicator class.\nThis class is only set on your document if the polyfill loads and is needed.\n\nBy default this option is `false`.\nSet this to `true` to prevent the class from being added.\n\n```js\npostcssFocusWithin({ disablePolyfillReadyClass: true })\n```\n\n```pcss\n.my-form-field:focus-within label {\n\tbackground-color: yellow;\n}\n\n/* becomes */\n\n.my-form-field[focus-within] label {\n\tbackground-color: yellow;\n}\n.my-form-field:focus-within label {\n\tbackground-color: yellow;\n}\n```\n\n## Browser\n\n```js\nimport focusWithinInit from 'postcss-focus-within/browser';\n\nfocusWithinInit();\n```\n\nor\n\n```html\n<!-- When using a CDN url you will have to manually update the version number -->\n<script src=\"https://unpkg.com/postcss-focus-within@8.0.1/dist/browser-global.js\"></script>\n<script>focusWithinInit()</script>\n```\n\n[PostCSS Focus Within] works in all major browsers, including Safari 6+ and\nInternet Explorer 9+ without any additional polyfills.\n\n### Browser Usage\n\n#### force\n\nThe `force` option determines whether the library runs even if the browser\nsupports the selector or not. By default, it won't run if the browser does\nsupport the selector.\n\n```js\nfocusWithinInit({ force: true });\n```\n\n#### replaceWith\n\nSimilar to the option for the PostCSS Plugin, `replaceWith` determines the\nattribute or class to apply to an element when it's considered to be `:focus-within`.\n\n```js\nfocusWithinInit({ replaceWith: '.focus-within });\n```\n\nThis option should be used if it was changed at PostCSS configuration level.\n\n### Using with Next.js\n\nGiven that Next.js imports packages both on the browser and on the server, you need to make sure that the package is only imported on the browser.\n\nAs outlined in the [Next.js documentation](https://nextjs.org/docs/advanced-features/dynamic-import#with-external-libraries), you need to load the package with a dynamic import:\n\n```jsx\nuseEffect(async () => {\n\tconst focusWithinInit = (await import('postcss-focus-within/browser')).default;\n\tfocusWithinInit();\n}, []);\n```\n\n[cli-url]: https://github.com/csstools/postcss-plugins/actions/workflows/test.yml?query=workflow/test\n[css-url]: https://cssdb.org/#focus-within-pseudo-class\n[discord]: https://discord.gg/bUadyRwkJS\n[npm-url]: https://www.npmjs.com/package/postcss-focus-within\n\n[PostCSS]: https://github.com/postcss/postcss\n[PostCSS Focus Within]: https://github.com/csstools/postcss-plugins/tree/main/plugins/postcss-focus-within\n[Selectors Level 4 specification]: https://www.w3.org/TR/selectors-4/#the-focus-within-pseudo\n","publish_time":1518910058113,"_cnpm_publish_time":1518910058113,"dist-tags":{"latest":"10.0.1"}}