@getoutline/react-roving-tabindex
Advanced tools
Comparing version 3.2.3 to 3.2.4
@@ -59,2 +59,3 @@ import React, { createContext, useReducer, useEffect, useMemo, useRef, useContext, useCallback } from 'react'; | ||
ActionType["FOCUSED"] = "FOCUSED"; | ||
ActionType["ITEMS_UPDATED"] = "ITEMS_UPDATED"; | ||
})(ActionType || (ActionType = {})); | ||
@@ -119,3 +120,3 @@ | ||
} | ||
return __assign(__assign({}, state), { selectedId: getUpdatedSelectedId(newTabStops, state.selectedId), tabStops: newTabStops, rowStartMap: null }); | ||
return __assign(__assign({}, state), { allowFocusing: false, selectedId: getUpdatedSelectedId(newTabStops, state.selectedId), tabStops: newTabStops, rowStartMap: null }); | ||
} | ||
@@ -142,2 +143,5 @@ case ActionType.TAB_STOP_UPDATED: { | ||
} | ||
case ActionType.ITEMS_UPDATED: { | ||
return __assign(__assign({}, state), { items: action.payload.items }); | ||
} | ||
case ActionType.KEY_DOWN: { | ||
@@ -412,2 +416,3 @@ var _b = action.payload, id_3 = _b.id, key = _b.key, ctrlKey = _b.ctrlKey; | ||
var INITIAL_STATE = { | ||
items: [], | ||
selectedId: null, | ||
@@ -465,4 +470,7 @@ allowFocusing: false, | ||
var Provider = function (_a) { | ||
var children = _a.children, options = _a.options; | ||
var children = _a.children, options = _a.options, items = _a.items; | ||
var _b = useReducer(reducer, __assign(__assign({}, INITIAL_STATE), options)), state = _b[0], dispatch = _b[1]; | ||
useEffect(function () { | ||
dispatch({ type: ActionType.ITEMS_UPDATED, payload: { items: items } }); | ||
}, [items]); | ||
// Update the options whenever they change: | ||
@@ -546,3 +554,3 @@ useEffect(function () { | ||
}; | ||
}, []); | ||
}, [context.state.items]); | ||
// Update the tab stop data if rowIndex or disabled change. | ||
@@ -549,0 +557,0 @@ // The isMounted flag is used to prevent this effect running |
@@ -68,2 +68,3 @@ 'use strict'; | ||
ActionType["FOCUSED"] = "FOCUSED"; | ||
ActionType["ITEMS_UPDATED"] = "ITEMS_UPDATED"; | ||
})(exports.ActionType || (exports.ActionType = {})); | ||
@@ -128,3 +129,3 @@ | ||
} | ||
return __assign(__assign({}, state), { selectedId: getUpdatedSelectedId(newTabStops, state.selectedId), tabStops: newTabStops, rowStartMap: null }); | ||
return __assign(__assign({}, state), { allowFocusing: false, selectedId: getUpdatedSelectedId(newTabStops, state.selectedId), tabStops: newTabStops, rowStartMap: null }); | ||
} | ||
@@ -151,2 +152,5 @@ case exports.ActionType.TAB_STOP_UPDATED: { | ||
} | ||
case exports.ActionType.ITEMS_UPDATED: { | ||
return __assign(__assign({}, state), { items: action.payload.items }); | ||
} | ||
case exports.ActionType.KEY_DOWN: { | ||
@@ -421,2 +425,3 @@ var _b = action.payload, id_3 = _b.id, key = _b.key, ctrlKey = _b.ctrlKey; | ||
var INITIAL_STATE = { | ||
items: [], | ||
selectedId: null, | ||
@@ -474,4 +479,7 @@ allowFocusing: false, | ||
var Provider = function (_a) { | ||
var children = _a.children, options = _a.options; | ||
var children = _a.children, options = _a.options, items = _a.items; | ||
var _b = React.useReducer(reducer, __assign(__assign({}, INITIAL_STATE), options)), state = _b[0], dispatch = _b[1]; | ||
React.useEffect(function () { | ||
dispatch({ type: exports.ActionType.ITEMS_UPDATED, payload: { items: items } }); | ||
}, [items]); | ||
// Update the options whenever they change: | ||
@@ -555,3 +563,3 @@ React.useEffect(function () { | ||
}; | ||
}, []); | ||
}, [context.state.items]); | ||
// Update the tab stop data if rowIndex or disabled change. | ||
@@ -558,0 +566,0 @@ // The isMounted flag is used to prevent this effect running |
@@ -6,2 +6,3 @@ import React, { ReactElement, ReactNode } from "react"; | ||
state: Readonly<{ | ||
items: unknown[]; | ||
selectedId: string | null; | ||
@@ -60,5 +61,6 @@ allowFocusing: boolean; | ||
*/ | ||
export declare const Provider: ({ children, options }: { | ||
export declare const Provider: ({ children, options, items }: { | ||
children: ReactNode; | ||
options?: Partial<Pick<Readonly<{ | ||
items: unknown[]; | ||
selectedId: string | null; | ||
@@ -77,2 +79,3 @@ allowFocusing: boolean; | ||
}>, "direction" | "focusOnClick" | "loopAround">> | undefined; | ||
items: State["items"]; | ||
}) => ReactElement; |
@@ -29,2 +29,3 @@ /// <reference types="react" /> | ||
export declare type State = Readonly<{ | ||
items: Array<unknown>; | ||
selectedId: string | null; | ||
@@ -46,3 +47,4 @@ allowFocusing: boolean; | ||
OPTIONS_UPDATED = "OPTIONS_UPDATED", | ||
FOCUSED = "FOCUSED" | ||
FOCUSED = "FOCUSED", | ||
ITEMS_UPDATED = "ITEMS_UPDATED" | ||
} | ||
@@ -53,2 +55,7 @@ export declare type Action = { | ||
} | { | ||
type: ActionType.ITEMS_UPDATED; | ||
payload: { | ||
items: State["items"]; | ||
}; | ||
} | { | ||
type: ActionType.UNREGISTER_TAB_STOP; | ||
@@ -55,0 +62,0 @@ payload: { |
{ | ||
"name": "@getoutline/react-roving-tabindex", | ||
"version": "3.2.3", | ||
"version": "3.2.4", | ||
"description": "React implementation of a roving tabindex, now with grid support", | ||
@@ -5,0 +5,0 @@ "author": "stevejay", |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
203323
1464