@necto/mergers 1.4.0 → 1.5.1
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/dist/index.cjs +1 -0
- package/dist/index.d.cts +43 -0
- package/dist/index.js +1 -1
- package/package.json +12 -4
package/dist/index.cjs
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";var c=Object.defineProperty;var u=Object.getOwnPropertyDescriptor;var l=Object.getOwnPropertyNames;var a=Object.prototype.hasOwnProperty;var p=(n,t)=>{for(var r in t)c(n,r,{get:t[r],enumerable:!0})},h=(n,t,r,o)=>{if(t&&typeof t=="object"||typeof t=="function")for(let e of l(t))!a.call(n,e)&&e!==r&&c(n,e,{get:()=>t[e],enumerable:!(o=u(t,e))||o.enumerable});return n};var d=n=>h(c({},"__esModule",{value:!0}),n);var R={};p(R,{mergeProps:()=>g,mergeRefs:()=>y});module.exports=d(R);function i(n,t){if(typeof n=="function")return n(t);n!=null&&(n.current=t)}function y(...n){return n.length===1&&n[0]?n[0]:t=>{let r=!1,o=n.map(e=>{let f=i(e,t);return r||=typeof f=="function",f});if(r)return()=>{o.forEach((e,f)=>{typeof e=="function"?e():i(n[f],null)})}}}function g(...n){if(n.length===0)return{};if(n.length===1)return typeof n[0]=="object"&&n[0]!==null?n[0]:{};let t={},r={};for(let o of n)if(!(typeof o!="object"||o===null)){for(let e in o)if(Object.hasOwn(o,e)){if(e==="children")continue;let f=o[e];e.startsWith("on")&&typeof f=="function"?(r[e]??=[],r[e].push(f)):t[e]=f}}for(let o in r)Object.hasOwn(r,o)&&r[o].length>0&&(t[o]=(...e)=>{for(let f of r[o])f?.(...e)});for(let o=n.length-1;o>=0;o--){let e=n[o];if(typeof e=="object"&&e!==null&&"children"in e){t.children=e.children;break}}return t}0&&(module.exports={mergeProps,mergeRefs});
|
package/dist/index.d.cts
ADDED
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import { Ref, RefObject } from 'react';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Copyright (c) Corinvo, LLC. and affiliates.
|
|
5
|
+
*
|
|
6
|
+
* This source code is licensed under the MIT license found in the
|
|
7
|
+
* LICENSE file in the root directory of this source tree.
|
|
8
|
+
*
|
|
9
|
+
*/
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* Merges multiple React refs into a single ref callback.
|
|
13
|
+
*
|
|
14
|
+
* Useful when you need to assign a value to multiple refs (e.g., both a forwarded ref and a local ref).
|
|
15
|
+
* If any of the refs return a cleanup function, the merged ref will return a cleanup function that calls all cleanups.
|
|
16
|
+
*
|
|
17
|
+
* @template T The type of the ref value.
|
|
18
|
+
* @param {...Array<Ref<T> | RefObject<T> | null | undefined>} refs - The refs to merge.
|
|
19
|
+
* @returns {Ref<T>} A single ref callback that updates all provided refs and handles cleanup if necessary.
|
|
20
|
+
*/
|
|
21
|
+
declare function mergeRefs<T>(...refs: Array<Ref<T> | RefObject<T> | null | undefined>): Ref<T>;
|
|
22
|
+
|
|
23
|
+
/**
|
|
24
|
+
* Copyright (c) Corinvo, LLC. and affiliates.
|
|
25
|
+
*
|
|
26
|
+
* This source code is licensed under the MIT license found in the
|
|
27
|
+
* LICENSE file in the root directory of this source tree.
|
|
28
|
+
*
|
|
29
|
+
*/
|
|
30
|
+
/**
|
|
31
|
+
* Merges multiple objects, combining properties.
|
|
32
|
+
* For properties starting with 'on' (conventionally event handlers),
|
|
33
|
+
* it creates a single function that calls all provided handlers.
|
|
34
|
+
* The 'children' property is taken from the last object in the list.
|
|
35
|
+
* For all other properties, the value from later objects overrides
|
|
36
|
+
* the value from earlier objects.
|
|
37
|
+
*
|
|
38
|
+
* @param listOfObjects - An array of objects to merge.
|
|
39
|
+
* @returns A single object with merged properties.
|
|
40
|
+
*/
|
|
41
|
+
declare function mergeProps(...listOfObjects: Record<string, any>[]): Record<string, any>;
|
|
42
|
+
|
|
43
|
+
export { mergeProps, mergeRefs };
|
package/dist/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
|
|
1
|
+
function c(n,r){if(typeof n=="function")return n(r);n!=null&&(n.current=r)}function i(...n){return n.length===1&&n[0]?n[0]:r=>{let f=!1,t=n.map(e=>{let o=c(e,r);return f||=typeof o=="function",o});if(f)return()=>{t.forEach((e,o)=>{typeof e=="function"?e():c(n[o],null)})}}}function l(...n){if(n.length===0)return{};if(n.length===1)return typeof n[0]=="object"&&n[0]!==null?n[0]:{};let r={},f={};for(let t of n)if(!(typeof t!="object"||t===null)){for(let e in t)if(Object.hasOwn(t,e)){if(e==="children")continue;let o=t[e];e.startsWith("on")&&typeof o=="function"?(f[e]??=[],f[e].push(o)):r[e]=o}}for(let t in f)Object.hasOwn(f,t)&&f[t].length>0&&(r[t]=(...e)=>{for(let o of f[t])o?.(...e)});for(let t=n.length-1;t>=0;t--){let e=n[t];if(typeof e=="object"&&e!==null&&"children"in e){r.children=e.children;break}}return r}export{l as mergeProps,i as mergeRefs};
|
package/package.json
CHANGED
|
@@ -1,14 +1,22 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@necto/mergers",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.5.1",
|
|
4
4
|
"description": "",
|
|
5
5
|
"files": [
|
|
6
6
|
"dist",
|
|
7
7
|
"README.md"
|
|
8
8
|
],
|
|
9
|
-
"
|
|
10
|
-
"
|
|
11
|
-
"
|
|
9
|
+
"type": "module",
|
|
10
|
+
"types": "./dist/index.d.ts",
|
|
11
|
+
"main": "./dist/index.cjs",
|
|
12
|
+
"module": "./dist/index.js",
|
|
13
|
+
"exports": {
|
|
14
|
+
".": {
|
|
15
|
+
"types": "./dist/index.d.ts",
|
|
16
|
+
"import": "./dist/index.js",
|
|
17
|
+
"require": "./dist/index.cjs"
|
|
18
|
+
}
|
|
19
|
+
},
|
|
12
20
|
"keywords": [],
|
|
13
21
|
"author": "Corinvo OSS Team",
|
|
14
22
|
"license": "MIT",
|