@chakra-ui/descendant
Advanced tools
Comparing version 2.1.3 to 2.1.4
@@ -1,2 +0,2 @@ | ||
/// <reference types="react" /> | ||
import React from "react"; | ||
import { DescendantsManager, DescendantOptions } from "./descendant"; | ||
@@ -7,6 +7,6 @@ /** | ||
*/ | ||
declare function useDescendants<T extends HTMLElement = HTMLElement, K = {}>(): DescendantsManager<T, K>; | ||
declare function useDescendants<T extends HTMLElement = HTMLElement, K extends Record<string, any> = {}>(): DescendantsManager<T, K>; | ||
export interface UseDescendantsReturn extends ReturnType<typeof useDescendants> { | ||
} | ||
export declare function createDescendantContext<T extends HTMLElement = HTMLElement, K = {}>(): readonly [import("react").Provider<DescendantsManager<T, K>>, () => DescendantsManager<T, K>, () => DescendantsManager<T, K>, (options?: DescendantOptions<K> | undefined) => { | ||
export declare function createDescendantContext<T extends HTMLElement = HTMLElement, K extends Record<string, any> = {}>(): readonly [React.Provider<DescendantsManager<T, K>>, () => DescendantsManager<T, K>, () => DescendantsManager<T, K>, (options?: DescendantOptions<K> | undefined) => { | ||
descendants: UseDescendantsReturn; | ||
@@ -13,0 +13,0 @@ index: number; |
{ | ||
"name": "@chakra-ui/descendant", | ||
"version": "2.1.3", | ||
"version": "2.1.4", | ||
"description": "Register child nodes of a react element for better accessibility", | ||
@@ -5,0 +5,0 @@ "keywords": [ |
@@ -23,8 +23,8 @@ # Descendant | ||
Descendants observer is an utility hook for keeping track of descendant elements | ||
Descendants observer is a utility hook for keeping track of descendant elements | ||
and their relative indices. | ||
In short, this package allows each item in a list to know it's relative index | ||
and the parent of the list can keep track of each child, without needing to | ||
render in a loop and pass each component an index. | ||
In short, this package allows each item in a list to know its relative index and | ||
the parent of the list can keep track of each child, without needing to render | ||
in a loop and pass each component an index. | ||
@@ -31,0 +31,0 @@ This enables component composition: |
import { createContext, mergeRefs } from "@chakra-ui/react-utils" | ||
import { RefCallback, useRef, useState } from "react" | ||
import React, { RefCallback, useRef, useState } from "react" | ||
import { DescendantsManager, DescendantOptions } from "./descendant" | ||
@@ -10,3 +10,6 @@ import { useSafeLayoutEffect, cast } from "./utils" | ||
*/ | ||
function useDescendants<T extends HTMLElement = HTMLElement, K = {}>() { | ||
function useDescendants< | ||
T extends HTMLElement = HTMLElement, | ||
K extends Record<string, any> = {}, | ||
>() { | ||
const descendants = useRef(new DescendantsManager<T, K>()) | ||
@@ -44,5 +47,6 @@ useSafeLayoutEffect(() => { | ||
*/ | ||
function useDescendant<T extends HTMLElement = HTMLElement, K = {}>( | ||
options?: DescendantOptions<K>, | ||
) { | ||
function useDescendant< | ||
T extends HTMLElement = HTMLElement, | ||
K extends Record<string, any> = {}, | ||
>(options?: DescendantOptions<K>) { | ||
const descendants = useDescendantsContext() | ||
@@ -86,3 +90,3 @@ const [index, setIndex] = useState(-1) | ||
T extends HTMLElement = HTMLElement, | ||
K = {}, | ||
K extends Record<string, any> = {}, | ||
>() { | ||
@@ -89,0 +93,0 @@ type ContextProviderType = React.Provider<DescendantsManager<T, K>> |
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
47787
1177