{"name":"aria-hidden","version":"1.2.5","keywords":["DOM","aria","hidden","inert"],"author":{"name":"Anton Korzunov","email":"thekashey@gmail.com"},"license":"MIT","_id":"aria-hidden@1.2.5","maintainers":[{"name":"kashey","email":"thekashey@gmail.com"}],"homepage":"https://github.com/theKashey/aria-hidden#readme","bugs":{"url":"https://github.com/theKashey/aria-hidden/issues"},"dist":{"shasum":"2afe11b89968444114ccbdc4b974a54728b028ef","tarball":"http://registry-npm.ywwl.com/aria-hidden/download/aria-hidden-1.2.5.tgz","fileCount":9,"integrity":"sha512-N+u63/2br5AG+OSrk0rIgFOYPSEYlkD7Yk5fq3LDole6QDIAbAFpbchE5fhBiUdRV2Fa8pWAaXvy+VK/maBeTA==","signatures":[{"sig":"MEYCIQCHJEPL8S/LY8XLBOw5gtRDWg48gu/YVVYZWCt5YDuv+wIhANFKzmdSEAHk//tVIa+UaWCoc6023BcwsjPQjvUkUGom","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":31053,"size":5378,"noattachment":false,"key":"/aria-hidden/-/aria-hidden-1.2.5.tgz"},"main":"dist/es5/index.js","types":"dist/es5/index.d.ts","module":"dist/es2015/index.js","engines":{"node":">=10"},"gitHead":"05b571b2b9c286b57bbf3e253f2ae01080cfd84c","scripts":{"dev":"lib-builder dev","lint":"lib-builder lint","size":"size-limit","test":"jest","build":"lib-builder build && yarn size:report","format":"lib-builder format","update":"lib-builder update","prepare":"husky install","release":"yarn build && yarn test","test:ci":"jest --runInBand --coverage","changelog":"conventional-changelog -p angular -i CHANGELOG.md -s","prepublish":"yarn build","size:report":"size-limit --json > .size.json","prepublish-only":"yarn build && yarn changelog","changelog:rewrite":"conventional-changelog -p angular -i CHANGELOG.md -s -r 0"},"_npmUser":{"name":"kashey","email":"thekashey@gmail.com"},"prettier":{"semi":true,"tabWidth":2,"printWidth":120,"singleQuote":true,"trailingComma":"es5"},"repository":{"url":"git+https://github.com/theKashey/aria-hidden.git","type":"git"},"_npmVersion":"10.8.2","description":"Cast aria-hidden to everything, except...","directories":{},"jsnext:main":"dist/es2015/index.js","lint-staged":{"*.{ts,tsx}":["prettier --write","eslint --fix"],"*.{js,css,json,md}":["prettier --write"]},"sideEffects":false,"_nodeVersion":"20.19.2","dependencies":{"tslib":"^2.0.0","caniuse-lite":"^1.0.30001718"},"module:es2019":"dist/es2019/index.js","_hasShrinkwrap":false,"packageManager":"yarn@1.22.22+sha512.a6b2f7906b721bba3d67d4aff083df04dad64c399707841b7acf00f6b133b7ac24255f2652fa22ae3534329dc6180534e98d17432037ff6fd140556e2bb3137e","devDependencies":{"@theuiteam/lib-builder":"^1.0.0","@size-limit/preset-small-lib":"^11.1.6"},"_npmOperationalInternal":{"tmp":"tmp/aria-hidden_1.2.5_1747533102010_0.6530029579124583","host":"s3://npm-registry-packages-npm-production"},"readme":"# aria-hidden\n\n[![NPM](https://nodei.co/npm/aria-hidden.png?downloads=true&stars=true)](https://nodei.co/npm/aria-hidden/)\n\nHides from ARIA everything, except provided node(s).\n\nHelps to isolate modal dialogs and focused task - the content will be not accessible using\naccessible tools.\n\nNow with [HTML inert](https://developer.mozilla.org/en-US/docs/Web/API/HTMLElement/inert) support\n\n# API\n\nJust call `hideOthers` with DOM-node you want to keep, and it will _hide_ everything else.\n`targetNode` could be placed anywhere - its siblings would be hidden, but it and its parents - not.\n\n> \"hidden\" in terms or `aria-hidden`\n\n```js\nimport { hideOthers } from 'aria-hidden';\n\nconst undo = hideOthers(exceptThisDOMnode);\n// everything else is \"aria-hidden\"\n\n// undo changes\nundo();\n```\n\nyou also may limit the effect spread by providing top level node as a second parameter\n\n```js\n// keep only `anotherNode` node visible in #app\n// the rest of document will be untouched\nhideOthers(anotherNode, document.getElementById('app'));\n```\n\n> `parentNode` defaults to document.body\n\n# Inert\n\nWhile `aria-hidden` played important role in the past and will play in the future - the main\nuse case always was around isolating content and making elements \"transparent\" not only for aria, but for\nuser interaction as well.\n\nThis is why you might consider using `inertOthers`\n\n```tsx\nimport { hideOthers, inertOthers, supportsInert } from 'aria-hidden';\n\n// focus on element mean \"hide others\". Ideally disable interactions\nconst focusOnElement = (node) => (supportsInert() ? inertOthers(node) : hideOthers(node));\n```\n\nthe same function as above is already contructed and exported as\n\n```tsx\nimport { suppressOthers } from 'aria-hidden';\n\nsuppressOthers([keepThisNode, andThis]);\n```\n\n⚠️ Note - inert **will disable any interactions** with _suppressed_ elements ⚠️\n\n### Suppressing interactivity without inert\n\nOne can `marker`, the third argument to a function, to mark hidden elements.\nLater one can create a style matching given marker to apply `pointer-events:none`\n\n```css\n[hidden-node] {\n  pointer-events: none;\n}\n```\n\n```tsx\nhideOthers(notThisOne, undefined /*parent = document*/, 'hidden-node');\n```\n\nGenerally speaking the same can be achieved by addressing `[aria-hidden]` nodes, but\nnot all `aria-hidden` nodes are expected to be non-interactive.\nHence, it's better to separate concerns.\n\n# Inspiration\n\nBased on [smooth-ui](https://github.com/smooth-code/smooth-ui) modal dialogs.\n\n# See also\n\n- [inert](https://github.com/WICG/inert) - The HTML attribute/property to mark parts of the DOM tree as \"inert\".\n- [react-focus-lock](https://github.com/theKashey/react-focus-lock) to lock Focus inside modal.\n- [react-scroll-lock](https://github.com/theKashey/react-scroll-lock) to disable page scroll while modal is opened.\n\n# Size\n\nCode is 30 lines long\n\n# Licence\n\nMIT\n","publish_time":1747533102216,"_cnpm_publish_time":1747533102216,"dist-tags":{"latest":"1.2.6"}}