1 | import _extends from "@babel/runtime/helpers/esm/extends";
|
2 | /**
|
3 | * Combines the two get*Props functions from Base UI hooks into one.
|
4 | * Useful when a hook uses two other hooks behind the scenes
|
5 | * (such as useSelect that depends on useList and useButton for its root slot).
|
6 | *
|
7 | * The resulting function will return the combined props.
|
8 | * They are merged from left to right, similarly to how Object.assign works.
|
9 | *
|
10 | * The getSecondProps function will receive the result of the getFirstProps function as its argument,
|
11 | * so its event handlers can call the previous handlers and act depending on its result.
|
12 | *
|
13 | * @param getFirstProps - A getter function that returns the props for the first slot. It receives the external event handlers as its argument.
|
14 | * @param getSecondProps - A getter function that returns the props for the second slot. It receives the result of the getFirstProps function as its argument.
|
15 | */
|
16 | export function combineHooksSlotProps(getFirstProps, getSecondProps) {
|
17 | return function getCombinedProps(external = {}) {
|
18 | const firstResult = _extends({}, external, getFirstProps(external));
|
19 | const result = _extends({}, firstResult, getSecondProps(firstResult));
|
20 | return result;
|
21 | };
|
22 | } |
\ | No newline at end of file |