import { AutoType } from "@griddo/core"; import * as React from "react"; // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- // GriddoCoreComponent is a closure function component that wraps a list of // modules with Griddo utilities, for example wrappers required for display in // the Griddo page editor. // It is necessary to go through this component only in those that we want said // functionalities. // ----------------------------------------------------------------------------- // eslint-disable-next-line import/order import { GriddoCoreComponent } from "./GriddoCoreComponent"; // ----------------------------------------------------------------------------- // Import React components // ----------------------------------------------------------------------------- // We import the components with React.lazy to get code splitting in the // builder and shrink the bundle. // ----------------------------------------------------------------------------- const BasicCard = React.lazy(() => import("./BasicCard")); // ----------------------------------------------------------------------------- // Whitelist components for // ----------------------------------------------------------------------------- // Generate a components object to pass to as a valid list of // components of the instance that we need to select or interact with them in // the editor. // ----------------------------------------------------------------------------- const components = {}; // ----------------------------------------------------------------------------- // Whitelist types for // ----------------------------------------------------------------------------- // We create an union type with all the props to pass it to , // that way way when we use if we pass it the component prop // we will have autocompletion and safe access to the props of said component. // ----------------------------------------------------------------------------- type ComponentProps = AutoType.BasicCard; // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- // This closure function returns the components that are passed through the // props libComponents, wrapped with functionality needed by the editor Griddo // pages. // ----------------------------------------------------------------------------- const GriddoComponent = (props: ComponentProps) => { const { component } = props; return ( ); }; // ----------------------------------------------------------------------------- // Component named export // ----------------------------------------------------------------------------- export { BasicCard, GriddoComponent }; // ----------------------------------------------------------------------------- // Griddo bundle export // ----------------------------------------------------------------------------- export default components;