react-roving-tabindex
Advanced tools
Comparing version 0.7.0 to 0.7.1
@@ -176,3 +176,5 @@ import findIndex from 'array-find-index'; | ||
// The returned callbacks handleKeyDown and handleClick are stable. | ||
function useRovingTabIndex(domElementRef, disabled, id) { | ||
function useRovingTabIndex( | ||
// eslint-disable-next-line @typescript-eslint/no-explicit-any | ||
domElementRef, disabled, id) { | ||
// This id is stable for the life of the component: | ||
@@ -198,4 +200,7 @@ var tabIndexId = React.useRef(id || uniqueId("roving-tabindex_")); | ||
}, [disabled]); | ||
var getDirection = function (event) { | ||
if (context.state.direction === "horizontal" || context.state.direction === "both") { | ||
var getDirection = function ( | ||
// eslint-disable-next-line @typescript-eslint/no-explicit-any | ||
event) { | ||
if (context.state.direction === "horizontal" || | ||
context.state.direction === "both") { | ||
if (event.key === "ArrowLeft") { | ||
@@ -208,3 +213,4 @@ return TabDirection.Previous; | ||
} | ||
if (context.state.direction === "vertical" || context.state.direction === "both") { | ||
if (context.state.direction === "vertical" || | ||
context.state.direction === "both") { | ||
if (event.key === "ArrowUp") { | ||
@@ -219,3 +225,5 @@ return TabDirection.Previous; | ||
}; | ||
var handleKeyDown = React.useCallback(function (event) { | ||
var handleKeyDown = React.useCallback( | ||
// eslint-disable-next-line @typescript-eslint/no-explicit-any | ||
function (event) { | ||
var payload = { id: tabIndexId.current }; | ||
@@ -260,3 +268,5 @@ var direction = getDirection(event); | ||
// changes from false to true. | ||
function useFocusEffect(focused, ref) { | ||
function useFocusEffect(focused, | ||
// eslint-disable-next-line @typescript-eslint/no-explicit-any | ||
ref) { | ||
React.useLayoutEffect(function () { | ||
@@ -263,0 +273,0 @@ if (focused && ref.current) { |
@@ -182,3 +182,5 @@ 'use strict'; | ||
// The returned callbacks handleKeyDown and handleClick are stable. | ||
function useRovingTabIndex(domElementRef, disabled, id) { | ||
function useRovingTabIndex( | ||
// eslint-disable-next-line @typescript-eslint/no-explicit-any | ||
domElementRef, disabled, id) { | ||
// This id is stable for the life of the component: | ||
@@ -204,4 +206,7 @@ var tabIndexId = React.useRef(id || uniqueId("roving-tabindex_")); | ||
}, [disabled]); | ||
var getDirection = function (event) { | ||
if (context.state.direction === "horizontal" || context.state.direction === "both") { | ||
var getDirection = function ( | ||
// eslint-disable-next-line @typescript-eslint/no-explicit-any | ||
event) { | ||
if (context.state.direction === "horizontal" || | ||
context.state.direction === "both") { | ||
if (event.key === "ArrowLeft") { | ||
@@ -214,3 +219,4 @@ return TabDirection.Previous; | ||
} | ||
if (context.state.direction === "vertical" || context.state.direction === "both") { | ||
if (context.state.direction === "vertical" || | ||
context.state.direction === "both") { | ||
if (event.key === "ArrowUp") { | ||
@@ -225,3 +231,5 @@ return TabDirection.Previous; | ||
}; | ||
var handleKeyDown = React.useCallback(function (event) { | ||
var handleKeyDown = React.useCallback( | ||
// eslint-disable-next-line @typescript-eslint/no-explicit-any | ||
function (event) { | ||
var payload = { id: tabIndexId.current }; | ||
@@ -266,3 +274,5 @@ var direction = getDirection(event); | ||
// changes from false to true. | ||
function useFocusEffect(focused, ref) { | ||
function useFocusEffect(focused, | ||
// eslint-disable-next-line @typescript-eslint/no-explicit-any | ||
ref) { | ||
React.useLayoutEffect(function () { | ||
@@ -269,0 +279,0 @@ if (focused && ref.current) { |
@@ -66,3 +66,3 @@ import React from "react"; | ||
}; | ||
declare const Provider: ({ children, direction }: Props) => JSX.Element; | ||
declare const Provider: ({ children, direction }: Props) => React.ReactElement<any, string | ((props: any) => React.ReactElement<any, string | any | (new (props: any) => React.Component<any, any, any>)> | null) | (new (props: any) => React.Component<any, any, any>)>; | ||
export default Provider; |
{ | ||
"name": "react-roving-tabindex", | ||
"version": "0.7.0", | ||
"description": "React Hooks implementation of a roving tabindex", | ||
"version": "0.7.1", | ||
"description": "React implementation of a roving tabindex", | ||
"author": "stevejay", | ||
"license": "MIT", | ||
"keywords": [ | ||
"hooks", | ||
"react", | ||
"roving", | ||
"tabindex", | ||
"react", | ||
"hooks" | ||
"tab", | ||
"tabindex" | ||
], | ||
@@ -23,3 +24,3 @@ "repository": "stevejay/react-roving-tabindex", | ||
"test": "cross-env CI=1 jest --env=jsdom", | ||
"test:watch": "jest --env=jsdom --watch", | ||
"test:watch": "jest --env=jsdom --watch", | ||
"test:coverage": "jest --env=jsdom --coverage", | ||
@@ -30,4 +31,18 @@ "build": "rollup -c", | ||
"storybook": "start-storybook -p 9001 -c .storybook", | ||
"deploy-storybook": "storybook-to-ghpages" | ||
"deploy-storybook": "storybook-to-ghpages", | ||
"eslint": "eslint --max-warnings 0 \"src/**/*.{js,jsx,ts,tsx}\"", | ||
"lint": "npm run eslint", | ||
"lint-staged": "lint-staged" | ||
}, | ||
"husky": { | ||
"hooks": { | ||
"pre-commit": "lint-staged" | ||
} | ||
}, | ||
"lint-staged": { | ||
"*.{js,jsx,tsx,ts}": [ | ||
"eslint --fix --max-warnings 0 \"src/**/*.{js,jsx,ts,tsx}\"", | ||
"git add" | ||
] | ||
}, | ||
"dependencies": { | ||
@@ -43,3 +58,3 @@ "array-find-index": "^1.0.2", | ||
"devDependencies": { | ||
"@babel/core": "^7.6.3", | ||
"@babel/core": "^7.6.4", | ||
"@babel/preset-env": "^7.6.3", | ||
@@ -50,3 +65,3 @@ "@babel/preset-react": "^7.6.3", | ||
"@storybook/addon-knobs": "^5.2.5", | ||
"@storybook/react": "^5.2.3", | ||
"@storybook/react": "^5.2.5", | ||
"@storybook/storybook-deployer": "^2.8.1", | ||
@@ -56,9 +71,10 @@ "@svgr/rollup": "^4.3.3", | ||
"@types/array-find-index": "^1.0.0", | ||
"@types/jest": "^24.0.18", | ||
"@types/jest": "^24.0.19", | ||
"@types/jsdom": "^12.2.4", | ||
"@types/lodash.uniqueid": "^4.0.6", | ||
"@types/react": "^16.9.5", | ||
"@types/react-dom": "^16.9.1", | ||
"@types/storybook__react": "^4.0.2", | ||
"@types/styled-components": "4.1.8", | ||
"@types/warning": "^3.0.0", | ||
"@typescript-eslint/eslint-plugin": "^2.5.0", | ||
"@typescript-eslint/parser": "^2.5.0", | ||
"awesome-typescript-loader": "^5.2.1", | ||
@@ -68,12 +84,19 @@ "babel-jest": "^24.9.0", | ||
"cross-env": "^6.0.3", | ||
"eslint": "^6.5.1", | ||
"eslint-config-prettier": "^6.4.0", | ||
"eslint-plugin-prettier": "^3.1.1", | ||
"eslint-plugin-react": "^7.16.0", | ||
"gh-pages": "^2.1.1", | ||
"husky": "^3.0.9", | ||
"jest": "^24.9.0", | ||
"jsdom": "^15.2.0", | ||
"lint-staged": "^9.4.2", | ||
"lodash": "^4.17.15", | ||
"npm-check": "^5.9.0", | ||
"react": "^16.10.2", | ||
"react-dom": "^16.10.2", | ||
"prettier": "1.18.2", | ||
"react": "^16.11.0", | ||
"react-dom": "^16.11.0", | ||
"react-hooks-testing-library": "^0.6.0", | ||
"react-test-renderer": "^16.10.2", | ||
"rollup": "^1.23.1", | ||
"react-test-renderer": "^16.11.0", | ||
"rollup": "^1.25.2", | ||
"rollup-plugin-commonjs": "^10.1.0", | ||
@@ -85,2 +108,3 @@ "rollup-plugin-node-resolve": "^5.2.0", | ||
"rollup-plugin-url": "^3.0.0", | ||
"styled-components": "^4.4.0", | ||
"typescript": "^3.6.4" | ||
@@ -87,0 +111,0 @@ }, |
@@ -101,3 +101,3 @@ # react-roving-tabindex | ||
This is useful if you need to support server-side rendering. The value initially passed with be used for the lifetime of the containing component. | ||
This is useful if you need to support server-side rendering. The value initially passed will be used for the lifetime of the containing component. | ||
@@ -113,1 +113,7 @@ You can change the navigation direction by passing a direction to the Provider. This will change the left and right arrow keys for up and down. | ||
MIT © [stevejay](https://github.com/stevejay) | ||
## Development | ||
### Issues | ||
- The `@types/styled-components` package is currently downgraded to v4.1.8 because of [this issue](https://github.com/DefinitelyTyped/DefinitelyTyped/issues/33311) |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
91771
17
620
118
48