{"id":27398029,"url":"https://github.com/dead/react-js-spatial-navigation","last_synced_at":"2025-04-14T01:28:42.635Z","repository":{"id":26876009,"uuid":"107998232","full_name":"dead/react-js-spatial-navigation","owner":"dead","description":"A wrapper of js-spatial-navigation to react components","archived":false,"fork":false,"pushed_at":"2022-02-10T11:51:15.000Z","size":69,"stargazers_count":30,"open_issues_count":11,"forks_count":31,"subscribers_count":2,"default_branch":"master","last_synced_at":"2024-04-26T20:34:28.967Z","etag":null,"topics":["react","reactjs","spatial-navigation"],"latest_commit_sha":null,"homepage":null,"language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/dead.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.md","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2017-10-23T15:03:31.000Z","updated_at":"2023-09-26T14:11:45.000Z","dependencies_parsed_at":"2022-07-24T14:00:05.286Z","dependency_job_id":null,"html_url":"https://github.com/dead/react-js-spatial-navigation","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dead%2Freact-js-spatial-navigation","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dead%2Freact-js-spatial-navigation/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dead%2Freact-js-spatial-navigation/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dead%2Freact-js-spatial-navigation/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/dead","download_url":"https://codeload.github.com/dead/react-js-spatial-navigation/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248806765,"owners_count":21164566,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["react","reactjs","spatial-navigation"],"created_at":"2025-04-14T01:28:41.943Z","updated_at":"2025-04-14T01:28:42.623Z","avatar_url":"https://github.com/dead.png","language":"JavaScript","funding_links":[],"categories":["Navigation libraries"],"sub_categories":["Google Chromecast"],"readme":"# react-js-spatial-navigation\nA wrapper of js-spatial-navigation to react components\n\n## Example\n```javascript\nimport React from 'react';\nimport { render } from 'react-dom';\nimport SpatialNavigation, { Focusable, FocusableSection } from 'react-js-spatial-navigation'\n\nfunction focus1() {\n  console.log('focused 1')\n}\n\nfunction unfocus2() {\n  console.log('unfocus 2')\n}\n\nconst App = () =\u003e (\n  \u003cSpatialNavigation\u003e\n    \u003cFocusable onFocus={focus1}\u003e\n      \u003cp\u003eElement 1\u003c/p\u003e\n    \u003c/Focusable\u003e\n    \u003cFocusable onUnfocus={unfocus2}\u003e\n      \u003cp\u003eElement 2\u003c/p\u003e\n    \u003c/Focusable\u003e\n\n    \u003cFocusableSection defaultElement=\"active\"\u003e\n      \u003cFocusable\u003e\n        \u003cp\u003eElement 3\u003c/p\u003e\n      \u003c/Focusable\u003e\n      \u003cFocusable className=\"active\"\u003e\n        \u003cp\u003eElement 4\u003c/p\u003e\n      \u003c/Focusable\u003e\n    \u003c/FocusableSection\u003e\n  \u003c/SpatialNavigation\u003e\n);\n\nrender(\u003cApp /\u003e, document.getElementById('root'));\n```\n[Live Example](https://codesandbox.io/s/ryn6450wrn)\n\n## Documentation\n\n### `\u003cSpatialNavigation\u003e`\nThis component initialize the Spatial Navigation library.\nIt should be used only one time and in the root node of the application.\nThe spatial navigation will only work within the Focusable components.\n\n### `\u003cFocusable\u003e`\nA Focusable component that handle the onFocus, onUnfocus, onClickEnter events.\n```\nProps:\n   onFocus: (optional)\n     A function that will be fired when the component is focused.\n\n   onUnfocus: (optional)\n     A function that will be fired when the component is unfocused.\n\n   onClickEnter: (optional)\n     A function that will be fired when the component is focused and enter key is pressed.\n```\n\n### `\u003cFocusableSection\u003e`\nA Focusable Section can specify a behaviour before focusing an element.\nI.e. selecting a default element, the first element or an active one.\n\n```\nProps:\n   defaultElement: (default: '')\n     The default element that will be focused when entering this section.\n     This can be:\n       * a valid selector string for \"querySelectorAll\".\n       * a NodeList or an array containing DOM elements.\n       * a single DOM element.\n       * an empty string.\n\n   enterTo: (default: 'default-element')\n     If the focus comes from another section, you can define which element in this section should be focused first.\n     This can be:\n       * 'last-focused' indicates the last focused element before we left this section last time. If this section has never been focused yet, the default element (if any) will be chosen next.\n       * 'default-element' indicates the element defined in defaultElement.\n       * an empty string.\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdead%2Freact-js-spatial-navigation","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdead%2Freact-js-spatial-navigation","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdead%2Freact-js-spatial-navigation/lists"}