@ptolemy2002/react-proxy-context 1.1.0 → 1.1.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/index.js +29 -4
- package/package.json +1 -1
package/index.js
CHANGED
|
@@ -711,19 +711,44 @@ var require_react_utils = __commonJS({
|
|
|
711
711
|
}
|
|
712
712
|
var clsx_default = clsx;
|
|
713
713
|
var import_is_callable2 = __toESM2(require_is_callable2());
|
|
714
|
-
|
|
715
|
-
|
|
714
|
+
function compareChildren(a, b) {
|
|
715
|
+
if (a === b) return true;
|
|
716
|
+
if (typeof a !== "object" || typeof b !== "object") return false;
|
|
717
|
+
const aIsArray = Array.isArray(a);
|
|
718
|
+
const bIsArray = Array.isArray(b);
|
|
719
|
+
if (aIsArray && bIsArray) {
|
|
720
|
+
if (a.length !== b.length) return false;
|
|
721
|
+
return a.every((item, index) => compareChildren(item, b[index]));
|
|
722
|
+
}
|
|
723
|
+
if (aIsArray || bIsArray) return false;
|
|
724
|
+
if (a.key || b.key) return a.key === b.key;
|
|
725
|
+
if (a.type !== b.type) return false;
|
|
726
|
+
return compareChildren(a.props.children, b.props.children);
|
|
727
|
+
}
|
|
728
|
+
var partialMemo2 = (component, deps = [], displayName) => {
|
|
729
|
+
const result = (0, import_react2.memo)(component, (prevProps, nextProps) => {
|
|
716
730
|
if (deps.length === 0) return true;
|
|
731
|
+
const defaultBehavior = (prop) => {
|
|
732
|
+
if (prop === "children") return compareChildren(prevProps.children, nextProps.children);
|
|
733
|
+
return prevProps[prop] === nextProps[prop];
|
|
734
|
+
};
|
|
717
735
|
return deps.every((dep) => {
|
|
718
|
-
if ((0, import_is_callable2.default)(dep)) return dep(prevProps, nextProps);
|
|
719
|
-
return
|
|
736
|
+
if ((0, import_is_callable2.default)(dep)) return dep(prevProps, nextProps, defaultBehavior);
|
|
737
|
+
return defaultBehavior(dep);
|
|
720
738
|
});
|
|
721
739
|
});
|
|
740
|
+
if (!displayName) {
|
|
741
|
+
result.displayName = (component.displayName ?? component.name) + " (Memo)";
|
|
742
|
+
} else {
|
|
743
|
+
result.displayName = displayName;
|
|
744
|
+
}
|
|
745
|
+
return result;
|
|
722
746
|
};
|
|
723
747
|
var Spacer = (0, import_react2.memo)(function({ size = "1rem", horizontal = false, style = {}, className = null, ...props } = {}) {
|
|
724
748
|
const keyName = horizontal ? "width" : "height";
|
|
725
749
|
return /* @__PURE__ */ import_react2.default.createElement("div", { className: clsx_default("spacer", className), style: { ...style, [keyName]: size }, ...props });
|
|
726
750
|
});
|
|
751
|
+
Spacer.displayName = "Spacer";
|
|
727
752
|
}
|
|
728
753
|
});
|
|
729
754
|
|