@necto-react/hooks 2.6.0 → 2.10.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +1 -1
- package/README.md +19 -0
- package/dist/index.cjs +1 -0
- package/dist/index.d.cts +1000 -0
- package/dist/index.d.ts +957 -51
- package/dist/index.global.js +37 -0
- package/dist/index.js +1 -10
- package/package.json +21 -19
- package/dist/index.es.js +0 -10
- package/dist/index.es.js.map +0 -1
- package/dist/index.js.map +0 -1
package/dist/index.d.cts
ADDED
|
@@ -0,0 +1,1000 @@
|
|
|
1
|
+
import { ForwardedRef, Context, HTMLAttributes, RefObject, FocusEvent, ReactNode, CSSProperties } from 'react';
|
|
2
|
+
import { DisabledFlags, FocusEvents, DOMAttributes, FocusableDOMProps, HoverEvent, KeyboardEvents, RenderProps } from '@necto-react/types';
|
|
3
|
+
import { FocusableElement, PressEvent } from '@necto/types';
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* Copyright (c) Corinvo, LLC. and affiliates.
|
|
7
|
+
*
|
|
8
|
+
* This source code is licensed under the MIT license found in the
|
|
9
|
+
* LICENSE file in the root directory of this source tree.
|
|
10
|
+
*
|
|
11
|
+
*/
|
|
12
|
+
|
|
13
|
+
/**
|
|
14
|
+
* Props for the useContextProps hook.
|
|
15
|
+
*/
|
|
16
|
+
interface UseContextPropsProps<T, E extends Element> {
|
|
17
|
+
/**
|
|
18
|
+
* Component props, must include optional slot property and optional ref.
|
|
19
|
+
*/
|
|
20
|
+
props: T & {
|
|
21
|
+
/**
|
|
22
|
+
* The slot name to retrieve from the context. If null, context is not used.
|
|
23
|
+
*/
|
|
24
|
+
slot?: string | null;
|
|
25
|
+
/**
|
|
26
|
+
* Optional forwarded ref for the component.
|
|
27
|
+
*/
|
|
28
|
+
ref?: ForwardedRef<E>;
|
|
29
|
+
};
|
|
30
|
+
/**
|
|
31
|
+
* Forwarded ref for the component (from React.forwardRef).
|
|
32
|
+
*/
|
|
33
|
+
ref: ForwardedRef<E>;
|
|
34
|
+
/**
|
|
35
|
+
* React context to retrieve slot values from.
|
|
36
|
+
* The context value can be:
|
|
37
|
+
* - an object with `slots` (mapping slot names to values)
|
|
38
|
+
* - a value of the same type as props (with optional ref)
|
|
39
|
+
* - null or undefined
|
|
40
|
+
*/
|
|
41
|
+
context: Context<{
|
|
42
|
+
slots?: Record<string | symbol, T & {
|
|
43
|
+
slot?: string | null;
|
|
44
|
+
ref?: ForwardedRef<E>;
|
|
45
|
+
}>;
|
|
46
|
+
} | (T & {
|
|
47
|
+
slot?: string | null;
|
|
48
|
+
ref?: ForwardedRef<E>;
|
|
49
|
+
}) | null | undefined>;
|
|
50
|
+
}
|
|
51
|
+
/**
|
|
52
|
+
* Return type for the useContextProps hook.
|
|
53
|
+
*/
|
|
54
|
+
type UseContextPropsReturn<T, E extends Element> = [
|
|
55
|
+
T,
|
|
56
|
+
(value: E | null) => void
|
|
57
|
+
];
|
|
58
|
+
|
|
59
|
+
/**
|
|
60
|
+
* React hook that merges props and refs from both component and context, including styles.
|
|
61
|
+
*
|
|
62
|
+
* @template T The props type.
|
|
63
|
+
* @template E The element type.
|
|
64
|
+
* @param {UseContextPropsProps<T, E>} params - Component props, ref, and context.
|
|
65
|
+
* @returns {UseContextPropsReturn<T, E>} A tuple of merged props and merged ref.
|
|
66
|
+
*/
|
|
67
|
+
declare function useContextProps<T, E extends Element>({ props, ref, context }: UseContextPropsProps<T, E>): UseContextPropsReturn<T, E>;
|
|
68
|
+
|
|
69
|
+
/**
|
|
70
|
+
* Copyright (c) Corinvo, LLC. and affiliates.
|
|
71
|
+
*
|
|
72
|
+
* This source code is licensed under the MIT license found in the
|
|
73
|
+
* LICENSE file in the root directory of this source tree.
|
|
74
|
+
*
|
|
75
|
+
*/
|
|
76
|
+
|
|
77
|
+
/**
|
|
78
|
+
* Props for the useDisabled hook.
|
|
79
|
+
*/
|
|
80
|
+
interface UseDisabledProps {
|
|
81
|
+
/** The key of the disabled flag to check. Defaults to 'general'. */
|
|
82
|
+
type?: keyof DisabledFlags;
|
|
83
|
+
/** The fallback value if the flag is not set. Defaults to false. */
|
|
84
|
+
defaultFallback?: boolean;
|
|
85
|
+
}
|
|
86
|
+
/**
|
|
87
|
+
* Return type for the useDisabled hook.
|
|
88
|
+
*/
|
|
89
|
+
type UseDisabledPropsReturn = boolean;
|
|
90
|
+
|
|
91
|
+
/**
|
|
92
|
+
* Copyright (c) Corinvo, LLC. and affiliates.
|
|
93
|
+
*
|
|
94
|
+
* This source code is licensed under the MIT license found in the
|
|
95
|
+
* LICENSE file in the root directory of this source tree.
|
|
96
|
+
*
|
|
97
|
+
*/
|
|
98
|
+
|
|
99
|
+
/**
|
|
100
|
+
* React hook to determine if a specific feature or component type is disabled.
|
|
101
|
+
*
|
|
102
|
+
* @param {keyof DisabledFlags} type - The key of the disabled flag to check. Defaults to 'general'.
|
|
103
|
+
* @param {boolean} defaultFallback - The fallback value if the flag is not set. Defaults to false.
|
|
104
|
+
* @returns {boolean} True if the specified type is disabled, otherwise the fallback value.
|
|
105
|
+
*/
|
|
106
|
+
declare function useDisabled(props?: UseDisabledProps): UseDisabledPropsReturn;
|
|
107
|
+
|
|
108
|
+
/**
|
|
109
|
+
* Copyright (c) Corinvo, LLC. and affiliates.
|
|
110
|
+
*
|
|
111
|
+
* This source code is licensed under the MIT license found in the
|
|
112
|
+
* LICENSE file in the root directory of this source tree.
|
|
113
|
+
*
|
|
114
|
+
*/
|
|
115
|
+
|
|
116
|
+
/**
|
|
117
|
+
* Props for the useDisabledProps hook.
|
|
118
|
+
*/
|
|
119
|
+
interface UseDisabledPropsProps {
|
|
120
|
+
/** The key of the disabled flag to check. Defaults to 'general'. */
|
|
121
|
+
type?: keyof DisabledFlags;
|
|
122
|
+
/** Additional props to merge with the disabled attributes. */
|
|
123
|
+
extraProps?: HTMLAttributes<HTMLElement>;
|
|
124
|
+
}
|
|
125
|
+
/**
|
|
126
|
+
* Return type for the useDisabledProps hook.
|
|
127
|
+
*/
|
|
128
|
+
type UseDisabledPropsPropsReturn = HTMLAttributes<HTMLElement>;
|
|
129
|
+
|
|
130
|
+
/**
|
|
131
|
+
* Copyright (c) Corinvo, LLC. and affiliates.
|
|
132
|
+
*
|
|
133
|
+
* This source code is licensed under the MIT license found in the
|
|
134
|
+
* LICENSE file in the root directory of this source tree.
|
|
135
|
+
*
|
|
136
|
+
*/
|
|
137
|
+
|
|
138
|
+
/**
|
|
139
|
+
* Returns HTML props with appropriate disabled attributes based on the disabled state.
|
|
140
|
+
*
|
|
141
|
+
* @param {UseDisabledPropsOptions} options - Options for the hook.
|
|
142
|
+
* @returns {HTMLAttributes<HTMLElement>} The merged props including disabled and aria-disabled if applicable.
|
|
143
|
+
*/
|
|
144
|
+
declare function useDisabledProps(props?: UseDisabledPropsProps): UseDisabledPropsPropsReturn;
|
|
145
|
+
|
|
146
|
+
/**
|
|
147
|
+
* Copyright (c) Corinvo, LLC. and affiliates.
|
|
148
|
+
*
|
|
149
|
+
* This source code is licensed under the MIT license found in the
|
|
150
|
+
* LICENSE file in the root directory of this source tree.
|
|
151
|
+
*
|
|
152
|
+
*/
|
|
153
|
+
/**
|
|
154
|
+
* Indicates whether partial visibility is allowed, or specifies the edge(s) to check for partial visibility.
|
|
155
|
+
*/
|
|
156
|
+
type PartialVisibility = boolean | 'top' | 'right' | 'bottom' | 'left';
|
|
157
|
+
/**
|
|
158
|
+
* Props for the useElementVisibility hook.
|
|
159
|
+
*/
|
|
160
|
+
interface UseElementVisibilityProps {
|
|
161
|
+
/** Whether partial visibility is allowed, or which edge to check. */
|
|
162
|
+
partialVisibility?: PartialVisibility;
|
|
163
|
+
/** The threshold(s) at which to trigger the observer callback. */
|
|
164
|
+
threshold?: number | number[];
|
|
165
|
+
/** Margin around the root element. Can shrink or grow each side of the root element's bounding box. */
|
|
166
|
+
rootMargin?: string;
|
|
167
|
+
/** The element that is used as the viewport for checking visibility. */
|
|
168
|
+
root?: Element | Document | null;
|
|
169
|
+
/** Whether the visibility check is active. */
|
|
170
|
+
active?: boolean;
|
|
171
|
+
/** Whether the visibility state should persist once element becomes visible. */
|
|
172
|
+
once?: boolean;
|
|
173
|
+
/** Callback fired when the visibility state changes. */
|
|
174
|
+
onChange?: (isVisible: boolean) => void;
|
|
175
|
+
}
|
|
176
|
+
/** Intersection details provided by IntersectionObserver. */
|
|
177
|
+
interface IntersectionDetails {
|
|
178
|
+
/** Whether the element is intersecting with the root. */
|
|
179
|
+
isIntersecting: boolean;
|
|
180
|
+
/** The ratio of the intersection area to the bounding box of the target. */
|
|
181
|
+
intersectionRatio: number;
|
|
182
|
+
/** The rectangle describing the intersection between the target and root. */
|
|
183
|
+
intersectionRect: DOMRectReadOnly;
|
|
184
|
+
/** The bounding rectangle of the target element. */
|
|
185
|
+
boundingClientRect: DOMRectReadOnly;
|
|
186
|
+
/** The bounding rectangle of the root element. */
|
|
187
|
+
rootBounds: DOMRectReadOnly | null;
|
|
188
|
+
/** The time at which the intersection was recorded. */
|
|
189
|
+
time: number;
|
|
190
|
+
}
|
|
191
|
+
/**
|
|
192
|
+
* Return type for the useElementVisibility hook.
|
|
193
|
+
*/
|
|
194
|
+
type UseElementVisibilityReturn<T extends Element = Element> = [
|
|
195
|
+
(node: T | null) => void,
|
|
196
|
+
boolean,
|
|
197
|
+
IntersectionDetails | null
|
|
198
|
+
];
|
|
199
|
+
|
|
200
|
+
/**
|
|
201
|
+
* Copyright (c) Corinvo, LLC. and affiliates.
|
|
202
|
+
*
|
|
203
|
+
* This source code is licensed under the MIT license found in the
|
|
204
|
+
* LICENSE file in the root directory of this source tree.
|
|
205
|
+
*
|
|
206
|
+
*/
|
|
207
|
+
|
|
208
|
+
/**
|
|
209
|
+
* React hook that observes the visibility of a DOM element using the Intersection Observer API.
|
|
210
|
+
*
|
|
211
|
+
* @template T The type of the element being observed.
|
|
212
|
+
* @param {UseElementVisibilityProps} [props] - Options to control visibility observation and callbacks.
|
|
213
|
+
* @returns {UseElementVisibilityReturn<T>} A tuple containing the ref to the element, the visibility state, and intersection details.
|
|
214
|
+
*/
|
|
215
|
+
declare function useElementVisibility<T extends Element = Element>(props?: UseElementVisibilityProps): UseElementVisibilityReturn<T>;
|
|
216
|
+
|
|
217
|
+
/**
|
|
218
|
+
* Copyright (c) Corinvo, LLC. and affiliates.
|
|
219
|
+
*
|
|
220
|
+
* This source code is licensed under the MIT license found in the
|
|
221
|
+
* LICENSE file in the root directory of this source tree.
|
|
222
|
+
*
|
|
223
|
+
*/
|
|
224
|
+
|
|
225
|
+
/**
|
|
226
|
+
* Props for the useFocus hook.
|
|
227
|
+
*/
|
|
228
|
+
interface UseFocusProps<T = FocusableElement> extends FocusEvents<T> {
|
|
229
|
+
/** Whether focus events are disabled. */
|
|
230
|
+
isDisabled?: boolean;
|
|
231
|
+
}
|
|
232
|
+
/**
|
|
233
|
+
* Return type for the useFocus hook.
|
|
234
|
+
*/
|
|
235
|
+
interface UseFocusReturn<T = FocusableElement> {
|
|
236
|
+
/** Props that can be spread onto a focusable DOM element. */
|
|
237
|
+
focusProps?: DOMAttributes<T>;
|
|
238
|
+
}
|
|
239
|
+
|
|
240
|
+
/**
|
|
241
|
+
* Portions of this file are based on code from the React Aria Spectrum library by Adobe,
|
|
242
|
+
* licensed under the Apache License, Version 2.0.
|
|
243
|
+
* Copyright (c) Adobe. All rights reserved.
|
|
244
|
+
* See: https://github.com/adobe/react-spectrum
|
|
245
|
+
*
|
|
246
|
+
* Modifications copyright (c) Corinvo, LLC. and affiliates. All rights reserved.
|
|
247
|
+
*
|
|
248
|
+
* This file contains code licensed under:
|
|
249
|
+
* - The MIT License (see LICENSE in the root directory) for Corinvo modifications.
|
|
250
|
+
* - The Apache License, Version 2.0 for portions from Adobe.
|
|
251
|
+
*
|
|
252
|
+
* Modifications have been made to adapt the code for use in this project.
|
|
253
|
+
*/
|
|
254
|
+
|
|
255
|
+
/**
|
|
256
|
+
* React hook that manages focus and blur event handling for a focusable element.
|
|
257
|
+
*
|
|
258
|
+
* @template T The type of the focusable element.
|
|
259
|
+
* @param {UseFocusProps<T>} [props] - Options and event handlers for focus management.
|
|
260
|
+
* @returns {UseFocusReturn<T>} An object containing props to spread on the target element for focus management.
|
|
261
|
+
*/
|
|
262
|
+
declare function useFocus<T extends FocusableElement = FocusableElement>(props?: UseFocusProps<T>): UseFocusReturn<T>;
|
|
263
|
+
|
|
264
|
+
/**
|
|
265
|
+
* Copyright (c) Corinvo, LLC. and affiliates.
|
|
266
|
+
*
|
|
267
|
+
* This source code is licensed under the MIT license found in the
|
|
268
|
+
* LICENSE file in the root directory of this source tree.
|
|
269
|
+
*
|
|
270
|
+
*/
|
|
271
|
+
|
|
272
|
+
interface UseFocusableProps extends FocusableDOMProps, FocusEvents {
|
|
273
|
+
isDisabled?: boolean;
|
|
274
|
+
autoFocus?: boolean;
|
|
275
|
+
}
|
|
276
|
+
type UseFocusableReturn = {};
|
|
277
|
+
|
|
278
|
+
/**
|
|
279
|
+
* Portions of this file are based on code from the React Aria Spectrum library by Adobe,
|
|
280
|
+
* licensed under the Apache License, Version 2.0.
|
|
281
|
+
* Copyright (c) Adobe. All rights reserved.
|
|
282
|
+
* See: https://github.com/adobe/react-spectrum
|
|
283
|
+
*
|
|
284
|
+
* Modifications copyright (c) Corinvo, LLC. and affiliates. All rights reserved.
|
|
285
|
+
*
|
|
286
|
+
* This file contains code licensed under:
|
|
287
|
+
* - The MIT License (see LICENSE in the root directory) for Corinvo modifications.
|
|
288
|
+
* - The Apache License, Version 2.0 for portions from Adobe.
|
|
289
|
+
*
|
|
290
|
+
* Modifications have been made to adapt the code for use in this project.
|
|
291
|
+
*/
|
|
292
|
+
|
|
293
|
+
/**
|
|
294
|
+
* React hook that provides focus management and keyboard accessibility for a focusable element.
|
|
295
|
+
* Handles autofocus, disabled state, tab order, and merges focus and keyboard props.
|
|
296
|
+
*
|
|
297
|
+
* @param {UseFocusableProps} props - Props controlling focus behavior and accessibility.
|
|
298
|
+
* @param {RefObject<FocusableElement | null>} domRef - Ref to the DOM element to manage focus for.
|
|
299
|
+
* @returns {UseFocusableReturn} Object containing merged props for focusable behavior.
|
|
300
|
+
*/
|
|
301
|
+
declare function useFocusable(props: UseFocusableProps, domRef: RefObject<FocusableElement | null>): UseFocusableReturn;
|
|
302
|
+
|
|
303
|
+
/**
|
|
304
|
+
* Copyright (c) Corinvo, LLC. and affiliates.
|
|
305
|
+
*
|
|
306
|
+
* This source code is licensed under the MIT license found in the
|
|
307
|
+
* LICENSE file in the root directory of this source tree.
|
|
308
|
+
*
|
|
309
|
+
*/
|
|
310
|
+
|
|
311
|
+
/**
|
|
312
|
+
* Props for the useFocusRing hook.
|
|
313
|
+
*/
|
|
314
|
+
interface UseFocusRingProps {
|
|
315
|
+
/** Whether to track focus visibility within a subtree instead of just the element. */
|
|
316
|
+
within?: boolean;
|
|
317
|
+
/** Whether the target element is a text input. */
|
|
318
|
+
isTextInput?: boolean;
|
|
319
|
+
/** Whether the element should automatically receive focus when mounted. */
|
|
320
|
+
autoFocus?: boolean;
|
|
321
|
+
}
|
|
322
|
+
/**
|
|
323
|
+
* Return value for the useFocusRing hook.
|
|
324
|
+
*/
|
|
325
|
+
interface UseFocusRingReturn {
|
|
326
|
+
/** Whether the element is currently focused. */
|
|
327
|
+
isFocused: boolean;
|
|
328
|
+
/** Whether the focus is visible (e.g., due to keyboard navigation). */
|
|
329
|
+
isFocusVisible: boolean;
|
|
330
|
+
/** Props to spread onto the target element to enable focus ring behavior. */
|
|
331
|
+
focusProps: DOMAttributes;
|
|
332
|
+
}
|
|
333
|
+
|
|
334
|
+
/**
|
|
335
|
+
* Portions of this file are based on code from the React Aria Spectrum library by Adobe,
|
|
336
|
+
* licensed under the Apache License, Version 2.0.
|
|
337
|
+
* Copyright (c) Adobe. All rights reserved.
|
|
338
|
+
* See: https://github.com/adobe/react-spectrum
|
|
339
|
+
*
|
|
340
|
+
* Modifications copyright (c) Corinvo, LLC. and affiliates. All rights reserved.
|
|
341
|
+
*
|
|
342
|
+
* This file contains code licensed under:
|
|
343
|
+
* - The MIT License (see LICENSE in the root directory) for Corinvo modifications.
|
|
344
|
+
* - The Apache License, Version 2.0 for portions from Adobe.
|
|
345
|
+
*
|
|
346
|
+
* Modifications have been made to adapt the code for use in this project.
|
|
347
|
+
*/
|
|
348
|
+
|
|
349
|
+
/**
|
|
350
|
+
* React hook that manages focus state and focus ring visibility for an element.
|
|
351
|
+
*
|
|
352
|
+
* @param {UseFocusRingProps} [props] - Options to control focus ring behavior.
|
|
353
|
+
* @returns {UseFocusRingReturn} An object containing focus state, focus visibility, and props to spread on the target element.
|
|
354
|
+
*/
|
|
355
|
+
declare function useFocusRing(props?: UseFocusRingProps): UseFocusRingReturn;
|
|
356
|
+
|
|
357
|
+
/**
|
|
358
|
+
* Copyright (c) Corinvo, LLC. and affiliates.
|
|
359
|
+
*
|
|
360
|
+
* This source code is licensed under the MIT license found in the
|
|
361
|
+
* LICENSE file in the root directory of this source tree.
|
|
362
|
+
*
|
|
363
|
+
*/
|
|
364
|
+
/**
|
|
365
|
+
* Props for the useFocusVisible hook.
|
|
366
|
+
*/
|
|
367
|
+
interface UseFocusVisibleProps {
|
|
368
|
+
/** Whether the target element is a text input. */
|
|
369
|
+
isTextInput?: boolean;
|
|
370
|
+
/** Whether the element should automatically receive focus when mounted. */
|
|
371
|
+
autoFocus?: boolean;
|
|
372
|
+
}
|
|
373
|
+
/**
|
|
374
|
+
* Return value for the useFocusVisible hook.
|
|
375
|
+
*/
|
|
376
|
+
interface UseFocusVisibleReturn {
|
|
377
|
+
/** Whether focus is currently visible (e.g., due to keyboard navigation). */
|
|
378
|
+
isFocusVisible: boolean;
|
|
379
|
+
}
|
|
380
|
+
|
|
381
|
+
/**
|
|
382
|
+
* Portions of this file are based on code from the React Aria Spectrum library by Adobe,
|
|
383
|
+
* licensed under the Apache License, Version 2.0.
|
|
384
|
+
* Copyright (c) Adobe. All rights reserved.
|
|
385
|
+
* See: https://github.com/adobe/react-spectrum
|
|
386
|
+
*
|
|
387
|
+
* Modifications copyright (c) Corinvo, LLC. and affiliates. All rights reserved.
|
|
388
|
+
*
|
|
389
|
+
* This file contains code licensed under:
|
|
390
|
+
* - The MIT License (see LICENSE in the root directory) for Corinvo modifications.
|
|
391
|
+
* - The Apache License, Version 2.0 for portions from Adobe.
|
|
392
|
+
*
|
|
393
|
+
* Modifications have been made to adapt the code for use in this project.
|
|
394
|
+
*/
|
|
395
|
+
|
|
396
|
+
/**
|
|
397
|
+
* React hook that provides focus visibility tracking.
|
|
398
|
+
*
|
|
399
|
+
* @param {UseFocusVisibleProps} [props] - Options for focus visibility behavior.
|
|
400
|
+
* @returns {UseFocusVisibleReturn} An object containing the focus visibility state.
|
|
401
|
+
*/
|
|
402
|
+
declare function useFocusVisible(props?: UseFocusVisibleProps): UseFocusVisibleReturn;
|
|
403
|
+
|
|
404
|
+
/**
|
|
405
|
+
* Copyright (c) Corinvo, LLC. and affiliates.
|
|
406
|
+
*
|
|
407
|
+
* This source code is licensed under the MIT license found in the
|
|
408
|
+
* LICENSE file in the root directory of this source tree.
|
|
409
|
+
*
|
|
410
|
+
*/
|
|
411
|
+
/**
|
|
412
|
+
* Represents the type of user interaction modality that triggered focus.
|
|
413
|
+
*
|
|
414
|
+
* - 'keyboard': Focus was triggered via keyboard input (e.g., Tab key).
|
|
415
|
+
* - 'pointer': Focus was triggered via pointer input (e.g., mouse, touch).
|
|
416
|
+
* - 'virtual': Focus was triggered programmatically or by assistive technology.
|
|
417
|
+
*/
|
|
418
|
+
type Modality = 'keyboard' | 'pointer' | 'virtual';
|
|
419
|
+
/**
|
|
420
|
+
* Props for the useFocusVisibleListener hook.
|
|
421
|
+
*/
|
|
422
|
+
interface UseFocusVisibleListenerProps {
|
|
423
|
+
/** Function called when focus visibility changes. */
|
|
424
|
+
fn: (isFocusVisible: boolean) => void;
|
|
425
|
+
/** Dependency array that determines when to rebind the listener. */
|
|
426
|
+
deps: ReadonlyArray<any>;
|
|
427
|
+
/** Additional options for focus visibility tracking. */
|
|
428
|
+
opts?: {
|
|
429
|
+
isTextInput?: boolean;
|
|
430
|
+
};
|
|
431
|
+
}
|
|
432
|
+
|
|
433
|
+
/**
|
|
434
|
+
* Copyright (c) Corinvo, LLC. and affiliates.
|
|
435
|
+
*
|
|
436
|
+
* This source code is licensed under the MIT license found in the
|
|
437
|
+
* LICENSE file in the root directory of this source tree.
|
|
438
|
+
*
|
|
439
|
+
*/
|
|
440
|
+
|
|
441
|
+
/**
|
|
442
|
+
* Returns the current interaction modality.
|
|
443
|
+
*
|
|
444
|
+
* @returns {Modality | null} The current interaction modality (keyboard, pointer, or virtual) or null if unknown.
|
|
445
|
+
*/
|
|
446
|
+
declare function getInteractionModality(): Modality | null;
|
|
447
|
+
|
|
448
|
+
/**
|
|
449
|
+
* React hook that listens for focus visibility changes based on interaction modality.
|
|
450
|
+
*
|
|
451
|
+
* @param {UseFocusVisibleListenerProps} props - The props for the focus visible listener.
|
|
452
|
+
* @returns {void}
|
|
453
|
+
*/
|
|
454
|
+
declare function useFocusVisibleListener(props: UseFocusVisibleListenerProps): void;
|
|
455
|
+
|
|
456
|
+
/**
|
|
457
|
+
* Copyright (c) Corinvo, LLC. and affiliates.
|
|
458
|
+
*
|
|
459
|
+
* This source code is licensed under the MIT license found in the
|
|
460
|
+
* LICENSE file in the root directory of this source tree.
|
|
461
|
+
*
|
|
462
|
+
*/
|
|
463
|
+
|
|
464
|
+
/**
|
|
465
|
+
* Props for the useFocusWithin hook.
|
|
466
|
+
*/
|
|
467
|
+
interface UseFocusWithinProps {
|
|
468
|
+
/** Whether the focus events should be disabled. */
|
|
469
|
+
isDisabled?: boolean;
|
|
470
|
+
/** Handler that is called when focus enters the element or its descendants. */
|
|
471
|
+
onFocusWithin?: (e: FocusEvent) => void;
|
|
472
|
+
/** Handler that is called when focus leaves the element or its descendants. */
|
|
473
|
+
onBlurWithin?: (e: FocusEvent) => void;
|
|
474
|
+
/** Handler that is called when the focus state within the element changes. */
|
|
475
|
+
onFocusWithinChange?: (isFocusWithin: boolean) => void;
|
|
476
|
+
}
|
|
477
|
+
/**
|
|
478
|
+
* The result returned by the useFocusWithin hook.
|
|
479
|
+
*/
|
|
480
|
+
interface FocusWithinReturn {
|
|
481
|
+
/** Props to spread onto the target element to enable focus within tracking. */
|
|
482
|
+
focusWithinProps: DOMAttributes;
|
|
483
|
+
}
|
|
484
|
+
|
|
485
|
+
/**
|
|
486
|
+
* Portions of this file are based on code from the React Aria Spectrum library by Adobe,
|
|
487
|
+
* licensed under the Apache License, Version 2.0.
|
|
488
|
+
* Copyright (c) Adobe. All rights reserved.
|
|
489
|
+
* See: https://github.com/adobe/react-spectrum
|
|
490
|
+
*
|
|
491
|
+
* Modifications copyright (c) Corinvo, LLC. and affiliates. All rights reserved.
|
|
492
|
+
*
|
|
493
|
+
* This file contains code licensed under:
|
|
494
|
+
* - The MIT License (see LICENSE in the root directory) for Corinvo modifications.
|
|
495
|
+
* - The Apache License, Version 2.0 for portions from Adobe.
|
|
496
|
+
*
|
|
497
|
+
* Modifications have been made to adapt the code for use in this project.
|
|
498
|
+
*/
|
|
499
|
+
|
|
500
|
+
declare function useFocusWithin(props: UseFocusWithinProps): FocusWithinReturn;
|
|
501
|
+
|
|
502
|
+
/**
|
|
503
|
+
* Copyright (c) Corinvo, LLC. and affiliates.
|
|
504
|
+
*
|
|
505
|
+
* This source code is licensed under the MIT license found in the
|
|
506
|
+
* LICENSE file in the root directory of this source tree.
|
|
507
|
+
*
|
|
508
|
+
*/
|
|
509
|
+
/**
|
|
510
|
+
* Interface for managing global event listeners with enhanced type safety.
|
|
511
|
+
*/
|
|
512
|
+
interface UseGlobalListenersReturn {
|
|
513
|
+
/**
|
|
514
|
+
* Adds a global event listener to the specified element.
|
|
515
|
+
*
|
|
516
|
+
* @param el The target element.
|
|
517
|
+
* @param type The event type.
|
|
518
|
+
* @param listener The event listener function.
|
|
519
|
+
* @param options Optional options.
|
|
520
|
+
*/
|
|
521
|
+
addGlobalListener<K extends keyof WindowEventMap | keyof DocumentEventMap>(el: Window | EventTarget, type: K, listener: (this: Document, ev: K extends keyof WindowEventMap ? WindowEventMap[K] : K extends keyof DocumentEventMap ? DocumentEventMap[K] : never) => void, options?: boolean | AddEventListenerOptions): void;
|
|
522
|
+
/**
|
|
523
|
+
* Adds a global event listener to the specified element.
|
|
524
|
+
*
|
|
525
|
+
* @param el The target element.
|
|
526
|
+
* @param type The event type.
|
|
527
|
+
* @param listener The event listener function or object.
|
|
528
|
+
* @param options Optional options.
|
|
529
|
+
*/
|
|
530
|
+
addGlobalListener(el: EventTarget, type: string, listener: EventListenerOrEventListenerObject, options?: boolean | AddEventListenerOptions): void;
|
|
531
|
+
/**
|
|
532
|
+
* Removes a global event listener from the specified element.
|
|
533
|
+
*
|
|
534
|
+
* @param el The target element.
|
|
535
|
+
* @param type The event type.
|
|
536
|
+
* @param listener The event listener function.
|
|
537
|
+
* @param options Optional options.
|
|
538
|
+
*/
|
|
539
|
+
removeGlobalListener<K extends keyof WindowEventMap & keyof DocumentEventMap>(el: Window | EventTarget, type: K, listener: (this: Document, ev: K extends keyof WindowEventMap ? WindowEventMap[K] : DocumentEventMap[K]) => void, options?: boolean | EventListenerOptions): void;
|
|
540
|
+
/**
|
|
541
|
+
* Removes a global event listener from the specified element.
|
|
542
|
+
*
|
|
543
|
+
* @param el The target element.
|
|
544
|
+
* @param type The event type.
|
|
545
|
+
* @param listener The event listener function or object.
|
|
546
|
+
* @param options Optional options.
|
|
547
|
+
*/
|
|
548
|
+
removeGlobalListener(el: EventTarget, type: string, listener: EventListenerOrEventListenerObject, options?: boolean | EventListenerOptions): void;
|
|
549
|
+
/**
|
|
550
|
+
* Removes all global event listeners.
|
|
551
|
+
*/
|
|
552
|
+
removeAllGlobalListeners(): void;
|
|
553
|
+
}
|
|
554
|
+
|
|
555
|
+
/**
|
|
556
|
+
* Portions of this file are based on code from the React Aria Spectrum library by Adobe,
|
|
557
|
+
* licensed under the Apache License, Version 2.0.
|
|
558
|
+
* Copyright (c) Adobe. All rights reserved.
|
|
559
|
+
* See: https://github.com/adobe/react-spectrum
|
|
560
|
+
*
|
|
561
|
+
* Modifications copyright (c) Corinvo, LLC. and affiliates. All rights reserved.
|
|
562
|
+
*
|
|
563
|
+
* This file contains code licensed under:
|
|
564
|
+
* - The MIT License (see LICENSE in the root directory) for Corinvo modifications.
|
|
565
|
+
* - The Apache License, Version 2.0 for portions from Adobe.
|
|
566
|
+
*
|
|
567
|
+
* Modifications have been made to adapt the code for use in this project.
|
|
568
|
+
*/
|
|
569
|
+
|
|
570
|
+
declare function useGlobalListeners(): UseGlobalListenersReturn;
|
|
571
|
+
|
|
572
|
+
/**
|
|
573
|
+
* Copyright (c) Corinvo, LLC. and affiliates.
|
|
574
|
+
*
|
|
575
|
+
* This source code is licensed under the MIT license found in the
|
|
576
|
+
* LICENSE file in the root directory of this source tree.
|
|
577
|
+
*
|
|
578
|
+
*/
|
|
579
|
+
|
|
580
|
+
/**
|
|
581
|
+
* Props for the useHover hook.
|
|
582
|
+
*/
|
|
583
|
+
interface UseHoverProps extends HoverEvent {
|
|
584
|
+
/** Whether hover events are disabled. */
|
|
585
|
+
isDisabled?: boolean;
|
|
586
|
+
/** Called when a hover interaction starts. */
|
|
587
|
+
onHoverStart?: (event: HoverEvent) => void;
|
|
588
|
+
/** Called when a hover interaction ends. */
|
|
589
|
+
onHoverEnd?: (event: HoverEvent) => void;
|
|
590
|
+
/** Called when the hover state changes. */
|
|
591
|
+
onHoverChange?: (isHovered: boolean) => void;
|
|
592
|
+
}
|
|
593
|
+
/**
|
|
594
|
+
* Return type for the useHover hook.
|
|
595
|
+
*/
|
|
596
|
+
interface UseHoverReturn {
|
|
597
|
+
/** Props that can be passed on to render in the DOM. */
|
|
598
|
+
hoverProps: DOMAttributes;
|
|
599
|
+
/** Wether the current context is hovered or not. */
|
|
600
|
+
isHovered: boolean;
|
|
601
|
+
}
|
|
602
|
+
|
|
603
|
+
/**
|
|
604
|
+
* React hook that manages hover state and hover event handlers for an element.
|
|
605
|
+
*
|
|
606
|
+
* @param {UseHoverProps} [props] - Options to control hover behavior and event handlers.
|
|
607
|
+
* @returns {UseHoverReturn} An object containing hover state and props to spread on the target element.
|
|
608
|
+
*/
|
|
609
|
+
declare function useHover(props?: UseHoverProps): UseHoverReturn;
|
|
610
|
+
|
|
611
|
+
/**
|
|
612
|
+
* Copyright (c) Corinvo, LLC. and affiliates.
|
|
613
|
+
*
|
|
614
|
+
* This source code is licensed under the MIT license found in the
|
|
615
|
+
* LICENSE file in the root directory of this source tree.
|
|
616
|
+
*
|
|
617
|
+
*/
|
|
618
|
+
/**
|
|
619
|
+
* Props for the useId hook.
|
|
620
|
+
*/
|
|
621
|
+
interface UseIdProps {
|
|
622
|
+
/** Optional custom prefix for the generated ID. */
|
|
623
|
+
prefix?: string;
|
|
624
|
+
/** Optional default ID to use instead of generating one. */
|
|
625
|
+
defaultId?: string;
|
|
626
|
+
}
|
|
627
|
+
|
|
628
|
+
/**
|
|
629
|
+
* Generates a unique, stable ID for React components, optionally with a custom prefix.
|
|
630
|
+
*
|
|
631
|
+
* @param {UseIdProps} [props] - Optional props object. You can provide a custom prefix and/or a defaultId.
|
|
632
|
+
* @returns {UseIdReturns} The generated or provided unique ID.
|
|
633
|
+
*/
|
|
634
|
+
declare function useId(props?: UseIdProps): string;
|
|
635
|
+
|
|
636
|
+
/**
|
|
637
|
+
* Copyright (c) Corinvo, LLC. and affiliates.
|
|
638
|
+
*
|
|
639
|
+
* This source code is licensed under the MIT license found in the
|
|
640
|
+
* LICENSE file in the root directory of this source tree.
|
|
641
|
+
*
|
|
642
|
+
*/
|
|
643
|
+
|
|
644
|
+
/**
|
|
645
|
+
* Props for the useKeyboard hook.
|
|
646
|
+
*/
|
|
647
|
+
interface UseKeyboardProps extends KeyboardEvents {
|
|
648
|
+
/**
|
|
649
|
+
* Whether the keyboard interaction is disabled.
|
|
650
|
+
* Defaults to false.
|
|
651
|
+
*/
|
|
652
|
+
isDisabled?: boolean;
|
|
653
|
+
}
|
|
654
|
+
/**
|
|
655
|
+
* Return value of the useKeyboard hook.
|
|
656
|
+
*/
|
|
657
|
+
interface UseKeyboardReturn {
|
|
658
|
+
/**
|
|
659
|
+
* Props to be spread onto the target element to enable keyboard interactions.
|
|
660
|
+
*/
|
|
661
|
+
keyboardProps: DOMAttributes;
|
|
662
|
+
}
|
|
663
|
+
|
|
664
|
+
/**
|
|
665
|
+
* Copyright (c) Corinvo, LLC. and affiliates.
|
|
666
|
+
*
|
|
667
|
+
* This source code is licensed under the MIT license found in the
|
|
668
|
+
* LICENSE file in the root directory of this source tree.
|
|
669
|
+
*
|
|
670
|
+
*/
|
|
671
|
+
|
|
672
|
+
/**
|
|
673
|
+
* React hook that provides keyboard event handlers based on the disabled state.
|
|
674
|
+
*
|
|
675
|
+
* @param {UseKeyboardProps} props - Props controlling keyboard interaction.
|
|
676
|
+
* @returns {UseKeyboardReturn} Object containing keyboard event handler props.
|
|
677
|
+
*/
|
|
678
|
+
declare function useKeyboard(props: UseKeyboardProps): UseKeyboardReturn;
|
|
679
|
+
|
|
680
|
+
/**
|
|
681
|
+
* Copyright (c) Corinvo, LLC. and affiliates.
|
|
682
|
+
*
|
|
683
|
+
* This source code is licensed under the MIT license found in the
|
|
684
|
+
* LICENSE file in the root directory of this source tree.
|
|
685
|
+
*
|
|
686
|
+
*/
|
|
687
|
+
|
|
688
|
+
/**
|
|
689
|
+
* Specifies how the mounted state should be accessed.
|
|
690
|
+
*/
|
|
691
|
+
type MountedAccessType = 'function' | 'ref' | 'boolean';
|
|
692
|
+
/**
|
|
693
|
+
* Props for the useMounted hook.
|
|
694
|
+
*/
|
|
695
|
+
interface UseMountedProps {
|
|
696
|
+
/** The type of access to the mounted state. */
|
|
697
|
+
type?: MountedAccessType;
|
|
698
|
+
}
|
|
699
|
+
/**
|
|
700
|
+
* Return type for the useMounted hook, varies based on the access type.
|
|
701
|
+
*
|
|
702
|
+
* - 'ref': Returns a RefObject containing the mounted state
|
|
703
|
+
* - 'boolean': Returns a boolean value directly
|
|
704
|
+
* - 'function': Returns a function that returns the current mounted state
|
|
705
|
+
*/
|
|
706
|
+
type UseMountedReturn<T extends MountedAccessType> = T extends 'ref' ? RefObject<boolean> : T extends 'boolean' ? boolean : () => boolean;
|
|
707
|
+
|
|
708
|
+
/**
|
|
709
|
+
* Copyright (c) Corinvo, LLC. and affiliates.
|
|
710
|
+
*
|
|
711
|
+
* This source code is licensed under the MIT license found in the
|
|
712
|
+
* LICENSE file in the root directory of this source tree.
|
|
713
|
+
*
|
|
714
|
+
*/
|
|
715
|
+
|
|
716
|
+
/**
|
|
717
|
+
* React hook that tracks whether a component is mounted.
|
|
718
|
+
*
|
|
719
|
+
* @template T The type of access to the mounted state (function, ref, or boolean).
|
|
720
|
+
* @param {UseMountedProps & { type: T }} [props] - Options to configure the hook behavior.
|
|
721
|
+
* @returns {UseMountedReturn<T>} The mounted state in the requested format.
|
|
722
|
+
*/
|
|
723
|
+
declare function useMounted<T extends MountedAccessType = 'function'>(props?: UseMountedProps & {
|
|
724
|
+
type: T;
|
|
725
|
+
}): UseMountedReturn<T>;
|
|
726
|
+
|
|
727
|
+
/**
|
|
728
|
+
* Copyright (c) Corinvo, LLC. and affiliates.
|
|
729
|
+
*
|
|
730
|
+
* This source code is licensed under the MIT license found in the
|
|
731
|
+
* LICENSE file in the root directory of this source tree.
|
|
732
|
+
*
|
|
733
|
+
*/
|
|
734
|
+
|
|
735
|
+
/**
|
|
736
|
+
* Props for the usePress hook.
|
|
737
|
+
*/
|
|
738
|
+
interface UsePressProps {
|
|
739
|
+
/** Whether the press interaction is disabled. */
|
|
740
|
+
isDisabled?: boolean;
|
|
741
|
+
/** Prevents the element from receiving focus when pressed. */
|
|
742
|
+
preventFocusOnPress?: boolean;
|
|
743
|
+
/** Allows text selection during press interactions. */
|
|
744
|
+
allowTextSelectionOnPress?: boolean;
|
|
745
|
+
/** Ref to the target DOM element. */
|
|
746
|
+
ref?: RefObject<HTMLElement>;
|
|
747
|
+
/** Handler called when a press interaction is successfully completed. */
|
|
748
|
+
onPress?: (e: PressEvent) => void;
|
|
749
|
+
/** Handler called when a press interaction starts (e.g., mouse down, touch start, key down). */
|
|
750
|
+
onPressStart?: (e: PressEvent) => void;
|
|
751
|
+
/** Handler called when a press interaction ends (e.g., mouse up, touch end, key up). */
|
|
752
|
+
onPressEnd?: (e: PressEvent) => void;
|
|
753
|
+
/** Handler called when the pressed state changes. */
|
|
754
|
+
onPressChange?: (isPressed: boolean) => void;
|
|
755
|
+
/** Handler called when a press is released over the target. */
|
|
756
|
+
onPressUp?: (e: PressEvent) => void;
|
|
757
|
+
/** Handler called on click events for compatibility. */
|
|
758
|
+
onClick?: (e: MouseEvent) => void;
|
|
759
|
+
}
|
|
760
|
+
/**
|
|
761
|
+
* Return type for the usePress hook.
|
|
762
|
+
*/
|
|
763
|
+
interface UsePressReturn {
|
|
764
|
+
/** Props to spread onto the target element to enable press interactions. */
|
|
765
|
+
pressProps: {
|
|
766
|
+
onMouseDown?: (e: MouseEvent) => void;
|
|
767
|
+
onMouseUp?: (e: MouseEvent) => void;
|
|
768
|
+
onMouseLeave?: (e: MouseEvent) => void;
|
|
769
|
+
onMouseEnter?: (e: MouseEvent) => void;
|
|
770
|
+
onTouchStart?: (e: TouchEvent) => void;
|
|
771
|
+
onTouchEnd?: (e: TouchEvent) => void;
|
|
772
|
+
onKeyDown?: (e: KeyboardEvent) => void;
|
|
773
|
+
onKeyUp?: (e: KeyboardEvent) => void;
|
|
774
|
+
onClick?: (e: MouseEvent) => void;
|
|
775
|
+
};
|
|
776
|
+
/** Whether the element is currently pressed. */
|
|
777
|
+
isPressed: boolean;
|
|
778
|
+
}
|
|
779
|
+
|
|
780
|
+
/**
|
|
781
|
+
* Copyright (c) Corinvo, LLC. and affiliates.
|
|
782
|
+
*
|
|
783
|
+
* This source code is licensed under the MIT license found in the
|
|
784
|
+
* LICENSE file in the root directory of this source tree.
|
|
785
|
+
*
|
|
786
|
+
*/
|
|
787
|
+
|
|
788
|
+
/**
|
|
789
|
+
* Provides press (mouse, touch, keyboard) interaction logic for UI components.
|
|
790
|
+
* Handles accessibility, text selection, and emulated event quirks for consistent press behavior.
|
|
791
|
+
*
|
|
792
|
+
* @param {UsePressProps} props - Configuration options and event handlers for the press interaction.
|
|
793
|
+
* @returns {UsePressReturn} An object containing press event props to spread onto your element and the current pressed state.
|
|
794
|
+
*/
|
|
795
|
+
declare function usePress(props?: UsePressProps): UsePressReturn;
|
|
796
|
+
|
|
797
|
+
/**
|
|
798
|
+
* Copyright (c) Corinvo, LLC. and affiliates.
|
|
799
|
+
*
|
|
800
|
+
* This source code is licensed under the MIT license found in the
|
|
801
|
+
* LICENSE file in the root directory of this source tree.
|
|
802
|
+
*
|
|
803
|
+
*/
|
|
804
|
+
|
|
805
|
+
/**
|
|
806
|
+
* Props for the useRendererHook
|
|
807
|
+
*/
|
|
808
|
+
interface UseRendererProps<T> extends RenderProps<T> {
|
|
809
|
+
id?: string;
|
|
810
|
+
values: T;
|
|
811
|
+
defaultChildren?: ReactNode;
|
|
812
|
+
defaultClassName?: string;
|
|
813
|
+
defaultStyle?: CSSProperties;
|
|
814
|
+
[dataAttr: `data-${string}`]: string | undefined;
|
|
815
|
+
}
|
|
816
|
+
/**
|
|
817
|
+
* Return type for the useRenderer hook.
|
|
818
|
+
*/
|
|
819
|
+
interface UseRendererReturn {
|
|
820
|
+
className?: string;
|
|
821
|
+
style?: CSSProperties;
|
|
822
|
+
children?: ReactNode;
|
|
823
|
+
}
|
|
824
|
+
|
|
825
|
+
/**
|
|
826
|
+
* Copyright (c) Corinvo, LLC. and affiliates.
|
|
827
|
+
*
|
|
828
|
+
* This source code is licensed under the MIT license found in the
|
|
829
|
+
* LICENSE file in the root directory of this source tree.
|
|
830
|
+
*
|
|
831
|
+
*/
|
|
832
|
+
|
|
833
|
+
declare function useRenderer<T>(props: UseRendererProps<T>): UseRendererReturn;
|
|
834
|
+
|
|
835
|
+
/**
|
|
836
|
+
* Copyright (c) Corinvo, LLC. and affiliates.
|
|
837
|
+
*
|
|
838
|
+
* This source code is licensed under the MIT license found in the
|
|
839
|
+
* LICENSE file in the root directory of this source tree.
|
|
840
|
+
*
|
|
841
|
+
*/
|
|
842
|
+
|
|
843
|
+
/**
|
|
844
|
+
* Props for the useSlottedContext hook.
|
|
845
|
+
*/
|
|
846
|
+
interface UseSlottedContextProps<T> {
|
|
847
|
+
/**
|
|
848
|
+
* The React context to consume, which may be a slotted context value or a direct value.
|
|
849
|
+
*/
|
|
850
|
+
context: Context<{
|
|
851
|
+
slots?: Record<string | symbol, T>;
|
|
852
|
+
} | T | null | undefined>;
|
|
853
|
+
/**
|
|
854
|
+
* The slot name to retrieve from the context. If null, context is not used.
|
|
855
|
+
*/
|
|
856
|
+
slot?: string | null;
|
|
857
|
+
}
|
|
858
|
+
/**
|
|
859
|
+
* Return type for the useSlottedContext hook.
|
|
860
|
+
*/
|
|
861
|
+
type UseSlottedContextReturn<T> = T | null | undefined;
|
|
862
|
+
|
|
863
|
+
/**
|
|
864
|
+
* Portions of this file are based on code from the React Aria Spectrum library by Adobe,
|
|
865
|
+
* licensed under the Apache License, Version 2.0.
|
|
866
|
+
* Copyright (c) Adobe. All rights reserved.
|
|
867
|
+
* See: https://github.com/adobe/react-spectrum
|
|
868
|
+
*
|
|
869
|
+
* Modifications copyright (c) Corinvo, LLC. and affiliates. All rights reserved.
|
|
870
|
+
*
|
|
871
|
+
* This file contains code licensed under:
|
|
872
|
+
* - The MIT License (see LICENSE in the root directory) for Corinvo modifications.
|
|
873
|
+
* - The Apache License, Version 2.0 for portions from Adobe.
|
|
874
|
+
*
|
|
875
|
+
* Modifications have been made to adapt the code for use in this project.
|
|
876
|
+
*/
|
|
877
|
+
|
|
878
|
+
/**
|
|
879
|
+
* Retrieves a value from a React context, optionally using a named slot.
|
|
880
|
+
* Returns the slot value if available, the direct context value, or null/undefined.
|
|
881
|
+
* Throws an error if a specified slot does not exist in the context.
|
|
882
|
+
*
|
|
883
|
+
* @param {UseSlottedContextProps<T>} props - The context and optional slot name.
|
|
884
|
+
* @returns {UseSlottedContextReturn<T>} The value for the given slot, the direct context value, or null/undefined.
|
|
885
|
+
*/
|
|
886
|
+
declare function useSlottedContext<T>(props: UseSlottedContextProps<T>): UseSlottedContextReturn<T>;
|
|
887
|
+
|
|
888
|
+
/**
|
|
889
|
+
* Copyright (c) Corinvo, LLC. and affiliates.
|
|
890
|
+
*
|
|
891
|
+
* This source code is licensed under the MIT license found in the
|
|
892
|
+
* LICENSE file in the root directory of this source tree.
|
|
893
|
+
*
|
|
894
|
+
*/
|
|
895
|
+
|
|
896
|
+
/**
|
|
897
|
+
* Props for synchronizing a context ref with a local ref.
|
|
898
|
+
*
|
|
899
|
+
* @template T The type of the element or value referenced.
|
|
900
|
+
*/
|
|
901
|
+
interface UseSyncContextRefProps<T> {
|
|
902
|
+
/**
|
|
903
|
+
* Optional context object containing a ref to synchronize.
|
|
904
|
+
*/
|
|
905
|
+
context?: {
|
|
906
|
+
ref?: RefObject<T | null>;
|
|
907
|
+
};
|
|
908
|
+
/**
|
|
909
|
+
* Optional local ref to synchronize with the context ref.
|
|
910
|
+
*/
|
|
911
|
+
ref?: RefObject<T | null>;
|
|
912
|
+
}
|
|
913
|
+
|
|
914
|
+
/**
|
|
915
|
+
* Portions of this file are based on code from the React Aria Spectrum library by Adobe,
|
|
916
|
+
* licensed under the Apache License, Version 2.0.
|
|
917
|
+
* Copyright (c) Adobe. All rights reserved.
|
|
918
|
+
* See: https://github.com/adobe/react-spectrum
|
|
919
|
+
*
|
|
920
|
+
* Modifications copyright (c) Corinvo, LLC. and affiliates. All rights reserved.
|
|
921
|
+
*
|
|
922
|
+
* This file contains code licensed under:
|
|
923
|
+
* - The MIT License (see LICENSE in the root directory) for Corinvo modifications.
|
|
924
|
+
* - The Apache License, Version 2.0 for portions from Adobe.
|
|
925
|
+
*
|
|
926
|
+
* Modifications have been made to adapt the code for use in this project.
|
|
927
|
+
*/
|
|
928
|
+
|
|
929
|
+
declare function useSyncContextRef<T>(props?: UseSyncContextRefProps<T>): void;
|
|
930
|
+
|
|
931
|
+
/**
|
|
932
|
+
* Copyright (c) Corinvo, LLC. and affiliates.
|
|
933
|
+
*
|
|
934
|
+
* This source code is licensed under the MIT license found in the
|
|
935
|
+
* LICENSE file in the root directory of this source tree.
|
|
936
|
+
*
|
|
937
|
+
*/
|
|
938
|
+
|
|
939
|
+
/**
|
|
940
|
+
* Props for the useSyntheticBlurEvent hook.
|
|
941
|
+
*/
|
|
942
|
+
interface UseSyntheticBlurEventProps<T extends Element = Element> {
|
|
943
|
+
/**
|
|
944
|
+
* Handler called when the blur event is triggered on the target element.
|
|
945
|
+
* Receives a React FocusEvent for the target element.
|
|
946
|
+
*/
|
|
947
|
+
onBlur: (event: FocusEvent<T>) => void;
|
|
948
|
+
}
|
|
949
|
+
/**
|
|
950
|
+
* Return type for the useSyntheticBlurEvent hook.
|
|
951
|
+
*/
|
|
952
|
+
type UseSyntheticBlurEventReturn<T> = (event: FocusEvent<T>) => void;
|
|
953
|
+
|
|
954
|
+
/**
|
|
955
|
+
* Portions of this file are based on code from the React Aria Spectrum library by Adobe,
|
|
956
|
+
* licensed under the Apache License, Version 2.0.
|
|
957
|
+
* Copyright (c) Adobe. All rights reserved.
|
|
958
|
+
* See: https://github.com/adobe/react-spectrum
|
|
959
|
+
*
|
|
960
|
+
* Modifications copyright (c) Corinvo, LLC. and affiliates. All rights reserved.
|
|
961
|
+
*
|
|
962
|
+
* This file contains code licensed under:
|
|
963
|
+
* - The MIT License (see LICENSE in the root directory) for Corinvo modifications.
|
|
964
|
+
* - The Apache License, Version 2.0 for portions from Adobe.
|
|
965
|
+
*
|
|
966
|
+
* Modifications have been made to adapt the code for use in this project.
|
|
967
|
+
*/
|
|
968
|
+
|
|
969
|
+
/**
|
|
970
|
+
* React hook to handle synthetic blur events, particularly for disabled elements.
|
|
971
|
+
*
|
|
972
|
+
* @param onBlur - Callback to handle the blur event.
|
|
973
|
+
* @returns A callback to attach to the element's blur event.
|
|
974
|
+
*/
|
|
975
|
+
declare function useSyntheticBlurEvent<T extends Element = Element>(props: UseSyntheticBlurEventProps<T>): UseSyntheticBlurEventReturn<T>;
|
|
976
|
+
|
|
977
|
+
/**
|
|
978
|
+
* Returns a stable event callback that always invokes the latest version of the provided function.
|
|
979
|
+
*
|
|
980
|
+
* @param {T} fn - The event handler function to stabilize.
|
|
981
|
+
* @returns {T} A memoized callback that always calls the latest version of `fn`.
|
|
982
|
+
*/
|
|
983
|
+
declare function useEffectEvent<T extends (...args: any[]) => any>(fn: T): T;
|
|
984
|
+
|
|
985
|
+
/**
|
|
986
|
+
* Copyright (c) Corinvo, LLC. and affiliates.
|
|
987
|
+
*
|
|
988
|
+
* This source code is licensed under the MIT license found in the
|
|
989
|
+
* LICENSE file in the root directory of this source tree.
|
|
990
|
+
*
|
|
991
|
+
*/
|
|
992
|
+
/**
|
|
993
|
+
* React hook that determines if a browser feature is supported.
|
|
994
|
+
*
|
|
995
|
+
* @param {() => unknown} fn - Function that tests for feature support.
|
|
996
|
+
* @returns {boolean} Whether the feature is supported in the current environment.
|
|
997
|
+
*/
|
|
998
|
+
declare function useSupported(fn: () => unknown): boolean;
|
|
999
|
+
|
|
1000
|
+
export { type FocusWithinReturn, type UseContextPropsProps, type UseContextPropsReturn, type UseDisabledProps, type UseDisabledPropsProps, type UseDisabledPropsPropsReturn, type UseDisabledPropsReturn, type UseElementVisibilityProps, type UseElementVisibilityReturn, type UseFocusProps, type UseFocusReturn, type UseFocusRingProps, type UseFocusRingReturn, type UseFocusVisibleListenerProps, type UseFocusVisibleProps, type UseFocusVisibleReturn, type UseFocusWithinProps, type UseFocusableProps, type UseFocusableReturn, type UseGlobalListenersReturn, type UseHoverProps, type UseHoverReturn, type UseIdProps, type UseMountedProps, type UseMountedReturn, type UsePressProps, type UsePressReturn, type UseRendererProps, type UseRendererReturn, type UseSlottedContextProps, type UseSlottedContextReturn, type UseSyncContextRefProps, type UseSyntheticBlurEventProps, type UseSyntheticBlurEventReturn, getInteractionModality, useContextProps, useDisabled, useDisabledProps, useEffectEvent, useElementVisibility, useFocus, useFocusRing, useFocusVisible, useFocusVisibleListener, useFocusWithin, useFocusable, useGlobalListeners, useHover, useId, useKeyboard, useMounted, usePress, useRenderer, useSlottedContext, useSupported, useSyncContextRef, useSyntheticBlurEvent };
|