1 | import _extends from "@babel/runtime/helpers/esm/extends";
|
2 | import clsx from 'clsx';
|
3 | import { extractEventHandlers } from './extractEventHandlers';
|
4 | import { omitEventHandlers } from './omitEventHandlers';
|
5 |
|
6 |
|
7 |
|
8 |
|
9 |
|
10 |
|
11 |
|
12 |
|
13 |
|
14 |
|
15 |
|
16 |
|
17 |
|
18 | export function mergeSlotProps(parameters) {
|
19 | const {
|
20 | getSlotProps,
|
21 | additionalProps,
|
22 | externalSlotProps,
|
23 | externalForwardedProps,
|
24 | className
|
25 | } = parameters;
|
26 | if (!getSlotProps) {
|
27 |
|
28 |
|
29 | const joinedClasses = clsx(additionalProps?.className, className, externalForwardedProps?.className, externalSlotProps?.className);
|
30 | const mergedStyle = _extends({}, additionalProps?.style, externalForwardedProps?.style, externalSlotProps?.style);
|
31 | const props = _extends({}, additionalProps, externalForwardedProps, externalSlotProps);
|
32 | if (joinedClasses.length > 0) {
|
33 | props.className = joinedClasses;
|
34 | }
|
35 | if (Object.keys(mergedStyle).length > 0) {
|
36 | props.style = mergedStyle;
|
37 | }
|
38 | return {
|
39 | props,
|
40 | internalRef: undefined
|
41 | };
|
42 | }
|
43 |
|
44 |
|
45 |
|
46 |
|
47 | const eventHandlers = extractEventHandlers(_extends({}, externalForwardedProps, externalSlotProps));
|
48 | const componentsPropsWithoutEventHandlers = omitEventHandlers(externalSlotProps);
|
49 | const otherPropsWithoutEventHandlers = omitEventHandlers(externalForwardedProps);
|
50 | const internalSlotProps = getSlotProps(eventHandlers);
|
51 |
|
52 |
|
53 |
|
54 |
|
55 |
|
56 | const joinedClasses = clsx(internalSlotProps?.className, additionalProps?.className, className, externalForwardedProps?.className, externalSlotProps?.className);
|
57 | const mergedStyle = _extends({}, internalSlotProps?.style, additionalProps?.style, externalForwardedProps?.style, externalSlotProps?.style);
|
58 | const props = _extends({}, internalSlotProps, additionalProps, otherPropsWithoutEventHandlers, componentsPropsWithoutEventHandlers);
|
59 | if (joinedClasses.length > 0) {
|
60 | props.className = joinedClasses;
|
61 | }
|
62 | if (Object.keys(mergedStyle).length > 0) {
|
63 | props.style = mergedStyle;
|
64 | }
|
65 | return {
|
66 | props,
|
67 | internalRef: internalSlotProps.ref
|
68 | };
|
69 | } |
\ | No newline at end of file |