@neo4j-ndl/react
Version:
React implementation of Neo4j Design System
72 lines (71 loc) • 3.05 kB
TypeScript
/**
*
* Copyright (c) "Neo4j"
* Neo4j Sweden AB [http://neo4j.com]
*
* This file is part of Neo4j.
*
* Neo4j is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
import { type MouseEvent, type TouchEvent } from 'react';
export declare const removeNewlines: (input: string) => string;
/** Remove extra spaces from sting */
export declare const removeSpaces: (input: string) => string;
export declare const needleWarningMessage: (message: string) => void;
/**
* Toggles scroll on the provided document.
* Useful for disabling scroll when a popup is open (ie ContextMenu/Modal)
*/
export declare const useDocumentScrollToggle: () => (disable: boolean, doc?: Document) => void;
/**
* Detect if there is a click event outside
* of the provided element
* Source:
* https://hashnode.com/post/useonclickoutside-custom-hook-to-detect-the-mouse-click-on-outside-typescript-ckrejmy3h0k5r91s18iu42t28
*/
export declare const useOnClickOutside: <T extends HTMLElement = HTMLElement>(ref: React.RefObject<T>, handler: (event: MouseEvent | TouchEvent) => void) => void;
/**
* X - char long pseudo-random string
*/
export declare const randomId: (length: number) => string;
export declare function isRefObject<T>(obj: React.RefObject<T> | T): obj is React.RefObject<T>;
/**
* Equivalent to prevUntil/nextUntil in jQuery
* https://api.jquery.com/prevUntil/
* https://api.jquery.com/nextUntil/
*
* Additional functionality is added to circle back
* to the beginning of a list of siblings if it reaches the end
* or vice versa.
*/
export declare function findUntil(direction: 'next' | 'prev', el: Element | ChildNode, matchSelector: string): Element | null;
/**
* Find all html elements that are focusable given a parent element
* @param parentElement the parent element
* @returns an array of HTML elements
*/
export declare const findFocusableChildren: (parentElement: HTMLElement) => Element[];
/**
* Using the element that currently has focus, finds the previous sibling of the currently focused element that is focusable
* @param parentRef the parent element
* @returns the previous focusable element
*/
export declare const findFocusableSibling: (parentRef: React.RefObject<HTMLElement>, direction: "prev" | "next") => HTMLElement | undefined;
/**
* Convert hex color to rgb format
*
* @param hex color in hex code format
* @returns color in rgb format rgb(_, _, _)
*/
export declare const convertHexToRGB: (hex: string) => string;