Debian Codegraph @

node/@patternfly/react-core/dist/js/helpers/util.d.ts

raw
1 /**
2 * @param {string} input - String to capitalize first letter
3 */
4 export declare function capitalize(input: string): string;
5 /**
6 * @param {string} prefix - String to prefix ID with
7 */
8 export declare function getUniqueId(prefix?: string): string;
9 /**
10 * @param { any } this - "This" reference
11 * @param { Function } func - Function to debounce
12 * @param { number } wait - Debounce amount
13 */
14 export declare function debounce(this: any, func: (...args: any[]) => any, wait: number): (...args: any[]) => void;
15 /** This function returns whether or not an element is within the viewable area of a container. If partial is true,
16 * then this function will return true even if only part of the element is in view.
17 *
18 * @param {HTMLElement} container The container to check if the element is in view of.
19 * @param {HTMLElement} element The element to check if it is view
20 * @param {boolean} partial true if partial view is allowed
21 * @param {boolean} strict true if strict mode is set, never consider the container width and element width
22 *
23 * @returns { boolean } True if the component is in View.
24 */
25 export declare function isElementInView(container: HTMLElement, element: HTMLElement, partial: boolean, strict?: boolean): boolean;
26 /** This function returns the side the element is out of view on (right, left or both)
27 *
28 * @param {HTMLElement} container The container to check if the element is in view of.
29 * @param {HTMLElement} element The element to check if it is view
30 *
31 * @returns {string} right if the element is of the right, left if element is off the left or both if it is off on both sides.
32 */
33 export declare function sideElementIsOutOfView(container: HTMLElement, element: HTMLElement): string;
34 /** Interpolates a parameterized templateString using values from a templateVars object.
35 * The templateVars object should have keys and values which match the templateString's parameters.
36 * Example:
37 * const templateString: 'My name is ${firstName} ${lastName}';
38 * const templateVars: {
39 * firstName: 'Jon'
40 * lastName: 'Dough'
41 * };
42 * const result = fillTemplate(templateString, templateVars);
43 * // "My name is Jon Dough"
44 *
45 * @param {string} templateString The string passed by the consumer
46 * @param {object} templateVars The variables passed to the string
47 *
48 * @returns {string} The template string literal result
49 */
50 export declare function fillTemplate(templateString: string, templateVars: any): string;
51 /**
52 * This function allows for keyboard navigation through dropdowns. The custom argument is optional.
53 *
54 * @param {number} index The index of the element you're on
55 * @param {number} innerIndex Inner index number
56 * @param {string} position The orientation of the dropdown
57 * @param {string[]} refsCollection Array of refs to the items in the dropdown
58 * @param {object[]} kids Array of items in the dropdown
59 * @param {boolean} [custom] Allows for handling of flexible content
60 */
61 export declare function keyHandler(index: number, innerIndex: number, position: string, refsCollection: any[], kids: any[], custom?: boolean): void;
62 /** This function returns a list of tabbable items in a container
63 *
64 * @param {any} containerRef to the container
65 * @param {string} tababbleSelectors CSS selector string of tabbable items
66 */
67 export declare function findTabbableElements(containerRef: any, tababbleSelectors: string): any[];
68 /** This function is a helper for keyboard navigation through dropdowns.
69 *
70 * @param {number} index The index of the element you're on
71 * @param {string} position The orientation of the dropdown
72 * @param {string[]} collection Array of refs to the items in the dropdown
73 */
74 export declare function getNextIndex(index: number, position: string, collection: any[]): number;
75 /** This function is a helper for pluralizing strings.
76 *
77 * @param {number} i The quantity of the string you want to pluralize
78 * @param {string} singular The singular version of the string
79 * @param {string} plural The change to the string that should occur if the quantity is not equal to 1.
80 * Defaults to adding an 's'.
81 */
82 export declare function pluralize(i: number, singular: string, plural?: string): string;
83 /**
84 * This function is a helper for turning arrays of breakpointMod objects for flex and grid into style object
85 *
86 * @param {object} mods The modifiers object
87 * @param {string} css-variable The appropriate css variable for the component
88 */
89 export declare const setBreakpointCssVars: (mods: {
90 default?: string;
91 sm?: string;
92 md?: string;
93 lg?: string;
94 xl?: string;
95 '2xl'?: string;
96 '3xl'?: string;
97 }, cssVar: string) => React.CSSProperties;
98 export interface Mods {
99 default?: string;
100 xs?: string;
101 sm?: string;
102 md?: string;
103 lg?: string;
104 xl?: string;
105 '2xl'?: string;
106 '3xl'?: string;
107 '4xl'?: string;
108 }
109 /**
110 * This function is a helper for turning arrays of breakpointMod objects for data toolbar and flex into classes
111 *
112 * @param {object} mods The modifiers object
113 * @param {any} styles The appropriate styles object for the component
114 */
115 export declare const formatBreakpointMods: (mods: Mods, styles: any, stylePrefix?: string, breakpoint?: 'default' | 'sm' | 'md' | 'lg' | 'xl' | '2xl', vertical?: boolean) => any;
116 /**
117 * Return the breakpoint for the given height
118 *
119 * @param {number | null} height The height to check
120 * @returns {'default' | 'sm' | 'md' | 'lg' | 'xl' | '2xl'} The breakpoint
121 */
122 export declare const getVerticalBreakpoint: (height: number) => 'default' | 'sm' | 'md' | 'lg' | 'xl' | '2xl';
123 /**
124 * Return the breakpoint for the given width
125 *
126 * @param {number | null} width The width to check
127 * @returns {'default' | 'sm' | 'md' | 'lg' | 'xl' | '2xl'} The breakpoint
128 */
129 export declare const getBreakpoint: (width: number) => 'default' | 'sm' | 'md' | 'lg' | 'xl' | '2xl';
130 /**
131 *
132 * @param {string} s string to make camelCased
133 */
134 export declare const toCamel: (s: string) => string;
135 /**
136 * Copied from exenv
137 */
138 export declare const canUseDOM: boolean;
139 /**
140 * Calculate the width of the text
141 * Example:
142 * getTextWidth('my text', node)
143 *
144 * @param {string} text The text to calculate the width for
145 * @param {HTMLElement} node The HTML element
146 */
147 export declare const getTextWidth: (text: string, node: HTMLElement) => number;
148 /**
149 * Get the inner dimensions of an element
150 *
151 * @param {HTMLElement} node HTML element to calculate the inner dimensions for
152 */
153 export declare const innerDimensions: (node: HTMLElement) => {
154 height: number;
155 width: number;
156 };
157 /**
158 * This function is a helper for truncating text content on the left, leaving the right side of the content in view
159 *
160 * @param {HTMLElement} node HTML element
161 * @param {string} value The original text value
162 */
163 export declare const trimLeft: (node: HTMLElement, value: string) => void;
164 /**
165 * @param {string[]} events - Operations to prevent when disabled
166 */
167 export declare const preventedEvents: (events: string[]) => {};
168 /**
169 * @param {React.RefObject<any>[]} timeoutRefs - Timeout refs to clear
170 */
171 export declare const clearTimeouts: (timeoutRefs: React.RefObject<any>[]) => void;
172 /**
173 * Helper function to get the language direction of a given element, useful for figuring out if left-to-right
174 * or right-to-left specific logic should be applied.
175 *
176 * @param {HTMLElement} targetElement - Element the helper will get the language direction of
177 * @param {'ltr' | 'rtl'} defaultDirection - Language direction to assume if one can't be determined, defaults to 'ltr'
178 * @returns {'ltr' | 'rtl'} - The language direction of the target element
179 */
180 export declare const getLanguageDirection: (targetElement: HTMLElement, defaultDirection?: 'ltr' | 'rtl') => "ltr" | "rtl";
181 /**
182 * Gets a reference element based on a ref property, which can typically be 1 of several types.
183 *
184 * @param {HTMLElement | (() => HTMLElement) | React.RefObject<any>} refProp The ref property to get a reference element from.
185 * @returns The reference element if one is found.
186 */
187 export declare const getReferenceElement: (refProp: HTMLElement | (() => HTMLElement) | React.RefObject<any>) => any;
188 /**
189 * Gets the [client|offset|scroll]Left property of an element, and determines whether it needs to be
190 * adjusted for an RTL direction.
191 *
192 * @param {HTMLElement} targetElement - Element to get the inline-start property of.
193 * @param {HTMLElement} ancestorElement - Ancestor element to base the inline-start calculation off of when the direction is RTL.
194 * @param {'client' | 'offset' | 'scroll'} inlineType - The inline-start property type to base calculations on.
195 * @returns {number} - The value of the inline-start property.
196 */
197 export declare const getInlineStartProperty: (targetElement: HTMLElement, ancestorElement: HTMLElement, inlineType?: 'client' | 'offset' | 'scroll') => number;
198 //# sourceMappingURL=util.d.ts.map