mirror of
https://github.com/zoriya/v10.git
synced 2026-08-12 00:49:29 +00:00
25 lines
807 B
TypeScript
25 lines
807 B
TypeScript
import { ComponentPropsWithRef, ElementType } from "react";
|
|
//#region src/utils/merge-props.d.ts
|
|
type Props<T extends ElementType = ElementType> = ComponentPropsWithRef<T>;
|
|
/**
|
|
* Merge multiple props objects.
|
|
*
|
|
* - Event handlers (on*): chained - external first, ours second
|
|
* - className: concatenated
|
|
* - style: merged objects (external wins conflicts)
|
|
* - other: last one wins
|
|
*
|
|
* @public
|
|
* @example
|
|
* ```ts
|
|
* const merged = mergeProps(
|
|
* { onClick: ourHandler, className: 'base' },
|
|
* { onClick: theirHandler, className: 'custom' }
|
|
* );
|
|
* // { onClick: chainedHandler, className: 'custom base' }
|
|
* ```
|
|
*/
|
|
declare function mergeProps<T extends ElementType>(...propSets: (Props<T> | undefined)[]): Props<T>;
|
|
//#endregion
|
|
export { mergeProps };
|
|
//# sourceMappingURL=merge-props.d.ts.map
|