From a418e7adeaa4b686fbde91ae09d7546fa02146c0 Mon Sep 17 00:00:00 2001 From: Anton Korzunov Date: Wed, 28 Feb 2024 12:26:23 +1100 Subject: [PATCH] fix: correct typescript definitions for focus helpers --- UI/UI.d.ts | 10 +++++----- react-focus-lock.d.ts | 11 ++++++----- 2 files changed, 11 insertions(+), 10 deletions(-) diff --git a/UI/UI.d.ts b/UI/UI.d.ts index 3321c5c..51cdc1b 100644 --- a/UI/UI.d.ts +++ b/UI/UI.d.ts @@ -59,20 +59,20 @@ export type FocusControl = { * focuses the next element in the scope. * If active element is not in the scope, autofocus will be triggered first */ - focusNext(options:FocusOptions):Promise; + focusNext(options?:FocusOptions):Promise; /** * focuses the prev element in the scope. * If active element is not in the scope, autofocus will be triggered first */ - focusPrev():Promise; + focusPrev(options?:FocusOptions):Promise; /** * focused the first element in the scope */ - focusFirst(options: Pick):Promise; + focusFirst(options?: Pick):Promise; /** * focused the last element in the scope */ - focusLast(options: Pick):Promise; + focusLast(options?: Pick):Promise; } @@ -81,7 +81,7 @@ export type FocusControl = { * - can be used outside of FocusLock * @see {@link useFocusScope} for use cases inside of FocusLock */ -export function useFocusController(...shards: HTMLElement[]):FocusControl; +export function useFocusController(...shards: ReadonlyArray):FocusControl; /** * returns FocusControl over the current FocusLock diff --git a/react-focus-lock.d.ts b/react-focus-lock.d.ts index f7a34bd..f34c77d 100644 --- a/react-focus-lock.d.ts +++ b/react-focus-lock.d.ts @@ -59,29 +59,30 @@ export type FocusControl = { * focuses the next element in the scope. * If active element is not in the scope, autofocus will be triggered first */ - focusNext(options:FocusOptions):Promise; + focusNext(options?:FocusOptions):Promise; /** * focuses the prev element in the scope. * If active element is not in the scope, autofocus will be triggered first */ - focusPrev():Promise; + focusPrev(options?:FocusOptions):Promise; /** * focused the first element in the scope */ - focusFirst(options: Pick):Promise; + focusFirst(options?: Pick):Promise; /** * focused the last element in the scope */ - focusLast(options: Pick):Promise; + focusLast(options?: Pick):Promise; } /** * returns FocusControl over the union given elements, one or many * - can be used outside of FocusLock + * - can accept HTML elements or React Refs * @see {@link useFocusScope} for use cases inside of FocusLock */ -export function useFocusController(...shards: HTMLElement[]):FocusControl; +export function useFocusController(...shards: ReadonlyArray):FocusControl; /** * returns FocusControl over the current FocusLock