@ringcentral/spring-base 1.7.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.
Files changed (146) hide show
  1. package/LICENSE +22 -0
  2. package/README.md +61 -0
  3. package/chunks/twMerge.js +409 -0
  4. package/config.js +78 -0
  5. package/contexts.js +71 -0
  6. package/hooks.js +2101 -0
  7. package/index.d.ts +1 -0
  8. package/index.js +16 -0
  9. package/package.json +30 -0
  10. package/src/config.d.ts +40 -0
  11. package/src/contexts/ResponsiveContext/ResponsiveContext.d.ts +7 -0
  12. package/src/contexts/ResponsiveContext/breakpointList.d.ts +3 -0
  13. package/src/contexts/ResponsiveContext/getMatchDetail.d.ts +2 -0
  14. package/src/contexts/ResponsiveContext/index.d.ts +4 -0
  15. package/src/contexts/ResponsiveContext/types.d.ts +24 -0
  16. package/src/contexts/WindowContext.d.ts +9 -0
  17. package/src/contexts/index.d.ts +2 -0
  18. package/src/hooks/index.d.ts +43 -0
  19. package/src/hooks/useA11yKeyEvent/index.d.ts +1 -0
  20. package/src/hooks/useA11yKeyEvent/useA11yKeyEvent.d.ts +23 -0
  21. package/src/hooks/useActive/index.d.ts +1 -0
  22. package/src/hooks/useActive/useActive.d.ts +23 -0
  23. package/src/hooks/useAnnouncer/index.d.ts +1 -0
  24. package/src/hooks/useAnnouncer/useAnnouncer.d.ts +12 -0
  25. package/src/hooks/useAriaHideOutside/index.d.ts +1 -0
  26. package/src/hooks/useAriaHideOutside/useAriaHideOutside.d.ts +12 -0
  27. package/src/hooks/useAudio/index.d.ts +1 -0
  28. package/src/hooks/useAudio/useAudio.d.ts +21 -0
  29. package/src/hooks/useBodyScrollLock/index.d.ts +1 -0
  30. package/src/hooks/useBodyScrollLock/useBodyScrollLock.d.ts +25 -0
  31. package/src/hooks/useChange/index.d.ts +1 -0
  32. package/src/hooks/useChange/useChange.d.ts +12 -0
  33. package/src/hooks/useClickAway/index.d.ts +1 -0
  34. package/src/hooks/useClickAway/useClickAway.d.ts +22 -0
  35. package/src/hooks/useControlled/index.d.ts +1 -0
  36. package/src/hooks/useControlled/useControlled.d.ts +1 -0
  37. package/src/hooks/useDebounce/index.d.ts +1 -0
  38. package/src/hooks/useDebounce/useDebounce.d.ts +8 -0
  39. package/src/hooks/useEventCallback/index.d.ts +1 -0
  40. package/src/hooks/useEventCallback/useEventCallback.d.ts +1 -0
  41. package/src/hooks/useEventListener/index.d.ts +1 -0
  42. package/src/hooks/useEventListener/useEventListener.d.ts +32 -0
  43. package/src/hooks/useEver/index.d.ts +1 -0
  44. package/src/hooks/useEver/useEver.d.ts +13 -0
  45. package/src/hooks/useFocusVisible/index.d.ts +1 -0
  46. package/src/hooks/useFocusVisible/useFocusVisible.d.ts +22 -0
  47. package/src/hooks/useFontLoaded/index.d.ts +1 -0
  48. package/src/hooks/useFontLoaded/useFontLoaded.d.ts +13 -0
  49. package/src/hooks/useForceUpdate/index.d.ts +1 -0
  50. package/src/hooks/useForceUpdate/useForceUpdate.d.ts +5 -0
  51. package/src/hooks/useForkRef/index.d.ts +1 -0
  52. package/src/hooks/useForkRef/useForkRef.d.ts +19 -0
  53. package/src/hooks/useGlobalListener/createGlobalListener.d.ts +55 -0
  54. package/src/hooks/useGlobalListener/index.d.ts +2 -0
  55. package/src/hooks/useGlobalListener/useGlobalListener.d.ts +14 -0
  56. package/src/hooks/useHiddenTabindex/index.d.ts +1 -0
  57. package/src/hooks/useHiddenTabindex/useHiddenTabindex.d.ts +9 -0
  58. package/src/hooks/useHover/index.d.ts +2 -0
  59. package/src/hooks/useHover/useHover.d.ts +17 -0
  60. package/src/hooks/useHover/useHoverDirty.d.ts +8 -0
  61. package/src/hooks/useId/index.d.ts +1 -0
  62. package/src/hooks/useId/useId.d.ts +15 -0
  63. package/src/hooks/useImgLoaded/index.d.ts +1 -0
  64. package/src/hooks/useImgLoaded/useImgLoaded.d.ts +24 -0
  65. package/src/hooks/useInterval/index.d.ts +1 -0
  66. package/src/hooks/useInterval/useInterval.d.ts +43 -0
  67. package/src/hooks/useIsFocusVisible/index.d.ts +2 -0
  68. package/src/hooks/useIsFocusVisible/useIsFocusVisible.d.ts +9 -0
  69. package/src/hooks/useKeyDownOnce/index.d.ts +1 -0
  70. package/src/hooks/useKeyDownOnce/useKeyDownOnce.d.ts +15 -0
  71. package/src/hooks/useKeyboardMoveFocus/index.d.ts +3 -0
  72. package/src/hooks/useKeyboardMoveFocus/moveIndexInTwoDimension.d.ts +18 -0
  73. package/src/hooks/useKeyboardMoveFocus/useKeyboardMoveFocus.d.ts +49 -0
  74. package/src/hooks/useKeyboardMoveFocus/useOnlyOneFocusable.d.ts +17 -0
  75. package/src/hooks/useLongPress/index.d.ts +1 -0
  76. package/src/hooks/useLongPress/useLongPress.d.ts +39 -0
  77. package/src/hooks/useMountState/index.d.ts +1 -0
  78. package/src/hooks/useMountState/useMountState.d.ts +16 -0
  79. package/src/hooks/useOnLayoutReRender/index.d.ts +1 -0
  80. package/src/hooks/useOnLayoutReRender/useOnLayoutReRender.d.ts +5 -0
  81. package/src/hooks/useOnReRender/index.d.ts +1 -0
  82. package/src/hooks/useOnReRender/useOnReRender.d.ts +5 -0
  83. package/src/hooks/useOverflow/index.d.ts +1 -0
  84. package/src/hooks/useOverflow/useOverflow.d.ts +11 -0
  85. package/src/hooks/usePrevious/index.d.ts +1 -0
  86. package/src/hooks/usePrevious/usePrevious.d.ts +7 -0
  87. package/src/hooks/useRefState/index.d.ts +1 -0
  88. package/src/hooks/useRefState/useRefState.d.ts +21 -0
  89. package/src/hooks/useResizeObserver/index.d.ts +1 -0
  90. package/src/hooks/useResizeObserver/useResizeObserver.d.ts +24 -0
  91. package/src/hooks/useResponsiveMatch/index.d.ts +1 -0
  92. package/src/hooks/useResponsiveMatch/useResponsiveMatch.d.ts +7 -0
  93. package/src/hooks/useResultRef/index.d.ts +1 -0
  94. package/src/hooks/useResultRef/useResultRef.d.ts +10 -0
  95. package/src/hooks/useRetry/index.d.ts +1 -0
  96. package/src/hooks/useRetry/useRetry.d.ts +35 -0
  97. package/src/hooks/useSleep/index.d.ts +1 -0
  98. package/src/hooks/useSleep/useSleep.d.ts +22 -0
  99. package/src/hooks/useTabOut/index.d.ts +1 -0
  100. package/src/hooks/useTabOut/useTabOut.d.ts +10 -0
  101. package/src/hooks/useTestRunnerDetection.d.ts +7 -0
  102. package/src/hooks/useThrottle/index.d.ts +1 -0
  103. package/src/hooks/useThrottle/useThrottle.d.ts +8 -0
  104. package/src/hooks/useTimeout/index.d.ts +1 -0
  105. package/src/hooks/useTimeout/useTimeout.d.ts +2 -0
  106. package/src/hooks/useTouchMouseEvent/index.d.ts +1 -0
  107. package/src/hooks/useTouchMouseEvent/useTouchMouseEvent.d.ts +56 -0
  108. package/src/index.d.ts +5 -0
  109. package/src/typings/BaseColor.d.ts +14 -0
  110. package/src/typings/BaseSize.d.ts +15 -0
  111. package/src/typings/ComponentTypes.d.ts +50 -0
  112. package/src/typings/ExtractValue.d.ts +2 -0
  113. package/src/typings/OverridableTypes.d.ts +45 -0
  114. package/src/typings/UnionOmit.d.ts +3 -0
  115. package/src/typings/UnitMap.d.ts +28 -0
  116. package/src/typings/index.d.ts +7 -0
  117. package/src/utils/a11yKeyboardCode.d.ts +8 -0
  118. package/src/utils/ariaHideOutside.d.ts +9 -0
  119. package/src/utils/capitalize.d.ts +1 -0
  120. package/src/utils/checkDefaultPrevented.d.ts +3 -0
  121. package/src/utils/checkElementName.d.ts +2 -0
  122. package/src/utils/checkKeyboardEvent.d.ts +2 -0
  123. package/src/utils/classes/globalStateClasses.d.ts +14 -0
  124. package/src/utils/classes/index.d.ts +2 -0
  125. package/src/utils/classes/useClasses.d.ts +41 -0
  126. package/src/utils/combineProps.d.ts +90 -0
  127. package/src/utils/devlog.d.ts +7 -0
  128. package/src/utils/getRefElement.d.ts +6 -0
  129. package/src/utils/getTitle.d.ts +1 -0
  130. package/src/utils/index.d.ts +25 -0
  131. package/src/utils/isRef.d.ts +2 -0
  132. package/src/utils/isSuiElement.d.ts +1 -0
  133. package/src/utils/isUrl.d.ts +1 -0
  134. package/src/utils/isWebKit154.d.ts +9 -0
  135. package/src/utils/omit.d.ts +2 -0
  136. package/src/utils/outerSize.d.ts +8 -0
  137. package/src/utils/ownerDocument.d.ts +1 -0
  138. package/src/utils/ownerWindow.d.ts +1 -0
  139. package/src/utils/pick.d.ts +2 -0
  140. package/src/utils/preloadImg.d.ts +2 -0
  141. package/src/utils/removeClassName.d.ts +35 -0
  142. package/src/utils/runKeyHandler.d.ts +12 -0
  143. package/src/utils/selectionHandler.d.ts +23 -0
  144. package/src/utils/twMerge.d.ts +4 -0
  145. package/typings.js +1 -0
  146. package/utils.js +333 -0
@@ -0,0 +1,15 @@
1
+ declare type BaseSizes = {
2
+ xxxsmall: any;
3
+ xxsmall: any;
4
+ xsmall: any;
5
+ small: any;
6
+ medium: any;
7
+ large: any;
8
+ inherit: any;
9
+ xlarge: any;
10
+ xxlarge: any;
11
+ xxxlarge: any;
12
+ };
13
+ export declare type BaseSizeKey = keyof BaseSizes;
14
+ export declare type BaseSize<T extends BaseSizeKey = 'small' | 'medium' | 'large'> = keyof Pick<BaseSizes, T>;
15
+ export {};
@@ -0,0 +1,50 @@
1
+ import type { MotionProps } from 'framer-motion';
2
+ import type { ComponentPropsWithRef, ElementType, HTMLAttributes, LegacyRef } from 'react';
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>> & {
5
+ /** Override the motion applied to the component */
6
+ motionProps?: MotionProps | null;
7
+ };
8
+ export declare type ClassesProp<K extends string> = {
9
+ /** Override or extend the styles applied to the component */
10
+ classes?: Partial<Record<K | 'root' | GlobalStateClassesKey, string>>;
11
+ };
12
+ export declare type PropsWithRoot<P, R extends ElementType, O extends string = ''> = P & Omit<ComponentPropsWithRef<R>, keyof P | O>;
13
+ 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> : P & {
14
+ /** className for `root` slot */
15
+ className?: string;
16
+ }) & ExtendAttributes;
17
+ /**
18
+ * make props work with classes key type and add `root`
19
+ *
20
+ * @example
21
+ * ```tsx
22
+ * type ClassesKeys = 'foo' | 'bar';
23
+ *
24
+ * type MyComponentProps = WithClassesProps<{ example: string }, ClassesKeys>
25
+ *
26
+ * const props: MyComponentProps;
27
+ *
28
+ * props.classes = 'root';
29
+ * props.classes = 'bar';
30
+ * props.classes = 'foo';
31
+ * ```
32
+ */
33
+ export declare type WithClassesProps<P, C extends string> = P & ClassesProp<C>;
34
+ /**
35
+ * @deprecated use `WithClassesProps` instead, just rename
36
+ */
37
+ export declare type BaseOverridableProps<P, C extends string> = WithClassesProps<P, C>;
38
+ export declare type OverridableProps<B, T extends ElementType> = B & {
39
+ /**
40
+ * The component used for the root node.
41
+ * Either a string to use a HTML element or a component.
42
+ */
43
+ component?: T;
44
+ } & Omit<ComponentPropsWithRef<T>, keyof B>;
45
+ export declare type RefFromProps<P> = P extends {
46
+ ref?: LegacyRef<infer R> | undefined;
47
+ } ? R : never;
48
+ export declare type HTMLDataAttribute = {
49
+ [key: `data-${string}`]: unknown;
50
+ };
@@ -0,0 +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];
@@ -0,0 +1,45 @@
1
+ /**
2
+ * This file copy from MUI
3
+ *
4
+ * https://github.com/mui/material-ui/blob/master/packages/mui-types/index.d.ts
5
+ */
6
+ import type React from 'react';
7
+ /**
8
+ * Remove properties `K` from `T`.
9
+ * Distributive for union types.
10
+ *
11
+ * @internal
12
+ */
13
+ export declare type DistributiveOmit<T, K extends keyof any> = T extends any ? Omit<T, K> : never;
14
+ /**
15
+ * A component whose root component can be controlled via a `component` prop.
16
+ *
17
+ * Adjusts valid props based on the type of `component`.
18
+ */
19
+ export interface OverridableComponent<M extends OverridableTypeMap> {
20
+ <C extends React.ElementType>(props: {
21
+ /**
22
+ * The component used for the root node.
23
+ * Either a string to use a HTML element or a component.
24
+ */
25
+ component: C;
26
+ } & OverrideProps<M, C>): JSX.Element | null;
27
+ (props: DefaultComponentProps<M>): JSX.Element | null;
28
+ displayName?: string;
29
+ }
30
+ /**
31
+ * Props of the component if `component={Component}` is used.
32
+ */
33
+ export declare type OverrideProps<M extends OverridableTypeMap, C extends React.ElementType> = (BaseProps<M> & DistributiveOmit<React.ComponentPropsWithRef<C>, keyof BaseProps<M>>);
34
+ /**
35
+ * Props if `component={Component}` is NOT used.
36
+ */
37
+ export declare type DefaultComponentProps<M extends OverridableTypeMap> = BaseProps<M> & DistributiveOmit<React.ComponentPropsWithRef<M['defaultComponent']>, keyof BaseProps<M>>;
38
+ /**
39
+ * Props defined on the component.
40
+ */
41
+ export declare type BaseProps<M extends OverridableTypeMap> = M['props'];
42
+ export interface OverridableTypeMap {
43
+ props: {};
44
+ defaultComponent: React.ElementType;
45
+ }
@@ -0,0 +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>);
@@ -0,0 +1,28 @@
1
+ /**
2
+ * @ignore
3
+ *
4
+ * fixed a map with unit key
5
+ */
6
+ export declare type UnitMap<T extends string | number | symbol, K = any> = {
7
+ [key in T]: K;
8
+ };
9
+ /**
10
+ * @ignore
11
+ *
12
+ * convert `classes` type to `classes map` type
13
+ */
14
+ export declare type ClassesMap<T extends {
15
+ classes?: any;
16
+ } | undefined, K = any> = Partial<UnitMap<Classes<T>, K>>;
17
+ declare type ClassesReturn<T extends {
18
+ classes?: any;
19
+ } | undefined> = keyof NonNullable<NonNullable<T>['classes']>;
20
+ /**
21
+ * get type of `classes` prop
22
+ *
23
+ * @returns classes type of prop
24
+ */
25
+ export declare type Classes<T extends {
26
+ classes?: any;
27
+ } | undefined> = ClassesReturn<T>;
28
+ export {};
@@ -0,0 +1,7 @@
1
+ export * from './BaseColor';
2
+ export * from './BaseSize';
3
+ export * from './ComponentTypes';
4
+ export * from './ExtractValue';
5
+ export * from './UnionOmit';
6
+ export * from './UnitMap';
7
+ export * from './OverridableTypes';
@@ -0,0 +1,8 @@
1
+ export declare const a11yKeyboard: {
2
+ ArrowLeft: string;
3
+ ArrowRight: string;
4
+ Space: string;
5
+ Escape: string;
6
+ Enter: string;
7
+ Tab: string;
8
+ };
@@ -0,0 +1,9 @@
1
+ /**
2
+ * Hides all elements in the DOM outside the given targets from screen readers using aria-hidden,
3
+ * and returns a function to revert these changes. In addition, changes to the DOM are watched
4
+ * and new elements outside the targets are automatically hidden.
5
+ * @param targets - The elements that should remain visible.
6
+ * @param root - Nothing will be hidden above this element.
7
+ * @returns - A function to restore all hidden elements.
8
+ */
9
+ export declare const ariaHideOutside: (targets: Element[], root?: HTMLElement) => () => void;
@@ -0,0 +1 @@
1
+ export declare function capitalize(string: string): string;
@@ -0,0 +1,3 @@
1
+ import { SyntheticEvent } from 'react';
2
+ /** check is that event preventDefault */
3
+ export declare const checkDefaultPrevented: (fc: (e: SyntheticEvent, ...args: any[]) => void) => (e: SyntheticEvent, ...args: any[]) => void;
@@ -0,0 +1,2 @@
1
+ import { ReactElement } from 'react';
2
+ export declare function checkElementName<T = any>(element: any, names: string[]): element is ReactElement<T>;
@@ -0,0 +1,2 @@
1
+ import { KeyboardEvent } from 'react';
2
+ export declare const isDeleteKeyboardEvent: (keyboardEvent: KeyboardEvent) => boolean;
@@ -0,0 +1,14 @@
1
+ export declare const globalStateClasses: {
2
+ active: string;
3
+ checked: string;
4
+ completed: string;
5
+ disabled: string;
6
+ expanded: string;
7
+ focused: string;
8
+ focusVisible: string;
9
+ focusVisibleWithin: string;
10
+ required: string;
11
+ selected: string;
12
+ dragged: string;
13
+ };
14
+ export declare type GlobalStateClassesKey = keyof typeof globalStateClasses;
@@ -0,0 +1,2 @@
1
+ export * from './globalStateClasses';
2
+ export * from './useClasses';
@@ -0,0 +1,41 @@
1
+ import type { CamelCase } from 'type-fest';
2
+ import { GlobalStateClassesKey } from './globalStateClasses';
3
+ export declare type Cls<T extends {
4
+ name: string;
5
+ classes: string;
6
+ }> = (...classValues: Array<T['classes'] | GlobalStateClassesKey | {
7
+ [key in T['classes'] | GlobalStateClassesKey]?: boolean | undefined | null;
8
+ } | undefined | null | false>) => string;
9
+ /**
10
+ * Custom hook for generating CSS classes based on input parameters.
11
+ *
12
+ * pick class from object with prefix of object like `sui-${prefix}-${key}`
13
+ *
14
+ * `className` will be apply to the `cls('root')` class.
15
+ *
16
+ * camelCase will be used for the key in the inputClasses object.
17
+ *
18
+ * and apply to kebabCase in the class name.
19
+ *
20
+ * ```tsx
21
+ * type BaseButtonClasses =
22
+ * | 'root'
23
+ * | 'content'
24
+ * | 'start-slot';
25
+ *
26
+ * const cls = useClasses<BaseButtonClasses>('button', {
27
+ * root: 'custom-button-root',
28
+ * content: 'custom-button-content',
29
+ * startSlot: 'custom-button-start-slot',
30
+ * }, 'custom-root-class');
31
+ *
32
+ * <button className={cls('root')}>Button</button> // 'sui-button-root custom-button-root custom-root-class'
33
+ * <button className={cls('content')}>Button</button> // 'sui-button-content custom-button-content'
34
+ *
35
+ * <button className={cls('start-slot')}>Button</button> // 'sui-button-start-slot custom-button-start-slot'
36
+ * ```
37
+ */
38
+ export declare const useClasses: <T extends {
39
+ name: string;
40
+ classes: string;
41
+ }>(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>;
@@ -0,0 +1,90 @@
1
+ /**
2
+ * Combine props object together
3
+ *
4
+ * that will group className, classes together
5
+ * function will auto combine together,
6
+ * trigger order is `intoProps.someFn(e) => defaultProps.someFn(e)`
7
+ *
8
+ * @param baseProps base props you want to combine together
9
+ * @param newProps want to combine in to props
10
+ * @param coverPropKeys some prop key you want to cover, not combine when type is function, ex. `ComponentType`
11
+ *
12
+ *
13
+ * @example
14
+ * ```tsx
15
+ * combineProps(
16
+ {
17
+ children: <A />,
18
+ value: '1',
19
+ className: 'a1',
20
+ classes: {
21
+ root: 'root1'
22
+ },
23
+ count: 1,
24
+ size: 'large',
25
+ onClick: fn1
26
+ },
27
+ {
28
+ children: <B />,
29
+ value: '2',
30
+ className: 'a2',
31
+ classes: {
32
+ root: 'root2'
33
+ },
34
+ count: 2,
35
+ size: undefined,
36
+ onClick: fn2
37
+ },
38
+ )
39
+ // output result:
40
+ {
41
+ children: <B />,
42
+ value: '2',
43
+ className: 'a1 a2',
44
+ classes: {
45
+ root: 'root1 root2'
46
+ },
47
+ count: 2,
48
+ size: 'large',
49
+ onClick: (e) => {
50
+ fn2(e);
51
+ fn1(e);
52
+ }
53
+ }
54
+ * ```
55
+ */
56
+ export declare const combineProps: <T>(baseProps: T, newProps: T | Partial<T>, coverPropKeys?: (keyof T)[] | undefined) => NonNullable<T>;
57
+ /**
58
+ * Combine two classes
59
+ *
60
+ * @param baseClasses base classes you want to combine together
61
+ * @param newClasses new classes want to combine in to props
62
+ *
63
+ * @example
64
+ * ```ts
65
+ * combineClasses(
66
+ {
67
+ root: 'a1',
68
+ input: 'a1',
69
+ un1: undefined,
70
+ un2: 'a4',
71
+ },
72
+ {
73
+ root: 'a1',
74
+ input: 'a2',
75
+ un1: 'a3',
76
+ un2: undefined,
77
+ un3: 'a5',
78
+ },
79
+ )
80
+ // output result:
81
+ {
82
+ root: 'a1 a1',
83
+ input: 'a1 a2',
84
+ un1: 'a3',
85
+ un2: 'a4',
86
+ un3: 'a5',
87
+ }
88
+ * ```
89
+ */
90
+ export declare const combineClasses: <T>(baseClasses: T, newClasses: T | Partial<T>) => NonNullable<T>;
@@ -0,0 +1,7 @@
1
+ export declare type DevlogArgs = {
2
+ condition?: boolean;
3
+ scope: string;
4
+ message: string;
5
+ level?: 'warn' | 'error';
6
+ };
7
+ export declare function logInDev({ scope, message, level, condition, }: DevlogArgs): void;
@@ -0,0 +1,6 @@
1
+ import { MutableRefObject, RefObject } from 'react';
2
+ export declare type RefOrElementOrCallback<T = HTMLElement> = RefObject<T> | (() => T) | T;
3
+ /**
4
+ * get element from React ref or callback
5
+ */
6
+ export declare const getRefElement: <T>(ref: T) => T extends () => infer R ? R : T extends RefObject<infer C> | MutableRefObject<infer C> ? C : T;
@@ -0,0 +1 @@
1
+ export declare const getTitle: (text: any) => string | undefined;
@@ -0,0 +1,25 @@
1
+ export * from './a11yKeyboardCode';
2
+ export * from './ariaHideOutside';
3
+ export * from './capitalize';
4
+ export * from './checkDefaultPrevented';
5
+ export * from './checkElementName';
6
+ export * from './checkKeyboardEvent';
7
+ export * from './classes';
8
+ export * from './combineProps';
9
+ export * from './devlog';
10
+ export * from './getRefElement';
11
+ export * from './getTitle';
12
+ export * from './isRef';
13
+ export * from './isSuiElement';
14
+ export * from './isUrl';
15
+ export * from './isWebKit154';
16
+ export * from './omit';
17
+ export * from './outerSize';
18
+ export * from './ownerDocument';
19
+ export * from './ownerWindow';
20
+ export * from './pick';
21
+ export * from './preloadImg';
22
+ export * from './removeClassName';
23
+ export * from './runKeyHandler';
24
+ export * from './selectionHandler';
25
+ export * from './twMerge';
@@ -0,0 +1,2 @@
1
+ import React from 'react';
2
+ export declare const isRef: <T = any>(obj: any) => obj is React.RefObject<T>;
@@ -0,0 +1 @@
1
+ export declare const isSuiElement: (element: any, suiNames: readonly string[]) => boolean;
@@ -0,0 +1 @@
1
+ export declare function isUrl(url: string): RegExpMatchArray | null;
@@ -0,0 +1,9 @@
1
+ /**
2
+ * Conditionally apply a workaround for the CSS transition bug in Safari 15.4 / WebKit browsers.
3
+ * Remove this workaround once the WebKit bug fix is released.
4
+ *
5
+ * follow up:
6
+ * https://github.com/mui/material-ui/pull/31975/files
7
+ * https://github.com/mui/material-ui/pull/32202/files
8
+ */
9
+ export declare const isWebKit154: boolean;
@@ -0,0 +1,2 @@
1
+ /** enhance lodash type */
2
+ export declare const omit: <T extends Record<string, unknown>, K extends (keyof T)[]>(classes: T | undefined, keys: K) => Partial<{ [K2 in Exclude<keyof T, K[number]>]: T[K2]; }>;
@@ -0,0 +1,8 @@
1
+ /**
2
+ * get that full height and margin with margin
3
+ * that will ignore transform animation
4
+ */
5
+ export declare function outerSize(el: HTMLElement): {
6
+ readonly height: number;
7
+ readonly width: number;
8
+ };
@@ -0,0 +1 @@
1
+ export { unstable_ownerDocument as ownerDocument } from '@mui/utils';
@@ -0,0 +1 @@
1
+ export declare const ownerWindow: (node: Node | undefined) => Window & typeof globalThis;
@@ -0,0 +1,2 @@
1
+ /** enhance lodash type */
2
+ export declare const pick: <T extends Record<string, unknown>, K extends (keyof T)[]>(classes: T | undefined, keys: K) => { [K2 in Extract<keyof T, K[number]>]: T[K2]; };
@@ -0,0 +1,2 @@
1
+ /** preload image file */
2
+ export declare function preloadImg(url: string): Promise<void>;
@@ -0,0 +1,35 @@
1
+ import { RefOrElementOrCallback } from './getRefElement';
2
+ declare type RemoveClassNameOptions = {
3
+ /**
4
+ * make replace also scan child nodes
5
+ *
6
+ * @default false
7
+ */
8
+ scanChildren?: boolean;
9
+ /**
10
+ * is that should fullMatch class name
11
+ *
12
+ * @default false
13
+ */
14
+ fullMatch?: boolean;
15
+ };
16
+ /**
17
+ * remove className from element, default will not scan child nodes, if you want to scan child nodes, set `scanChildren` to `true`.
18
+ *
19
+ * @param target target element reference or element or callback
20
+ * @param removeClass className to remove, default will use class `includes` to check, if you want to use full match, set `fullMatch` to `true`
21
+ *
22
+ * @example
23
+ * ```js
24
+ * elm => <div class="abc bcd efg abc-def"></div>
25
+ *
26
+ * removeClassName(elmRef, 'bcd');
27
+ *
28
+ * elm => <div class="abc efg abc-def"></div>
29
+ *
30
+ * removeClassName(elmRef, 'abc');
31
+ * elm => <div class="efg"></div>
32
+ * ```
33
+ */
34
+ export declare function removeClassName(target: RefOrElementOrCallback, removeClass: string, { scanChildren, fullMatch }?: RemoveClassNameOptions): void;
35
+ export {};
@@ -0,0 +1,12 @@
1
+ import { KeyboardEvent } from 'react';
2
+ declare type KeyHandlers = Record<KeyboardEvent['key'], () => void>;
3
+ /**
4
+ * Executes the corresponding key handler function based on the provided keyboard event.
5
+ * If a handler is found for the pressed key, it will be invoked.
6
+ * Additionally, it prevents any side effects caused by the event, such as page scrolling.
7
+ *
8
+ * @param e - The keyboard event.
9
+ * @param keyHandlers - An object containing key-handler mappings.
10
+ */
11
+ export declare const runKeyHandler: (e: KeyboardEvent<unknown>, keyHandlers: KeyHandlers) => void;
12
+ export {};
@@ -0,0 +1,23 @@
1
+ import { RefOrElementOrCallback } from './getRefElement';
2
+ /**
3
+ * get current input element selection position and is that selectRange state
4
+ */
5
+ export declare function getSelectionPosition<T extends HTMLInputElement | HTMLTextAreaElement>(sourceTarget: RefOrElementOrCallback<T>): {
6
+ isSelectRange: boolean;
7
+ position: {
8
+ start: number;
9
+ end: number;
10
+ };
11
+ };
12
+ /**
13
+ * set input element selection position position,
14
+ * if you need scroll that into view set `scrollIntoView` as true
15
+ */
16
+ export declare function setSelectionPosition<T extends HTMLInputElement | HTMLTextAreaElement>(target: RefOrElementOrCallback<T>, options: {
17
+ start: number | null;
18
+ end: number | null;
19
+ direction?: 'forward' | 'backward' | 'none' | undefined;
20
+ scrollIntoView?: boolean;
21
+ }): void;
22
+ /** clean whole selection */
23
+ export declare function clearWindowSelection(): void;
@@ -0,0 +1,4 @@
1
+ /**
2
+ * Merge tailwind classes with additional class groups for spring-ui
3
+ */
4
+ export declare const twMerge: (...classLists: import("tailwind-merge").ClassNameValue[]) => string;
package/typings.js ADDED
@@ -0,0 +1 @@
1
+