1
0
Fork 0
mirror of https://github.com/vale981/Vulcan synced 2025-03-13 05:46:38 -04:00
Vulcan/packages/vulcan-forms/lib/modules/mergeWithComponents.js

20 lines
633 B
JavaScript
Raw Normal View History

/**
* Data structure to mix global Components and local FormComponents
* without the need to merge
*/
import { Components } from 'meteor/vulcan:core';
// Example with Proxy (might be unstable/hard to reason about)
//const mergeWithComponents = (myComponents = {}) => {
// const handler = {
// get: function(target, name) {
// return name in target ? target[name] : Components[name];
// }
// };
// const proxy = new Proxy(myComponents, handler);
// return proxy;
//};
const mergeWithComponents = myComponents => (myComponents ? { ...Components, ...myComponents } : Components);
export default mergeWithComponents;