@ringcentral/spring-base 1.9.3 → 1.11.1

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.
Files changed (49) hide show
  1. package/hooks.js +108 -20
  2. package/package.json +1 -1
  3. package/src/config.d.ts +2 -2
  4. package/src/contexts/ResponsiveContext/ResponsiveContext.d.ts +1 -1
  5. package/src/contexts/ResponsiveContext/types.d.ts +8 -8
  6. package/src/contexts/WindowContext.d.ts +1 -1
  7. package/src/hooks/useA11yKeyEvent/useA11yKeyEvent.d.ts +2 -2
  8. package/src/hooks/useActive/useActive.d.ts +5 -5
  9. package/src/hooks/useAnnouncer/useAnnouncer.d.ts +1 -1
  10. package/src/hooks/useAriaHideOutside/useAriaHideOutside.d.ts +1 -1
  11. package/src/hooks/useAudio/useAudio.d.ts +1 -1
  12. package/src/hooks/useBodyScrollLock/bodyScrollLock.d.ts +1 -1
  13. package/src/hooks/useBodyScrollLock/useBodyScrollLock.d.ts +1 -1
  14. package/src/hooks/useClickAway/useClickAway.d.ts +3 -3
  15. package/src/hooks/useDebounce/useDebounce.d.ts +1 -1
  16. package/src/hooks/useEventListener/useEventListener.d.ts +2 -2
  17. package/src/hooks/useFocusVisible/useFocusVisible.d.ts +1 -1
  18. package/src/hooks/useGlobalListener/createGlobalListener.d.ts +2 -2
  19. package/src/hooks/useGlobalListener/useGlobalListener.d.ts +2 -2
  20. package/src/hooks/useHover/useHover.d.ts +3 -3
  21. package/src/hooks/useHover/useHoverDirty.d.ts +1 -1
  22. package/src/hooks/useImgLoaded/useImgLoaded.d.ts +2 -2
  23. package/src/hooks/useKeyDownOnce/useKeyDownOnce.d.ts +3 -3
  24. package/src/hooks/useKeyboardMoveFocus/moveIndexInTwoDimension.d.ts +1 -1
  25. package/src/hooks/useKeyboardMoveFocus/useKeyboardMoveFocus.d.ts +1 -1
  26. package/src/hooks/useKeyboardMoveFocus/useOnlyOneFocusable.d.ts +2 -2
  27. package/src/hooks/useLongPress/useLongPress.d.ts +3 -3
  28. package/src/hooks/useOnLayoutReRender/useOnLayoutReRender.d.ts +1 -1
  29. package/src/hooks/useOnReRender/useOnReRender.d.ts +1 -1
  30. package/src/hooks/useRefState/useRefState.d.ts +1 -1
  31. package/src/hooks/useResizeObserver/useResizeObserver.d.ts +1 -1
  32. package/src/hooks/useResponsiveMatch/useResponsiveMatch.d.ts +1 -1
  33. package/src/hooks/useRetry/useRetry.d.ts +2 -2
  34. package/src/hooks/useThrottle/useThrottle.d.ts +1 -1
  35. package/src/hooks/useVirtuosoExternalWindow/useVirtuosoExternalWindow.d.ts +1 -1
  36. package/src/typings/BaseColor.d.ts +2 -2
  37. package/src/typings/BaseSize.d.ts +3 -3
  38. package/src/typings/ComponentTypes.d.ts +10 -10
  39. package/src/typings/ExtractValue.d.ts +2 -2
  40. package/src/typings/OverridableTypes.d.ts +4 -4
  41. package/src/typings/UnionOmit.d.ts +3 -3
  42. package/src/typings/UnitMap.d.ts +4 -4
  43. package/src/utils/classes/globalStateClasses.d.ts +1 -1
  44. package/src/utils/classes/useClasses.d.ts +2 -2
  45. package/src/utils/combineProps.d.ts +1 -1
  46. package/src/utils/devlog.d.ts +1 -1
  47. package/src/utils/getRefElement.d.ts +1 -1
  48. package/src/utils/removeClassName.d.ts +1 -1
  49. package/src/utils/runKeyHandler.d.ts +1 -1
package/hooks.js CHANGED
@@ -1,7 +1,7 @@
1
1
  import { unstable_useEventCallback, unstable_ownerDocument, unstable_Timeout, unstable_useForkRef } from '@mui/utils';
2
2
  export { unstable_useControlled as useControlled } from '@mui/utils';
3
3
  import * as React from 'react';
4
- import { useState, useEffect, useRef, useCallback, useLayoutEffect, useMemo } from 'react';
4
+ import { useState, useRef, useEffect, useCallback, useLayoutEffect, useMemo } from 'react';
5
5
  import { useWindowContext, useResponsiveContext, getMatchDetail } from './contexts.js';
6
6
  import uniqueId from 'lodash/uniqueId';
7
7
  import { useButton as useButton$1 } from '@mui/base/useButton';
@@ -41,10 +41,13 @@ const isNativeButton = (el) => {
41
41
  };
42
42
  const useActive = ({ onKeyDown, onKeyUp, onMouseDown, onClick, disabled = false, } = {}) => {
43
43
  const [active, setActive] = useState(false);
44
+ const activeTargetRef = useRef(null);
44
45
  const { document: targetDocument = document } = useWindowContext();
45
46
  useEffect(() => {
46
- if (disabled)
47
+ if (disabled) {
47
48
  setActive(false);
49
+ activeTargetRef.current = null;
50
+ }
48
51
  }, [disabled]);
49
52
  if (disabled) {
50
53
  return {
@@ -63,16 +66,19 @@ const useActive = ({ onKeyDown, onKeyUp, onMouseDown, onClick, disabled = false,
63
66
  }, { once: true });
64
67
  };
65
68
  const handleKeyDown = (event) => {
69
+ const isSpaceKey = event.key === ' ';
66
70
  onKeyDown?.(event);
67
71
  if (event.defaultPrevented) {
72
+ if (isSpaceKey) {
73
+ activeTargetRef.current = null;
74
+ }
68
75
  return;
69
76
  }
70
- if (event.target === event.currentTarget &&
71
- !isNativeButton(event.target) &&
72
- event.key === ' ') {
73
- event.preventDefault();
74
- }
75
- if (event.target === event.currentTarget && event.key === ' ') {
77
+ if (event.target === event.currentTarget && isSpaceKey) {
78
+ activeTargetRef.current = event.currentTarget;
79
+ if (!isNativeButton(event.target)) {
80
+ event.preventDefault();
81
+ }
76
82
  setActive(true);
77
83
  }
78
84
  if (event.target === event.currentTarget &&
@@ -83,13 +89,19 @@ const useActive = ({ onKeyDown, onKeyUp, onMouseDown, onClick, disabled = false,
83
89
  }
84
90
  };
85
91
  const handleKeyUp = (event) => {
92
+ const isSpaceKey = event.key === ' ';
86
93
  if (event.target === event.currentTarget) {
87
94
  setActive(false);
88
95
  }
89
96
  onKeyUp?.(event);
90
- if (event.target === event.currentTarget &&
97
+ const hadMatchingSpaceKeyDown = activeTargetRef.current === event.currentTarget;
98
+ if (isSpaceKey) {
99
+ activeTargetRef.current = null;
100
+ }
101
+ if (hadMatchingSpaceKeyDown &&
102
+ event.target === event.currentTarget &&
91
103
  !isNativeButton(event.target) &&
92
- event.key === ' ' &&
104
+ isSpaceKey &&
93
105
  !event.defaultPrevented) {
94
106
  onClick?.(event);
95
107
  }
@@ -140,19 +152,36 @@ const visuallyHiddenStyles = `
140
152
  `;
141
153
  const useAnnouncer = (id) => {
142
154
  const _id = useId(id ? `rc-announcer-${id}` : 'rc-announcer', !id);
155
+ const { document: targetDocument, externalWindow, globalThis: contextGlobal, } = useWindowContext();
156
+ const win = externalWindow ?? contextGlobal;
143
157
  const ref = useRef(null);
158
+ const lastMessageRef = useRef();
159
+ const pendingTimerRef = useRef(null);
160
+ const clearPendingTimer = useCallback(() => {
161
+ pendingTimerRef.current?.();
162
+ pendingTimerRef.current = null;
163
+ }, []);
144
164
  useEffect(() => {
145
- const el = document.createElement('div');
165
+ const currentDocument = targetDocument ??
166
+ (typeof contextGlobal.document !== 'undefined'
167
+ ? contextGlobal.document
168
+ : undefined);
169
+ if (!currentDocument?.body) {
170
+ return undefined;
171
+ }
172
+ const el = currentDocument.createElement('div');
146
173
  ref.current = el;
147
174
  el.id = _id;
148
175
  el.setAttribute('aria-live', 'assertive');
149
176
  el.setAttribute('aria-atomic', 'true');
150
177
  el.setAttribute('aria-hidden', 'false');
178
+ el.setAttribute('data-live-announcer', 'true');
151
179
  el.setAttribute('style', visuallyHiddenStyles);
152
- document.body.appendChild(el);
180
+ currentDocument.body.appendChild(el);
153
181
  return () => {
154
- setTimeout(() => {
155
- const body = document.body;
182
+ clearPendingTimer();
183
+ win.setTimeout(() => {
184
+ const body = currentDocument.body;
156
185
  if (body.contains(el)) {
157
186
  body.removeChild(el);
158
187
  }
@@ -161,14 +190,37 @@ const useAnnouncer = (id) => {
161
190
  }
162
191
  });
163
192
  };
164
- }, [_id]);
193
+ }, [_id, targetDocument, contextGlobal, win, clearPendingTimer]);
165
194
  return useCallback((message) => {
166
195
  const el = ref.current;
167
- if (el && message) {
168
- el.setAttribute('aria-hidden', 'false');
196
+ if (!el)
197
+ return;
198
+ clearPendingTimer();
199
+ if (!message) {
200
+ el.textContent = '';
201
+ lastMessageRef.current = undefined;
202
+ return;
203
+ }
204
+ if (lastMessageRef.current !== message) {
169
205
  el.textContent = message;
206
+ lastMessageRef.current = message;
207
+ return;
170
208
  }
171
- }, []);
209
+ el.textContent = '\u200B';
210
+ const timerId = win.setTimeout(() => {
211
+ if (el && ref.current === el) {
212
+ el.textContent = message;
213
+ lastMessageRef.current = message;
214
+ }
215
+ if (pendingTimerRef.current === cancelTimer) {
216
+ pendingTimerRef.current = null;
217
+ }
218
+ }, 100);
219
+ const cancelTimer = () => {
220
+ win.clearTimeout(timerId);
221
+ };
222
+ pendingTimerRef.current = cancelTimer;
223
+ }, [clearPendingTimer, win]);
172
224
  };
173
225
 
174
226
  function useButton(parameters) {
@@ -486,6 +538,18 @@ const useFocusVisible = ({ onFocusVisible, onFocus, onBlur, within = false, } =
486
538
  const { isFocusVisibleRef, onFocus: handleFocusVisible, onBlur: handleBlurVisible, ref: focusVisibleRef, } = useIsFocusVisible();
487
539
  const [focusVisible, setFocusVisible] = useState(false);
488
540
  const [focusVisibleWithin, setFocusVisibleWithin] = useState(false);
541
+ const globalFocusListenerRef = useRef(null);
542
+ const containerRef = useRef(null);
543
+ const ownerDocumentRef = useRef(null);
544
+ const removeGlobalFocusListener = useCallback(() => {
545
+ if (globalFocusListenerRef.current) {
546
+ ownerDocumentRef.current?.removeEventListener('focus', globalFocusListenerRef.current, true);
547
+ globalFocusListenerRef.current = null;
548
+ }
549
+ }, []);
550
+ useEffect(() => {
551
+ return removeGlobalFocusListener;
552
+ }, [removeGlobalFocusListener]);
489
553
  const handleBlur = (event) => {
490
554
  handleBlurVisible(event);
491
555
  if (isFocusVisibleRef.current === false) {
@@ -495,6 +559,11 @@ const useFocusVisible = ({ onFocusVisible, onFocus, onBlur, within = false, } =
495
559
  setFocusVisibleWithin(false);
496
560
  }
497
561
  }
562
+ if (within &&
563
+ globalFocusListenerRef.current &&
564
+ !event.currentTarget.contains(event.relatedTarget)) {
565
+ removeGlobalFocusListener();
566
+ }
498
567
  onBlur?.(event);
499
568
  };
500
569
  const handleFocus = (event) => {
@@ -524,6 +593,25 @@ const useFocusVisible = ({ onFocusVisible, onFocus, onBlur, within = false, } =
524
593
  if (isFocusVisibleRef.current === true) {
525
594
  updateState();
526
595
  onFocusVisible?.(event);
596
+ if (within) {
597
+ removeGlobalFocusListener();
598
+ containerRef.current = event.currentTarget;
599
+ ownerDocumentRef.current = event.currentTarget.ownerDocument;
600
+ const ownerDoc = ownerDocumentRef.current;
601
+ const listener = (e) => {
602
+ if (e.target && !containerRef.current?.contains(e.target)) {
603
+ setFocusVisibleWithin(false);
604
+ ownerDoc.removeEventListener('focus', listener, true);
605
+ globalFocusListenerRef.current = null;
606
+ }
607
+ };
608
+ globalFocusListenerRef.current = listener;
609
+ ownerDoc.addEventListener('focus', listener, true);
610
+ }
611
+ }
612
+ else if (within) {
613
+ setFocusVisibleWithin(false);
614
+ removeGlobalFocusListener();
527
615
  }
528
616
  onFocus?.(event);
529
617
  };
@@ -646,8 +734,8 @@ function getListenerOverloadOption(args) {
646
734
  }
647
735
  else {
648
736
  const { startImmediately, customKey, target, ...restOptions } = {
649
- ...(args[0] || {}),
650
- ...(args[1] || {}),
737
+ ...args[0],
738
+ ...args[1],
651
739
  };
652
740
  options = restOptions;
653
741
  config = {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ringcentral/spring-base",
3
- "version": "1.9.3",
3
+ "version": "1.11.1",
4
4
  "author": "RingCentral",
5
5
  "description": "Core utilities, hooks, and foundational functionality for Spring UI components, providing essential building blocks for React applications",
6
6
  "main": "./index.js",
package/src/config.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- declare type WarningFunctionType = ((message: string, options?: {
1
+ type WarningFunctionType = ((message: string, options?: {
2
2
  level: 'warn' | 'error';
3
3
  }) => void) | undefined;
4
4
  interface RcConfigurationType {
@@ -6,7 +6,7 @@ interface RcConfigurationType {
6
6
  WARNING_FUNCTION: WarningFunctionType;
7
7
  }
8
8
  declare let rcConfiguration: RcConfigurationType;
9
- declare type RcConfigure = {
9
+ type RcConfigure = {
10
10
  warning?: boolean;
11
11
  warningFunction?: WarningFunctionType;
12
12
  };
@@ -1,6 +1,6 @@
1
1
  /// <reference types="react" />
2
2
  import { MatchedBreakpoint } from './types';
3
- declare type RcResponsiveContextValue = MatchedBreakpoint | undefined;
3
+ type RcResponsiveContextValue = MatchedBreakpoint | undefined;
4
4
  declare const RcResponsiveContext: import("react").Context<RcResponsiveContextValue>;
5
5
  declare const useResponsiveContext: () => RcResponsiveContextValue;
6
6
  export { RcResponsiveContext, useResponsiveContext };
@@ -1,13 +1,13 @@
1
- export declare type Breakpoint = 'xs' | 'sm' | 'md' | 'lg' | 'xl';
2
- export declare type MatchedBreakpoint = Breakpoint | null;
3
- export declare type GTBreakpoint = 'gt-xs' | 'gt-sm' | 'gt-md' | 'gt-lg' | 'gt-xl';
4
- export declare type LTBreakpoint = 'lt-sm' | 'lt-md' | 'lt-lg' | 'lt-xl';
5
- export declare type FullBreakpoint = GTBreakpoint | LTBreakpoint | Breakpoint;
6
- export declare type BreakpointMatchMap = Partial<Record<'gtXS' | 'gtSM' | 'gtMD' | 'gtLG' | 'gtXL' | 'ltSM' | 'ltMD' | 'ltLG' | 'ltXL' | FullBreakpoint, true>>;
7
- export declare type BreakpointMatchDetail = {
1
+ export type Breakpoint = 'xs' | 'sm' | 'md' | 'lg' | 'xl';
2
+ export type MatchedBreakpoint = Breakpoint | null;
3
+ export type GTBreakpoint = 'gt-xs' | 'gt-sm' | 'gt-md' | 'gt-lg' | 'gt-xl';
4
+ export type LTBreakpoint = 'lt-sm' | 'lt-md' | 'lt-lg' | 'lt-xl';
5
+ export type FullBreakpoint = GTBreakpoint | LTBreakpoint | Breakpoint;
6
+ export type BreakpointMatchMap = Partial<Record<'gtXS' | 'gtSM' | 'gtMD' | 'gtLG' | 'gtXL' | 'ltSM' | 'ltMD' | 'ltLG' | 'ltXL' | FullBreakpoint, true>>;
7
+ export type BreakpointMatchDetail = {
8
8
  matchBP: MatchedBreakpoint;
9
9
  gtMatchGroup: GTBreakpoint[];
10
10
  ltMatchGroup: LTBreakpoint[];
11
11
  matchMap: BreakpointMatchMap;
12
12
  };
13
- export declare type BreakpointMatchGroups = Pick<BreakpointMatchDetail, 'gtMatchGroup' | 'ltMatchGroup'>;
13
+ export type BreakpointMatchGroups = Pick<BreakpointMatchDetail, 'gtMatchGroup' | 'ltMatchGroup'>;
@@ -1,5 +1,5 @@
1
1
  /// <reference types="react" />
2
- declare type WindowContextValue = {
2
+ type WindowContextValue = {
3
3
  globalThis: typeof globalThis;
4
4
  externalWindow?: Window & typeof globalThis;
5
5
  document?: Document;
@@ -1,6 +1,6 @@
1
- export declare type useA11yKeyEventOptions = {
1
+ export type useA11yKeyEventOptions = {
2
2
  onlyOnFocus?: boolean;
3
3
  preventDefault?: boolean;
4
4
  checkKeys?: string[];
5
5
  };
6
- export declare const useA11yKeyEvent: (fn?: ((e: any) => void) | undefined, { onlyOnFocus, preventDefault, checkKeys, }?: useA11yKeyEventOptions) => (event: React.KeyboardEvent<HTMLElement>) => void;
6
+ export declare const useA11yKeyEvent: (fn?: (e: any) => void, { onlyOnFocus, preventDefault, checkKeys, }?: useA11yKeyEventOptions) => (event: React.KeyboardEvent<HTMLElement>) => void;
@@ -1,5 +1,5 @@
1
1
  import { EventHandler, KeyboardEventHandler, MouseEventHandler, SyntheticEvent } from 'react';
2
- export declare type UseActiveOptions = {
2
+ export type UseActiveOptions = {
3
3
  onKeyDown?: KeyboardEventHandler;
4
4
  onKeyUp?: KeyboardEventHandler;
5
5
  onMouseDown?: MouseEventHandler;
@@ -8,10 +8,10 @@ export declare type UseActiveOptions = {
8
8
  };
9
9
  export declare const useActive: ({ onKeyDown, onKeyUp, onMouseDown, onClick, disabled, }?: UseActiveOptions) => {
10
10
  activeHandlers: {
11
- onKeyDown: KeyboardEventHandler<Element> | undefined;
12
- onKeyUp: KeyboardEventHandler<Element> | undefined;
13
- onMouseDown: MouseEventHandler<Element> | undefined;
14
- onClick: ((event: SyntheticEvent<Element, Event>) => void) | undefined;
11
+ onKeyDown: KeyboardEventHandler | undefined;
12
+ onKeyUp: KeyboardEventHandler | undefined;
13
+ onMouseDown: MouseEventHandler | undefined;
14
+ onClick: EventHandler<SyntheticEvent<Element, Event>> | undefined;
15
15
  };
16
16
  active: boolean;
17
17
  };
@@ -1,2 +1,2 @@
1
1
  export declare const visuallyHiddenStyles = "\n clip-path: inset(100%);\n clip: rect(1px, 1px, 1px, 1px);\n height: 1px;\n overflow: hidden;\n position: absolute;\n white-space: nowrap;\n width: 1px;\n";
2
- export declare const useAnnouncer: (id?: string | undefined) => (message?: string | undefined) => void;
2
+ export declare const useAnnouncer: (id?: string) => (message?: string) => void;
@@ -1,5 +1,5 @@
1
1
  /// <reference types="react" />
2
- export declare type UseAriaHideOutsideProps = {
2
+ export type UseAriaHideOutsideProps = {
3
3
  enable?: boolean;
4
4
  };
5
5
  export declare const useAriaHideOutside: (props?: UseAriaHideOutsideProps) => {
@@ -1 +1 @@
1
- export declare const useAudio: (init?: ((audio: HTMLAudioElement) => void) | undefined) => HTMLAudioElement;
1
+ export declare const useAudio: (init?: (audio: HTMLAudioElement) => void) => HTMLAudioElement;
@@ -1,4 +1,4 @@
1
- declare type Win = Window & typeof globalThis;
1
+ type Win = Window & typeof globalThis;
2
2
  export interface ScrollLockOptions {
3
3
  reserveScrollBarGap?: boolean;
4
4
  allowTouchMove?: (el: Element) => boolean;
@@ -1,5 +1,5 @@
1
1
  import { RefObject } from 'react';
2
- export declare type UseBodyScrollLockTarget = HTMLElement | RefObject<HTMLElement | null> | null | undefined;
2
+ export type UseBodyScrollLockTarget = HTMLElement | RefObject<HTMLElement | null> | null | undefined;
3
3
  export interface UseBodyScrollLockOptions {
4
4
  disabled?: boolean;
5
5
  reserveScrollBarGap?: boolean;
@@ -1,10 +1,10 @@
1
- import { SyntheticEvent } from 'react';
2
- export declare type useClickAwayProps = {
1
+ import { RefCallback, SyntheticEvent } from 'react';
2
+ export type useClickAwayProps = {
3
3
  disableReactTree?: boolean;
4
4
  isEnabled?: boolean;
5
5
  };
6
6
  export declare const useClickAway: (onClickAway: (event: MouseEvent | TouchEvent) => void, props?: useClickAwayProps) => {
7
- clickAwayRef: (instance: Element | null) => void;
7
+ clickAwayRef: RefCallback<Element>;
8
8
  clickAwayHandler: {
9
9
  onClick: (e: SyntheticEvent) => void;
10
10
  onTouchEnd: (e: SyntheticEvent) => void;
@@ -1,2 +1,2 @@
1
1
  import type { DebounceSettings } from 'lodash';
2
- export declare const useDebounce: <F extends (...args: any[]) => any>(fn: F, debounceTime?: number, options?: DebounceSettings | undefined) => import("lodash").DebouncedFunc<F>;
2
+ export declare const useDebounce: <F extends (...args: any[]) => any>(fn: F, debounceTime?: number, options?: DebounceSettings) => import("lodash").DebouncedFunc<F>;
@@ -1,9 +1,9 @@
1
1
  import { RefOrElementOrCallback } from '../../utils';
2
- export declare type UseEventListenerAction = {
2
+ export type UseEventListenerAction = {
3
3
  listen: () => void;
4
4
  remove: () => void;
5
5
  };
6
- export declare type UseEventListenerConfig = {
6
+ export type UseEventListenerConfig = {
7
7
  startImmediately?: boolean;
8
8
  };
9
9
  export declare function useEventListener<T = Event>(target: RefOrElementOrCallback<EventTarget> | EventTarget | null | undefined, key: string, callback: (event: T) => void, options?: AddEventListenerOptions & UseEventListenerConfig): {
@@ -1,5 +1,5 @@
1
1
  import { FocusEventHandler, FocusEvent, Ref } from 'react';
2
- export declare type UseFocusVisibleOptions = {
2
+ export type UseFocusVisibleOptions = {
3
3
  onFocusVisible?: FocusEventHandler;
4
4
  onFocus?: FocusEventHandler;
5
5
  onBlur?: FocusEventHandler;
@@ -4,11 +4,11 @@ export declare const globalListenerEventMap: Map<string, {
4
4
  exec: (e: any) => void;
5
5
  listeners: Set<(e: any) => void>;
6
6
  }>;
7
- export declare type CreateGlobalListenerConfig = {
7
+ export type CreateGlobalListenerConfig = {
8
8
  customKey?: string;
9
9
  target?: RefOrElementOrCallback | EventTarget;
10
10
  };
11
- export declare const createGlobalListener: <T extends SyntheticEvent<Element, Event>>(key: string, listener: (event?: T | undefined) => void, options?: boolean | AddEventListenerOptions | undefined, { customKey, target: targetProp, }?: CreateGlobalListenerConfig) => {
11
+ export declare const createGlobalListener: <T extends SyntheticEvent<Element, Event>>(key: string, listener: (event?: T) => void, options?: AddEventListenerOptions | boolean, { customKey, target: targetProp, }?: CreateGlobalListenerConfig) => {
12
12
  listen: () => void;
13
13
  remove: () => void;
14
14
  readonly state: {
@@ -1,7 +1,7 @@
1
1
  import { SyntheticEvent } from 'react';
2
2
  import { createGlobalListener, CreateGlobalListenerConfig } from './createGlobalListener';
3
- declare type GlobalListener = ReturnType<typeof createGlobalListener>;
4
- export declare type UseGlobalListenerConfig = CreateGlobalListenerConfig & {
3
+ type GlobalListener = ReturnType<typeof createGlobalListener>;
4
+ export type UseGlobalListenerConfig = CreateGlobalListenerConfig & {
5
5
  startImmediately?: boolean;
6
6
  };
7
7
  export declare function useGlobalListener<T extends SyntheticEvent>(key: string, listener: (event?: T) => void, config?: UseGlobalListenerConfig): GlobalListener;
@@ -1,5 +1,5 @@
1
1
  import { MouseEvent, MouseEventHandler } from 'react';
2
- export declare type UseHoverOptions<E = HTMLElement> = {
2
+ export type UseHoverOptions<E = HTMLElement> = {
3
3
  onMouseEnter?: MouseEventHandler<E>;
4
4
  onMouseLeave?: MouseEventHandler<E>;
5
5
  disabled?: boolean;
@@ -7,8 +7,8 @@ export declare type UseHoverOptions<E = HTMLElement> = {
7
7
  };
8
8
  export declare const useHover: <E = HTMLElement>({ onMouseEnter: handleMouseEnter, onMouseLeave: handleMouseLeave, disabled, disableReactTree, }?: UseHoverOptions<E>) => {
9
9
  hoverHandlers: {
10
- onMouseEnter: (event: MouseEvent<E, globalThis.MouseEvent>) => void;
11
- onMouseLeave: (event: MouseEvent<E, globalThis.MouseEvent>) => void;
10
+ onMouseEnter: (event: MouseEvent<E>) => void;
11
+ onMouseLeave: (event: MouseEvent<E>) => void;
12
12
  };
13
13
  hover: boolean;
14
14
  };
@@ -1,5 +1,5 @@
1
1
  import { RefOrElementOrCallback } from '../../utils';
2
- export declare type UseHoverDirtyOptions = {
2
+ export type UseHoverDirtyOptions = {
3
3
  target: RefOrElementOrCallback | EventTarget | null | undefined;
4
4
  disabled?: boolean;
5
5
  };
@@ -1,10 +1,10 @@
1
1
  import { ComponentProps } from 'react';
2
- declare type UseImgLoadedProps = {
2
+ type UseImgLoadedProps = {
3
3
  src?: string;
4
4
  srcSet?: string;
5
5
  crossOrigin?: ComponentProps<'img'>['crossOrigin'];
6
6
  referrerPolicy?: ComponentProps<'img'>['referrerPolicy'];
7
7
  };
8
- declare type LoadedState = false | 'loaded' | 'error';
8
+ type LoadedState = false | 'loaded' | 'error';
9
9
  export declare const useImgLoaded: ({ crossOrigin, referrerPolicy, src, srcSet, }: UseImgLoadedProps) => LoadedState;
10
10
  export {};
@@ -1,9 +1,9 @@
1
1
  /// <reference types="react" />
2
- export declare type UseKeyDownOnce<T> = {
2
+ export type UseKeyDownOnce<T> = {
3
3
  onKeyUp?: (e: React.KeyboardEvent<T>) => void;
4
4
  onKeyDown?: (e: React.KeyboardEvent<T>) => void;
5
5
  };
6
6
  export declare const useKeyDownOnce: <T>(includeKeys: string[], { onKeyDown, onKeyUp }: UseKeyDownOnce<T>) => {
7
- onKeyDown: (e: import("react").KeyboardEvent<T>) => void;
8
- onKeyUp: (e: import("react").KeyboardEvent<T>) => void;
7
+ onKeyDown: (e: React.KeyboardEvent<T>) => void;
8
+ onKeyUp: (e: React.KeyboardEvent<T>) => void;
9
9
  };
@@ -1,4 +1,4 @@
1
- export declare type MoveIndexInTwoDimensionalOptions = {
1
+ export type MoveIndexInTwoDimensionalOptions = {
2
2
  currIndex: number;
3
3
  columns: number;
4
4
  total: number;
@@ -1,6 +1,6 @@
1
1
  /// <reference types="react" />
2
2
  import { MoveIndexInTwoDimensionalOptions } from './moveIndexInTwoDimension';
3
- export declare type UseKeyboardMoveFocusParams<T> = {
3
+ export type UseKeyboardMoveFocusParams<T> = {
4
4
  focusedIndexRef: React.MutableRefObject<number>;
5
5
  onFocusedIndexChange: (event: React.KeyboardEvent<HTMLElement>, index: number) => void;
6
6
  options: T[];
@@ -1,5 +1,5 @@
1
1
  /// <reference types="react" />
2
- export declare type UseOnlyOneFocusableParams = {
2
+ export type UseOnlyOneFocusableParams = {
3
3
  focusedIndexRef: React.MutableRefObject<number>;
4
4
  containerRef: React.RefObject<HTMLElement>;
5
5
  };
@@ -7,5 +7,5 @@ export declare const useOnlyOneFocusable: ({ focusedIndexRef, containerRef, }: U
7
7
  moveFocusedId: string;
8
8
  focusIndex: (toIndex: number) => void;
9
9
  setIndexTabIndex: (toIndex: number) => void;
10
- getItemProps: (index: number, options?: Omit<import("react").HTMLAttributes<HTMLElement>, "children"> | undefined) => Omit<import("react").HTMLAttributes<HTMLElement>, "children">;
10
+ getItemProps: (index: number, options?: Omit<React.HTMLAttributes<HTMLElement>, 'children'>) => Omit<import("react").HTMLAttributes<HTMLElement>, "children">;
11
11
  };
@@ -6,12 +6,12 @@ export interface UseLongPressOptions {
6
6
  delay?: number;
7
7
  externalWindow?: Window;
8
8
  }
9
- export declare type UseLongPressEventReason = 'keyboard' | 'click' | 'tap';
10
- export declare type UseLongPressOutput<T> = {
9
+ export type UseLongPressEventReason = 'keyboard' | 'click' | 'tap';
10
+ export type UseLongPressOutput<T> = {
11
11
  onTap?: (e: React.MouseEvent<T, MouseEvent> | React.TouchEvent<T> | React.KeyboardEvent<T>, reason: UseLongPressEventReason) => void;
12
12
  onPress?: (e: React.MouseEvent<T, MouseEvent> | React.TouchEvent<T> | React.KeyboardEvent<T>, reason: UseLongPressEventReason) => void;
13
13
  };
14
- export declare type UseLongPressInput<T> = {
14
+ export type UseLongPressInput<T> = {
15
15
  onKeyUp?: (e: React.KeyboardEvent<T>) => void;
16
16
  onKeyDown?: (e: React.KeyboardEvent<T>) => void;
17
17
  } & UseTouchMouseEvent<T>;
@@ -1,2 +1,2 @@
1
1
  import { DependencyList } from 'react';
2
- export declare const useOnLayoutReRender: (cb: () => any, deps?: DependencyList | undefined) => void;
2
+ export declare const useOnLayoutReRender: (cb: () => any, deps?: DependencyList) => void;
@@ -1,2 +1,2 @@
1
1
  import { DependencyList } from 'react';
2
- export declare const useOnReRender: (cb: () => any, deps?: DependencyList | undefined) => void;
2
+ export declare const useOnReRender: (cb: () => any, deps?: DependencyList) => void;
@@ -1,2 +1,2 @@
1
1
  /// <reference types="react" />
2
- export declare const useRefState: <T>(value: T, customUpdate?: (() => void) | undefined) => readonly [import("react").MutableRefObject<T>, (toValue: T, isUpdate?: any) => void];
2
+ export declare const useRefState: <T>(value: T, customUpdate?: () => void) => readonly [import("react").MutableRefObject<T>, (toValue: T, isUpdate?: any) => void];
@@ -1,6 +1,6 @@
1
1
  import { type DebounceSettings, type ThrottleSettings } from 'lodash';
2
2
  import { RefOrElementOrCallback } from '../../utils';
3
- export declare type PerformanceOptions = {
3
+ export type PerformanceOptions = {
4
4
  mode?: 'debounce' | 'throttle' | 'none';
5
5
  time?: number;
6
6
  ignoreFireWhenObserve?: boolean;
@@ -1,3 +1,3 @@
1
1
  import { BreakpointMatchMap, MatchedBreakpoint } from '../../contexts';
2
- declare const useResponsiveMatch: (defaultBreakpoint?: MatchedBreakpoint | undefined) => BreakpointMatchMap;
2
+ declare const useResponsiveMatch: (defaultBreakpoint?: MatchedBreakpoint) => BreakpointMatchMap;
3
3
  export { useResponsiveMatch };
@@ -1,4 +1,4 @@
1
- export declare type UseRetryOptions = {
1
+ export type UseRetryOptions = {
2
2
  retryTimes: number;
3
3
  intervalTime: number;
4
4
  onStart?: () => void;
@@ -6,7 +6,7 @@ export declare type UseRetryOptions = {
6
6
  onComplete?: (times?: number) => void;
7
7
  onCancel?: () => void;
8
8
  };
9
- export declare const useRetry: <T extends (...args: any[]) => boolean | Promise<boolean>>(cb: T, options?: UseRetryOptions | undefined) => {
9
+ export declare const useRetry: <T extends (...args: any[]) => boolean | Promise<boolean>>(cb: T, options?: UseRetryOptions) => {
10
10
  retry: (...args: Parameters<T>) => Promise<void>;
11
11
  cancel: () => void;
12
12
  };
@@ -1,2 +1,2 @@
1
1
  import type { ThrottleSettings } from 'lodash';
2
- export declare const useThrottle: <F extends (...args: any[]) => any>(fn: F, throttleTime?: number, options?: ThrottleSettings | undefined) => import("lodash").DebouncedFunc<F>;
2
+ export declare const useThrottle: <F extends (...args: any[]) => any>(fn: F, throttleTime?: number, options?: ThrottleSettings) => import("lodash").DebouncedFunc<F>;
@@ -1,4 +1,4 @@
1
- declare type ExternalWindowProps = {
1
+ type ExternalWindowProps = {
2
2
  externalWindow: Window & typeof globalThis;
3
3
  };
4
4
  export declare const useVirtuosoExternalWindow: () => ExternalWindowProps | undefined;
@@ -1,4 +1,4 @@
1
- declare type DefaultBaseColor = {
1
+ type DefaultBaseColor = {
2
2
  primary: any;
3
3
  secondary: any;
4
4
  inherit: any;
@@ -9,5 +9,5 @@ declare type DefaultBaseColor = {
9
9
  action: any;
10
10
  neutral: any;
11
11
  };
12
- export declare type BaseColor<T extends keyof DefaultBaseColor = 'primary' | 'secondary'> = keyof Pick<DefaultBaseColor, T>;
12
+ export type BaseColor<T extends keyof DefaultBaseColor = 'primary' | 'secondary'> = keyof Pick<DefaultBaseColor, T>;
13
13
  export {};
@@ -1,4 +1,4 @@
1
- declare type BaseSizes = {
1
+ type BaseSizes = {
2
2
  xxxsmall: any;
3
3
  xxsmall: any;
4
4
  xsmall: any;
@@ -10,6 +10,6 @@ declare type BaseSizes = {
10
10
  xxlarge: any;
11
11
  xxxlarge: any;
12
12
  };
13
- export declare type BaseSizeKey = keyof BaseSizes;
14
- export declare type BaseSize<T extends BaseSizeKey = 'small' | 'medium' | 'large'> = keyof Pick<BaseSizes, T>;
13
+ export type BaseSizeKey = keyof BaseSizes;
14
+ export type BaseSize<T extends BaseSizeKey = 'small' | 'medium' | 'large'> = keyof Pick<BaseSizes, T>;
15
15
  export {};
@@ -1,25 +1,25 @@
1
1
  import type { MotionProps } from 'framer-motion';
2
2
  import type { ComponentPropsWithRef, ElementType, HTMLAttributes, LegacyRef } from 'react';
3
3
  import type { GlobalStateClassesKey } from '../utils/classes/globalStateClasses';
4
- export declare type GroupedMotionProps<P = {}> = Pick<MotionProps, Extract<keyof HTMLAttributes<Element>, keyof MotionProps>> & Omit<P, Extract<keyof HTMLAttributes<Element>, keyof MotionProps>> & {
4
+ export type GroupedMotionProps<P = {}> = Pick<MotionProps, Extract<keyof HTMLAttributes<Element>, keyof MotionProps>> & Omit<P, Extract<keyof HTMLAttributes<Element>, keyof MotionProps>> & {
5
5
  motionProps?: MotionProps | null;
6
6
  };
7
- export declare type ClassesProp<K extends string> = {
7
+ export type ClassesProp<K extends string> = {
8
8
  classes?: Partial<Record<K | 'root' | GlobalStateClassesKey, string>>;
9
9
  };
10
- export declare type PropsWithRoot<P, R extends ElementType, O extends string = '', E = HTMLDataAttribute> = P & Omit<ComponentPropsWithRef<R>, keyof P | O> & E;
11
- export declare type SlotProps<R extends ElementType, O extends keyof ComponentPropsWithRef<R> = never, E = HTMLDataAttribute> = Omit<ComponentPropsWithRef<R>, O | 'className'> & E;
12
- export declare type StandardProps<P, C extends string, R extends ElementType | void = void, O extends string = '', ExtendAttributes = HTMLDataAttribute> = ClassesProp<C> & (R extends ElementType ? PropsWithRoot<P, R, 'classes' | O, ExtendAttributes> : P & {
10
+ export type PropsWithRoot<P, R extends ElementType, O extends string = '', E = HTMLDataAttribute> = P & Omit<ComponentPropsWithRef<R>, keyof P | O> & E;
11
+ export type SlotProps<R extends ElementType, O extends keyof ComponentPropsWithRef<R> = never, E = HTMLDataAttribute> = Omit<ComponentPropsWithRef<R>, O | 'className'> & E;
12
+ export type StandardProps<P, C extends string, R extends ElementType | void = void, O extends string = '', ExtendAttributes = HTMLDataAttribute> = ClassesProp<C> & (R extends ElementType ? PropsWithRoot<P, R, 'classes' | O, ExtendAttributes> : P & {
13
13
  className?: string;
14
14
  }) & ExtendAttributes;
15
- export declare type WithClassesProps<P, C extends string> = P & ClassesProp<C>;
16
- export declare type BaseOverridableProps<P, C extends string> = WithClassesProps<P, C>;
17
- export declare type OverridableProps<B, T extends ElementType, E = HTMLDataAttribute> = B & {
15
+ export type WithClassesProps<P, C extends string> = P & ClassesProp<C>;
16
+ export type BaseOverridableProps<P, C extends string> = WithClassesProps<P, C>;
17
+ export type OverridableProps<B, T extends ElementType, E = HTMLDataAttribute> = B & {
18
18
  component?: T;
19
19
  } & Omit<ComponentPropsWithRef<T>, keyof B> & E;
20
- export declare type RefFromProps<P> = P extends {
20
+ export type RefFromProps<P> = P extends {
21
21
  ref?: LegacyRef<infer R> | undefined;
22
22
  } ? R : never;
23
- export declare type HTMLDataAttribute = {
23
+ export type HTMLDataAttribute = {
24
24
  [key: `data-${string}`]: unknown;
25
25
  };
@@ -1,2 +1,2 @@
1
- export declare type ExtractArray<T> = T extends ReadonlyArray<infer U> ? U : never;
2
- export declare type ExtractRecord<T extends Record<string, unknown>> = T[keyof T];
1
+ export type ExtractArray<T> = T extends ReadonlyArray<infer U> ? U : never;
2
+ export type ExtractRecord<T extends Record<string, unknown>> = T[keyof T];
@@ -1,5 +1,5 @@
1
1
  import type React from 'react';
2
- export declare type DistributiveOmit<T, K extends keyof any> = T extends any ? Omit<T, K> : never;
2
+ export type DistributiveOmit<T, K extends keyof any> = T extends any ? Omit<T, K> : never;
3
3
  export interface OverridableComponent<M extends OverridableTypeMap> {
4
4
  <C extends React.ElementType>(props: {
5
5
  component: C;
@@ -7,9 +7,9 @@ export interface OverridableComponent<M extends OverridableTypeMap> {
7
7
  (props: DefaultComponentProps<M>): JSX.Element | null;
8
8
  displayName?: string;
9
9
  }
10
- export declare type OverrideProps<M extends OverridableTypeMap, C extends React.ElementType> = (BaseProps<M> & DistributiveOmit<React.ComponentPropsWithRef<C>, keyof BaseProps<M>>);
11
- export declare type DefaultComponentProps<M extends OverridableTypeMap> = BaseProps<M> & DistributiveOmit<React.ComponentPropsWithRef<M['defaultComponent']>, keyof BaseProps<M>>;
12
- export declare type BaseProps<M extends OverridableTypeMap> = M['props'];
10
+ export type OverrideProps<M extends OverridableTypeMap, C extends React.ElementType> = (BaseProps<M> & DistributiveOmit<React.ComponentPropsWithRef<C>, keyof BaseProps<M>>);
11
+ export type DefaultComponentProps<M extends OverridableTypeMap> = BaseProps<M> & DistributiveOmit<React.ComponentPropsWithRef<M['defaultComponent']>, keyof BaseProps<M>>;
12
+ export type BaseProps<M extends OverridableTypeMap> = M['props'];
13
13
  export interface OverridableTypeMap {
14
14
  props: {};
15
15
  defaultComponent: React.ElementType;
@@ -1,3 +1,3 @@
1
- export declare type UnionPick<T extends string, K extends T> = keyof Pick<Record<T, any>, K>;
2
- export declare type UnionOmit<T extends string, K extends T> = keyof Omit<Record<T, any>, K>;
3
- export declare type LiteralUnion<T> = T | (string & Record<never, never>);
1
+ export type UnionPick<T extends string, K extends T> = keyof Pick<Record<T, any>, K>;
2
+ export type UnionOmit<T extends string, K extends T> = keyof Omit<Record<T, any>, K>;
3
+ export type LiteralUnion<T> = T | (string & Record<never, never>);
@@ -1,13 +1,13 @@
1
- export declare type UnitMap<T extends string | number | symbol, K = any> = {
1
+ export type UnitMap<T extends string | number | symbol, K = any> = {
2
2
  [key in T]: K;
3
3
  };
4
- export declare type ClassesMap<T extends {
4
+ export type ClassesMap<T extends {
5
5
  classes?: any;
6
6
  } | undefined, K = any> = Partial<UnitMap<Classes<T>, K>>;
7
- declare type ClassesReturn<T extends {
7
+ type ClassesReturn<T extends {
8
8
  classes?: any;
9
9
  } | undefined> = keyof NonNullable<NonNullable<T>['classes']>;
10
- export declare type Classes<T extends {
10
+ export type Classes<T extends {
11
11
  classes?: any;
12
12
  } | undefined> = ClassesReturn<T>;
13
13
  export {};
@@ -11,4 +11,4 @@ export declare const globalStateClasses: {
11
11
  selected: string;
12
12
  dragged: string;
13
13
  };
14
- export declare type GlobalStateClassesKey = keyof typeof globalStateClasses;
14
+ export type GlobalStateClassesKey = keyof typeof globalStateClasses;
@@ -1,6 +1,6 @@
1
1
  import type { CamelCase } from 'type-fest';
2
2
  import { GlobalStateClassesKey } from './globalStateClasses';
3
- export declare type Cls<T extends {
3
+ export type Cls<T extends {
4
4
  name: string;
5
5
  classes: string;
6
6
  }> = (...classValues: Array<T['classes'] | GlobalStateClassesKey | {
@@ -9,4 +9,4 @@ export declare type Cls<T extends {
9
9
  export declare const useClasses: <T extends {
10
10
  name: string;
11
11
  classes: string;
12
- }>(prefix: T["name"], inputClasses?: Partial<Record<"disabled" | "active" | "checked" | "completed" | "expanded" | "focused" | "focusVisible" | "focusVisibleWithin" | "required" | "selected" | "dragged" | CamelCase<T["classes"]>, string>> | undefined, className?: string | undefined) => Cls<T>;
12
+ }>(prefix: T['name'], inputClasses?: Partial<Record<CamelCase<T['classes'] | GlobalStateClassesKey>, string>>, className?: string) => Cls<T>;
@@ -1,2 +1,2 @@
1
- export declare const combineProps: <T>(baseProps: T, newProps: T | Partial<T>, coverPropKeys?: (keyof T)[] | undefined) => NonNullable<T>;
1
+ export declare const combineProps: <T>(baseProps: T, newProps: T | Partial<T>, coverPropKeys?: (keyof T)[]) => NonNullable<T>;
2
2
  export declare const combineClasses: <T>(baseClasses: T, newClasses: T | Partial<T>) => NonNullable<T>;
@@ -1,4 +1,4 @@
1
- export declare type DevlogArgs = {
1
+ export type DevlogArgs = {
2
2
  condition?: boolean;
3
3
  scope: string;
4
4
  message: string;
@@ -1,3 +1,3 @@
1
1
  import { MutableRefObject, RefObject } from 'react';
2
- export declare type RefOrElementOrCallback<T = HTMLElement> = RefObject<T> | (() => T) | T;
2
+ export type RefOrElementOrCallback<T = HTMLElement> = RefObject<T> | (() => T) | T;
3
3
  export declare const getRefElement: <T>(ref: T) => T extends () => infer R ? R : T extends RefObject<infer C> | MutableRefObject<infer C> ? C : T;
@@ -1,5 +1,5 @@
1
1
  import { RefOrElementOrCallback } from './getRefElement';
2
- declare type RemoveClassNameOptions = {
2
+ type RemoveClassNameOptions = {
3
3
  scanChildren?: boolean;
4
4
  fullMatch?: boolean;
5
5
  };
@@ -1,4 +1,4 @@
1
1
  import { KeyboardEvent } from 'react';
2
- declare type KeyHandlers = Record<KeyboardEvent['key'], () => void>;
2
+ type KeyHandlers = Record<KeyboardEvent['key'], () => void>;
3
3
  export declare const runKeyHandler: (e: KeyboardEvent<unknown>, keyHandlers: KeyHandlers) => void;
4
4
  export {};