@webiny/app 0.0.0-mt-2 → 0.0.0-unstable.085ff6572f
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/App.d.ts +29 -0
- package/App.js +105 -0
- package/App.js.map +1 -0
- package/apollo-client/InMemoryCache.d.ts +1 -1
- package/apollo-client/InMemoryCache.js +33 -36
- package/apollo-client/InMemoryCache.js.map +1 -0
- package/components/Image.js +18 -16
- package/components/Image.js.map +1 -0
- package/components/Routes.js +27 -17
- package/components/Routes.js.map +1 -0
- package/components/View.js +21 -14
- package/components/View.js.map +1 -0
- package/components/index.d.ts +1 -0
- package/components/index.js +19 -1
- package/components/index.js.map +1 -0
- package/config.d.ts +8 -0
- package/config.js +30 -0
- package/config.js.map +1 -0
- package/contexts/Ui/index.d.ts +1 -4
- package/contexts/Ui/index.js +32 -42
- package/contexts/Ui/index.js.map +1 -0
- package/core/AddRoute.d.ts +3 -0
- package/core/AddRoute.js +19 -0
- package/core/AddRoute.js.map +1 -0
- package/core/DebounceRender.d.ts +11 -0
- package/core/DebounceRender.js +41 -0
- package/core/DebounceRender.js.map +1 -0
- package/core/Plugin.d.ts +8 -0
- package/core/Plugin.js +21 -0
- package/core/Plugin.js.map +1 -0
- package/core/Plugins.d.ts +12 -0
- package/core/Plugins.js +45 -0
- package/core/Plugins.js.map +1 -0
- package/core/Provider.d.ts +9 -0
- package/core/Provider.js +21 -0
- package/core/Provider.js.map +1 -0
- package/core/Routes.d.ts +6 -0
- package/core/Routes.js +42 -0
- package/core/Routes.js.map +1 -0
- package/core/createProvider.d.ts +6 -0
- package/core/createProvider.js +13 -0
- package/core/createProvider.js.map +1 -0
- package/core/createProviderPlugin.d.ts +8 -0
- package/core/createProviderPlugin.js +21 -0
- package/core/createProviderPlugin.js.map +1 -0
- package/hooks/useAutocomplete/index.js +12 -1
- package/hooks/useAutocomplete/index.js.map +1 -0
- package/hooks/useAutocomplete/useAutocomplete.d.ts +6 -1
- package/hooks/useAutocomplete/useAutocomplete.js +16 -14
- package/hooks/useAutocomplete/useAutocomplete.js.map +1 -0
- package/hooks/useDataList/functions/getData.d.ts +1 -1
- package/hooks/useDataList/functions/getData.js +12 -4
- package/hooks/useDataList/functions/getData.js.map +1 -0
- package/hooks/useDataList/functions/getError.d.ts +1 -1
- package/hooks/useDataList/functions/getError.js +12 -4
- package/hooks/useDataList/functions/getError.js.map +1 -0
- package/hooks/useDataList/functions/getMeta.d.ts +1 -1
- package/hooks/useDataList/functions/getMeta.js +12 -4
- package/hooks/useDataList/functions/getMeta.js.map +1 -0
- package/hooks/useDataList/functions/index.js +27 -3
- package/hooks/useDataList/functions/index.js.map +1 -0
- package/hooks/useDataList/functions/searchDataByKey.d.ts +1 -1
- package/hooks/useDataList/functions/searchDataByKey.js +8 -6
- package/hooks/useDataList/functions/searchDataByKey.js.map +1 -0
- package/hooks/useDataList/index.js +12 -1
- package/hooks/useDataList/index.js.map +1 -0
- package/hooks/useDataList/useDataList.d.ts +4 -4
- package/hooks/useDataList/useDataList.js +47 -58
- package/hooks/useDataList/useDataList.js.map +1 -0
- package/hooks/useDataList/utils/index.js +20 -2
- package/hooks/useDataList/utils/index.js.map +1 -0
- package/hooks/useDataList/utils/prepareLoadListParams.d.ts +10 -3
- package/hooks/useDataList/utils/prepareLoadListParams.js +19 -15
- package/hooks/useDataList/utils/prepareLoadListParams.js.map +1 -0
- package/hooks/useDataList/utils/redirectToRouteWithQueryParams.d.ts +13 -4
- package/hooks/useDataList/utils/redirectToRouteWithQueryParams.js +11 -4
- package/hooks/useDataList/utils/redirectToRouteWithQueryParams.js.map +1 -0
- package/hooks/useDataList/utils/types.js +5 -1
- package/hooks/useDataList/utils/types.js.map +1 -0
- package/hooks/useHandler.d.ts +11 -1
- package/hooks/useHandler.js +11 -5
- package/hooks/useHandler.js.map +1 -0
- package/hooks/useHandlers.d.ts +1 -1
- package/hooks/useHandlers.js +14 -6
- package/hooks/useHandlers.js.map +1 -0
- package/hooks/useUi.js +12 -5
- package/hooks/useUi.js.map +1 -0
- package/i18n/i18n.js +14 -5
- package/i18n/i18n.js.map +1 -0
- package/i18n/index.js +13 -1
- package/i18n/index.js.map +1 -0
- package/index.d.ts +15 -0
- package/index.js +147 -0
- package/index.js.map +1 -0
- package/package.json +33 -25
- package/plugins/AddQuerySelectionPlugin.d.ts +9 -2
- package/plugins/AddQuerySelectionPlugin.js +73 -52
- package/plugins/AddQuerySelectionPlugin.js.map +1 -0
- package/plugins/ApolloCacheObjectIdPlugin.d.ts +8 -8
- package/plugins/ApolloCacheObjectIdPlugin.js +23 -25
- package/plugins/ApolloCacheObjectIdPlugin.js.map +1 -0
- package/plugins/ApolloDynamicLink.d.ts +3 -2
- package/plugins/ApolloDynamicLink.js +30 -32
- package/plugins/ApolloDynamicLink.js.map +1 -0
- package/plugins/ApolloLinkPlugin.d.ts +5 -5
- package/plugins/ApolloLinkPlugin.js +32 -29
- package/plugins/ApolloLinkPlugin.js.map +1 -0
- package/plugins/ConsoleLinkPlugin.js +25 -24
- package/plugins/ConsoleLinkPlugin.js.map +1 -0
- package/plugins/LocaleHeaderLinkPlugin.d.ts +3 -7
- package/plugins/LocaleHeaderLinkPlugin.js +28 -36
- package/plugins/LocaleHeaderLinkPlugin.js.map +1 -0
- package/plugins/NetworkErrorLinkPlugin/ErrorOverlay.d.ts +13 -5
- package/plugins/NetworkErrorLinkPlugin/ErrorOverlay.js +46 -45
- package/plugins/NetworkErrorLinkPlugin/ErrorOverlay.js.map +1 -0
- package/plugins/NetworkErrorLinkPlugin/StyledComponents.d.ts +10 -2
- package/plugins/NetworkErrorLinkPlugin/StyledComponents.js +13 -4
- package/plugins/NetworkErrorLinkPlugin/StyledComponents.js.map +1 -0
- package/plugins/NetworkErrorLinkPlugin/createErrorOverlay.d.ts +6 -4
- package/plugins/NetworkErrorLinkPlugin/createErrorOverlay.js +21 -17
- package/plugins/NetworkErrorLinkPlugin/createErrorOverlay.js.map +1 -0
- package/plugins/NetworkErrorLinkPlugin.js +31 -28
- package/plugins/NetworkErrorLinkPlugin.js.map +1 -0
- package/plugins/OmitTypenameLinkPlugin.js +22 -22
- package/plugins/OmitTypenameLinkPlugin.js.map +1 -0
- package/plugins/RoutePlugin.d.ts +2 -2
- package/plugins/RoutePlugin.js +26 -24
- package/plugins/RoutePlugin.js.map +1 -0
- package/plugins/TenantHeaderLinkPlugin.d.ts +3 -7
- package/plugins/TenantHeaderLinkPlugin.js +28 -39
- package/plugins/TenantHeaderLinkPlugin.js.map +1 -0
- package/plugins/ViewPlugin.d.ts +4 -4
- package/plugins/ViewPlugin.js +26 -24
- package/plugins/ViewPlugin.js.map +1 -0
- package/plugins/image.js +41 -55
- package/plugins/image.js.map +1 -0
- package/plugins/index.js +49 -33
- package/plugins/index.js.map +1 -0
- package/types.d.ts +20 -16
- package/types.js +12 -2
- package/types.js.map +1 -0
- package/utils/getApiUrl.d.ts +1 -0
- package/utils/getApiUrl.js +11 -0
- package/utils/getApiUrl.js.map +1 -0
- package/utils/getGqlApiUrl.d.ts +1 -0
- package/utils/getGqlApiUrl.js +11 -0
- package/utils/getGqlApiUrl.js.map +1 -0
- package/utils/getHeadlessCmsGqlApiUrl.d.ts +5 -0
- package/utils/getHeadlessCmsGqlApiUrl.js +17 -0
- package/utils/getHeadlessCmsGqlApiUrl.js.map +1 -0
- package/utils/getLocaleCode.d.ts +6 -0
- package/utils/getLocaleCode.js +42 -0
- package/utils/getLocaleCode.js.map +1 -0
- package/utils/getPrerenderId.d.ts +6 -0
- package/utils/getPrerenderId.js +10 -0
- package/utils/getPrerenderId.js.map +1 -0
- package/utils/getTenantId.d.ts +6 -0
- package/utils/getTenantId.js +34 -0
- package/utils/getTenantId.js.map +1 -0
- package/utils/index.d.ts +8 -0
- package/utils/index.js +93 -0
- package/utils/index.js.map +1 -0
- package/utils/isLocalhost.d.ts +1 -0
- package/utils/isLocalhost.js +14 -0
- package/utils/isLocalhost.js.map +1 -0
- package/utils/isPrerendering.d.ts +1 -0
- package/utils/isPrerendering.js +10 -0
- package/utils/isPrerendering.js.map +1 -0
package/App.d.ts
ADDED
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import React, { ReactElement } from "react";
|
|
2
|
+
import { RouteProps } from "@webiny/react-router";
|
|
3
|
+
import { HigherOrderComponent } from "@webiny/react-composition";
|
|
4
|
+
declare type RoutesByPath = {
|
|
5
|
+
[key: string]: ReactElement<RouteProps>;
|
|
6
|
+
};
|
|
7
|
+
interface State {
|
|
8
|
+
routes: RoutesByPath;
|
|
9
|
+
plugins: JSX.Element[];
|
|
10
|
+
providers: HigherOrderComponent[];
|
|
11
|
+
}
|
|
12
|
+
interface AppContext extends State {
|
|
13
|
+
addRoute(route: JSX.Element): void;
|
|
14
|
+
addProvider(hoc: HigherOrderComponent): void;
|
|
15
|
+
addPlugin(plugin: React.ReactNode): void;
|
|
16
|
+
}
|
|
17
|
+
declare const AppContext: React.Context<AppContext | undefined>;
|
|
18
|
+
export declare const useApp: () => AppContext;
|
|
19
|
+
export interface AppProps {
|
|
20
|
+
debounceRender?: number;
|
|
21
|
+
routes?: Array<RouteProps>;
|
|
22
|
+
providers?: Array<HigherOrderComponent>;
|
|
23
|
+
children?: React.ReactNode | React.ReactNode[];
|
|
24
|
+
}
|
|
25
|
+
export declare const App: {
|
|
26
|
+
({ debounceRender, routes, providers, children }: AppProps): JSX.Element;
|
|
27
|
+
displayName: string;
|
|
28
|
+
};
|
|
29
|
+
export {};
|
package/App.js
ADDED
|
@@ -0,0 +1,105 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _interopRequireWildcard = require("@babel/runtime/helpers/interopRequireWildcard").default;
|
|
4
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
|
|
5
|
+
Object.defineProperty(exports, "__esModule", {
|
|
6
|
+
value: true
|
|
7
|
+
});
|
|
8
|
+
exports.useApp = exports.App = void 0;
|
|
9
|
+
var _toConsumableArray2 = _interopRequireDefault(require("@babel/runtime/helpers/toConsumableArray"));
|
|
10
|
+
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
11
|
+
var _objectSpread4 = _interopRequireDefault(require("@babel/runtime/helpers/objectSpread2"));
|
|
12
|
+
var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime/helpers/slicedToArray"));
|
|
13
|
+
var _react = _interopRequireWildcard(require("react"));
|
|
14
|
+
var _reactRouter = require("@webiny/react-router");
|
|
15
|
+
var _reactComposition = require("@webiny/react-composition");
|
|
16
|
+
var _Routes = require("./core/Routes");
|
|
17
|
+
var _DebounceRender = require("./core/DebounceRender");
|
|
18
|
+
var _Plugins = require("./core/Plugins");
|
|
19
|
+
var AppContext = /*#__PURE__*/(0, _react.createContext)(undefined);
|
|
20
|
+
AppContext.displayName = "AppContext";
|
|
21
|
+
var useApp = function useApp() {
|
|
22
|
+
var appContext = (0, _react.useContext)(AppContext);
|
|
23
|
+
if (!appContext) {
|
|
24
|
+
throw Error("AppContext provider was not found. Are you using the \"useApp()\" hook in the right place?");
|
|
25
|
+
}
|
|
26
|
+
return appContext;
|
|
27
|
+
};
|
|
28
|
+
exports.useApp = useApp;
|
|
29
|
+
var App = function App(_ref) {
|
|
30
|
+
var _ref$debounceRender = _ref.debounceRender,
|
|
31
|
+
debounceRender = _ref$debounceRender === void 0 ? 50 : _ref$debounceRender,
|
|
32
|
+
_ref$routes = _ref.routes,
|
|
33
|
+
routes = _ref$routes === void 0 ? [] : _ref$routes,
|
|
34
|
+
_ref$providers = _ref.providers,
|
|
35
|
+
providers = _ref$providers === void 0 ? [] : _ref$providers,
|
|
36
|
+
children = _ref.children;
|
|
37
|
+
var _useState = (0, _react.useState)({
|
|
38
|
+
routes: routes.reduce(function (acc, item) {
|
|
39
|
+
return (0, _objectSpread4.default)((0, _objectSpread4.default)({}, acc), {}, (0, _defineProperty2.default)({}, item.path, /*#__PURE__*/_react.default.createElement(_reactRouter.Route, item)));
|
|
40
|
+
}, {}),
|
|
41
|
+
plugins: [],
|
|
42
|
+
providers: providers
|
|
43
|
+
}),
|
|
44
|
+
_useState2 = (0, _slicedToArray2.default)(_useState, 2),
|
|
45
|
+
state = _useState2[0],
|
|
46
|
+
setState = _useState2[1];
|
|
47
|
+
var addRoute = (0, _react.useCallback)(function (route) {
|
|
48
|
+
setState(function (state) {
|
|
49
|
+
return (0, _objectSpread4.default)((0, _objectSpread4.default)({}, state), {}, {
|
|
50
|
+
routes: (0, _objectSpread4.default)((0, _objectSpread4.default)({}, state.routes), {}, (0, _defineProperty2.default)({}, route.props.path, route))
|
|
51
|
+
});
|
|
52
|
+
});
|
|
53
|
+
}, []);
|
|
54
|
+
var addProvider = (0, _react.useCallback)(function (component) {
|
|
55
|
+
setState(function (state) {
|
|
56
|
+
if (state.providers.findIndex(function (m) {
|
|
57
|
+
return m === component;
|
|
58
|
+
}) > -1) {
|
|
59
|
+
return state;
|
|
60
|
+
}
|
|
61
|
+
return (0, _objectSpread4.default)((0, _objectSpread4.default)({}, state), {}, {
|
|
62
|
+
providers: [].concat((0, _toConsumableArray2.default)(state.providers), [component])
|
|
63
|
+
});
|
|
64
|
+
});
|
|
65
|
+
}, []);
|
|
66
|
+
var addPlugin = (0, _react.useCallback)(function (element) {
|
|
67
|
+
setState(function (state) {
|
|
68
|
+
return (0, _objectSpread4.default)((0, _objectSpread4.default)({}, state), {}, {
|
|
69
|
+
plugins: [].concat((0, _toConsumableArray2.default)(state.plugins), [element])
|
|
70
|
+
});
|
|
71
|
+
});
|
|
72
|
+
}, []);
|
|
73
|
+
var appContext = (0, _react.useMemo)(function () {
|
|
74
|
+
return (0, _objectSpread4.default)((0, _objectSpread4.default)({}, state), {}, {
|
|
75
|
+
addRoute: addRoute,
|
|
76
|
+
addProvider: addProvider,
|
|
77
|
+
addPlugin: addPlugin
|
|
78
|
+
});
|
|
79
|
+
}, [state]);
|
|
80
|
+
var AppRouter = (0, _react.useMemo)(function () {
|
|
81
|
+
return function AppRouter() {
|
|
82
|
+
var routes = Object.values(state.routes);
|
|
83
|
+
return /*#__PURE__*/_react.default.createElement(_Routes.Routes, {
|
|
84
|
+
key: routes.length,
|
|
85
|
+
routes: routes
|
|
86
|
+
});
|
|
87
|
+
};
|
|
88
|
+
}, [state.routes]);
|
|
89
|
+
var Providers = (0, _react.useMemo)(function () {
|
|
90
|
+
return _reactComposition.compose.apply(void 0, (0, _toConsumableArray2.default)(state.providers || []))(function (_ref2) {
|
|
91
|
+
var children = _ref2.children;
|
|
92
|
+
return /*#__PURE__*/_react.default.createElement(_DebounceRender.DebounceRender, {
|
|
93
|
+
wait: debounceRender
|
|
94
|
+
}, children);
|
|
95
|
+
});
|
|
96
|
+
}, [state.providers.length]);
|
|
97
|
+
Providers.displayName = "Providers";
|
|
98
|
+
return /*#__PURE__*/_react.default.createElement(AppContext.Provider, {
|
|
99
|
+
value: appContext
|
|
100
|
+
}, /*#__PURE__*/_react.default.createElement(_reactComposition.CompositionProvider, null, children, /*#__PURE__*/_react.default.createElement(_reactRouter.BrowserRouter, null, /*#__PURE__*/_react.default.createElement(Providers, null, /*#__PURE__*/_react.default.createElement(_Plugins.PluginsProvider, null, state.plugins), /*#__PURE__*/_react.default.createElement(_DebounceRender.DebounceRender, {
|
|
101
|
+
wait: debounceRender
|
|
102
|
+
}, /*#__PURE__*/_react.default.createElement(AppRouter, null))))));
|
|
103
|
+
};
|
|
104
|
+
exports.App = App;
|
|
105
|
+
App.displayName = "App";
|
package/App.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["AppContext","createContext","undefined","displayName","useApp","appContext","useContext","Error","App","debounceRender","routes","providers","children","useState","reduce","acc","item","path","plugins","state","setState","addRoute","useCallback","route","props","addProvider","component","findIndex","m","addPlugin","element","useMemo","AppRouter","Object","values","length","Providers","compose"],"sources":["App.tsx"],"sourcesContent":["import React, {\n createContext,\n useContext,\n useMemo,\n useState,\n useCallback,\n FunctionComponentElement,\n ReactElement\n} from \"react\";\nimport { BrowserRouter, RouteProps, Route } from \"@webiny/react-router\";\nimport { compose, HigherOrderComponent, CompositionProvider } from \"@webiny/react-composition\";\nimport { Routes as SortRoutes } from \"./core/Routes\";\nimport { DebounceRender } from \"./core/DebounceRender\";\nimport { PluginsProvider } from \"./core/Plugins\";\n\ntype RoutesByPath = {\n [key: string]: ReactElement<RouteProps>;\n};\n\ninterface State {\n routes: RoutesByPath;\n plugins: JSX.Element[];\n providers: HigherOrderComponent[];\n}\n\ninterface AppContext extends State {\n addRoute(route: JSX.Element): void;\n addProvider(hoc: HigherOrderComponent): void;\n addPlugin(plugin: React.ReactNode): void;\n}\n\nconst AppContext = createContext<AppContext | undefined>(undefined);\n\nAppContext.displayName = \"AppContext\";\n\nexport const useApp = () => {\n const appContext = useContext(AppContext);\n if (!appContext) {\n throw Error(\n `AppContext provider was not found. Are you using the \"useApp()\" hook in the right place?`\n );\n }\n return appContext;\n};\n\nexport interface AppProps {\n debounceRender?: number;\n routes?: Array<RouteProps>;\n providers?: Array<HigherOrderComponent>;\n children?: React.ReactNode | React.ReactNode[];\n}\n\nexport const App = ({ debounceRender = 50, routes = [], providers = [], children }: AppProps) => {\n const [state, setState] = useState<State>({\n routes: routes.reduce<RoutesByPath>((acc, item) => {\n return { ...acc, [item.path as string]: <Route {...item} /> };\n }, {}),\n plugins: [],\n providers\n });\n\n const addRoute = useCallback((route: FunctionComponentElement<RouteProps>) => {\n setState(state => {\n return {\n ...state,\n routes: { ...state.routes, [route.props.path as string]: route }\n };\n });\n }, []);\n\n const addProvider = useCallback(component => {\n setState(state => {\n if (state.providers.findIndex(m => m === component) > -1) {\n return state;\n }\n\n return {\n ...state,\n providers: [...state.providers, component]\n };\n });\n }, []);\n\n const addPlugin = useCallback(element => {\n setState(state => {\n return {\n ...state,\n plugins: [...state.plugins, element]\n };\n });\n }, []);\n\n const appContext = useMemo(\n () => ({\n ...state,\n addRoute,\n addProvider,\n addPlugin\n }),\n [state]\n );\n\n const AppRouter = useMemo(() => {\n return function AppRouter() {\n const routes = Object.values(state.routes);\n return <SortRoutes key={routes.length} routes={routes} />;\n };\n }, [state.routes]);\n\n const Providers = useMemo(() => {\n return compose(...(state.providers || []))(({ children }: any) => (\n <DebounceRender wait={debounceRender}>{children}</DebounceRender>\n ));\n }, [state.providers.length]);\n\n Providers.displayName = \"Providers\";\n\n return (\n <AppContext.Provider value={appContext}>\n <CompositionProvider>\n {children}\n <BrowserRouter>\n <Providers>\n <PluginsProvider>{state.plugins}</PluginsProvider>\n <DebounceRender wait={debounceRender}>\n <AppRouter />\n </DebounceRender>\n </Providers>\n </BrowserRouter>\n </CompositionProvider>\n </AppContext.Provider>\n );\n};\n\nApp.displayName = \"App\";\n"],"mappings":"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"}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { InMemoryCache as BaseInMemoryCache, InMemoryCacheConfig } from "apollo-cache-inmemory";
|
|
2
2
|
import { DocumentNode } from "graphql";
|
|
3
3
|
export declare class InMemoryCache extends BaseInMemoryCache {
|
|
4
|
-
private transformPlugins;
|
|
4
|
+
private readonly transformPlugins;
|
|
5
5
|
constructor(config?: InMemoryCacheConfig);
|
|
6
6
|
transformDocument(document: DocumentNode): DocumentNode;
|
|
7
7
|
}
|
|
@@ -1,45 +1,43 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
|
|
4
|
+
Object.defineProperty(exports, "__esModule", {
|
|
5
|
+
value: true
|
|
6
|
+
});
|
|
7
|
+
exports.InMemoryCache = void 0;
|
|
8
|
+
var _createForOfIteratorHelper2 = _interopRequireDefault(require("@babel/runtime/helpers/createForOfIteratorHelper"));
|
|
9
|
+
var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/classCallCheck"));
|
|
10
|
+
var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/createClass"));
|
|
11
|
+
var _assertThisInitialized2 = _interopRequireDefault(require("@babel/runtime/helpers/assertThisInitialized"));
|
|
12
|
+
var _get2 = _interopRequireDefault(require("@babel/runtime/helpers/get"));
|
|
13
|
+
var _getPrototypeOf2 = _interopRequireDefault(require("@babel/runtime/helpers/getPrototypeOf"));
|
|
14
|
+
var _inherits2 = _interopRequireDefault(require("@babel/runtime/helpers/inherits"));
|
|
15
|
+
var _createSuper2 = _interopRequireDefault(require("@babel/runtime/helpers/createSuper"));
|
|
16
|
+
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
17
|
+
var _apolloCacheInmemory = require("apollo-cache-inmemory");
|
|
18
|
+
var _plugins = require("@webiny/plugins");
|
|
19
|
+
var _AddQuerySelectionPlugin = require("../plugins/AddQuerySelectionPlugin");
|
|
20
|
+
var _ApolloLinkPlugin = require("../plugins/ApolloLinkPlugin");
|
|
21
|
+
var InMemoryCache = /*#__PURE__*/function (_BaseInMemoryCache) {
|
|
22
|
+
(0, _inherits2.default)(InMemoryCache, _BaseInMemoryCache);
|
|
23
|
+
var _super = (0, _createSuper2.default)(InMemoryCache);
|
|
19
24
|
function InMemoryCache(config) {
|
|
20
25
|
var _this;
|
|
21
|
-
|
|
22
|
-
_classCallCheck(this, InMemoryCache);
|
|
23
|
-
|
|
26
|
+
(0, _classCallCheck2.default)(this, InMemoryCache);
|
|
24
27
|
_this = _super.call(this, config);
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
_this.transformPlugins = plugins.byType(ApolloLinkPlugin.type).filter(function (pl) {
|
|
29
|
-
return pl instanceof AddQuerySelectionPlugin;
|
|
28
|
+
(0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "transformPlugins", void 0);
|
|
29
|
+
_this.transformPlugins = _plugins.plugins.byType(_ApolloLinkPlugin.ApolloLinkPlugin.type).filter(function (pl) {
|
|
30
|
+
return pl instanceof _AddQuerySelectionPlugin.AddQuerySelectionPlugin;
|
|
30
31
|
});
|
|
31
32
|
return _this;
|
|
32
33
|
}
|
|
33
|
-
|
|
34
|
-
_createClass(InMemoryCache, [{
|
|
34
|
+
(0, _createClass2.default)(InMemoryCache, [{
|
|
35
35
|
key: "transformDocument",
|
|
36
36
|
value: function transformDocument(document) {
|
|
37
37
|
// @ts-ignore
|
|
38
38
|
var operationName = document.definitions[0].name.value;
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
_step;
|
|
42
|
-
|
|
39
|
+
var _iterator = (0, _createForOfIteratorHelper2.default)(this.transformPlugins),
|
|
40
|
+
_step;
|
|
43
41
|
try {
|
|
44
42
|
for (_iterator.s(); !(_step = _iterator.n()).done;) {
|
|
45
43
|
var pl = _step.value;
|
|
@@ -50,10 +48,9 @@ export var InMemoryCache = /*#__PURE__*/function (_BaseInMemoryCache) {
|
|
|
50
48
|
} finally {
|
|
51
49
|
_iterator.f();
|
|
52
50
|
}
|
|
53
|
-
|
|
54
|
-
return _get(_getPrototypeOf(InMemoryCache.prototype), "transformDocument", this).call(this, document);
|
|
51
|
+
return (0, _get2.default)((0, _getPrototypeOf2.default)(InMemoryCache.prototype), "transformDocument", this).call(this, document);
|
|
55
52
|
}
|
|
56
53
|
}]);
|
|
57
|
-
|
|
58
54
|
return InMemoryCache;
|
|
59
|
-
}(
|
|
55
|
+
}(_apolloCacheInmemory.InMemoryCache);
|
|
56
|
+
exports.InMemoryCache = InMemoryCache;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["InMemoryCache","config","transformPlugins","plugins","byType","ApolloLinkPlugin","type","filter","pl","AddQuerySelectionPlugin","document","operationName","definitions","name","value","addSelectionToQuery","BaseInMemoryCache"],"sources":["InMemoryCache.ts"],"sourcesContent":["import { InMemoryCache as BaseInMemoryCache, InMemoryCacheConfig } from \"apollo-cache-inmemory\";\nimport { DocumentNode } from \"graphql\";\nimport { plugins } from \"@webiny/plugins\";\nimport { AddQuerySelectionPlugin } from \"../plugins/AddQuerySelectionPlugin\";\nimport { ApolloLinkPlugin } from \"../plugins/ApolloLinkPlugin\";\n\nexport class InMemoryCache extends BaseInMemoryCache {\n private readonly transformPlugins: AddQuerySelectionPlugin[];\n\n constructor(config?: InMemoryCacheConfig) {\n super(config);\n\n this.transformPlugins = plugins\n .byType<AddQuerySelectionPlugin>(ApolloLinkPlugin.type)\n .filter(pl => pl instanceof AddQuerySelectionPlugin);\n }\n\n public override transformDocument(document: DocumentNode): DocumentNode {\n // @ts-ignore\n const operationName = document.definitions[0].name.value;\n\n for (const pl of this.transformPlugins) {\n pl.addSelectionToQuery(operationName, document);\n }\n\n return super.transformDocument(document);\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;AAAA;AAEA;AACA;AACA;AAA+D,IAElDA,aAAa;EAAA;EAAA;EAGtB,uBAAYC,MAA4B,EAAE;IAAA;IAAA;IACtC,0BAAMA,MAAM;IAAE;IAEd,MAAKC,gBAAgB,GAAGC,gBAAO,CAC1BC,MAAM,CAA0BC,kCAAgB,CAACC,IAAI,CAAC,CACtDC,MAAM,CAAC,UAAAC,EAAE;MAAA,OAAIA,EAAE,YAAYC,gDAAuB;IAAA,EAAC;IAAC;EAC7D;EAAC;IAAA;IAAA,OAED,2BAAkCC,QAAsB,EAAgB;MACpE;MACA,IAAMC,aAAa,GAAGD,QAAQ,CAACE,WAAW,CAAC,CAAC,CAAC,CAACC,IAAI,CAACC,KAAK;MAAC,yDAExC,IAAI,CAACZ,gBAAgB;QAAA;MAAA;QAAtC,oDAAwC;UAAA,IAA7BM,EAAE;UACTA,EAAE,CAACO,mBAAmB,CAACJ,aAAa,EAAED,QAAQ,CAAC;QACnD;MAAC;QAAA;MAAA;QAAA;MAAA;MAED,wHAA+BA,QAAQ;IAC3C;EAAC;EAAA;AAAA,EApB8BM,kCAAiB;AAAA"}
|
package/components/Image.js
CHANGED
|
@@ -1,28 +1,30 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
|
|
4
|
+
Object.defineProperty(exports, "__esModule", {
|
|
5
|
+
value: true
|
|
6
|
+
});
|
|
7
|
+
exports.Image = void 0;
|
|
8
|
+
var _objectWithoutProperties2 = _interopRequireDefault(require("@babel/runtime/helpers/objectWithoutProperties"));
|
|
9
|
+
var _get2 = _interopRequireDefault(require("lodash/get"));
|
|
10
|
+
var _invariant = _interopRequireDefault(require("invariant"));
|
|
11
|
+
var _plugins = require("@webiny/plugins");
|
|
3
12
|
var _excluded = ["preset"];
|
|
4
|
-
|
|
5
|
-
import { plugins } from "@webiny/plugins";
|
|
6
|
-
export var Image = function Image(_ref) {
|
|
13
|
+
var Image = function Image(_ref) {
|
|
7
14
|
var presetName = _ref.preset,
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
var plugin = plugins.byName("image-component");
|
|
11
|
-
|
|
15
|
+
props = (0, _objectWithoutProperties2.default)(_ref, _excluded);
|
|
16
|
+
var plugin = _plugins.plugins.byName("image-component");
|
|
12
17
|
if (!plugin) {
|
|
13
18
|
throw new Error("Image component plugin (type \"image-component\") not defined.");
|
|
14
19
|
}
|
|
15
|
-
|
|
16
20
|
if (presetName) {
|
|
17
|
-
var preset =
|
|
18
|
-
|
|
19
|
-
invariant(preset, "Transform preset \"".concat(presetName, "\" not found."));
|
|
21
|
+
var preset = (0, _get2.default)(plugin, "presets.".concat(presetName));
|
|
22
|
+
(0, _invariant.default)(preset, "Transform preset \"".concat(presetName, "\" not found."));
|
|
20
23
|
props.transform = preset;
|
|
21
24
|
}
|
|
22
|
-
|
|
23
25
|
if (props.transform) {
|
|
24
26
|
props.src = plugin.getImageSrc(props);
|
|
25
27
|
}
|
|
26
|
-
|
|
27
28
|
return plugin.render(props);
|
|
28
|
-
};
|
|
29
|
+
};
|
|
30
|
+
exports.Image = Image;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["Image","presetName","preset","props","plugin","plugins","byName","Error","invariant","transform","src","getImageSrc","render"],"sources":["Image.tsx"],"sourcesContent":["import * as React from \"react\";\nimport invariant from \"invariant\";\nimport { plugins } from \"@webiny/plugins\";\nimport { get } from \"lodash\";\nimport { ImageComponentPlugin, ImageProps } from \"~/types\";\n\nexport const Image: React.FC<ImageProps> = ({ preset: presetName, ...props }) => {\n const plugin = plugins.byName<ImageComponentPlugin>(\"image-component\");\n if (!plugin) {\n throw new Error(`Image component plugin (type \"image-component\") not defined.`);\n }\n\n if (presetName) {\n const preset = get(plugin, `presets.${presetName}`);\n invariant(preset, `Transform preset \"${presetName}\" not found.`);\n props.transform = preset;\n }\n\n if (props.transform) {\n props.src = plugin.getImageSrc(props);\n }\n\n return plugin.render(props);\n};\n"],"mappings":";;;;;;;;;AACA;AACA;AAA0C;AAInC,IAAMA,KAA2B,GAAG,SAA9BA,KAA2B,OAAyC;EAAA,IAA3BC,UAAU,QAAlBC,MAAM;IAAiBC,KAAK;EACtE,IAAMC,MAAM,GAAGC,gBAAO,CAACC,MAAM,CAAuB,iBAAiB,CAAC;EACtE,IAAI,CAACF,MAAM,EAAE;IACT,MAAM,IAAIG,KAAK,kEAAgE;EACnF;EAEA,IAAIN,UAAU,EAAE;IACZ,IAAMC,MAAM,GAAG,mBAAIE,MAAM,oBAAaH,UAAU,EAAG;IACnD,IAAAO,kBAAS,EAACN,MAAM,+BAAuBD,UAAU,mBAAe;IAChEE,KAAK,CAACM,SAAS,GAAGP,MAAM;EAC5B;EAEA,IAAIC,KAAK,CAACM,SAAS,EAAE;IACjBN,KAAK,CAACO,GAAG,GAAGN,MAAM,CAACO,WAAW,CAACR,KAAK,CAAC;EACzC;EAEA,OAAOC,MAAM,CAACQ,MAAM,CAACT,KAAK,CAAC;AAC/B,CAAC;AAAC"}
|
package/components/Routes.js
CHANGED
|
@@ -1,35 +1,45 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
|
|
4
|
+
Object.defineProperty(exports, "__esModule", {
|
|
5
|
+
value: true
|
|
6
|
+
});
|
|
7
|
+
exports.Routes = void 0;
|
|
8
|
+
var _toConsumableArray2 = _interopRequireDefault(require("@babel/runtime/helpers/toConsumableArray"));
|
|
9
|
+
var _react = _interopRequireDefault(require("react"));
|
|
10
|
+
var _plugins = require("@webiny/plugins");
|
|
11
|
+
var _reactRouter = require("@webiny/react-router");
|
|
12
|
+
// This file is necessary only for backwards compatibility.
|
|
13
|
+
// We'll remove this once the legacy rendering engine is removed.
|
|
14
|
+
|
|
15
|
+
var Routes = function Routes() {
|
|
6
16
|
// We cannot call `sort` on the array returned by the `plugins.byType` call - it is read-only.
|
|
7
|
-
var routes =
|
|
17
|
+
var routes = (0, _toConsumableArray2.default)(_plugins.plugins.byType("route")).sort(function (a, b) {
|
|
8
18
|
var pathA = a.route.props.path || "*";
|
|
9
|
-
var pathB = b.route.props.path || "*";
|
|
19
|
+
var pathB = b.route.props.path || "*";
|
|
10
20
|
|
|
21
|
+
// This will sort paths at the very bottom of the list
|
|
11
22
|
if (pathA === "/" && pathB === "*") {
|
|
12
23
|
return -1;
|
|
13
|
-
}
|
|
14
|
-
|
|
24
|
+
}
|
|
15
25
|
|
|
26
|
+
// This will push * and / to the bottom of the list
|
|
16
27
|
if (pathA === "*" || pathA === "/") {
|
|
17
28
|
return 1;
|
|
18
|
-
}
|
|
19
|
-
|
|
29
|
+
}
|
|
20
30
|
|
|
31
|
+
// This will push * and / to the bottom of the list
|
|
21
32
|
if (["*", "/"].includes(pathB)) {
|
|
22
33
|
return -1;
|
|
23
34
|
}
|
|
24
|
-
|
|
25
35
|
return 0;
|
|
26
36
|
});
|
|
27
|
-
|
|
28
|
-
return /*#__PURE__*/React.createElement(Switch, null, routes.map(function (_ref) {
|
|
37
|
+
return /*#__PURE__*/_react.default.createElement(_reactRouter.Routes, null, routes.map(function (_ref) {
|
|
29
38
|
var route = _ref.route,
|
|
30
|
-
|
|
31
|
-
return /*#__PURE__*/
|
|
39
|
+
name = _ref.name;
|
|
40
|
+
return /*#__PURE__*/_react.default.cloneElement(route, {
|
|
32
41
|
key: name
|
|
33
42
|
});
|
|
34
43
|
}));
|
|
35
|
-
};
|
|
44
|
+
};
|
|
45
|
+
exports.Routes = Routes;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["Routes","routes","plugins","byType","sort","a","b","pathA","route","props","path","pathB","includes","map","name","React","cloneElement","key"],"sources":["Routes.tsx"],"sourcesContent":["// This file is necessary only for backwards compatibility.\n// We'll remove this once the legacy rendering engine is removed.\nimport React from \"react\";\nimport { plugins } from \"@webiny/plugins\";\nimport { Routes as ReactRouterRoutes } from \"@webiny/react-router\";\nimport { RoutePlugin } from \"../types\";\n\nexport const Routes = () => {\n // We cannot call `sort` on the array returned by the `plugins.byType` call - it is read-only.\n const routes = [...plugins.byType<RoutePlugin>(\"route\")].sort((a, b) => {\n const pathA = a.route.props.path || \"*\";\n const pathB = b.route.props.path || \"*\";\n\n // This will sort paths at the very bottom of the list\n if (pathA === \"/\" && pathB === \"*\") {\n return -1;\n }\n\n // This will push * and / to the bottom of the list\n if (pathA === \"*\" || pathA === \"/\") {\n return 1;\n }\n\n // This will push * and / to the bottom of the list\n if ([\"*\", \"/\"].includes(pathB)) {\n return -1;\n }\n\n return 0;\n });\n\n return (\n <ReactRouterRoutes>\n {routes.map(({ route, name }) => React.cloneElement(route, { key: name }))}\n </ReactRouterRoutes>\n );\n};\n"],"mappings":";;;;;;;;AAEA;AACA;AACA;AAJA;AACA;;AAMO,IAAMA,MAAM,GAAG,SAATA,MAAM,GAAS;EACxB;EACA,IAAMC,MAAM,GAAG,iCAAIC,gBAAO,CAACC,MAAM,CAAc,OAAO,CAAC,EAAEC,IAAI,CAAC,UAACC,CAAC,EAAEC,CAAC,EAAK;IACpE,IAAMC,KAAK,GAAGF,CAAC,CAACG,KAAK,CAACC,KAAK,CAACC,IAAI,IAAI,GAAG;IACvC,IAAMC,KAAK,GAAGL,CAAC,CAACE,KAAK,CAACC,KAAK,CAACC,IAAI,IAAI,GAAG;;IAEvC;IACA,IAAIH,KAAK,KAAK,GAAG,IAAII,KAAK,KAAK,GAAG,EAAE;MAChC,OAAO,CAAC,CAAC;IACb;;IAEA;IACA,IAAIJ,KAAK,KAAK,GAAG,IAAIA,KAAK,KAAK,GAAG,EAAE;MAChC,OAAO,CAAC;IACZ;;IAEA;IACA,IAAI,CAAC,GAAG,EAAE,GAAG,CAAC,CAACK,QAAQ,CAACD,KAAK,CAAC,EAAE;MAC5B,OAAO,CAAC,CAAC;IACb;IAEA,OAAO,CAAC;EACZ,CAAC,CAAC;EAEF,oBACI,6BAAC,mBAAiB,QACbV,MAAM,CAACY,GAAG,CAAC;IAAA,IAAGL,KAAK,QAALA,KAAK;MAAEM,IAAI,QAAJA,IAAI;IAAA,oBAAOC,cAAK,CAACC,YAAY,CAACR,KAAK,EAAE;MAAES,GAAG,EAAEH;IAAK,CAAC,CAAC;EAAA,EAAC,CAC1D;AAE5B,CAAC;AAAC"}
|
package/components/View.js
CHANGED
|
@@ -1,23 +1,30 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _interopRequireWildcard = require("@babel/runtime/helpers/interopRequireWildcard").default;
|
|
4
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
|
|
5
|
+
Object.defineProperty(exports, "__esModule", {
|
|
6
|
+
value: true
|
|
7
|
+
});
|
|
8
|
+
exports.View = void 0;
|
|
9
|
+
var _objectSpread2 = _interopRequireDefault(require("@babel/runtime/helpers/objectSpread2"));
|
|
10
|
+
var _react = _interopRequireWildcard(require("react"));
|
|
11
|
+
var _plugins = require("@webiny/plugins");
|
|
12
|
+
var _ViewPlugin = require("../plugins/ViewPlugin");
|
|
13
|
+
var View = function View(_ref) {
|
|
6
14
|
var name = _ref.name,
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
var viewPlugins = plugins.byType(ViewPlugin.type).filter(function (pl) {
|
|
15
|
+
children = _ref.children,
|
|
16
|
+
_ref$props = _ref.props,
|
|
17
|
+
props = _ref$props === void 0 ? {} : _ref$props;
|
|
18
|
+
var viewPlugins = _plugins.plugins.byType(_ViewPlugin.ViewPlugin.type).filter(function (pl) {
|
|
11
19
|
return pl.key === name;
|
|
12
20
|
});
|
|
13
|
-
|
|
14
21
|
if (viewPlugins.length) {
|
|
15
22
|
children = viewPlugins.reduce(function (el, pl) {
|
|
16
|
-
return pl.render(
|
|
23
|
+
return pl.render((0, _objectSpread2.default)({
|
|
17
24
|
children: el
|
|
18
25
|
}, props));
|
|
19
26
|
}, children);
|
|
20
27
|
}
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
28
|
+
return /*#__PURE__*/_react.default.createElement(_react.Fragment, null, children || null);
|
|
29
|
+
};
|
|
30
|
+
exports.View = View;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["View","name","children","props","viewPlugins","plugins","byType","ViewPlugin","type","filter","pl","key","length","reduce","el","render"],"sources":["View.tsx"],"sourcesContent":["import React, { Fragment } from \"react\";\nimport { plugins } from \"@webiny/plugins\";\nimport { ViewPlugin } from \"../plugins/ViewPlugin\";\n\ninterface Props {\n name: string;\n props?: Record<string, any>;\n children?: React.ReactNode;\n}\n\nexport const View = ({ name, children, props = {} }: Props) => {\n const viewPlugins = plugins.byType<ViewPlugin>(ViewPlugin.type).filter(pl => pl.key === name);\n\n if (viewPlugins.length) {\n children = viewPlugins.reduce((el, pl) => pl.render({ children: el, ...props }), children);\n }\n\n return <Fragment>{children || null}</Fragment>;\n};\n"],"mappings":";;;;;;;;;AAAA;AACA;AACA;AAQO,IAAMA,IAAI,GAAG,SAAPA,IAAI,OAA8C;EAAA,IAAxCC,IAAI,QAAJA,IAAI;IAAEC,QAAQ,QAARA,QAAQ;IAAA,kBAAEC,KAAK;IAALA,KAAK,2BAAG,CAAC,CAAC;EAC7C,IAAMC,WAAW,GAAGC,gBAAO,CAACC,MAAM,CAAaC,sBAAU,CAACC,IAAI,CAAC,CAACC,MAAM,CAAC,UAAAC,EAAE;IAAA,OAAIA,EAAE,CAACC,GAAG,KAAKV,IAAI;EAAA,EAAC;EAE7F,IAAIG,WAAW,CAACQ,MAAM,EAAE;IACpBV,QAAQ,GAAGE,WAAW,CAACS,MAAM,CAAC,UAACC,EAAE,EAAEJ,EAAE;MAAA,OAAKA,EAAE,CAACK,MAAM;QAAGb,QAAQ,EAAEY;MAAE,GAAKX,KAAK,EAAG;IAAA,GAAED,QAAQ,CAAC;EAC9F;EAEA,oBAAO,6BAAC,eAAQ,QAAEA,QAAQ,IAAI,IAAI,CAAY;AAClD,CAAC;AAAC"}
|
package/components/index.d.ts
CHANGED
package/components/index.js
CHANGED
|
@@ -1 +1,19 @@
|
|
|
1
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
Object.defineProperty(exports, "Image", {
|
|
7
|
+
enumerable: true,
|
|
8
|
+
get: function get() {
|
|
9
|
+
return _Image.Image;
|
|
10
|
+
}
|
|
11
|
+
});
|
|
12
|
+
Object.defineProperty(exports, "Routes", {
|
|
13
|
+
enumerable: true,
|
|
14
|
+
get: function get() {
|
|
15
|
+
return _Routes.Routes;
|
|
16
|
+
}
|
|
17
|
+
});
|
|
18
|
+
var _Image = require("./Image");
|
|
19
|
+
var _Routes = require("./Routes");
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":[],"sources":["index.ts"],"sourcesContent":["export { Image } from \"./Image\";\nexport { Routes } from \"./Routes\";\n"],"mappings":";;;;;;;;;;;;;;;;;AAAA;AACA"}
|
package/config.d.ts
ADDED
package/config.js
ADDED
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.config = void 0;
|
|
7
|
+
var deepFreeze = function deepFreeze(obj) {
|
|
8
|
+
Object.keys(obj).forEach(function (prop) {
|
|
9
|
+
if (typeof obj[prop] === "object" && !Object.isFrozen(obj[prop])) {
|
|
10
|
+
deepFreeze(obj[prop]);
|
|
11
|
+
}
|
|
12
|
+
});
|
|
13
|
+
return Object.freeze(obj);
|
|
14
|
+
};
|
|
15
|
+
function createConfig() {
|
|
16
|
+
var _config = {};
|
|
17
|
+
return {
|
|
18
|
+
set: function set(config) {
|
|
19
|
+
_config = deepFreeze(config);
|
|
20
|
+
},
|
|
21
|
+
get: function get() {
|
|
22
|
+
return _config;
|
|
23
|
+
},
|
|
24
|
+
getKey: function getKey(key, defaultValue) {
|
|
25
|
+
return key in _config ? _config[key] : defaultValue;
|
|
26
|
+
}
|
|
27
|
+
};
|
|
28
|
+
}
|
|
29
|
+
var config = createConfig();
|
|
30
|
+
exports.config = config;
|
package/config.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["deepFreeze","obj","Object","keys","forEach","prop","isFrozen","freeze","createConfig","_config","set","config","get","getKey","key","defaultValue"],"sources":["config.ts"],"sourcesContent":["export type Config = Record<string, any>;\n\ninterface AppConfig {\n set(config: Config): void;\n get(): Config;\n getKey<T = string>(key: string, defaultValue: T): T;\n}\n\nconst deepFreeze = (obj: Record<string, any>): Record<string, any> => {\n Object.keys(obj).forEach(prop => {\n if (typeof obj[prop] === \"object\" && !Object.isFrozen(obj[prop])) {\n deepFreeze(obj[prop]);\n }\n });\n return Object.freeze(obj);\n};\n\nfunction createConfig(): AppConfig {\n let _config: Record<string, any> = {};\n\n return {\n set(config: Config) {\n _config = deepFreeze(config);\n },\n get() {\n return _config;\n },\n getKey(key, defaultValue) {\n return key in _config ? _config[key] : defaultValue;\n }\n };\n}\n\nexport const config = createConfig();\n"],"mappings":";;;;;;AAQA,IAAMA,UAAU,GAAG,SAAbA,UAAU,CAAIC,GAAwB,EAA0B;EAClEC,MAAM,CAACC,IAAI,CAACF,GAAG,CAAC,CAACG,OAAO,CAAC,UAAAC,IAAI,EAAI;IAC7B,IAAI,OAAOJ,GAAG,CAACI,IAAI,CAAC,KAAK,QAAQ,IAAI,CAACH,MAAM,CAACI,QAAQ,CAACL,GAAG,CAACI,IAAI,CAAC,CAAC,EAAE;MAC9DL,UAAU,CAACC,GAAG,CAACI,IAAI,CAAC,CAAC;IACzB;EACJ,CAAC,CAAC;EACF,OAAOH,MAAM,CAACK,MAAM,CAACN,GAAG,CAAC;AAC7B,CAAC;AAED,SAASO,YAAY,GAAc;EAC/B,IAAIC,OAA4B,GAAG,CAAC,CAAC;EAErC,OAAO;IACHC,GAAG,eAACC,MAAc,EAAE;MAChBF,OAAO,GAAGT,UAAU,CAACW,MAAM,CAAC;IAChC,CAAC;IACDC,GAAG,iBAAG;MACF,OAAOH,OAAO;IAClB,CAAC;IACDI,MAAM,kBAACC,GAAG,EAAEC,YAAY,EAAE;MACtB,OAAOD,GAAG,IAAIL,OAAO,GAAGA,OAAO,CAACK,GAAG,CAAC,GAAGC,YAAY;IACvD;EACJ,CAAC;AACL;AAEO,IAAMJ,MAAM,GAAGH,YAAY,EAAE;AAAC"}
|
package/contexts/Ui/index.d.ts
CHANGED
|
@@ -18,10 +18,7 @@ export interface UiContextValue {
|
|
|
18
18
|
}
|
|
19
19
|
export declare class UiProvider extends React.Component<Props, State> {
|
|
20
20
|
state: State;
|
|
21
|
-
|
|
21
|
+
private readonly setData;
|
|
22
22
|
render(): JSX.Element;
|
|
23
23
|
}
|
|
24
|
-
export declare const UiConsumer: ({ children }: {
|
|
25
|
-
children: any;
|
|
26
|
-
}) => JSX.Element;
|
|
27
24
|
export {};
|
package/contexts/Ui/index.js
CHANGED
|
@@ -1,69 +1,59 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
|
|
4
|
+
Object.defineProperty(exports, "__esModule", {
|
|
5
|
+
value: true
|
|
6
|
+
});
|
|
7
|
+
exports.UiProvider = exports.UiContext = void 0;
|
|
8
|
+
var _objectSpread2 = _interopRequireDefault(require("@babel/runtime/helpers/objectSpread2"));
|
|
9
|
+
var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/classCallCheck"));
|
|
10
|
+
var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/createClass"));
|
|
11
|
+
var _assertThisInitialized2 = _interopRequireDefault(require("@babel/runtime/helpers/assertThisInitialized"));
|
|
12
|
+
var _inherits2 = _interopRequireDefault(require("@babel/runtime/helpers/inherits"));
|
|
13
|
+
var _createSuper2 = _interopRequireDefault(require("@babel/runtime/helpers/createSuper"));
|
|
14
|
+
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
15
|
+
var _react = _interopRequireDefault(require("react"));
|
|
16
|
+
var _plugins = require("@webiny/plugins");
|
|
17
|
+
var UiContext = /*#__PURE__*/_react.default.createContext({});
|
|
18
|
+
exports.UiContext = UiContext;
|
|
19
|
+
var UiProvider = /*#__PURE__*/function (_React$Component) {
|
|
20
|
+
(0, _inherits2.default)(UiProvider, _React$Component);
|
|
21
|
+
var _super = (0, _createSuper2.default)(UiProvider);
|
|
16
22
|
function UiProvider() {
|
|
17
23
|
var _this;
|
|
18
|
-
|
|
19
|
-
_classCallCheck(this, UiProvider);
|
|
20
|
-
|
|
24
|
+
(0, _classCallCheck2.default)(this, UiProvider);
|
|
21
25
|
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
|
|
22
26
|
args[_key] = arguments[_key];
|
|
23
27
|
}
|
|
24
|
-
|
|
25
28
|
_this = _super.call.apply(_super, [this].concat(args));
|
|
26
|
-
|
|
27
|
-
_defineProperty(_assertThisInitialized(_this), "state", {
|
|
29
|
+
(0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "state", {
|
|
28
30
|
ui: {}
|
|
29
31
|
});
|
|
30
|
-
|
|
31
|
-
_defineProperty(_assertThisInitialized(_this), "setData", function (setter) {
|
|
32
|
+
(0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "setData", function (setter) {
|
|
32
33
|
return _this.setState(function (state) {
|
|
33
34
|
return {
|
|
34
|
-
ui:
|
|
35
|
+
ui: (0, _objectSpread2.default)((0, _objectSpread2.default)({}, state.ui), setter(state.ui))
|
|
35
36
|
};
|
|
36
37
|
});
|
|
37
38
|
});
|
|
38
|
-
|
|
39
39
|
return _this;
|
|
40
40
|
}
|
|
41
|
-
|
|
42
|
-
_createClass(UiProvider, [{
|
|
41
|
+
(0, _createClass2.default)(UiProvider, [{
|
|
43
42
|
key: "render",
|
|
44
43
|
value: function render() {
|
|
45
|
-
var value =
|
|
44
|
+
var value = (0, _objectSpread2.default)((0, _objectSpread2.default)({}, this.state.ui), {}, {
|
|
46
45
|
setState: this.setData
|
|
47
46
|
});
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
return /*#__PURE__*/React.createElement(UiContext.Provider, {
|
|
47
|
+
var uiStatePlugins = _plugins.plugins.byType("ui-state");
|
|
48
|
+
return /*#__PURE__*/_react.default.createElement(UiContext.Provider, {
|
|
51
49
|
value: value
|
|
52
50
|
}, uiStatePlugins.map(function (pl) {
|
|
53
|
-
return /*#__PURE__*/
|
|
51
|
+
return /*#__PURE__*/_react.default.cloneElement(pl.render(), {
|
|
54
52
|
key: pl.name
|
|
55
53
|
});
|
|
56
54
|
}), this.props.children);
|
|
57
55
|
}
|
|
58
56
|
}]);
|
|
59
|
-
|
|
60
57
|
return UiProvider;
|
|
61
|
-
}(
|
|
62
|
-
|
|
63
|
-
var children = _ref.children;
|
|
64
|
-
return /*#__PURE__*/React.createElement(UiContext.Consumer, null, function (ui) {
|
|
65
|
-
return /*#__PURE__*/React.cloneElement(children, {
|
|
66
|
-
ui: ui
|
|
67
|
-
});
|
|
68
|
-
});
|
|
69
|
-
};
|
|
58
|
+
}(_react.default.Component);
|
|
59
|
+
exports.UiProvider = UiProvider;
|