chore: refine named exports (#2249)
This commit is contained in:
parent
4db497b496
commit
b4041d3971
@ -1,55 +1,8 @@
|
||||
import bootstrap from './bootstrap';
|
||||
import {
|
||||
registerPreviewStyle,
|
||||
getPreviewStyles,
|
||||
registerPreviewTemplate,
|
||||
getPreviewTemplate,
|
||||
registerWidget,
|
||||
getWidget,
|
||||
resolveWidget,
|
||||
registerEditorComponent,
|
||||
getEditorComponents,
|
||||
registerWidgetValueSerializer,
|
||||
getWidgetValueSerializer,
|
||||
registerBackend,
|
||||
getBackend,
|
||||
registerMediaLibrary,
|
||||
getMediaLibrary,
|
||||
} from 'Lib/registry';
|
||||
import Registry from 'Lib/registry';
|
||||
|
||||
export const NetlifyCmsCore = {
|
||||
registerPreviewStyle,
|
||||
getPreviewStyles,
|
||||
registerPreviewTemplate,
|
||||
getPreviewTemplate,
|
||||
registerWidget,
|
||||
getWidget,
|
||||
resolveWidget,
|
||||
registerEditorComponent,
|
||||
getEditorComponents,
|
||||
registerWidgetValueSerializer,
|
||||
getWidgetValueSerializer,
|
||||
registerBackend,
|
||||
getBackend,
|
||||
registerMediaLibrary,
|
||||
getMediaLibrary,
|
||||
...Registry,
|
||||
init: bootstrap,
|
||||
};
|
||||
export {
|
||||
registerPreviewStyle,
|
||||
getPreviewStyles,
|
||||
registerPreviewTemplate,
|
||||
getPreviewTemplate,
|
||||
registerWidget,
|
||||
getWidget,
|
||||
resolveWidget,
|
||||
registerEditorComponent,
|
||||
getEditorComponents,
|
||||
registerWidgetValueSerializer,
|
||||
getWidgetValueSerializer,
|
||||
registerBackend,
|
||||
getBackend,
|
||||
registerMediaLibrary,
|
||||
getMediaLibrary,
|
||||
bootstrap as init,
|
||||
};
|
||||
export default NetlifyCmsCore;
|
||||
|
@ -40,15 +40,3 @@ export const NetlifyCmsDefaultExports = {
|
||||
ReactDOM,
|
||||
UUId,
|
||||
};
|
||||
export {
|
||||
EmotionCore,
|
||||
EmotionStyled,
|
||||
Immutable,
|
||||
ImmutablePropTypes,
|
||||
Lodash,
|
||||
Moment,
|
||||
PropTypes,
|
||||
React,
|
||||
ReactDOM,
|
||||
UUId,
|
||||
};
|
||||
|
@ -1,3 +1,10 @@
|
||||
import controlComponent from './BooleanControl';
|
||||
export const NetlifyCmsWidgetBoolean = { controlComponent };
|
||||
export { controlComponent };
|
||||
|
||||
const Widget = (opts = {}) => ({
|
||||
name: 'boolean',
|
||||
controlComponent,
|
||||
...opts,
|
||||
});
|
||||
|
||||
export const NetlifyCmsWidgetBoolean = { Widget, controlComponent };
|
||||
export default NetlifyCmsWidgetBoolean;
|
||||
|
@ -9,4 +9,4 @@ const Widget = (opts = {}) => ({
|
||||
});
|
||||
|
||||
export const NetlifyCmsWidgetDate = { Widget, controlComponent, previewComponent };
|
||||
export { Widget as default, controlComponent, previewComponent };
|
||||
export default NetlifyCmsWidgetDate;
|
||||
|
@ -1,5 +1,7 @@
|
||||
import React from 'react';
|
||||
import { controlComponent as DateControl } from 'netlify-cms-widget-date';
|
||||
import NetlifyCmsWidgetDate from 'netlify-cms-widget-date';
|
||||
|
||||
const DateControl = NetlifyCmsWidgetDate.controlComponent;
|
||||
|
||||
export default class DateTimeControl extends React.Component {
|
||||
render() {
|
||||
|
@ -1,6 +1,7 @@
|
||||
import controlComponent from './DateTimeControl';
|
||||
import { previewComponent } from 'netlify-cms-widget-date';
|
||||
import NetlifyCmsWidgetDate from 'netlify-cms-widget-date';
|
||||
|
||||
const previewComponent = NetlifyCmsWidgetDate.previewComponent;
|
||||
const Widget = (opts = {}) => ({
|
||||
name: 'datetime',
|
||||
controlComponent,
|
||||
@ -9,4 +10,4 @@ const Widget = (opts = {}) => ({
|
||||
});
|
||||
|
||||
export const NetlifyCmsWidgetDatetime = { Widget, controlComponent, previewComponent };
|
||||
export { Widget as default, controlComponent, previewComponent };
|
||||
export default NetlifyCmsWidgetDatetime;
|
||||
|
@ -2,5 +2,12 @@ import withFileControl from './withFileControl';
|
||||
import previewComponent from './FilePreview';
|
||||
|
||||
const controlComponent = withFileControl();
|
||||
export const NetlifyCmsWidgetFile = { controlComponent, previewComponent, withFileControl };
|
||||
export { controlComponent, previewComponent, withFileControl };
|
||||
const Widget = (opts = {}) => ({
|
||||
name: 'file',
|
||||
controlComponent,
|
||||
previewComponent,
|
||||
...opts,
|
||||
});
|
||||
|
||||
export const NetlifyCmsWidgetFile = { Widget, controlComponent, previewComponent, withFileControl };
|
||||
export default NetlifyCmsWidgetFile;
|
||||
|
@ -1,6 +1,12 @@
|
||||
import { withFileControl } from 'netlify-cms-widget-file';
|
||||
|
||||
const controlComponent = withFileControl({ forImage: true });
|
||||
import NetlifyCmsWidgetFile from 'netlify-cms-widget-file';
|
||||
import previewComponent from './ImagePreview';
|
||||
export const NetlifyCmsWidgetImage = { controlComponent, previewComponent };
|
||||
export { controlComponent, previewComponent };
|
||||
|
||||
const controlComponent = NetlifyCmsWidgetFile.withFileControl({ forImage: true });
|
||||
const Widget = (opts = {}) => ({
|
||||
name: 'image',
|
||||
controlComponent,
|
||||
...opts,
|
||||
});
|
||||
|
||||
export const NetlifyCmsWidgetImage = { Widget, controlComponent, previewComponent };
|
||||
export default NetlifyCmsWidgetImage;
|
||||
|
@ -7,7 +7,7 @@ import { jsx, css, ClassNames } from '@emotion/core';
|
||||
import { List, Map } from 'immutable';
|
||||
import { partial } from 'lodash';
|
||||
import { SortableContainer, SortableElement, SortableHandle } from 'react-sortable-hoc';
|
||||
import { controlComponent as ObjectControl } from 'netlify-cms-widget-object';
|
||||
import NetlifyCmsWidgetObject from 'netlify-cms-widget-object';
|
||||
import {
|
||||
TYPES_KEY,
|
||||
getTypedFieldForValue,
|
||||
@ -20,6 +20,8 @@ function valueToString(value) {
|
||||
return value ? value.join(',').replace(/,([^\s]|$)/g, ', $1') : '';
|
||||
}
|
||||
|
||||
const ObjectControl = NetlifyCmsWidgetObject.controlComponent;
|
||||
|
||||
const ListItem = styled.div();
|
||||
|
||||
const SortableListItem = SortableElement(ListItem);
|
||||
|
@ -1,4 +1,13 @@
|
||||
import controlComponent from './ListControl';
|
||||
import { previewComponent } from 'netlify-cms-widget-object';
|
||||
export const NetlifyCmsWidgetList = { controlComponent, previewComponent };
|
||||
export { controlComponent, previewComponent };
|
||||
import NetlifyCmsWidgetObject from 'netlify-cms-widget-object';
|
||||
|
||||
const previewComponent = NetlifyCmsWidgetObject.previewComponent;
|
||||
const Widget = (opts = {}) => ({
|
||||
name: 'list',
|
||||
controlComponent,
|
||||
previewComponent,
|
||||
...opts,
|
||||
});
|
||||
|
||||
export const NetlifyCmsWidgetList = { Widget, controlComponent, previewComponent };
|
||||
export default NetlifyCmsWidgetList;
|
||||
|
@ -1,6 +1,13 @@
|
||||
import withMapControl from './withMapControl';
|
||||
import previewComponent from './MapPreview';
|
||||
const controlComponent = withMapControl();
|
||||
|
||||
export const NetlifyCmsWidgetMap = { controlComponent, previewComponent };
|
||||
export { controlComponent, previewComponent };
|
||||
const controlComponent = withMapControl();
|
||||
const Widget = (opts = {}) => ({
|
||||
name: 'map',
|
||||
controlComponent,
|
||||
previewComponent,
|
||||
...opts,
|
||||
});
|
||||
|
||||
export const NetlifyCmsWidgetMap = { Widget, controlComponent, previewComponent };
|
||||
export default NetlifyCmsWidgetMap;
|
||||
|
@ -1,4 +1,12 @@
|
||||
import controlComponent from './MarkdownControl';
|
||||
import previewComponent from './MarkdownPreview';
|
||||
export const NetlifyCmsWidgetMarkdown = { controlComponent, previewComponent };
|
||||
export { controlComponent, previewComponent };
|
||||
|
||||
const Widget = (opts = {}) => ({
|
||||
name: 'markdown',
|
||||
controlComponent,
|
||||
previewComponent,
|
||||
...opts,
|
||||
});
|
||||
|
||||
export const NetlifyCmsWidgetMarkdown = { Widget, controlComponent, previewComponent };
|
||||
export default NetlifyCmsWidgetMarkdown;
|
||||
|
@ -3,7 +3,9 @@ import { fromJS } from 'immutable';
|
||||
import { render, fireEvent } from 'react-testing-library';
|
||||
import 'react-testing-library/cleanup-after-each';
|
||||
import 'jest-dom/extend-expect';
|
||||
import { controlComponent as NumberControl } from '../';
|
||||
import { NetlifyCmsWidgetNumber } from '../';
|
||||
|
||||
const NumberControl = NetlifyCmsWidgetNumber.controlComponent;
|
||||
|
||||
const fieldSettings = {
|
||||
min: -20,
|
||||
|
@ -1,4 +1,12 @@
|
||||
import controlComponent from './NumberControl';
|
||||
import previewComponent from './NumberPreview';
|
||||
export const NetlifyCmsWidgetNumber = { controlComponent, previewComponent };
|
||||
export { controlComponent, previewComponent };
|
||||
|
||||
const Widget = (opts = {}) => ({
|
||||
name: 'number',
|
||||
controlComponent,
|
||||
previewComponent,
|
||||
...opts,
|
||||
});
|
||||
|
||||
export const NetlifyCmsWidgetNumber = { Widget, controlComponent, previewComponent };
|
||||
export default NetlifyCmsWidgetNumber;
|
||||
|
@ -1,4 +1,12 @@
|
||||
import controlComponent from './ObjectControl';
|
||||
import previewComponent from './ObjectPreview';
|
||||
export const NetlifyCmsWidgetObject = { controlComponent, previewComponent };
|
||||
export { controlComponent, previewComponent };
|
||||
|
||||
const Widget = (opts = {}) => ({
|
||||
name: 'object',
|
||||
controlComponent,
|
||||
previewComponent,
|
||||
...opts,
|
||||
});
|
||||
|
||||
export const NetlifyCmsWidgetObject = { Widget, controlComponent, previewComponent };
|
||||
export default NetlifyCmsWidgetObject;
|
||||
|
@ -4,7 +4,9 @@ import { last } from 'lodash';
|
||||
import { render, fireEvent, wait } from 'react-testing-library';
|
||||
import 'react-testing-library/cleanup-after-each';
|
||||
import 'jest-dom/extend-expect';
|
||||
import { controlComponent as RelationControl } from '../';
|
||||
import { NetlifyCmsWidgetRelation } from '../';
|
||||
|
||||
const RelationControl = NetlifyCmsWidgetRelation.controlComponent;
|
||||
|
||||
const fieldConfig = {
|
||||
name: 'post',
|
||||
|
@ -1,4 +1,12 @@
|
||||
import controlComponent from './RelationControl';
|
||||
import previewComponent from './RelationPreview';
|
||||
export const NetlifyCmsWidgetRelation = { controlComponent, previewComponent };
|
||||
export { controlComponent, previewComponent };
|
||||
|
||||
const Widget = (opts = {}) => ({
|
||||
name: 'relation',
|
||||
controlComponent,
|
||||
previewComponent,
|
||||
...opts,
|
||||
});
|
||||
|
||||
export const NetlifyCmsWidgetRelation = { Widget, controlComponent, previewComponent };
|
||||
export default NetlifyCmsWidgetRelation;
|
||||
|
@ -3,7 +3,9 @@ import { fromJS } from 'immutable';
|
||||
import { render, fireEvent } from 'react-testing-library';
|
||||
import 'react-testing-library/cleanup-after-each';
|
||||
import 'jest-dom/extend-expect';
|
||||
import { controlComponent as SelectControl } from '../';
|
||||
import { NetlifyCmsWidgetSelect } from '../';
|
||||
|
||||
const SelectControl = NetlifyCmsWidgetSelect.controlComponent;
|
||||
|
||||
const options = [
|
||||
{ value: 'foo', label: 'Foo' },
|
||||
|
@ -1,4 +1,12 @@
|
||||
import controlComponent from './SelectControl';
|
||||
import previewComponent from './SelectPreview';
|
||||
export const NetlifyCmsWidgetSelect = { controlComponent, previewComponent };
|
||||
export { controlComponent, previewComponent };
|
||||
|
||||
const Widget = (opts = {}) => ({
|
||||
name: 'select',
|
||||
controlComponent,
|
||||
previewComponent,
|
||||
...opts,
|
||||
});
|
||||
|
||||
export const NetlifyCmsWidgetSelect = { Widget, controlComponent, previewComponent };
|
||||
export default NetlifyCmsWidgetSelect;
|
||||
|
@ -1,4 +1,12 @@
|
||||
import controlComponent from './StringControl';
|
||||
import previewComponent from './StringPreview';
|
||||
export const NetlifyCmsWidgetString = { controlComponent, previewComponent };
|
||||
export { controlComponent, previewComponent };
|
||||
|
||||
const Widget = (opts = {}) => ({
|
||||
name: 'string',
|
||||
controlComponent,
|
||||
previewComponent,
|
||||
...opts,
|
||||
});
|
||||
|
||||
export const NetlifyCmsWidgetString = { Widget, controlComponent, previewComponent };
|
||||
export default NetlifyCmsWidgetString;
|
||||
|
@ -1,5 +1,12 @@
|
||||
import controlComponent from './TextControl';
|
||||
import previewComponent from './TextPreview';
|
||||
|
||||
export const NetlifyCmsWidgetText = { controlComponent, previewComponent };
|
||||
export { controlComponent, previewComponent };
|
||||
const Widget = (opts = {}) => ({
|
||||
name: 'text',
|
||||
controlComponent,
|
||||
previewComponent,
|
||||
...opts,
|
||||
});
|
||||
|
||||
export const NetlifyCmsWidgetText = { Widget, controlComponent, previewComponent };
|
||||
export default NetlifyCmsWidgetText;
|
||||
|
@ -1,12 +1,12 @@
|
||||
import { registerBackend } from 'netlify-cms-core';
|
||||
import { NetlifyCmsCore as CMS } from 'netlify-cms-core';
|
||||
import { GitHubBackend } from 'netlify-cms-backend-github';
|
||||
import { GitLabBackend } from 'netlify-cms-backend-gitlab';
|
||||
import { GitGatewayBackend } from 'netlify-cms-backend-git-gateway';
|
||||
import { BitbucketBackend } from 'netlify-cms-backend-bitbucket';
|
||||
import { TestBackend } from 'netlify-cms-backend-test';
|
||||
|
||||
registerBackend('git-gateway', GitGatewayBackend);
|
||||
registerBackend('github', GitHubBackend);
|
||||
registerBackend('gitlab', GitLabBackend);
|
||||
registerBackend('bitbucket', BitbucketBackend);
|
||||
registerBackend('test-repo', TestBackend);
|
||||
CMS.registerBackend('git-gateway', GitGatewayBackend);
|
||||
CMS.registerBackend('github', GitHubBackend);
|
||||
CMS.registerBackend('gitlab', GitLabBackend);
|
||||
CMS.registerBackend('bitbucket', BitbucketBackend);
|
||||
CMS.registerBackend('test-repo', TestBackend);
|
||||
|
@ -1,4 +1,4 @@
|
||||
import { registerEditorComponent } from 'netlify-cms-core';
|
||||
import { NetlifyCmsCore as CMS } from 'netlify-cms-core';
|
||||
import image from 'netlify-cms-editor-component-image';
|
||||
|
||||
registerEditorComponent(image);
|
||||
CMS.registerEditorComponent(image);
|
||||
|
@ -1,6 +1,6 @@
|
||||
import createReactClass from 'create-react-class';
|
||||
import React from 'react';
|
||||
import * as CMS from 'netlify-cms-core';
|
||||
import { NetlifyCmsCore as CMS } from 'netlify-cms-core';
|
||||
import './backends';
|
||||
import './widgets';
|
||||
import './editor-components';
|
||||
|
@ -1,6 +1,6 @@
|
||||
import { registerMediaLibrary } from 'netlify-cms-core';
|
||||
import { NetlifyCmsCore as CMS } from 'netlify-cms-core';
|
||||
import uploadcare from 'netlify-cms-media-library-uploadcare';
|
||||
import cloudinary from 'netlify-cms-media-library-cloudinary';
|
||||
|
||||
registerMediaLibrary(uploadcare);
|
||||
registerMediaLibrary(cloudinary);
|
||||
CMS.registerMediaLibrary(uploadcare);
|
||||
CMS.registerMediaLibrary(cloudinary);
|
||||
|
@ -1,69 +1,32 @@
|
||||
import { registerWidget } from 'netlify-cms-core';
|
||||
import * as NetlifyCmsWidgetString from 'netlify-cms-widget-string';
|
||||
import * as NetlifyCmsWidgetNumber from 'netlify-cms-widget-number';
|
||||
import * as NetlifyCmsWidgetText from 'netlify-cms-widget-text';
|
||||
import * as NetlifyCmsWidgetImage from 'netlify-cms-widget-image';
|
||||
import * as NetlifyCmsWidgetFile from 'netlify-cms-widget-file';
|
||||
import * as NetlifyCmsWidgetSelect from 'netlify-cms-widget-select';
|
||||
import * as NetlifyCmsWidgetMarkdown from 'netlify-cms-widget-markdown';
|
||||
import * as NetlifyCmsWidgetList from 'netlify-cms-widget-list';
|
||||
import * as NetlifyCmsWidgetObject from 'netlify-cms-widget-object';
|
||||
import * as NetlifyCmsWidgetRelation from 'netlify-cms-widget-relation';
|
||||
import * as NetlifyCmsWidgetBoolean from 'netlify-cms-widget-boolean';
|
||||
import * as NetlifyCmsWidgetMap from 'netlify-cms-widget-map';
|
||||
import { NetlifyCmsWidgetDate } from 'netlify-cms-widget-date';
|
||||
import { NetlifyCmsWidgetDatetime } from 'netlify-cms-widget-datetime';
|
||||
import { NetlifyCmsCore as CMS } from 'netlify-cms-core';
|
||||
import NetlifyCmsWidgetString from 'netlify-cms-widget-string';
|
||||
import NetlifyCmsWidgetNumber from 'netlify-cms-widget-number';
|
||||
import NetlifyCmsWidgetText from 'netlify-cms-widget-text';
|
||||
import NetlifyCmsWidgetImage from 'netlify-cms-widget-image';
|
||||
import NetlifyCmsWidgetFile from 'netlify-cms-widget-file';
|
||||
import NetlifyCmsWidgetSelect from 'netlify-cms-widget-select';
|
||||
import NetlifyCmsWidgetMarkdown from 'netlify-cms-widget-markdown';
|
||||
import NetlifyCmsWidgetList from 'netlify-cms-widget-list';
|
||||
import NetlifyCmsWidgetObject from 'netlify-cms-widget-object';
|
||||
import NetlifyCmsWidgetRelation from 'netlify-cms-widget-relation';
|
||||
import NetlifyCmsWidgetBoolean from 'netlify-cms-widget-boolean';
|
||||
import NetlifyCmsWidgetMap from 'netlify-cms-widget-map';
|
||||
import NetlifyCmsWidgetDate from 'netlify-cms-widget-date';
|
||||
import NetlifyCmsWidgetDatetime from 'netlify-cms-widget-datetime';
|
||||
|
||||
registerWidget(
|
||||
'string',
|
||||
NetlifyCmsWidgetString.controlComponent,
|
||||
NetlifyCmsWidgetString.previewComponent,
|
||||
);
|
||||
registerWidget(
|
||||
'number',
|
||||
NetlifyCmsWidgetNumber.controlComponent,
|
||||
NetlifyCmsWidgetNumber.previewComponent,
|
||||
);
|
||||
registerWidget(
|
||||
'text',
|
||||
NetlifyCmsWidgetText.controlComponent,
|
||||
NetlifyCmsWidgetText.previewComponent,
|
||||
);
|
||||
registerWidget(
|
||||
'list',
|
||||
NetlifyCmsWidgetList.controlComponent,
|
||||
NetlifyCmsWidgetList.previewComponent,
|
||||
);
|
||||
registerWidget(
|
||||
'markdown',
|
||||
NetlifyCmsWidgetMarkdown.controlComponent,
|
||||
NetlifyCmsWidgetMarkdown.previewComponent,
|
||||
);
|
||||
registerWidget(
|
||||
'image',
|
||||
NetlifyCmsWidgetImage.controlComponent,
|
||||
NetlifyCmsWidgetImage.previewComponent,
|
||||
);
|
||||
registerWidget(
|
||||
'file',
|
||||
NetlifyCmsWidgetFile.controlComponent,
|
||||
NetlifyCmsWidgetFile.previewComponent,
|
||||
);
|
||||
registerWidget(
|
||||
'select',
|
||||
NetlifyCmsWidgetSelect.controlComponent,
|
||||
NetlifyCmsWidgetSelect.previewComponent,
|
||||
);
|
||||
registerWidget(
|
||||
'object',
|
||||
NetlifyCmsWidgetObject.controlComponent,
|
||||
NetlifyCmsWidgetObject.previewComponent,
|
||||
);
|
||||
registerWidget(
|
||||
'relation',
|
||||
NetlifyCmsWidgetRelation.controlComponent,
|
||||
NetlifyCmsWidgetRelation.previewComponent,
|
||||
);
|
||||
registerWidget('boolean', NetlifyCmsWidgetBoolean.controlComponent);
|
||||
registerWidget('map', NetlifyCmsWidgetMap.controlComponent, NetlifyCmsWidgetMap.previewComponent);
|
||||
registerWidget([NetlifyCmsWidgetDate.Widget(), NetlifyCmsWidgetDatetime.Widget()]);
|
||||
CMS.registerWidget([
|
||||
NetlifyCmsWidgetString.Widget(),
|
||||
NetlifyCmsWidgetNumber.Widget(),
|
||||
NetlifyCmsWidgetText.Widget(),
|
||||
NetlifyCmsWidgetImage.Widget(),
|
||||
NetlifyCmsWidgetFile.Widget(),
|
||||
NetlifyCmsWidgetSelect.Widget(),
|
||||
NetlifyCmsWidgetMarkdown.Widget(),
|
||||
NetlifyCmsWidgetList.Widget(),
|
||||
NetlifyCmsWidgetObject.Widget(),
|
||||
NetlifyCmsWidgetRelation.Widget(),
|
||||
NetlifyCmsWidgetBoolean.Widget(),
|
||||
NetlifyCmsWidgetMap.Widget(),
|
||||
NetlifyCmsWidgetDate.Widget(),
|
||||
NetlifyCmsWidgetDatetime.Widget(),
|
||||
]);
|
||||
|
Loading…
x
Reference in New Issue
Block a user