@rzl-zone/core-react
Advanced tools
| /*! | ||
| * ======================================================================== | ||
| * @rzl-zone/core-react | ||
| * ------------------------------------------------------------------------ | ||
| * Version: `0.0.13-beta.1` | ||
| * Author: `Rizalvin Dwiky <rizalvindwiky1998@gmail.com>` | ||
| * Repository: `https://github.com/rzl-zone/rzl-zone/tree/main/packages/core-react` | ||
| * ======================================================================== | ||
| */ | ||
| "use strict"; | ||
| var __create = Object.create; | ||
| var __defProp = Object.defineProperty; | ||
| var __getOwnPropDesc = Object.getOwnPropertyDescriptor; | ||
| var __getOwnPropNames = Object.getOwnPropertyNames; | ||
| var __getProtoOf = Object.getPrototypeOf; | ||
| var __hasOwnProp = Object.prototype.hasOwnProperty; | ||
| var __copyProps = (to, from, except, desc) => { | ||
| if (from && typeof from === "object" || typeof from === "function") { | ||
| for (var keys = __getOwnPropNames(from), i = 0, n = keys.length, key; i < n; i++) { | ||
| key = keys[i]; | ||
| if (!__hasOwnProp.call(to, key) && key !== except) { | ||
| __defProp(to, key, { | ||
| get: ((k) => from[k]).bind(null, key), | ||
| enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable | ||
| }); | ||
| } | ||
| } | ||
| } | ||
| return to; | ||
| }; | ||
| var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { | ||
| value: mod, | ||
| enumerable: true | ||
| }) : target, mod)); | ||
| Object.defineProperty(exports, '__toESM', { | ||
| enumerable: true, | ||
| get: function () { | ||
| return __toESM; | ||
| } | ||
| }); |
@@ -5,3 +5,3 @@ /*! | ||
| * ------------------------------------------------------------------------ | ||
| * Version: `0.0.13-beta.0` | ||
| * Version: `0.0.13-beta.1` | ||
| * Author: `Rizalvin Dwiky <rizalvindwiky1998@gmail.com>` | ||
@@ -8,0 +8,0 @@ * Repository: `https://github.com/rzl-zone/rzl-zone/tree/main/packages/core-react` |
@@ -5,3 +5,3 @@ /*! | ||
| * ------------------------------------------------------------------------ | ||
| * Version: `0.0.13-beta.0` | ||
| * Version: `0.0.13-beta.1` | ||
| * Author: `Rizalvin Dwiky <rizalvindwiky1998@gmail.com>` | ||
@@ -8,0 +8,0 @@ * Repository: `https://github.com/rzl-zone/rzl-zone/tree/main/packages/core-react` |
@@ -5,3 +5,3 @@ /*! | ||
| * ------------------------------------------------------------------------ | ||
| * Version: `0.0.13-beta.0` | ||
| * Version: `0.0.13-beta.1` | ||
| * Author: `Rizalvin Dwiky <rizalvindwiky1998@gmail.com>` | ||
@@ -8,0 +8,0 @@ * Repository: `https://github.com/rzl-zone/rzl-zone/tree/main/packages/core-react` |
@@ -5,3 +5,3 @@ /*! | ||
| * ------------------------------------------------------------------------ | ||
| * Version: `0.0.13-beta.0` | ||
| * Version: `0.0.13-beta.1` | ||
| * Author: `Rizalvin Dwiky <rizalvindwiky1998@gmail.com>` | ||
@@ -8,0 +8,0 @@ * Repository: `https://github.com/rzl-zone/rzl-zone/tree/main/packages/core-react` |
@@ -5,3 +5,3 @@ /*! | ||
| * ------------------------------------------------------------------------ | ||
| * Version: `0.0.13-beta.0` | ||
| * Version: `0.0.13-beta.1` | ||
| * Author: `Rizalvin Dwiky <rizalvindwiky1998@gmail.com>` | ||
@@ -8,0 +8,0 @@ * Repository: `https://github.com/rzl-zone/rzl-zone/tree/main/packages/core-react` |
@@ -5,3 +5,3 @@ /*! | ||
| * ------------------------------------------------------------------------ | ||
| * Version: `0.0.13-beta.0` | ||
| * Version: `0.0.13-beta.1` | ||
| * Author: `Rizalvin Dwiky <rizalvindwiky1998@gmail.com>` | ||
@@ -8,0 +8,0 @@ * Repository: `https://github.com/rzl-zone/rzl-zone/tree/main/packages/core-react` |
@@ -5,3 +5,3 @@ /*! | ||
| * ------------------------------------------------------------------------ | ||
| * Version: `0.0.13-beta.0` | ||
| * Version: `0.0.13-beta.1` | ||
| * Author: `Rizalvin Dwiky <rizalvindwiky1998@gmail.com>` | ||
@@ -14,6 +14,6 @@ * Repository: `https://github.com/rzl-zone/rzl-zone/tree/main/packages/core-react` | ||
| Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' }); | ||
| const require_chunk = require('../chunk-D2J91LqI.cjs'); | ||
| const require_rolldown_runtime = require('../rolldown-runtime-CQPxKT-D.cjs'); | ||
| let _rzl_zone_utils_js_predicates = require("@rzl-zone/utils-js/predicates"); | ||
| let react = require("react"); | ||
| react = require_chunk.__toESM(react); | ||
| react = require_rolldown_runtime.__toESM(react, 1); | ||
| function createRequiredContext(name, defaultValue) { | ||
@@ -20,0 +20,0 @@ if (!(0, _rzl_zone_utils_js_predicates.isNonEmptyString)(name)) throw new Error("Invalid `context` name passed to `createRequiredContext`: expected a non-empty string."); |
@@ -5,3 +5,3 @@ /*! | ||
| * ------------------------------------------------------------------------ | ||
| * Version: `0.0.13-beta.0` | ||
| * Version: `0.0.13-beta.1` | ||
| * Author: `Rizalvin Dwiky <rizalvindwiky1998@gmail.com>` | ||
@@ -8,0 +8,0 @@ * Repository: `https://github.com/rzl-zone/rzl-zone/tree/main/packages/core-react` |
@@ -5,3 +5,3 @@ /*! | ||
| * ------------------------------------------------------------------------ | ||
| * Version: `0.0.13-beta.0` | ||
| * Version: `0.0.13-beta.1` | ||
| * Author: `Rizalvin Dwiky <rizalvindwiky1998@gmail.com>` | ||
@@ -8,0 +8,0 @@ * Repository: `https://github.com/rzl-zone/rzl-zone/tree/main/packages/core-react` |
@@ -5,3 +5,3 @@ /*! | ||
| * ------------------------------------------------------------------------ | ||
| * Version: `0.0.13-beta.0` | ||
| * Version: `0.0.13-beta.1` | ||
| * Author: `Rizalvin Dwiky <rizalvindwiky1998@gmail.com>` | ||
@@ -8,0 +8,0 @@ * Repository: `https://github.com/rzl-zone/rzl-zone/tree/main/packages/core-react` |
@@ -5,3 +5,3 @@ /*! | ||
| * ------------------------------------------------------------------------ | ||
| * Version: `0.0.13-beta.0` | ||
| * Version: `0.0.13-beta.1` | ||
| * Author: `Rizalvin Dwiky <rizalvindwiky1998@gmail.com>` | ||
@@ -8,0 +8,0 @@ * Repository: `https://github.com/rzl-zone/rzl-zone/tree/main/packages/core-react` |
@@ -5,3 +5,3 @@ /*! | ||
| * ------------------------------------------------------------------------ | ||
| * Version: `0.0.13-beta.0` | ||
| * Version: `0.0.13-beta.1` | ||
| * Author: `Rizalvin Dwiky <rizalvindwiky1998@gmail.com>` | ||
@@ -8,0 +8,0 @@ * Repository: `https://github.com/rzl-zone/rzl-zone/tree/main/packages/core-react` |
@@ -5,3 +5,3 @@ /*! | ||
| * ------------------------------------------------------------------------ | ||
| * Version: `0.0.13-beta.0` | ||
| * Version: `0.0.13-beta.1` | ||
| * Author: `Rizalvin Dwiky <rizalvindwiky1998@gmail.com>` | ||
@@ -8,0 +8,0 @@ * Repository: `https://github.com/rzl-zone/rzl-zone/tree/main/packages/core-react` |
@@ -5,3 +5,3 @@ /*! | ||
| * ------------------------------------------------------------------------ | ||
| * Version: `0.0.13-beta.0` | ||
| * Version: `0.0.13-beta.1` | ||
| * Author: `Rizalvin Dwiky <rizalvindwiky1998@gmail.com>` | ||
@@ -8,0 +8,0 @@ * Repository: `https://github.com/rzl-zone/rzl-zone/tree/main/packages/core-react` |
@@ -5,3 +5,3 @@ /*! | ||
| * ------------------------------------------------------------------------ | ||
| * Version: `0.0.13-beta.0` | ||
| * Version: `0.0.13-beta.1` | ||
| * Author: `Rizalvin Dwiky <rizalvindwiky1998@gmail.com>` | ||
@@ -14,5 +14,5 @@ * Repository: `https://github.com/rzl-zone/rzl-zone/tree/main/packages/core-react` | ||
| Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' }); | ||
| const require_chunk = require('../chunk-D2J91LqI.cjs'); | ||
| const require_rolldown_runtime = require('../rolldown-runtime-CQPxKT-D.cjs'); | ||
| let react = require("react"); | ||
| react = require_chunk.__toESM(react, 1); | ||
| react = require_rolldown_runtime.__toESM(react, 1); | ||
| const useEffectEvent = "useEffectEvent" in react ? { ...react }.useEffectEvent : (callback) => { | ||
@@ -19,0 +19,0 @@ const ref = react.useRef(callback); |
@@ -5,3 +5,3 @@ /*! | ||
| * ------------------------------------------------------------------------ | ||
| * Version: `0.0.13-beta.0` | ||
| * Version: `0.0.13-beta.1` | ||
| * Author: `Rizalvin Dwiky <rizalvindwiky1998@gmail.com>` | ||
@@ -8,0 +8,0 @@ * Repository: `https://github.com/rzl-zone/rzl-zone/tree/main/packages/core-react` |
@@ -5,3 +5,3 @@ /*! | ||
| * ------------------------------------------------------------------------ | ||
| * Version: `0.0.13-beta.0` | ||
| * Version: `0.0.13-beta.1` | ||
| * Author: `Rizalvin Dwiky <rizalvindwiky1998@gmail.com>` | ||
@@ -8,0 +8,0 @@ * Repository: `https://github.com/rzl-zone/rzl-zone/tree/main/packages/core-react` |
@@ -5,3 +5,3 @@ /*! | ||
| * ------------------------------------------------------------------------ | ||
| * Version: `0.0.13-beta.0` | ||
| * Version: `0.0.13-beta.1` | ||
| * Author: `Rizalvin Dwiky <rizalvindwiky1998@gmail.com>` | ||
@@ -8,0 +8,0 @@ * Repository: `https://github.com/rzl-zone/rzl-zone/tree/main/packages/core-react` |
@@ -5,3 +5,3 @@ /*! | ||
| * ------------------------------------------------------------------------ | ||
| * Version: `0.0.13-beta.0` | ||
| * Version: `0.0.13-beta.1` | ||
| * Author: `Rizalvin Dwiky <rizalvindwiky1998@gmail.com>` | ||
@@ -8,0 +8,0 @@ * Repository: `https://github.com/rzl-zone/rzl-zone/tree/main/packages/core-react` |
@@ -5,3 +5,3 @@ /*! | ||
| * ------------------------------------------------------------------------ | ||
| * Version: `0.0.13-beta.0` | ||
| * Version: `0.0.13-beta.1` | ||
| * Author: `Rizalvin Dwiky <rizalvindwiky1998@gmail.com>` | ||
@@ -8,0 +8,0 @@ * Repository: `https://github.com/rzl-zone/rzl-zone/tree/main/packages/core-react` |
@@ -5,3 +5,3 @@ /*! | ||
| * ------------------------------------------------------------------------ | ||
| * Version: `0.0.13-beta.0` | ||
| * Version: `0.0.13-beta.1` | ||
| * Author: `Rizalvin Dwiky <rizalvindwiky1998@gmail.com>` | ||
@@ -8,0 +8,0 @@ * Repository: `https://github.com/rzl-zone/rzl-zone/tree/main/packages/core-react` |
@@ -5,3 +5,3 @@ /*! | ||
| * ------------------------------------------------------------------------ | ||
| * Version: `0.0.13-beta.0` | ||
| * Version: `0.0.13-beta.1` | ||
| * Author: `Rizalvin Dwiky <rizalvindwiky1998@gmail.com>` | ||
@@ -8,0 +8,0 @@ * Repository: `https://github.com/rzl-zone/rzl-zone/tree/main/packages/core-react` |
@@ -5,3 +5,3 @@ /*! | ||
| * ------------------------------------------------------------------------ | ||
| * Version: `0.0.13-beta.0` | ||
| * Version: `0.0.13-beta.1` | ||
| * Author: `Rizalvin Dwiky <rizalvindwiky1998@gmail.com>` | ||
@@ -8,0 +8,0 @@ * Repository: `https://github.com/rzl-zone/rzl-zone/tree/main/packages/core-react` |
@@ -5,3 +5,3 @@ /*! | ||
| * ------------------------------------------------------------------------ | ||
| * Version: `0.0.13-beta.0` | ||
| * Version: `0.0.13-beta.1` | ||
| * Author: `Rizalvin Dwiky <rizalvindwiky1998@gmail.com>` | ||
@@ -8,0 +8,0 @@ * Repository: `https://github.com/rzl-zone/rzl-zone/tree/main/packages/core-react` |
@@ -5,3 +5,3 @@ /*! | ||
| * ------------------------------------------------------------------------ | ||
| * Version: `0.0.13-beta.0` | ||
| * Version: `0.0.13-beta.1` | ||
| * Author: `Rizalvin Dwiky <rizalvindwiky1998@gmail.com>` | ||
@@ -8,0 +8,0 @@ * Repository: `https://github.com/rzl-zone/rzl-zone/tree/main/packages/core-react` |
@@ -5,3 +5,3 @@ /*! | ||
| * ------------------------------------------------------------------------ | ||
| * Version: `0.0.13-beta.0` | ||
| * Version: `0.0.13-beta.1` | ||
| * Author: `Rizalvin Dwiky <rizalvindwiky1998@gmail.com>` | ||
@@ -8,0 +8,0 @@ * Repository: `https://github.com/rzl-zone/rzl-zone/tree/main/packages/core-react` |
@@ -5,3 +5,3 @@ /*! | ||
| * ------------------------------------------------------------------------ | ||
| * Version: `0.0.13-beta.0` | ||
| * Version: `0.0.13-beta.1` | ||
| * Author: `Rizalvin Dwiky <rizalvindwiky1998@gmail.com>` | ||
@@ -8,0 +8,0 @@ * Repository: `https://github.com/rzl-zone/rzl-zone/tree/main/packages/core-react` |
@@ -5,3 +5,3 @@ /*! | ||
| * ------------------------------------------------------------------------ | ||
| * Version: `0.0.13-beta.0` | ||
| * Version: `0.0.13-beta.1` | ||
| * Author: `Rizalvin Dwiky <rizalvindwiky1998@gmail.com>` | ||
@@ -8,0 +8,0 @@ * Repository: `https://github.com/rzl-zone/rzl-zone/tree/main/packages/core-react` |
@@ -5,3 +5,3 @@ /*! | ||
| * ------------------------------------------------------------------------ | ||
| * Version: `0.0.13-beta.0` | ||
| * Version: `0.0.13-beta.1` | ||
| * Author: `Rizalvin Dwiky <rizalvindwiky1998@gmail.com>` | ||
@@ -8,0 +8,0 @@ * Repository: `https://github.com/rzl-zone/rzl-zone/tree/main/packages/core-react` |
@@ -5,3 +5,3 @@ /*! | ||
| * ------------------------------------------------------------------------ | ||
| * Version: `0.0.13-beta.0` | ||
| * Version: `0.0.13-beta.1` | ||
| * Author: `Rizalvin Dwiky <rizalvindwiky1998@gmail.com>` | ||
@@ -8,0 +8,0 @@ * Repository: `https://github.com/rzl-zone/rzl-zone/tree/main/packages/core-react` |
@@ -5,3 +5,3 @@ /*! | ||
| * ------------------------------------------------------------------------ | ||
| * Version: `0.0.13-beta.0` | ||
| * Version: `0.0.13-beta.1` | ||
| * Author: `Rizalvin Dwiky <rizalvindwiky1998@gmail.com>` | ||
@@ -8,0 +8,0 @@ * Repository: `https://github.com/rzl-zone/rzl-zone/tree/main/packages/core-react` |
@@ -1,1 +0,1 @@ | ||
| {"version":3,"file":"merge-props.cjs","names":[],"sources":["../../src/utils/merge-props.ts"],"sourcesContent":["/* eslint-disable quotes */\n/* eslint-disable @typescript-eslint/no-explicit-any */\n/* eslint-disable @typescript-eslint/no-unsafe-function-type */\ntype UnionToIntersection<U> = (U extends any ? (k: U) => void : never) extends (\n k: infer I\n) => void\n ? I\n : never;\n\nfunction pushProp(\n target: { [key: string]: any },\n key: string,\n value: unknown[]\n): void {\n if (key === \"className\") {\n target.className = [target.className, value].join(\" \").trim();\n } else if (key === \"style\") {\n target.style = { ...target.style, ...value };\n } else if (typeof value === \"function\") {\n const oldFn = target[key] as Function | undefined;\n target[key] = oldFn\n ? (...args: unknown[]) => {\n oldFn(...args);\n (value as Function)(...args);\n }\n : value;\n } else if (\n // skip merging undefined values\n value === undefined ||\n // skip if both value are the same primitive value\n (typeof value !== \"object\" && value === target[key])\n ) {\n return;\n } else if (!(key in target)) {\n target[key] = value;\n } else {\n throw new Error(\n `Didn’t know how to merge prop '${key}'. ` +\n `Only 'className', 'style', and event handlers are supported`\n );\n }\n}\n\ntype MergedProps<T extends object[]> = {\n [K in keyof UnionToIntersection<T[number]>]: K extends \"className\"\n ? string\n : K extends \"style\"\n ? UnionToIntersection<T[number]>[K]\n : Exclude<Extract<T[number], { [Q in K]: unknown }>[K], undefined>;\n};\n\n/** -------------------------------------------------------------------\n * * ***Merges multiple props objects into a single props object with\n * predictable and React-friendly merging behavior.***\n * --------------------------------------------------------------------\n *\n * This utility is designed to safely merge component props where certain\n * keys require special handling instead of simple overwrites.\n *\n * - **Behavior:**\n * - Concatenates duplicate `className` values with a single space\n * - Shallow-merges duplicate `style` objects (later props take precedence)\n * - Chains duplicate function values (commonly event handlers),\n * executing them from left to right\n * - Skips merging `undefined` values\n * - Preserves identical primitive values without reassigning\n * - Throws an error for unsupported duplicate keys\n *\n * Later props in the argument list always have higher precedence\n * when conflicts occur.\n *\n * This makes the function especially suitable for **React / JSX props\n * composition**, such as combining props from hooks, components,\n * and user overrides.\n *\n * @typeParam T - A tuple of props object types to be merged.\n * @param props - One or more props objects. Later objects override\n * earlier ones when applicable.\n *\n * @returns A single merged props object with correctly inferred types,\n * including special handling for `className` and `style`.\n *\n * @throws {Error} If duplicate keys other than `className`, `style`,\n * or function values are encountered.\n *\n * @example\n * ```ts\n * mergeProps(\n * { className: \"btn\", onClick: () => console.log(\"a\") },\n * { className: \"btn-primary\", onClick: () => console.log(\"b\") }\n * );\n * // => {\n * // className: \"btn btn-primary\",\n * // onClick: () => { a(); b(); }\n * // }\n * ```\n *\n * @example\n * ```ts\n * mergeProps(\n * { style: { color: \"red\", fontSize: 12 } },\n * { style: { fontSize: 14 } }\n * );\n * // => { style: { color: \"red\", fontSize: 14 } }\n * ```\n */\nexport function mergeProps<T extends object[]>(...props: T): MergedProps<T> {\n if (props.length === 1) {\n return props[0] as MergedProps<T>;\n }\n\n return props.reduce((merged, ps: { [key: string]: any }) => {\n for (const key in ps) {\n pushProp(merged, key, ps[key]);\n }\n return merged;\n }, {}) as MergedProps<T>;\n}\n"],"mappings":";;;;;;;;;;;;;AASA,SAAS,SACP,QACA,KACA,OACM;CACN,IAAI,QAAQ,aACV,OAAO,YAAY,CAAC,OAAO,WAAW,KAAK,EAAE,KAAK,GAAG,EAAE,KAAK;MACvD,IAAI,QAAQ,SACjB,OAAO,QAAQ;EAAE,GAAG,OAAO;EAAO,GAAG;CAAM;MACtC,IAAI,OAAO,UAAU,YAAY;EACtC,MAAM,QAAQ,OAAO;EACrB,OAAO,OAAO,SACT,GAAG,SAAoB;GACtB,MAAM,GAAG,IAAI;GACb,AAAC,MAAmB,GAAG,IAAI;EAC7B,IACA;CACN,OAAO,IAEL,UAAU,UAET,OAAO,UAAU,YAAY,UAAU,OAAO,MAE/C;MACK,IAAI,EAAE,OAAO,SAClB,OAAO,OAAO;MAEd,MAAM,IAAI,MACR,kCAAkC,IAAI,+DAExC;AAEJ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAiEA,SAAgB,WAA+B,GAAG,OAA0B;CAC1E,IAAI,MAAM,WAAW,GACnB,OAAO,MAAM;CAGf,OAAO,MAAM,QAAQ,QAAQ,OAA+B;EAC1D,KAAK,MAAM,OAAO,IAChB,SAAS,QAAQ,KAAK,GAAG,IAAI;EAE/B,OAAO;CACT,GAAG,CAAC,CAAC;AACP"} | ||
| {"version":3,"file":"merge-props.cjs","names":[],"sources":["../../src/utils/merge-props.ts"],"sourcesContent":["/* eslint-disable quotes */\n/* eslint-disable @typescript-eslint/no-explicit-any */\n/* eslint-disable @typescript-eslint/no-unsafe-function-type */\ntype UnionToIntersection<U> = (U extends any ? (k: U) => void : never) extends (\n k: infer I\n) => void\n ? I\n : never;\n\nfunction pushProp(\n target: { [key: string]: any },\n key: string,\n value: unknown[]\n): void {\n if (key === \"className\") {\n target.className = [target.className, value].join(\" \").trim();\n } else if (key === \"style\") {\n target.style = { ...target.style, ...value };\n } else if (typeof value === \"function\") {\n const oldFn = target[key] as Function | undefined;\n target[key] = oldFn\n ? (...args: unknown[]) => {\n oldFn(...args);\n (value as Function)(...args);\n }\n : value;\n } else if (\n // skip merging undefined values\n value === undefined ||\n // skip if both value are the same primitive value\n (typeof value !== \"object\" && value === target[key])\n ) {\n return;\n } else if (!(key in target)) {\n target[key] = value;\n } else {\n throw new Error(\n `Didn’t know how to merge prop '${key}'. ` +\n `Only 'className', 'style', and event handlers are supported`\n );\n }\n}\n\ntype MergedProps<T extends object[]> = {\n [K in keyof UnionToIntersection<T[number]>]: K extends \"className\"\n ? string\n : K extends \"style\"\n ? UnionToIntersection<T[number]>[K]\n : Exclude<Extract<T[number], { [Q in K]: unknown }>[K], undefined>;\n};\n\n/** -------------------------------------------------------------------\n * * ***Merges multiple props objects into a single props object with\n * predictable and React-friendly merging behavior.***\n * --------------------------------------------------------------------\n *\n * This utility is designed to safely merge component props where certain\n * keys require special handling instead of simple overwrites.\n *\n * - **Behavior:**\n * - Concatenates duplicate `className` values with a single space\n * - Shallow-merges duplicate `style` objects (later props take precedence)\n * - Chains duplicate function values (commonly event handlers),\n * executing them from left to right\n * - Skips merging `undefined` values\n * - Preserves identical primitive values without reassigning\n * - Throws an error for unsupported duplicate keys\n *\n * Later props in the argument list always have higher precedence\n * when conflicts occur.\n *\n * This makes the function especially suitable for **React / JSX props\n * composition**, such as combining props from hooks, components,\n * and user overrides.\n *\n * @typeParam T - A tuple of props object types to be merged.\n * @param props - One or more props objects. Later objects override\n * earlier ones when applicable.\n *\n * @returns A single merged props object with correctly inferred types,\n * including special handling for `className` and `style`.\n *\n * @throws {Error} If duplicate keys other than `className`, `style`,\n * or function values are encountered.\n *\n * @example\n * ```ts\n * mergeProps(\n * { className: \"btn\", onClick: () => console.log(\"a\") },\n * { className: \"btn-primary\", onClick: () => console.log(\"b\") }\n * );\n * // => {\n * // className: \"btn btn-primary\",\n * // onClick: () => { a(); b(); }\n * // }\n * ```\n *\n * @example\n * ```ts\n * mergeProps(\n * { style: { color: \"red\", fontSize: 12 } },\n * { style: { fontSize: 14 } }\n * );\n * // => { style: { color: \"red\", fontSize: 14 } }\n * ```\n */\nexport function mergeProps<T extends object[]>(...props: T): MergedProps<T> {\n if (props.length === 1) {\n return props[0] as MergedProps<T>;\n }\n\n return props.reduce((merged, ps: { [key: string]: any }) => {\n for (const key in ps) {\n pushProp(merged, key, ps[key]);\n }\n return merged;\n }, {}) as MergedProps<T>;\n}\n"],"mappings":";;;;;;;;;;;;;AASA,SAAS,SACP,QACA,KACA,OACM;CACN,IAAI,QAAQ,aACV,OAAO,YAAY,CAAC,OAAO,WAAW,KAAK,CAAC,CAAC,KAAK,GAAG,CAAC,CAAC,KAAK;MACvD,IAAI,QAAQ,SACjB,OAAO,QAAQ;EAAE,GAAG,OAAO;EAAO,GAAG;CAAM;MACtC,IAAI,OAAO,UAAU,YAAY;EACtC,MAAM,QAAQ,OAAO;EACrB,OAAO,OAAO,SACT,GAAG,SAAoB;GACtB,MAAM,GAAG,IAAI;GACb,AAAC,MAAmB,GAAG,IAAI;EAC7B,IACA;CACN,OAAO,IAEL,UAAU,UAET,OAAO,UAAU,YAAY,UAAU,OAAO,MAE/C;MACK,IAAI,EAAE,OAAO,SAClB,OAAO,OAAO;MAEd,MAAM,IAAI,MACR,kCAAkC,IAAI,+DAExC;AAEJ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAiEA,SAAgB,WAA+B,GAAG,OAA0B;CAC1E,IAAI,MAAM,WAAW,GACnB,OAAO,MAAM;CAGf,OAAO,MAAM,QAAQ,QAAQ,OAA+B;EAC1D,KAAK,MAAM,OAAO,IAChB,SAAS,QAAQ,KAAK,GAAG,IAAI;EAE/B,OAAO;CACT,GAAG,CAAC,CAAC;AACP"} |
@@ -5,3 +5,3 @@ /*! | ||
| * ------------------------------------------------------------------------ | ||
| * Version: `0.0.13-beta.0` | ||
| * Version: `0.0.13-beta.1` | ||
| * Author: `Rizalvin Dwiky <rizalvindwiky1998@gmail.com>` | ||
@@ -8,0 +8,0 @@ * Repository: `https://github.com/rzl-zone/rzl-zone/tree/main/packages/core-react` |
@@ -5,3 +5,3 @@ /*! | ||
| * ------------------------------------------------------------------------ | ||
| * Version: `0.0.13-beta.0` | ||
| * Version: `0.0.13-beta.1` | ||
| * Author: `Rizalvin Dwiky <rizalvindwiky1998@gmail.com>` | ||
@@ -8,0 +8,0 @@ * Repository: `https://github.com/rzl-zone/rzl-zone/tree/main/packages/core-react` |
@@ -5,3 +5,3 @@ /*! | ||
| * ------------------------------------------------------------------------ | ||
| * Version: `0.0.13-beta.0` | ||
| * Version: `0.0.13-beta.1` | ||
| * Author: `Rizalvin Dwiky <rizalvindwiky1998@gmail.com>` | ||
@@ -8,0 +8,0 @@ * Repository: `https://github.com/rzl-zone/rzl-zone/tree/main/packages/core-react` |
@@ -1,1 +0,1 @@ | ||
| {"version":3,"file":"merge-props.js","names":[],"sources":["../../src/utils/merge-props.ts"],"sourcesContent":["/* eslint-disable quotes */\n/* eslint-disable @typescript-eslint/no-explicit-any */\n/* eslint-disable @typescript-eslint/no-unsafe-function-type */\ntype UnionToIntersection<U> = (U extends any ? (k: U) => void : never) extends (\n k: infer I\n) => void\n ? I\n : never;\n\nfunction pushProp(\n target: { [key: string]: any },\n key: string,\n value: unknown[]\n): void {\n if (key === \"className\") {\n target.className = [target.className, value].join(\" \").trim();\n } else if (key === \"style\") {\n target.style = { ...target.style, ...value };\n } else if (typeof value === \"function\") {\n const oldFn = target[key] as Function | undefined;\n target[key] = oldFn\n ? (...args: unknown[]) => {\n oldFn(...args);\n (value as Function)(...args);\n }\n : value;\n } else if (\n // skip merging undefined values\n value === undefined ||\n // skip if both value are the same primitive value\n (typeof value !== \"object\" && value === target[key])\n ) {\n return;\n } else if (!(key in target)) {\n target[key] = value;\n } else {\n throw new Error(\n `Didn’t know how to merge prop '${key}'. ` +\n `Only 'className', 'style', and event handlers are supported`\n );\n }\n}\n\ntype MergedProps<T extends object[]> = {\n [K in keyof UnionToIntersection<T[number]>]: K extends \"className\"\n ? string\n : K extends \"style\"\n ? UnionToIntersection<T[number]>[K]\n : Exclude<Extract<T[number], { [Q in K]: unknown }>[K], undefined>;\n};\n\n/** -------------------------------------------------------------------\n * * ***Merges multiple props objects into a single props object with\n * predictable and React-friendly merging behavior.***\n * --------------------------------------------------------------------\n *\n * This utility is designed to safely merge component props where certain\n * keys require special handling instead of simple overwrites.\n *\n * - **Behavior:**\n * - Concatenates duplicate `className` values with a single space\n * - Shallow-merges duplicate `style` objects (later props take precedence)\n * - Chains duplicate function values (commonly event handlers),\n * executing them from left to right\n * - Skips merging `undefined` values\n * - Preserves identical primitive values without reassigning\n * - Throws an error for unsupported duplicate keys\n *\n * Later props in the argument list always have higher precedence\n * when conflicts occur.\n *\n * This makes the function especially suitable for **React / JSX props\n * composition**, such as combining props from hooks, components,\n * and user overrides.\n *\n * @typeParam T - A tuple of props object types to be merged.\n * @param props - One or more props objects. Later objects override\n * earlier ones when applicable.\n *\n * @returns A single merged props object with correctly inferred types,\n * including special handling for `className` and `style`.\n *\n * @throws {Error} If duplicate keys other than `className`, `style`,\n * or function values are encountered.\n *\n * @example\n * ```ts\n * mergeProps(\n * { className: \"btn\", onClick: () => console.log(\"a\") },\n * { className: \"btn-primary\", onClick: () => console.log(\"b\") }\n * );\n * // => {\n * // className: \"btn btn-primary\",\n * // onClick: () => { a(); b(); }\n * // }\n * ```\n *\n * @example\n * ```ts\n * mergeProps(\n * { style: { color: \"red\", fontSize: 12 } },\n * { style: { fontSize: 14 } }\n * );\n * // => { style: { color: \"red\", fontSize: 14 } }\n * ```\n */\nexport function mergeProps<T extends object[]>(...props: T): MergedProps<T> {\n if (props.length === 1) {\n return props[0] as MergedProps<T>;\n }\n\n return props.reduce((merged, ps: { [key: string]: any }) => {\n for (const key in ps) {\n pushProp(merged, key, ps[key]);\n }\n return merged;\n }, {}) as MergedProps<T>;\n}\n"],"mappings":";;;;;;;;;;;AASA,SAAS,SACP,QACA,KACA,OACM;CACN,IAAI,QAAQ,aACV,OAAO,YAAY,CAAC,OAAO,WAAW,KAAK,EAAE,KAAK,GAAG,EAAE,KAAK;MACvD,IAAI,QAAQ,SACjB,OAAO,QAAQ;EAAE,GAAG,OAAO;EAAO,GAAG;CAAM;MACtC,IAAI,OAAO,UAAU,YAAY;EACtC,MAAM,QAAQ,OAAO;EACrB,OAAO,OAAO,SACT,GAAG,SAAoB;GACtB,MAAM,GAAG,IAAI;GACb,AAAC,MAAmB,GAAG,IAAI;EAC7B,IACA;CACN,OAAO,IAEL,UAAU,UAET,OAAO,UAAU,YAAY,UAAU,OAAO,MAE/C;MACK,IAAI,EAAE,OAAO,SAClB,OAAO,OAAO;MAEd,MAAM,IAAI,MACR,kCAAkC,IAAI,+DAExC;AAEJ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAiEA,SAAgB,WAA+B,GAAG,OAA0B;CAC1E,IAAI,MAAM,WAAW,GACnB,OAAO,MAAM;CAGf,OAAO,MAAM,QAAQ,QAAQ,OAA+B;EAC1D,KAAK,MAAM,OAAO,IAChB,SAAS,QAAQ,KAAK,GAAG,IAAI;EAE/B,OAAO;CACT,GAAG,CAAC,CAAC;AACP"} | ||
| {"version":3,"file":"merge-props.js","names":[],"sources":["../../src/utils/merge-props.ts"],"sourcesContent":["/* eslint-disable quotes */\n/* eslint-disable @typescript-eslint/no-explicit-any */\n/* eslint-disable @typescript-eslint/no-unsafe-function-type */\ntype UnionToIntersection<U> = (U extends any ? (k: U) => void : never) extends (\n k: infer I\n) => void\n ? I\n : never;\n\nfunction pushProp(\n target: { [key: string]: any },\n key: string,\n value: unknown[]\n): void {\n if (key === \"className\") {\n target.className = [target.className, value].join(\" \").trim();\n } else if (key === \"style\") {\n target.style = { ...target.style, ...value };\n } else if (typeof value === \"function\") {\n const oldFn = target[key] as Function | undefined;\n target[key] = oldFn\n ? (...args: unknown[]) => {\n oldFn(...args);\n (value as Function)(...args);\n }\n : value;\n } else if (\n // skip merging undefined values\n value === undefined ||\n // skip if both value are the same primitive value\n (typeof value !== \"object\" && value === target[key])\n ) {\n return;\n } else if (!(key in target)) {\n target[key] = value;\n } else {\n throw new Error(\n `Didn’t know how to merge prop '${key}'. ` +\n `Only 'className', 'style', and event handlers are supported`\n );\n }\n}\n\ntype MergedProps<T extends object[]> = {\n [K in keyof UnionToIntersection<T[number]>]: K extends \"className\"\n ? string\n : K extends \"style\"\n ? UnionToIntersection<T[number]>[K]\n : Exclude<Extract<T[number], { [Q in K]: unknown }>[K], undefined>;\n};\n\n/** -------------------------------------------------------------------\n * * ***Merges multiple props objects into a single props object with\n * predictable and React-friendly merging behavior.***\n * --------------------------------------------------------------------\n *\n * This utility is designed to safely merge component props where certain\n * keys require special handling instead of simple overwrites.\n *\n * - **Behavior:**\n * - Concatenates duplicate `className` values with a single space\n * - Shallow-merges duplicate `style` objects (later props take precedence)\n * - Chains duplicate function values (commonly event handlers),\n * executing them from left to right\n * - Skips merging `undefined` values\n * - Preserves identical primitive values without reassigning\n * - Throws an error for unsupported duplicate keys\n *\n * Later props in the argument list always have higher precedence\n * when conflicts occur.\n *\n * This makes the function especially suitable for **React / JSX props\n * composition**, such as combining props from hooks, components,\n * and user overrides.\n *\n * @typeParam T - A tuple of props object types to be merged.\n * @param props - One or more props objects. Later objects override\n * earlier ones when applicable.\n *\n * @returns A single merged props object with correctly inferred types,\n * including special handling for `className` and `style`.\n *\n * @throws {Error} If duplicate keys other than `className`, `style`,\n * or function values are encountered.\n *\n * @example\n * ```ts\n * mergeProps(\n * { className: \"btn\", onClick: () => console.log(\"a\") },\n * { className: \"btn-primary\", onClick: () => console.log(\"b\") }\n * );\n * // => {\n * // className: \"btn btn-primary\",\n * // onClick: () => { a(); b(); }\n * // }\n * ```\n *\n * @example\n * ```ts\n * mergeProps(\n * { style: { color: \"red\", fontSize: 12 } },\n * { style: { fontSize: 14 } }\n * );\n * // => { style: { color: \"red\", fontSize: 14 } }\n * ```\n */\nexport function mergeProps<T extends object[]>(...props: T): MergedProps<T> {\n if (props.length === 1) {\n return props[0] as MergedProps<T>;\n }\n\n return props.reduce((merged, ps: { [key: string]: any }) => {\n for (const key in ps) {\n pushProp(merged, key, ps[key]);\n }\n return merged;\n }, {}) as MergedProps<T>;\n}\n"],"mappings":";;;;;;;;;;;AASA,SAAS,SACP,QACA,KACA,OACM;CACN,IAAI,QAAQ,aACV,OAAO,YAAY,CAAC,OAAO,WAAW,KAAK,CAAC,CAAC,KAAK,GAAG,CAAC,CAAC,KAAK;MACvD,IAAI,QAAQ,SACjB,OAAO,QAAQ;EAAE,GAAG,OAAO;EAAO,GAAG;CAAM;MACtC,IAAI,OAAO,UAAU,YAAY;EACtC,MAAM,QAAQ,OAAO;EACrB,OAAO,OAAO,SACT,GAAG,SAAoB;GACtB,MAAM,GAAG,IAAI;GACb,AAAC,MAAmB,GAAG,IAAI;EAC7B,IACA;CACN,OAAO,IAEL,UAAU,UAET,OAAO,UAAU,YAAY,UAAU,OAAO,MAE/C;MACK,IAAI,EAAE,OAAO,SAClB,OAAO,OAAO;MAEd,MAAM,IAAI,MACR,kCAAkC,IAAI,+DAExC;AAEJ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAiEA,SAAgB,WAA+B,GAAG,OAA0B;CAC1E,IAAI,MAAM,WAAW,GACnB,OAAO,MAAM;CAGf,OAAO,MAAM,QAAQ,QAAQ,OAA+B;EAC1D,KAAK,MAAM,OAAO,IAChB,SAAS,QAAQ,KAAK,GAAG,IAAI;EAE/B,OAAO;CACT,GAAG,CAAC,CAAC;AACP"} |
@@ -5,3 +5,3 @@ /*! | ||
| * ------------------------------------------------------------------------ | ||
| * Version: `0.0.13-beta.0` | ||
| * Version: `0.0.13-beta.1` | ||
| * Author: `Rizalvin Dwiky <rizalvindwiky1998@gmail.com>` | ||
@@ -8,0 +8,0 @@ * Repository: `https://github.com/rzl-zone/rzl-zone/tree/main/packages/core-react` |
@@ -5,3 +5,3 @@ /*! | ||
| * ------------------------------------------------------------------------ | ||
| * Version: `0.0.13-beta.0` | ||
| * Version: `0.0.13-beta.1` | ||
| * Author: `Rizalvin Dwiky <rizalvindwiky1998@gmail.com>` | ||
@@ -8,0 +8,0 @@ * Repository: `https://github.com/rzl-zone/rzl-zone/tree/main/packages/core-react` |
@@ -5,3 +5,3 @@ /*! | ||
| * ------------------------------------------------------------------------ | ||
| * Version: `0.0.13-beta.0` | ||
| * Version: `0.0.13-beta.1` | ||
| * Author: `Rizalvin Dwiky <rizalvindwiky1998@gmail.com>` | ||
@@ -8,0 +8,0 @@ * Repository: `https://github.com/rzl-zone/rzl-zone/tree/main/packages/core-react` |
@@ -5,3 +5,3 @@ /*! | ||
| * ------------------------------------------------------------------------ | ||
| * Version: `0.0.13-beta.0` | ||
| * Version: `0.0.13-beta.1` | ||
| * Author: `Rizalvin Dwiky <rizalvindwiky1998@gmail.com>` | ||
@@ -8,0 +8,0 @@ * Repository: `https://github.com/rzl-zone/rzl-zone/tree/main/packages/core-react` |
@@ -5,3 +5,3 @@ /*! | ||
| * ------------------------------------------------------------------------ | ||
| * Version: `0.0.13-beta.0` | ||
| * Version: `0.0.13-beta.1` | ||
| * Author: `Rizalvin Dwiky <rizalvindwiky1998@gmail.com>` | ||
@@ -8,0 +8,0 @@ * Repository: `https://github.com/rzl-zone/rzl-zone/tree/main/packages/core-react` |
@@ -5,3 +5,3 @@ /*! | ||
| * ------------------------------------------------------------------------ | ||
| * Version: `0.0.13-beta.0` | ||
| * Version: `0.0.13-beta.1` | ||
| * Author: `Rizalvin Dwiky <rizalvindwiky1998@gmail.com>` | ||
@@ -8,0 +8,0 @@ * Repository: `https://github.com/rzl-zone/rzl-zone/tree/main/packages/core-react` |
@@ -5,3 +5,3 @@ /*! | ||
| * ------------------------------------------------------------------------ | ||
| * Version: `0.0.13-beta.0` | ||
| * Version: `0.0.13-beta.1` | ||
| * Author: `Rizalvin Dwiky <rizalvindwiky1998@gmail.com>` | ||
@@ -8,0 +8,0 @@ * Repository: `https://github.com/rzl-zone/rzl-zone/tree/main/packages/core-react` |
@@ -5,3 +5,3 @@ /*! | ||
| * ------------------------------------------------------------------------ | ||
| * Version: `0.0.13-beta.0` | ||
| * Version: `0.0.13-beta.1` | ||
| * Author: `Rizalvin Dwiky <rizalvindwiky1998@gmail.com>` | ||
@@ -8,0 +8,0 @@ * Repository: `https://github.com/rzl-zone/rzl-zone/tree/main/packages/core-react` |
+6
-6
| { | ||
| "name": "@rzl-zone/core-react", | ||
| "version": "0.0.13-beta.0", | ||
| "version": "0.0.13-beta.1", | ||
| "description": "Modern React core utilities and primitives.", | ||
@@ -98,5 +98,5 @@ "license": "MIT", | ||
| "dependencies": { | ||
| "@rzl-zone/core": "0.0.13-beta.0", | ||
| "@rzl-zone/core": "0.0.13-beta.1", | ||
| "@rzl-zone/node-only": "0.0.11", | ||
| "@rzl-zone/utils-js": "3.14.1-beta.0" | ||
| "@rzl-zone/utils-js": "3.14.1-beta.1" | ||
| }, | ||
@@ -110,6 +110,6 @@ "devDependencies": { | ||
| "react-dom": "^18.3.1", | ||
| "tsdown": "0.22.0", | ||
| "tsdown": "0.22.3", | ||
| "typescript": "6.0.3", | ||
| "@rzl-zone/build-tools": "0.0.13", | ||
| "@rzl-zone/eslint": "0.0.10", | ||
| "@rzl-zone/build-tools": "0.0.14-beta.0", | ||
| "@rzl-zone/eslint": "0.0.11-beta.0", | ||
| "@workspace/eslint-config": "0.0.0", | ||
@@ -116,0 +116,0 @@ "@workspace/typescript-config": "0.0.0" |
| /*! | ||
| * ======================================================================== | ||
| * @rzl-zone/core-react | ||
| * ------------------------------------------------------------------------ | ||
| * Version: `0.0.13-beta.0` | ||
| * Author: `Rizalvin Dwiky <rizalvindwiky1998@gmail.com>` | ||
| * Repository: `https://github.com/rzl-zone/rzl-zone/tree/main/packages/core-react` | ||
| * ======================================================================== | ||
| */ | ||
| "use strict"; | ||
| var __create = Object.create; | ||
| var __defProp = Object.defineProperty; | ||
| var __getOwnPropDesc = Object.getOwnPropertyDescriptor; | ||
| var __getOwnPropNames = Object.getOwnPropertyNames; | ||
| var __getProtoOf = Object.getPrototypeOf; | ||
| var __hasOwnProp = Object.prototype.hasOwnProperty; | ||
| var __copyProps = (to, from, except, desc) => { | ||
| if (from && typeof from === "object" || typeof from === "function") { | ||
| for (var keys = __getOwnPropNames(from), i = 0, n = keys.length, key; i < n; i++) { | ||
| key = keys[i]; | ||
| if (!__hasOwnProp.call(to, key) && key !== except) { | ||
| __defProp(to, key, { | ||
| get: ((k) => from[k]).bind(null, key), | ||
| enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable | ||
| }); | ||
| } | ||
| } | ||
| } | ||
| return to; | ||
| }; | ||
| var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { | ||
| value: mod, | ||
| enumerable: true | ||
| }) : target, mod)); | ||
| Object.defineProperty(exports, '__toESM', { | ||
| enumerable: true, | ||
| get: function () { | ||
| return __toESM; | ||
| } | ||
| }); |
180901
0.06%+ Added
+ Added
- Removed
- Removed
Updated