wix-style-react
Version:
wix-style-react
26 lines • 1.2 kB
TypeScript
import React from 'react';
type ItemNode = {
itemKey: string;
items?: ItemNode[];
};
type ItemKeyToParentKey = Record<string, string | undefined>;
export type SidebarStructure = {
items: ItemNode[];
keyToParentKey: ItemKeyToParentKey;
};
/**
* Recursively walks react children to create a tree of sidebar item nodes and
* their parent-child relationships.
*/
export declare const extractItemNodes: (children: React.ReactNode | React.ReactNode[]) => SidebarStructure;
export declare const getItemPath: (keyToParentKey: ItemKeyToParentKey, itemKey?: string) => string[];
export declare const isMenu: (keyToParentKey: ItemKeyToParentKey, itemKey: string) => boolean;
export declare const getMenuPath: (keyToParentKey: ItemKeyToParentKey, itemKey?: string) => string[];
export declare const getMaxDepth: (items?: ItemNode[]) => number;
/**
* Returns a new object with only the specified keys from the original one.
*/
export declare function pick<T extends Record<string, any>, K extends keyof T>(object: T, keys: K[]): Pick<T, K>;
export declare function pick<T extends Record<string, any>>(object: T, keys: string[]): Partial<T>;
export {};
//# sourceMappingURL=utils.d.ts.map