Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(components): register ui component #284

Merged
merged 4 commits into from
Aug 28, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions src/components.js
Original file line number Diff line number Diff line change
Expand Up @@ -56,4 +56,8 @@ const components = {
User: Form,
};

export const register = (name, component) => {
components[name] = component;
};

export default components;
10 changes: 5 additions & 5 deletions src/demo/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import compiler from 'mson/lib/compiler';
import register from 'mson/lib/compiler/register';
import components from './components';
import globals from 'mson/lib/globals';
import uiComponents from '../components';
import { register as uiRegister } from '../components';
import FieldEditorForm from 'mson/lib/form/field-editor-form';
import FieldEditorFormUI from '../field-editor-form';
import FormEditor from 'mson/lib/form/form-editor';
Expand All @@ -25,16 +25,16 @@ globals.set({ reCAPTCHASiteKey: '6LdIbGMUAAAAAJnipR9t-SnWzCbn0ZX2myXBIauh' });

// Register optional core components
register('FieldEditorForm', FieldEditorForm);
uiComponents.FieldEditorForm = FieldEditorFormUI;
uiRegister('FieldEditorForm', FieldEditorFormUI);
register('FormEditor', FormEditor);
uiComponents.FormEditor = FormEditorUI;
uiRegister('FormEditor', FormEditorUI);
register('FormBuilder', FormBuilder);

// You can register custom components with the backend and frontend separately
register('CustomComponent', CustomComponent);
uiComponents.CustomComponent = ReactCustomComponent;
uiRegister('CustomComponent', ReactCustomComponent);
register('CustomComponentJS', CustomComponentJS);
uiComponents.CustomComponentJS = ReactCustomComponentJS;
uiRegister('CustomComponentJS', ReactCustomComponentJS);

// You can also register UIComponents that bundle the frontend and backend together
register('CustomComponentNoProps', CustomComponentNoProps);
Expand Down