diff --git a/packages/react/.env b/packages/react/.env index fa923c0222..6effe85704 100644 --- a/packages/react/.env +++ b/packages/react/.env @@ -1 +1 @@ -REACT_APP_API_BASE_URL=127.0.0.1:5000 \ No newline at end of file +REACT_APP_API_BASE_URL=http://127.0.0.1:5000 \ No newline at end of file diff --git a/packages/react/.storybook/addons.js b/packages/react/.storybook/addons.js new file mode 100644 index 0000000000..b986e0ea46 --- /dev/null +++ b/packages/react/.storybook/addons.js @@ -0,0 +1,3 @@ +import '@storybook/addon-actions/register'; +import '@storybook/addon-links/register'; +import '@storybook/addon-cssresources/register'; \ No newline at end of file diff --git a/packages/react/.storybook/config.js b/packages/react/.storybook/config.js new file mode 100644 index 0000000000..84026a5d8a --- /dev/null +++ b/packages/react/.storybook/config.js @@ -0,0 +1,23 @@ +import { configure, addDecorator, addParameters } from '@storybook/react'; +import { withCssResources } from '@storybook/addon-cssresources'; + +const REACT_APP_API_BASE_URL = process.env.REACT_APP_API_BASE_URL; +addDecorator(withCssResources) +addParameters({ + cssresources: [{ + id: `bootstrap`, + code: ``, + picked: true, + }, { + id: `sfds`, + code: ``, + picked: true, + }, { + id: `style`, + code: ``, + picked: true, + }], +}); + +// automatically import all files ending in *.stories.js +configure(require.context('../src/stories', true, /\.stories\.js$/), module); diff --git a/packages/react/.storybook/presets.js b/packages/react/.storybook/presets.js new file mode 100644 index 0000000000..9e05fbe8c0 --- /dev/null +++ b/packages/react/.storybook/presets.js @@ -0,0 +1,3 @@ +module.exports = [ + '@storybook/addon-storysource/preset' +]; diff --git a/packages/react/src/utils/plugin.ts b/packages/react/src/utils/plugin.ts index a2dab2dd0d..0affc84684 100644 --- a/packages/react/src/utils/plugin.ts +++ b/packages/react/src/utils/plugin.ts @@ -1,3 +1,17 @@ +import * as React from 'react'; +import * as ReactDom from 'react-dom'; +import * as Redux from 'redux'; +import * as ReactRedux from 'react-redux'; +import PropTypes from 'prop-types'; +import * as ReactDesignSystem from '@salesforce/design-system-react'; +import styled from 'styled-components'; +import * as ReduxThunk from 'redux-thunk'; +import * as Immer from 'immer'; +import * as TSODataClient from 'ts-odata-client'; +import * as NodeFetch from 'node-fetch'; +import * as SteedosFilters from '@steedos/filters'; + +import * as ReactSteedos from '../export'; import store from "../stores/configureStore"; import { receivePluginInstance, receivePluginComponent } from '../actions'; import { ObjectHomeIFrame, generateIFrame } from "../components/object_home_iframe"; @@ -14,6 +28,25 @@ export const registerPlugin = ( pluginName, pluginInstance ) => { pluginInstance.initialize(registry, store); } + +export const registerWindowLibraries = () => { + window["React"] = React; + window["PropTypes"] = PropTypes; + window["ReactDom"] = ReactDom; + window["Redux"] = Redux; + window["ReactRedux"] = ReactRedux; + window["ReactDesignSystem"] = ReactDesignSystem; + window["ReactSteedos"] = ReactSteedos; + window["StyledComponents"] = styled; + window["ReduxThunk"] = ReduxThunk; + window["Immer"] = Immer; + window["TSODataClient"] = TSODataClient; + window["NodeFetch"] = NodeFetch; + window["SteedosFilters"] = SteedosFilters; + + window["registerPlugin"] = registerPlugin; +} + function dispatchPluginComponentAction(name: string, pluginId: string, component: any, id: string = "") { if(!id){ id = generateId(); diff --git a/yarn.lock b/yarn.lock index 922bb30f72..fd63f7f434 100644 Binary files a/yarn.lock and b/yarn.lock differ