@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.
- package/LICENSE +22 -0
- package/README.md +61 -0
- package/chunks/twMerge.js +409 -0
- package/config.js +78 -0
- package/contexts.js +71 -0
- package/hooks.js +2101 -0
- package/index.d.ts +1 -0
- package/index.js +16 -0
- package/package.json +30 -0
- package/src/config.d.ts +40 -0
- package/src/contexts/ResponsiveContext/ResponsiveContext.d.ts +7 -0
- package/src/contexts/ResponsiveContext/breakpointList.d.ts +3 -0
- package/src/contexts/ResponsiveContext/getMatchDetail.d.ts +2 -0
- package/src/contexts/ResponsiveContext/index.d.ts +4 -0
- package/src/contexts/ResponsiveContext/types.d.ts +24 -0
- package/src/contexts/WindowContext.d.ts +9 -0
- package/src/contexts/index.d.ts +2 -0
- package/src/hooks/index.d.ts +43 -0
- package/src/hooks/useA11yKeyEvent/index.d.ts +1 -0
- package/src/hooks/useA11yKeyEvent/useA11yKeyEvent.d.ts +23 -0
- package/src/hooks/useActive/index.d.ts +1 -0
- package/src/hooks/useActive/useActive.d.ts +23 -0
- package/src/hooks/useAnnouncer/index.d.ts +1 -0
- package/src/hooks/useAnnouncer/useAnnouncer.d.ts +12 -0
- package/src/hooks/useAriaHideOutside/index.d.ts +1 -0
- package/src/hooks/useAriaHideOutside/useAriaHideOutside.d.ts +12 -0
- package/src/hooks/useAudio/index.d.ts +1 -0
- package/src/hooks/useAudio/useAudio.d.ts +21 -0
- package/src/hooks/useBodyScrollLock/index.d.ts +1 -0
- package/src/hooks/useBodyScrollLock/useBodyScrollLock.d.ts +25 -0
- package/src/hooks/useChange/index.d.ts +1 -0
- package/src/hooks/useChange/useChange.d.ts +12 -0
- package/src/hooks/useClickAway/index.d.ts +1 -0
- package/src/hooks/useClickAway/useClickAway.d.ts +22 -0
- package/src/hooks/useControlled/index.d.ts +1 -0
- package/src/hooks/useControlled/useControlled.d.ts +1 -0
- package/src/hooks/useDebounce/index.d.ts +1 -0
- package/src/hooks/useDebounce/useDebounce.d.ts +8 -0
- package/src/hooks/useEventCallback/index.d.ts +1 -0
- package/src/hooks/useEventCallback/useEventCallback.d.ts +1 -0
- package/src/hooks/useEventListener/index.d.ts +1 -0
- package/src/hooks/useEventListener/useEventListener.d.ts +32 -0
- package/src/hooks/useEver/index.d.ts +1 -0
- package/src/hooks/useEver/useEver.d.ts +13 -0
- package/src/hooks/useFocusVisible/index.d.ts +1 -0
- package/src/hooks/useFocusVisible/useFocusVisible.d.ts +22 -0
- package/src/hooks/useFontLoaded/index.d.ts +1 -0
- package/src/hooks/useFontLoaded/useFontLoaded.d.ts +13 -0
- package/src/hooks/useForceUpdate/index.d.ts +1 -0
- package/src/hooks/useForceUpdate/useForceUpdate.d.ts +5 -0
- package/src/hooks/useForkRef/index.d.ts +1 -0
- package/src/hooks/useForkRef/useForkRef.d.ts +19 -0
- package/src/hooks/useGlobalListener/createGlobalListener.d.ts +55 -0
- package/src/hooks/useGlobalListener/index.d.ts +2 -0
- package/src/hooks/useGlobalListener/useGlobalListener.d.ts +14 -0
- package/src/hooks/useHiddenTabindex/index.d.ts +1 -0
- package/src/hooks/useHiddenTabindex/useHiddenTabindex.d.ts +9 -0
- package/src/hooks/useHover/index.d.ts +2 -0
- package/src/hooks/useHover/useHover.d.ts +17 -0
- package/src/hooks/useHover/useHoverDirty.d.ts +8 -0
- package/src/hooks/useId/index.d.ts +1 -0
- package/src/hooks/useId/useId.d.ts +15 -0
- package/src/hooks/useImgLoaded/index.d.ts +1 -0
- package/src/hooks/useImgLoaded/useImgLoaded.d.ts +24 -0
- package/src/hooks/useInterval/index.d.ts +1 -0
- package/src/hooks/useInterval/useInterval.d.ts +43 -0
- package/src/hooks/useIsFocusVisible/index.d.ts +2 -0
- package/src/hooks/useIsFocusVisible/useIsFocusVisible.d.ts +9 -0
- package/src/hooks/useKeyDownOnce/index.d.ts +1 -0
- package/src/hooks/useKeyDownOnce/useKeyDownOnce.d.ts +15 -0
- package/src/hooks/useKeyboardMoveFocus/index.d.ts +3 -0
- package/src/hooks/useKeyboardMoveFocus/moveIndexInTwoDimension.d.ts +18 -0
- package/src/hooks/useKeyboardMoveFocus/useKeyboardMoveFocus.d.ts +49 -0
- package/src/hooks/useKeyboardMoveFocus/useOnlyOneFocusable.d.ts +17 -0
- package/src/hooks/useLongPress/index.d.ts +1 -0
- package/src/hooks/useLongPress/useLongPress.d.ts +39 -0
- package/src/hooks/useMountState/index.d.ts +1 -0
- package/src/hooks/useMountState/useMountState.d.ts +16 -0
- package/src/hooks/useOnLayoutReRender/index.d.ts +1 -0
- package/src/hooks/useOnLayoutReRender/useOnLayoutReRender.d.ts +5 -0
- package/src/hooks/useOnReRender/index.d.ts +1 -0
- package/src/hooks/useOnReRender/useOnReRender.d.ts +5 -0
- package/src/hooks/useOverflow/index.d.ts +1 -0
- package/src/hooks/useOverflow/useOverflow.d.ts +11 -0
- package/src/hooks/usePrevious/index.d.ts +1 -0
- package/src/hooks/usePrevious/usePrevious.d.ts +7 -0
- package/src/hooks/useRefState/index.d.ts +1 -0
- package/src/hooks/useRefState/useRefState.d.ts +21 -0
- package/src/hooks/useResizeObserver/index.d.ts +1 -0
- package/src/hooks/useResizeObserver/useResizeObserver.d.ts +24 -0
- package/src/hooks/useResponsiveMatch/index.d.ts +1 -0
- package/src/hooks/useResponsiveMatch/useResponsiveMatch.d.ts +7 -0
- package/src/hooks/useResultRef/index.d.ts +1 -0
- package/src/hooks/useResultRef/useResultRef.d.ts +10 -0
- package/src/hooks/useRetry/index.d.ts +1 -0
- package/src/hooks/useRetry/useRetry.d.ts +35 -0
- package/src/hooks/useSleep/index.d.ts +1 -0
- package/src/hooks/useSleep/useSleep.d.ts +22 -0
- package/src/hooks/useTabOut/index.d.ts +1 -0
- package/src/hooks/useTabOut/useTabOut.d.ts +10 -0
- package/src/hooks/useTestRunnerDetection.d.ts +7 -0
- package/src/hooks/useThrottle/index.d.ts +1 -0
- package/src/hooks/useThrottle/useThrottle.d.ts +8 -0
- package/src/hooks/useTimeout/index.d.ts +1 -0
- package/src/hooks/useTimeout/useTimeout.d.ts +2 -0
- package/src/hooks/useTouchMouseEvent/index.d.ts +1 -0
- package/src/hooks/useTouchMouseEvent/useTouchMouseEvent.d.ts +56 -0
- package/src/index.d.ts +5 -0
- package/src/typings/BaseColor.d.ts +14 -0
- package/src/typings/BaseSize.d.ts +15 -0
- package/src/typings/ComponentTypes.d.ts +50 -0
- package/src/typings/ExtractValue.d.ts +2 -0
- package/src/typings/OverridableTypes.d.ts +45 -0
- package/src/typings/UnionOmit.d.ts +3 -0
- package/src/typings/UnitMap.d.ts +28 -0
- package/src/typings/index.d.ts +7 -0
- package/src/utils/a11yKeyboardCode.d.ts +8 -0
- package/src/utils/ariaHideOutside.d.ts +9 -0
- package/src/utils/capitalize.d.ts +1 -0
- package/src/utils/checkDefaultPrevented.d.ts +3 -0
- package/src/utils/checkElementName.d.ts +2 -0
- package/src/utils/checkKeyboardEvent.d.ts +2 -0
- package/src/utils/classes/globalStateClasses.d.ts +14 -0
- package/src/utils/classes/index.d.ts +2 -0
- package/src/utils/classes/useClasses.d.ts +41 -0
- package/src/utils/combineProps.d.ts +90 -0
- package/src/utils/devlog.d.ts +7 -0
- package/src/utils/getRefElement.d.ts +6 -0
- package/src/utils/getTitle.d.ts +1 -0
- package/src/utils/index.d.ts +25 -0
- package/src/utils/isRef.d.ts +2 -0
- package/src/utils/isSuiElement.d.ts +1 -0
- package/src/utils/isUrl.d.ts +1 -0
- package/src/utils/isWebKit154.d.ts +9 -0
- package/src/utils/omit.d.ts +2 -0
- package/src/utils/outerSize.d.ts +8 -0
- package/src/utils/ownerDocument.d.ts +1 -0
- package/src/utils/ownerWindow.d.ts +1 -0
- package/src/utils/pick.d.ts +2 -0
- package/src/utils/preloadImg.d.ts +2 -0
- package/src/utils/removeClassName.d.ts +35 -0
- package/src/utils/runKeyHandler.d.ts +12 -0
- package/src/utils/selectionHandler.d.ts +23 -0
- package/src/utils/twMerge.d.ts +4 -0
- package/typings.js +1 -0
- 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,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,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,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,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,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,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 @@
|
|
|
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 @@
|
|
|
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,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;
|
package/typings.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
|