zag-ripple 0.0.13 → 0.0.14
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/package.json +1 -1
- package/src/index.ripple +28 -1
package/package.json
CHANGED
package/src/index.ripple
CHANGED
|
@@ -1,4 +1,31 @@
|
|
|
1
|
-
export { mergeProps } from "@zag-js/core"
|
|
2
1
|
export * from "./normalize-props.ripple"
|
|
3
2
|
export * from "./machine.ripple"
|
|
4
3
|
export * from "./portal.ripple"
|
|
4
|
+
|
|
5
|
+
export function mergeProps<T extends Record<string, any>>(...args: T[]): T {
|
|
6
|
+
let result: any = {}
|
|
7
|
+
for (const props of args) {
|
|
8
|
+
if (!props) continue
|
|
9
|
+
for (const key in result) {
|
|
10
|
+
const pv = props[key]
|
|
11
|
+
const derefPv = @pv
|
|
12
|
+
if (key.startsWith("on") && typeof result[key] === "function" && typeof derefPv === "function") {
|
|
13
|
+
const prev = result[key]
|
|
14
|
+
result[key] = (...a: any[]) => { derefPv(...a); prev(...a) }
|
|
15
|
+
continue
|
|
16
|
+
}
|
|
17
|
+
result[key] = derefPv !== undefined ? derefPv : result[key]
|
|
18
|
+
}
|
|
19
|
+
for (const key in props) {
|
|
20
|
+
if (result[key] === undefined) {
|
|
21
|
+
const pv = props[key]
|
|
22
|
+
result[key] = @pv
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
for (const sym of Object.getOwnPropertySymbols(props)) {
|
|
26
|
+
result[sym] = (props as any)[sym]
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
return result
|
|
30
|
+
}
|
|
31
|
+
|