Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@yamada-ui/use-descendant

Package Overview
Dependencies
Maintainers
0
Versions
594
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@yamada-ui/use-descendant - npm Package Compare versions

Comparing version 1.0.24 to 1.0.25-dev-20241026093521

102

dist/index.d.ts

@@ -1,2 +0,2 @@

import { Provider } from 'react';
import * as react from 'react';

@@ -40,3 +40,3 @@ type DescendantOptions<T extends HTMLElement = HTMLElement, K = {}> = {

} = {}>() => {
readonly DescendantsContextProvider: Provider<{
DescendantsContextProvider: react.Provider<{
count: (filter?: FilterDescendant<T, K> | undefined) => number;

@@ -62,79 +62,23 @@ destroy: () => void;

}>;
readonly useDescendant: (options?: DescendantOptions<T, K>) => {
useDescendant: (options?: DescendantOptions<T, K>) => {
descendants: {
count: (filter?: FilterDescendant<HTMLElement, {
[key: string]: any;
}> | undefined) => number;
count: (filter?: FilterDescendant<T, K> | undefined) => number;
destroy: () => void;
enabledCount: (filter?: FilterDescendant<HTMLElement, {
[key: string]: any;
}> | undefined) => number;
enabledFirstValue: (filter?: FilterDescendant<HTMLElement, {
[key: string]: any;
}> | undefined) => Descendant<HTMLElement, {
[key: string]: any;
}> | undefined;
enabledIndexOf: (node?: HTMLElement | null | undefined, filter?: FilterDescendant<HTMLElement, {
[key: string]: any;
}> | undefined) => number;
enabledLastValue: (filter?: FilterDescendant<HTMLElement, {
[key: string]: any;
}> | undefined) => Descendant<HTMLElement, {
[key: string]: any;
}> | undefined;
enabledNextValue: (index: number, filter?: FilterDescendant<HTMLElement, {
[key: string]: any;
}> | undefined, loop?: boolean) => Descendant<HTMLElement, {
[key: string]: any;
}> | undefined;
enabledPrevValue: (index: number, filter?: FilterDescendant<HTMLElement, {
[key: string]: any;
}> | undefined, loop?: boolean) => Descendant<HTMLElement, {
[key: string]: any;
}> | undefined;
enabledValue: (index: number, filter?: FilterDescendant<HTMLElement, {
[key: string]: any;
}> | undefined) => Descendant<HTMLElement, {
[key: string]: any;
}> | undefined;
enabledValues: (filter?: FilterDescendant<HTMLElement, {
[key: string]: any;
}> | undefined) => Descendant<HTMLElement, {
[key: string]: any;
}>[];
firstValue: (filter?: FilterDescendant<HTMLElement, {
[key: string]: any;
}> | undefined) => Descendant<HTMLElement, {
[key: string]: any;
}> | undefined;
indexOf: (node?: HTMLElement | null | undefined) => number;
lastValue: (filter?: FilterDescendant<HTMLElement, {
[key: string]: any;
}> | undefined) => Descendant<HTMLElement, {
[key: string]: any;
}> | undefined;
nextValue: (index: number, filter?: FilterDescendant<HTMLElement, {
[key: string]: any;
}> | undefined, loop?: boolean) => Descendant<HTMLElement, {
[key: string]: any;
}> | undefined;
prevValue: (index: number, filter?: FilterDescendant<HTMLElement, {
[key: string]: any;
}> | undefined, loop?: boolean) => Descendant<HTMLElement, {
[key: string]: any;
}> | undefined;
register: (nodeOrOptions?: HTMLElement | DescendantOptions<HTMLElement, {
[key: string]: any;
}> | null | undefined) => void | ((node: HTMLElement | null) => void);
unregister: (node?: HTMLElement | undefined) => void;
value: (index: number, filter?: FilterDescendant<HTMLElement, {
[key: string]: any;
}> | undefined) => Descendant<HTMLElement, {
[key: string]: any;
}> | undefined;
values: (filter?: FilterDescendant<HTMLElement, {
[key: string]: any;
}> | undefined) => Descendant<HTMLElement, {
[key: string]: any;
}>[];
enabledCount: (filter?: FilterDescendant<T, K> | undefined) => number;
enabledFirstValue: (filter?: FilterDescendant<T, K> | undefined) => Descendant<T, K> | undefined;
enabledIndexOf: (node?: T | null | undefined, filter?: FilterDescendant<T, K> | undefined) => number;
enabledLastValue: (filter?: FilterDescendant<T, K> | undefined) => Descendant<T, K> | undefined;
enabledNextValue: (index: number, filter?: FilterDescendant<T, K> | undefined, loop?: boolean) => Descendant<T, K> | undefined;
enabledPrevValue: (index: number, filter?: FilterDescendant<T, K> | undefined, loop?: boolean) => Descendant<T, K> | undefined;
enabledValue: (index: number, filter?: FilterDescendant<T, K> | undefined) => Descendant<T, K> | undefined;
enabledValues: (filter?: FilterDescendant<T, K> | undefined) => Descendant<T, K>[];
firstValue: (filter?: FilterDescendant<T, K> | undefined) => Descendant<T, K> | undefined;
indexOf: (node?: T | null | undefined) => number;
lastValue: (filter?: FilterDescendant<T, K> | undefined) => Descendant<T, K> | undefined;
nextValue: (index: number, filter?: FilterDescendant<T, K> | undefined, loop?: boolean) => Descendant<T, K> | undefined;
prevValue: (index: number, filter?: FilterDescendant<T, K> | undefined, loop?: boolean) => Descendant<T, K> | undefined;
register: (nodeOrOptions?: T | DescendantOptions<T, K> | null | undefined) => void | ((node: T | null) => void);
unregister: (node?: T | undefined) => void;
value: (index: number, filter?: FilterDescendant<T, K> | undefined) => Descendant<T, K> | undefined;
values: (filter?: FilterDescendant<T, K> | undefined) => Descendant<T, K>[];
};

@@ -145,3 +89,3 @@ enabledIndex: number;

};
readonly useDescendants: () => {
useDescendants: () => {
count: (filter?: FilterDescendant<T, K> | undefined) => number;

@@ -167,3 +111,3 @@ destroy: () => void;

};
readonly useDescendantsContext: () => {
useDescendantsContext: () => {
count: (filter?: FilterDescendant<T, K> | undefined) => number;

@@ -170,0 +114,0 @@ destroy: () => void;

@@ -162,47 +162,44 @@ "use client"

};
var useDescendants = () => {
const descendants = (0, import_react.useRef)(descendantsManager());
(0, import_utils.useSafeLayoutEffect)(() => {
return () => descendants.current.destroy();
var createDescendant = () => {
const [DescendantsContextProvider, useDescendantsContext] = (0, import_utils.createContext)({
name: "DescendantsProvider",
errorMessage: "useDescendantsContext must be used within DescendantsContextProvider"
});
return descendants.current;
};
var [DescendantsContextProvider, useDescendantsContext] = (0, import_utils.createContext)({
name: "DescendantsProvider",
errorMessage: "useDescendantsContext must be used within DescendantsContextProvider"
});
var useDescendant = (options) => {
const descendants = useDescendantsContext();
const [index, setIndex] = (0, import_react.useState)(-1);
const ref = (0, import_react.useRef)(null);
(0, import_utils.useSafeLayoutEffect)(() => {
return () => {
const useDescendants = () => {
const descendants = (0, import_react.useRef)(descendantsManager());
(0, import_utils.useSafeLayoutEffect)(() => {
return () => descendants.current.destroy();
});
return descendants.current;
};
const useDescendant = (options) => {
const descendants = useDescendantsContext();
const [index, setIndex] = (0, import_react.useState)(-1);
const ref = (0, import_react.useRef)(null);
(0, import_utils.useSafeLayoutEffect)(() => {
return () => {
if (!ref.current) return;
descendants.unregister(ref.current);
};
}, []);
(0, import_utils.useSafeLayoutEffect)(() => {
if (!ref.current) return;
descendants.unregister(ref.current);
const dataIndex = Number(ref.current.dataset.index);
if (index != dataIndex && !Number.isNaN(dataIndex)) setIndex(dataIndex);
});
const refCallback = options ? (0, import_utils.cast)(descendants.register(options)) : (0, import_utils.cast)(descendants.register);
return {
descendants,
enabledIndex: descendants.enabledIndexOf(ref.current, options == null ? void 0 : options.filter),
index,
register: (0, import_utils.mergeRefs)(refCallback, ref)
};
}, []);
(0, import_utils.useSafeLayoutEffect)(() => {
if (!ref.current) return;
const dataIndex = Number(ref.current.dataset.index);
if (index != dataIndex && !Number.isNaN(dataIndex)) setIndex(dataIndex);
});
const refCallback = options ? (0, import_utils.cast)(descendants.register(options)) : (0, import_utils.cast)(descendants.register);
};
return {
descendants,
enabledIndex: descendants.enabledIndexOf(
ref.current,
options == null ? void 0 : options.filter
),
index,
register: (0, import_utils.mergeRefs)(refCallback, ref)
DescendantsContextProvider,
useDescendant,
useDescendants,
useDescendantsContext
};
};
var createDescendant = () => ({
DescendantsContextProvider: (0, import_utils.cast)(
DescendantsContextProvider
),
useDescendant: (options) => useDescendant(options),
useDescendants: () => useDescendants(),
useDescendantsContext: () => (0, import_utils.cast)(useDescendantsContext())
});
// Annotate the CommonJS export names for ESM import in node:

@@ -209,0 +206,0 @@ 0 && (module.exports = {

{
"name": "@yamada-ui/use-descendant",
"version": "1.0.24",
"version": "1.0.25-dev-20241026093521",
"description": "Yamada UI useDescendant custom hook",

@@ -5,0 +5,0 @@ "keywords": [

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc