@webiny/app 0.0.0-mt-3 → 0.0.0-unstable.06b2ede40f

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.
Files changed (211) hide show
  1. package/App.d.ts +26 -0
  2. package/App.js +95 -0
  3. package/App.js.map +1 -0
  4. package/AppContainer.d.ts +23 -0
  5. package/AppContainer.js +9 -0
  6. package/AppContainer.js.map +1 -0
  7. package/apollo-client/InMemoryCache.d.ts +4 -3
  8. package/apollo-client/InMemoryCache.js +13 -52
  9. package/apollo-client/InMemoryCache.js.map +1 -0
  10. package/apollo-client/IntrospectionFragmentMatcher.d.ts +11 -0
  11. package/apollo-client/IntrospectionFragmentMatcher.js +45 -0
  12. package/apollo-client/IntrospectionFragmentMatcher.js.map +1 -0
  13. package/components/Image.d.ts +3 -3
  14. package/components/Image.js +12 -17
  15. package/components/Image.js.map +1 -0
  16. package/components/Routes.d.ts +2 -2
  17. package/components/Routes.js +20 -19
  18. package/components/Routes.js.map +1 -0
  19. package/components/View.d.ts +1 -1
  20. package/components/View.js +13 -17
  21. package/components/View.js.map +1 -0
  22. package/components/index.d.ts +1 -0
  23. package/components/index.js +4 -1
  24. package/components/index.js.map +1 -0
  25. package/config/RouterConfig/Route.d.ts +30 -0
  26. package/config/RouterConfig/Route.js +42 -0
  27. package/config/RouterConfig/Route.js.map +1 -0
  28. package/config/RouterConfig.d.ts +32 -0
  29. package/config/RouterConfig.js +18 -0
  30. package/config/RouterConfig.js.map +1 -0
  31. package/config.d.ts +8 -0
  32. package/config.js +25 -0
  33. package/config.js.map +1 -0
  34. package/contexts/Ui/index.d.ts +5 -8
  35. package/contexts/Ui/index.js +27 -64
  36. package/contexts/Ui/index.js.map +1 -0
  37. package/core/DebounceRender.d.ts +12 -0
  38. package/core/DebounceRender.js +31 -0
  39. package/core/DebounceRender.js.map +1 -0
  40. package/core/Plugin.d.ts +8 -0
  41. package/core/Plugin.js +14 -0
  42. package/core/Plugin.js.map +1 -0
  43. package/core/Plugins.d.ts +15 -0
  44. package/core/Plugins.js +39 -0
  45. package/core/Plugins.js.map +1 -0
  46. package/core/Provider.d.ts +8 -0
  47. package/core/Provider.js +18 -0
  48. package/core/Provider.js.map +1 -0
  49. package/core/Routes.d.ts +6 -0
  50. package/core/Routes.js +34 -0
  51. package/core/Routes.js.map +1 -0
  52. package/core/createProvider.d.ts +10 -0
  53. package/core/createProvider.js +9 -0
  54. package/core/createProvider.js.map +1 -0
  55. package/core/createProviderPlugin.d.ts +8 -0
  56. package/core/createProviderPlugin.js +17 -0
  57. package/core/createProviderPlugin.js.map +1 -0
  58. package/hooks/useAutocomplete/index.js +3 -1
  59. package/hooks/useAutocomplete/index.js.map +1 -0
  60. package/hooks/useAutocomplete/useAutocomplete.d.ts +6 -1
  61. package/hooks/useAutocomplete/useAutocomplete.js +11 -15
  62. package/hooks/useAutocomplete/useAutocomplete.js.map +1 -0
  63. package/hooks/useDataList/functions/getData.d.ts +1 -1
  64. package/hooks/useDataList/functions/getData.js +3 -3
  65. package/hooks/useDataList/functions/getData.js.map +1 -0
  66. package/hooks/useDataList/functions/getError.d.ts +1 -1
  67. package/hooks/useDataList/functions/getError.js +3 -3
  68. package/hooks/useDataList/functions/getError.js.map +1 -0
  69. package/hooks/useDataList/functions/getMeta.d.ts +1 -1
  70. package/hooks/useDataList/functions/getMeta.js +3 -3
  71. package/hooks/useDataList/functions/getMeta.js.map +1 -0
  72. package/hooks/useDataList/functions/index.js +3 -1
  73. package/hooks/useDataList/functions/index.js.map +1 -0
  74. package/hooks/useDataList/functions/searchDataByKey.d.ts +1 -1
  75. package/hooks/useDataList/functions/searchDataByKey.js +5 -8
  76. package/hooks/useDataList/functions/searchDataByKey.js.map +1 -0
  77. package/hooks/useDataList/index.js +3 -1
  78. package/hooks/useDataList/index.js.map +1 -0
  79. package/hooks/useDataList/useDataList.d.ts +6 -6
  80. package/hooks/useDataList/useDataList.js +80 -90
  81. package/hooks/useDataList/useDataList.js.map +1 -0
  82. package/hooks/useDataList/utils/index.js +3 -1
  83. package/hooks/useDataList/utils/index.js.map +1 -0
  84. package/hooks/useDataList/utils/prepareLoadListParams.d.ts +9 -3
  85. package/hooks/useDataList/utils/prepareLoadListParams.js +35 -31
  86. package/hooks/useDataList/utils/prepareLoadListParams.js.map +1 -0
  87. package/hooks/useDataList/utils/redirectToRouteWithQueryParams.d.ts +13 -4
  88. package/hooks/useDataList/utils/redirectToRouteWithQueryParams.js +13 -9
  89. package/hooks/useDataList/utils/redirectToRouteWithQueryParams.js.map +1 -0
  90. package/hooks/useDataList/utils/types.d.ts +21 -15
  91. package/hooks/useDataList/utils/types.js +3 -1
  92. package/hooks/useDataList/utils/types.js.map +1 -0
  93. package/hooks/useHandler.d.ts +11 -1
  94. package/hooks/useHandler.js +13 -6
  95. package/hooks/useHandler.js.map +1 -0
  96. package/hooks/useHandlers.d.ts +4 -4
  97. package/hooks/useHandlers.js +15 -11
  98. package/hooks/useHandlers.js.map +1 -0
  99. package/hooks/useRegisterLegacyPlugin.d.ts +2 -0
  100. package/hooks/useRegisterLegacyPlugin.js +11 -0
  101. package/hooks/useRegisterLegacyPlugin.js.map +1 -0
  102. package/hooks/useUi.d.ts +1 -1
  103. package/hooks/useUi.js +5 -3
  104. package/hooks/useUi.js.map +1 -0
  105. package/i18n/i18n.js +3 -1
  106. package/i18n/i18n.js.map +1 -0
  107. package/i18n/index.js +3 -1
  108. package/i18n/index.js.map +1 -0
  109. package/index.d.ts +17 -0
  110. package/index.js +20 -0
  111. package/index.js.map +1 -0
  112. package/package.json +27 -27
  113. package/plugins/AddQuerySelectionPlugin.d.ts +10 -3
  114. package/plugins/AddQuerySelectionPlugin.js +63 -92
  115. package/plugins/AddQuerySelectionPlugin.js.map +1 -0
  116. package/plugins/ApolloCacheObjectIdPlugin.d.ts +8 -8
  117. package/plugins/ApolloCacheObjectIdPlugin.js +12 -36
  118. package/plugins/ApolloCacheObjectIdPlugin.js.map +1 -0
  119. package/plugins/ApolloDynamicLink.d.ts +3 -1
  120. package/plugins/ApolloDynamicLink.js +19 -50
  121. package/plugins/ApolloDynamicLink.js.map +1 -0
  122. package/plugins/ApolloLinkPlugin.d.ts +6 -6
  123. package/plugins/ApolloLinkPlugin.js +18 -39
  124. package/plugins/ApolloLinkPlugin.js.map +1 -0
  125. package/plugins/ConsoleLinkPlugin.js +19 -40
  126. package/plugins/ConsoleLinkPlugin.js.map +1 -0
  127. package/plugins/LocaleHeaderLinkPlugin.d.ts +3 -7
  128. package/plugins/LocaleHeaderLinkPlugin.js +22 -51
  129. package/plugins/LocaleHeaderLinkPlugin.js.map +1 -0
  130. package/plugins/NetworkErrorLinkPlugin/ErrorOverlay.d.ts +13 -5
  131. package/plugins/NetworkErrorLinkPlugin/ErrorOverlay.js +21 -31
  132. package/plugins/NetworkErrorLinkPlugin/ErrorOverlay.js.map +1 -0
  133. package/plugins/NetworkErrorLinkPlugin/StyledComponents.d.ts +8 -2
  134. package/plugins/NetworkErrorLinkPlugin/StyledComponents.js +76 -7
  135. package/plugins/NetworkErrorLinkPlugin/StyledComponents.js.map +1 -0
  136. package/plugins/NetworkErrorLinkPlugin/createErrorOverlay.d.ts +6 -4
  137. package/plugins/NetworkErrorLinkPlugin/createErrorOverlay.js +20 -16
  138. package/plugins/NetworkErrorLinkPlugin/createErrorOverlay.js.map +1 -0
  139. package/plugins/NetworkErrorLinkPlugin.js +20 -35
  140. package/plugins/NetworkErrorLinkPlugin.js.map +1 -0
  141. package/plugins/OmitTypenameLinkPlugin.js +11 -31
  142. package/plugins/OmitTypenameLinkPlugin.js.map +1 -0
  143. package/plugins/RoutePlugin.d.ts +3 -3
  144. package/plugins/RoutePlugin.js +12 -32
  145. package/plugins/RoutePlugin.js.map +1 -0
  146. package/plugins/TenantHeaderLinkPlugin.d.ts +3 -7
  147. package/plugins/TenantHeaderLinkPlugin.js +29 -61
  148. package/plugins/TenantHeaderLinkPlugin.js.map +1 -0
  149. package/plugins/ViewPlugin.d.ts +5 -5
  150. package/plugins/ViewPlugin.js +15 -37
  151. package/plugins/ViewPlugin.js.map +1 -0
  152. package/plugins/image.d.ts +1 -1
  153. package/plugins/image.js +65 -85
  154. package/plugins/image.js.map +1 -0
  155. package/plugins/index.d.ts +3 -3
  156. package/plugins/index.js +35 -42
  157. package/plugins/index.js.map +1 -0
  158. package/react-butterfiles/Files.d.ts +69 -0
  159. package/react-butterfiles/Files.js +227 -0
  160. package/react-butterfiles/Files.js.map +1 -0
  161. package/react-butterfiles/index.d.ts +2 -0
  162. package/react-butterfiles/index.js +4 -0
  163. package/react-butterfiles/index.js.map +1 -0
  164. package/react-butterfiles/utils/generateId.d.ts +1 -0
  165. package/react-butterfiles/utils/generateId.js +5 -0
  166. package/react-butterfiles/utils/generateId.js.map +1 -0
  167. package/react-butterfiles/utils/readFileContent.d.ts +1 -0
  168. package/react-butterfiles/utils/readFileContent.js +15 -0
  169. package/react-butterfiles/utils/readFileContent.js.map +1 -0
  170. package/renderApp.d.ts +2 -0
  171. package/renderApp.js +9 -0
  172. package/renderApp.js.map +1 -0
  173. package/types.d.ts +29 -24
  174. package/types.js +13 -1
  175. package/types.js.map +1 -0
  176. package/utils/createGenericContext.d.ts +13 -0
  177. package/utils/createGenericContext.js +25 -0
  178. package/utils/createGenericContext.js.map +1 -0
  179. package/utils/createHashing.d.ts +2 -0
  180. package/utils/createHashing.js +18 -0
  181. package/utils/createHashing.js.map +1 -0
  182. package/utils/getApiUrl.d.ts +1 -0
  183. package/utils/getApiUrl.js +5 -0
  184. package/utils/getApiUrl.js.map +1 -0
  185. package/utils/getGqlApiUrl.d.ts +1 -0
  186. package/utils/getGqlApiUrl.js +6 -0
  187. package/utils/getGqlApiUrl.js.map +1 -0
  188. package/utils/getHeadlessCmsGqlApiUrl.d.ts +5 -0
  189. package/utils/getHeadlessCmsGqlApiUrl.js +12 -0
  190. package/utils/getHeadlessCmsGqlApiUrl.js.map +1 -0
  191. package/utils/getLocaleCode.d.ts +6 -0
  192. package/utils/getLocaleCode.js +33 -0
  193. package/utils/getLocaleCode.js.map +1 -0
  194. package/utils/getPrerenderId.d.ts +6 -0
  195. package/utils/getPrerenderId.js +5 -0
  196. package/utils/getPrerenderId.js.map +1 -0
  197. package/utils/getTenantId.d.ts +6 -0
  198. package/utils/getTenantId.js +45 -0
  199. package/utils/getTenantId.js.map +1 -0
  200. package/utils/index.d.ts +10 -0
  201. package/utils/index.js +12 -0
  202. package/utils/index.js.map +1 -0
  203. package/utils/isLocalhost.d.ts +1 -0
  204. package/utils/isLocalhost.js +7 -0
  205. package/utils/isLocalhost.js.map +1 -0
  206. package/utils/isPrerendering.d.ts +1 -0
  207. package/utils/isPrerendering.js +5 -0
  208. package/utils/isPrerendering.js.map +1 -0
  209. package/utils/legacyPluginToReactComponent.d.ts +7 -0
  210. package/utils/legacyPluginToReactComponent.js +14 -0
  211. package/utils/legacyPluginToReactComponent.js.map +1 -0
package/App.d.ts ADDED
@@ -0,0 +1,26 @@
1
+ import React from "react";
2
+ import type { RouteProps } from "@webiny/react-router";
3
+ import type { GenericComponent, Decorator, DecoratorsCollection } from "@webiny/react-composition";
4
+ interface State {
5
+ plugins: JSX.Element[];
6
+ providers: Decorator<GenericComponent<ProviderProps>>[];
7
+ }
8
+ interface AppContext extends State {
9
+ addProvider(hoc: Decorator<GenericComponent<ProviderProps>>): void;
10
+ addPlugin(plugin: React.ReactNode): void;
11
+ }
12
+ declare const AppContext: React.Context<AppContext | undefined>;
13
+ export declare const useApp: () => AppContext;
14
+ export interface AppProps {
15
+ debounceRender?: number;
16
+ routes?: Array<RouteProps>;
17
+ providers?: Array<Decorator<GenericComponent<ProviderProps>>>;
18
+ decorators?: DecoratorsCollection;
19
+ children?: React.ReactNode | React.ReactNode[];
20
+ }
21
+ interface ProviderProps {
22
+ children: React.ReactNode;
23
+ }
24
+ export declare const AppBase: ({ debounceRender, routes, providers, children }: AppProps) => React.JSX.Element;
25
+ export declare const App: ({ decorators, ...props }: AppProps) => React.JSX.Element;
26
+ export {};
package/App.js ADDED
@@ -0,0 +1,95 @@
1
+ import React, { createContext, useContext, useMemo, useState, useCallback } from "react";
2
+ import { BrowserRouter, Route } from "@webiny/react-router";
3
+ import { CompositionProvider, compose } from "@webiny/react-composition";
4
+ import { Routes as SortRoutes } from "./core/Routes";
5
+ import { DebounceRender } from "./core/DebounceRender";
6
+ import { PluginsProvider } from "./core/Plugins";
7
+ import { RouterWithConfig, useRouterConfig } from "./config/RouterConfig";
8
+ import { AppContainer } from "./AppContainer";
9
+ const AppContext = /*#__PURE__*/createContext(undefined);
10
+ AppContext.displayName = "AppContext";
11
+ export const useApp = () => {
12
+ const appContext = useContext(AppContext);
13
+ if (!appContext) {
14
+ throw Error(`AppContext provider was not found. Are you using the "useApp()" hook in the right place?`);
15
+ }
16
+ return appContext;
17
+ };
18
+ export const AppBase = ({
19
+ debounceRender = 50,
20
+ routes = [],
21
+ providers = [],
22
+ children
23
+ }) => {
24
+ const [state, setState] = useState({
25
+ plugins: [],
26
+ providers
27
+ });
28
+ const addProvider = useCallback(component => {
29
+ setState(state => {
30
+ if (state.providers.findIndex(m => m === component) > -1) {
31
+ return state;
32
+ }
33
+ return {
34
+ ...state,
35
+ providers: [...state.providers, component]
36
+ };
37
+ });
38
+ }, []);
39
+ const addPlugin = useCallback(element => {
40
+ setState(state => {
41
+ return {
42
+ ...state,
43
+ plugins: [...state.plugins, element]
44
+ };
45
+ });
46
+ }, []);
47
+ const appContext = useMemo(() => ({
48
+ ...state,
49
+ addProvider,
50
+ addPlugin
51
+ }), [state]);
52
+ const AppRouter = useMemo(() => {
53
+ return function AppRouter() {
54
+ const routerConfig = useRouterConfig();
55
+ const combinedRoutes = [...routes, ...routerConfig.routes].map(r => {
56
+ return /*#__PURE__*/React.createElement(Route, {
57
+ path: r.path,
58
+ element: r.element,
59
+ key: r.path
60
+ });
61
+ });
62
+ return /*#__PURE__*/React.createElement(SortRoutes, {
63
+ key: routes.length,
64
+ routes: combinedRoutes
65
+ });
66
+ };
67
+ }, [routes]);
68
+ const Providers = useMemo(() => {
69
+ return compose(...(state.providers || []))(({
70
+ children
71
+ }) => {
72
+ return /*#__PURE__*/React.createElement(DebounceRender, {
73
+ wait: debounceRender
74
+ }, children);
75
+ });
76
+ }, [state.providers.length]);
77
+ Providers.displayName = "Providers";
78
+ return /*#__PURE__*/React.createElement(AppContext.Provider, {
79
+ value: appContext
80
+ }, children, /*#__PURE__*/React.createElement(AppContainer, null, /*#__PURE__*/React.createElement(BrowserRouter, null, /*#__PURE__*/React.createElement(Providers, null, /*#__PURE__*/React.createElement(PluginsProvider, null, state.plugins), /*#__PURE__*/React.createElement(DebounceRender, {
81
+ wait: debounceRender
82
+ }, /*#__PURE__*/React.createElement(RouterWithConfig, null, /*#__PURE__*/React.createElement(AppRouter, null)))))));
83
+ };
84
+ export const App = ({
85
+ decorators,
86
+ ...props
87
+ }) => {
88
+ return /*#__PURE__*/React.createElement(CompositionProvider, {
89
+ decorators: decorators
90
+ }, /*#__PURE__*/React.createElement(AppBase, Object.assign({
91
+ decorators: decorators
92
+ }, props)));
93
+ };
94
+
95
+ //# sourceMappingURL=App.js.map
package/App.js.map ADDED
@@ -0,0 +1 @@
1
+ {"version":3,"names":["React","createContext","useContext","useMemo","useState","useCallback","BrowserRouter","Route","CompositionProvider","compose","Routes","SortRoutes","DebounceRender","PluginsProvider","RouterWithConfig","useRouterConfig","AppContainer","AppContext","undefined","displayName","useApp","appContext","Error","AppBase","debounceRender","routes","providers","children","state","setState","plugins","addProvider","component","findIndex","m","addPlugin","element","AppRouter","routerConfig","combinedRoutes","map","r","createElement","path","key","length","Providers","wait","Provider","value","App","decorators","props","Object","assign"],"sources":["App.tsx"],"sourcesContent":["import React, { createContext, useContext, useMemo, useState, useCallback } from \"react\";\nimport type { RouteProps } from \"@webiny/react-router\";\nimport { BrowserRouter, Route } from \"@webiny/react-router\";\nimport type { GenericComponent, Decorator, DecoratorsCollection } from \"@webiny/react-composition\";\nimport { CompositionProvider, compose } from \"@webiny/react-composition\";\nimport { Routes as SortRoutes } from \"./core/Routes\";\nimport { DebounceRender } from \"./core/DebounceRender\";\nimport { PluginsProvider } from \"./core/Plugins\";\nimport { RouterWithConfig, useRouterConfig } from \"./config/RouterConfig\";\nimport { AppContainer } from \"./AppContainer\";\n\ninterface State {\n plugins: JSX.Element[];\n providers: Decorator<GenericComponent<ProviderProps>>[];\n}\n\ninterface AppContext extends State {\n addProvider(hoc: Decorator<GenericComponent<ProviderProps>>): void;\n\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<Decorator<GenericComponent<ProviderProps>>>;\n decorators?: DecoratorsCollection;\n children?: React.ReactNode | React.ReactNode[];\n}\n\ninterface ProviderProps {\n children: React.ReactNode;\n}\n\ntype ComponentWithChildren = React.ComponentType<{ children?: React.ReactNode }>;\n\nexport const AppBase = ({\n debounceRender = 50,\n routes = [],\n providers = [],\n children\n}: AppProps) => {\n const [state, setState] = useState<State>({\n plugins: [],\n providers\n });\n\n const addProvider = useCallback((component: Decorator<any>) => {\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: JSX.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 addProvider,\n addPlugin\n }),\n [state]\n );\n\n const AppRouter = useMemo(() => {\n return function AppRouter() {\n const routerConfig = useRouterConfig();\n const combinedRoutes = [...routes, ...routerConfig.routes].map(r => {\n return <Route path={r.path} element={r.element} key={r.path} />;\n });\n\n return <SortRoutes key={routes.length} routes={combinedRoutes} />;\n };\n }, [routes]);\n\n const Providers = useMemo(() => {\n return compose(...(state.providers || []))(({ children }: ProviderProps) => {\n return <DebounceRender wait={debounceRender}>{children}</DebounceRender>;\n });\n }, [state.providers.length]) as ComponentWithChildren;\n\n Providers.displayName = \"Providers\";\n\n return (\n <AppContext.Provider value={appContext}>\n {children}\n <AppContainer>\n <BrowserRouter>\n <Providers>\n <PluginsProvider>{state.plugins}</PluginsProvider>\n <DebounceRender wait={debounceRender}>\n <RouterWithConfig>\n <AppRouter />\n </RouterWithConfig>\n </DebounceRender>\n </Providers>\n </BrowserRouter>\n </AppContainer>\n </AppContext.Provider>\n );\n};\n\nexport const App = ({ decorators, ...props }: AppProps) => {\n return (\n <CompositionProvider decorators={decorators}>\n <AppBase decorators={decorators} {...props} />\n </CompositionProvider>\n );\n};\n"],"mappings":"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","ignoreList":[]}
@@ -0,0 +1,23 @@
1
+ import React from "react";
2
+ export interface AppContentProps {
3
+ children: React.ReactNode;
4
+ }
5
+ export declare const AppContainer: (({ children }: AppContentProps) => React.JSX.Element) & {
6
+ original: ({ children }: AppContentProps) => React.JSX.Element;
7
+ originalName: string;
8
+ displayName: string;
9
+ } & {
10
+ original: (({ children }: AppContentProps) => React.JSX.Element) & {
11
+ original: ({ children }: AppContentProps) => React.JSX.Element;
12
+ originalName: string;
13
+ displayName: string;
14
+ };
15
+ originalName: string;
16
+ displayName: string;
17
+ } & {
18
+ createDecorator: (decorator: import("@webiny/react-composition").ComponentDecorator<(({ children }: AppContentProps) => React.JSX.Element) & {
19
+ original: ({ children }: AppContentProps) => React.JSX.Element;
20
+ originalName: string;
21
+ displayName: string;
22
+ }>) => (props: unknown) => React.JSX.Element;
23
+ };
@@ -0,0 +1,9 @@
1
+ import React from "react";
2
+ import { makeDecoratable } from "@webiny/react-composition";
3
+ export const AppContainer = makeDecoratable("AppContainer", ({
4
+ children
5
+ }) => {
6
+ return /*#__PURE__*/React.createElement(React.Fragment, null, children);
7
+ });
8
+
9
+ //# sourceMappingURL=AppContainer.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["React","makeDecoratable","AppContainer","children","createElement","Fragment"],"sources":["AppContainer.tsx"],"sourcesContent":["import React from \"react\";\nimport { makeDecoratable } from \"@webiny/react-composition\";\n\nexport interface AppContentProps {\n children: React.ReactNode;\n}\n\nexport const AppContainer = makeDecoratable(\"AppContainer\", ({ children }: AppContentProps) => {\n return <>{children}</>;\n});\n"],"mappings":"AAAA,OAAOA,KAAK,MAAM,OAAO;AACzB,SAASC,eAAe,QAAQ,2BAA2B;AAM3D,OAAO,MAAMC,YAAY,GAAGD,eAAe,CAAC,cAAc,EAAE,CAAC;EAAEE;AAA0B,CAAC,KAAK;EAC3F,oBAAOH,KAAA,CAAAI,aAAA,CAAAJ,KAAA,CAAAK,QAAA,QAAGF,QAAW,CAAC;AAC1B,CAAC,CAAC","ignoreList":[]}
@@ -1,7 +1,8 @@
1
- import { InMemoryCache as BaseInMemoryCache, InMemoryCacheConfig } from "apollo-cache-inmemory";
2
- import { DocumentNode } from "graphql";
1
+ import type { InMemoryCacheConfig } from "apollo-cache-inmemory";
2
+ import { InMemoryCache as BaseInMemoryCache } from "apollo-cache-inmemory";
3
+ import type { DocumentNode } from "graphql";
3
4
  export declare class InMemoryCache extends BaseInMemoryCache {
4
- private transformPlugins;
5
+ private readonly transformPlugins;
5
6
  constructor(config?: InMemoryCacheConfig);
6
7
  transformDocument(document: DocumentNode): DocumentNode;
7
8
  }
@@ -1,59 +1,20 @@
1
- import _createForOfIteratorHelper from "@babel/runtime/helpers/createForOfIteratorHelper";
2
- import _classCallCheck from "@babel/runtime/helpers/classCallCheck";
3
- import _createClass from "@babel/runtime/helpers/createClass";
4
- import _assertThisInitialized from "@babel/runtime/helpers/assertThisInitialized";
5
- import _get from "@babel/runtime/helpers/get";
6
- import _getPrototypeOf from "@babel/runtime/helpers/getPrototypeOf";
7
- import _inherits from "@babel/runtime/helpers/inherits";
8
- import _createSuper from "@babel/runtime/helpers/createSuper";
9
- import _defineProperty from "@babel/runtime/helpers/defineProperty";
10
1
  import { InMemoryCache as BaseInMemoryCache } from "apollo-cache-inmemory";
11
2
  import { plugins } from "@webiny/plugins";
12
3
  import { AddQuerySelectionPlugin } from "../plugins/AddQuerySelectionPlugin";
13
4
  import { ApolloLinkPlugin } from "../plugins/ApolloLinkPlugin";
14
- export var InMemoryCache = /*#__PURE__*/function (_BaseInMemoryCache) {
15
- _inherits(InMemoryCache, _BaseInMemoryCache);
16
-
17
- var _super = _createSuper(InMemoryCache);
18
-
19
- function InMemoryCache(config) {
20
- var _this;
21
-
22
- _classCallCheck(this, InMemoryCache);
23
-
24
- _this = _super.call(this, config);
25
-
26
- _defineProperty(_assertThisInitialized(_this), "transformPlugins", void 0);
27
-
28
- _this.transformPlugins = plugins.byType(ApolloLinkPlugin.type).filter(function (pl) {
29
- return pl instanceof AddQuerySelectionPlugin;
30
- });
31
- return _this;
5
+ export class InMemoryCache extends BaseInMemoryCache {
6
+ constructor(config) {
7
+ super(config);
8
+ this.transformPlugins = plugins.byType(ApolloLinkPlugin.type).filter(pl => pl instanceof AddQuerySelectionPlugin);
32
9
  }
33
-
34
- _createClass(InMemoryCache, [{
35
- key: "transformDocument",
36
- value: function transformDocument(document) {
37
- // @ts-ignore
38
- var operationName = document.definitions[0].name.value;
39
-
40
- var _iterator = _createForOfIteratorHelper(this.transformPlugins),
41
- _step;
42
-
43
- try {
44
- for (_iterator.s(); !(_step = _iterator.n()).done;) {
45
- var pl = _step.value;
46
- pl.addSelectionToQuery(operationName, document);
47
- }
48
- } catch (err) {
49
- _iterator.e(err);
50
- } finally {
51
- _iterator.f();
52
- }
53
-
54
- return _get(_getPrototypeOf(InMemoryCache.prototype), "transformDocument", this).call(this, document);
10
+ transformDocument(document) {
11
+ // @ts-expect-error
12
+ const operationName = document.definitions[0].name.value;
13
+ for (const pl of this.transformPlugins) {
14
+ pl.addSelectionToQuery(operationName, document);
55
15
  }
56
- }]);
16
+ return super.transformDocument(document);
17
+ }
18
+ }
57
19
 
58
- return InMemoryCache;
59
- }(BaseInMemoryCache);
20
+ //# sourceMappingURL=InMemoryCache.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["InMemoryCache","BaseInMemoryCache","plugins","AddQuerySelectionPlugin","ApolloLinkPlugin","constructor","config","transformPlugins","byType","type","filter","pl","transformDocument","document","operationName","definitions","name","value","addSelectionToQuery"],"sources":["InMemoryCache.ts"],"sourcesContent":["import type { InMemoryCacheConfig } from \"apollo-cache-inmemory\";\nimport { InMemoryCache as BaseInMemoryCache } from \"apollo-cache-inmemory\";\nimport type { 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-expect-error\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":"AACA,SAASA,aAAa,IAAIC,iBAAiB,QAAQ,uBAAuB;AAE1E,SAASC,OAAO,QAAQ,iBAAiB;AACzC,SAASC,uBAAuB;AAChC,SAASC,gBAAgB;AAEzB,OAAO,MAAMJ,aAAa,SAASC,iBAAiB,CAAC;EAGjDI,WAAWA,CAACC,MAA4B,EAAE;IACtC,KAAK,CAACA,MAAM,CAAC;IAEb,IAAI,CAACC,gBAAgB,GAAGL,OAAO,CAC1BM,MAAM,CAA0BJ,gBAAgB,CAACK,IAAI,CAAC,CACtDC,MAAM,CAACC,EAAE,IAAIA,EAAE,YAAYR,uBAAuB,CAAC;EAC5D;EAEgBS,iBAAiBA,CAACC,QAAsB,EAAgB;IACpE;IACA,MAAMC,aAAa,GAAGD,QAAQ,CAACE,WAAW,CAAC,CAAC,CAAC,CAACC,IAAI,CAACC,KAAK;IAExD,KAAK,MAAMN,EAAE,IAAI,IAAI,CAACJ,gBAAgB,EAAE;MACpCI,EAAE,CAACO,mBAAmB,CAACJ,aAAa,EAAED,QAAQ,CAAC;IACnD;IAEA,OAAO,KAAK,CAACD,iBAAiB,CAACC,QAAQ,CAAC;EAC5C;AACJ","ignoreList":[]}
@@ -0,0 +1,11 @@
1
+ import type { IdValue } from "apollo-utilities";
2
+ import type { ReadStoreContext, FragmentMatcherInterface, IntrospectionResultData } from "apollo-cache-inmemory";
3
+ export declare class IntrospectionFragmentMatcher implements FragmentMatcherInterface {
4
+ private readonly isReady;
5
+ private readonly possibleTypesMap;
6
+ constructor(options?: {
7
+ introspectionQueryResultData?: IntrospectionResultData;
8
+ });
9
+ match(idValue: IdValue, typeCondition: string, context: ReadStoreContext): boolean;
10
+ private parseIntrospectionResult;
11
+ }
@@ -0,0 +1,45 @@
1
+ import { invariant } from "ts-invariant";
2
+ export class IntrospectionFragmentMatcher {
3
+ possibleTypesMap = {};
4
+ constructor(options) {
5
+ if (options && options.introspectionQueryResultData) {
6
+ this.possibleTypesMap = this.parseIntrospectionResult(options.introspectionQueryResultData);
7
+ this.isReady = true;
8
+ } else {
9
+ this.isReady = false;
10
+ }
11
+ this.match = this.match.bind(this);
12
+ }
13
+ match(idValue, typeCondition, context) {
14
+ invariant(this.isReady, "FragmentMatcher.match() was called before FragmentMatcher.init()");
15
+ const obj = context.store.get(idValue.id);
16
+ const isRootQuery = idValue.id === "ROOT_QUERY";
17
+ if (!obj) {
18
+ // https://github.com/apollographql/apollo-client/pull/4620
19
+ return isRootQuery;
20
+ }
21
+ const {
22
+ __typename = isRootQuery && "Query"
23
+ } = obj;
24
+ invariant(__typename, `Cannot match fragment because __typename property is missing: ${JSON.stringify(obj)}`);
25
+ if (__typename === typeCondition) {
26
+ return true;
27
+ }
28
+ const implementingTypes = this.possibleTypesMap[typeCondition];
29
+ if (__typename && implementingTypes && implementingTypes.indexOf(__typename) > -1) {
30
+ return true;
31
+ }
32
+ return false;
33
+ }
34
+ parseIntrospectionResult(introspectionResultData) {
35
+ const typeMap = {};
36
+ introspectionResultData.__schema.types.forEach(type => {
37
+ if (type.kind === "UNION" || type.kind === "INTERFACE") {
38
+ typeMap[type.name] = type.possibleTypes.map(implementingType => implementingType.name);
39
+ }
40
+ });
41
+ return typeMap;
42
+ }
43
+ }
44
+
45
+ //# sourceMappingURL=IntrospectionFragmentMatcher.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["invariant","IntrospectionFragmentMatcher","possibleTypesMap","constructor","options","introspectionQueryResultData","parseIntrospectionResult","isReady","match","bind","idValue","typeCondition","context","obj","store","get","id","isRootQuery","__typename","JSON","stringify","implementingTypes","indexOf","introspectionResultData","typeMap","__schema","types","forEach","type","kind","name","possibleTypes","map","implementingType"],"sources":["IntrospectionFragmentMatcher.ts"],"sourcesContent":["import type { IdValue } from \"apollo-utilities\";\nimport { invariant } from \"ts-invariant\";\n\nimport type {\n ReadStoreContext,\n FragmentMatcherInterface,\n PossibleTypesMap,\n IntrospectionResultData\n} from \"apollo-cache-inmemory\";\n\nexport class IntrospectionFragmentMatcher implements FragmentMatcherInterface {\n private readonly isReady: boolean;\n private readonly possibleTypesMap: PossibleTypesMap = {};\n\n constructor(options?: { introspectionQueryResultData?: IntrospectionResultData }) {\n if (options && options.introspectionQueryResultData) {\n this.possibleTypesMap = this.parseIntrospectionResult(\n options.introspectionQueryResultData\n );\n this.isReady = true;\n } else {\n this.isReady = false;\n }\n\n this.match = this.match.bind(this);\n }\n\n public match(idValue: IdValue, typeCondition: string, context: ReadStoreContext) {\n invariant(this.isReady, \"FragmentMatcher.match() was called before FragmentMatcher.init()\");\n\n const obj = context.store.get(idValue.id);\n const isRootQuery = idValue.id === \"ROOT_QUERY\";\n\n if (!obj) {\n // https://github.com/apollographql/apollo-client/pull/4620\n return isRootQuery;\n }\n\n const { __typename = isRootQuery && \"Query\" } = obj;\n\n invariant(\n __typename,\n `Cannot match fragment because __typename property is missing: ${JSON.stringify(obj)}`\n );\n\n if (__typename === typeCondition) {\n return true;\n }\n\n const implementingTypes = this.possibleTypesMap[typeCondition];\n if (__typename && implementingTypes && implementingTypes.indexOf(__typename) > -1) {\n return true;\n }\n\n return false;\n }\n\n private parseIntrospectionResult(\n introspectionResultData: IntrospectionResultData\n ): PossibleTypesMap {\n const typeMap: PossibleTypesMap = {};\n introspectionResultData.__schema.types.forEach(type => {\n if (type.kind === \"UNION\" || type.kind === \"INTERFACE\") {\n typeMap[type.name] = type.possibleTypes.map(\n implementingType => implementingType.name\n );\n }\n });\n return typeMap;\n }\n}\n"],"mappings":"AACA,SAASA,SAAS,QAAQ,cAAc;AASxC,OAAO,MAAMC,4BAA4B,CAAqC;EAEzDC,gBAAgB,GAAqB,CAAC,CAAC;EAExDC,WAAWA,CAACC,OAAoE,EAAE;IAC9E,IAAIA,OAAO,IAAIA,OAAO,CAACC,4BAA4B,EAAE;MACjD,IAAI,CAACH,gBAAgB,GAAG,IAAI,CAACI,wBAAwB,CACjDF,OAAO,CAACC,4BACZ,CAAC;MACD,IAAI,CAACE,OAAO,GAAG,IAAI;IACvB,CAAC,MAAM;MACH,IAAI,CAACA,OAAO,GAAG,KAAK;IACxB;IAEA,IAAI,CAACC,KAAK,GAAG,IAAI,CAACA,KAAK,CAACC,IAAI,CAAC,IAAI,CAAC;EACtC;EAEOD,KAAKA,CAACE,OAAgB,EAAEC,aAAqB,EAAEC,OAAyB,EAAE;IAC7EZ,SAAS,CAAC,IAAI,CAACO,OAAO,EAAE,kEAAkE,CAAC;IAE3F,MAAMM,GAAG,GAAGD,OAAO,CAACE,KAAK,CAACC,GAAG,CAACL,OAAO,CAACM,EAAE,CAAC;IACzC,MAAMC,WAAW,GAAGP,OAAO,CAACM,EAAE,KAAK,YAAY;IAE/C,IAAI,CAACH,GAAG,EAAE;MACN;MACA,OAAOI,WAAW;IACtB;IAEA,MAAM;MAAEC,UAAU,GAAGD,WAAW,IAAI;IAAQ,CAAC,GAAGJ,GAAG;IAEnDb,SAAS,CACLkB,UAAU,EACV,iEAAiEC,IAAI,CAACC,SAAS,CAACP,GAAG,CAAC,EACxF,CAAC;IAED,IAAIK,UAAU,KAAKP,aAAa,EAAE;MAC9B,OAAO,IAAI;IACf;IAEA,MAAMU,iBAAiB,GAAG,IAAI,CAACnB,gBAAgB,CAACS,aAAa,CAAC;IAC9D,IAAIO,UAAU,IAAIG,iBAAiB,IAAIA,iBAAiB,CAACC,OAAO,CAACJ,UAAU,CAAC,GAAG,CAAC,CAAC,EAAE;MAC/E,OAAO,IAAI;IACf;IAEA,OAAO,KAAK;EAChB;EAEQZ,wBAAwBA,CAC5BiB,uBAAgD,EAChC;IAChB,MAAMC,OAAyB,GAAG,CAAC,CAAC;IACpCD,uBAAuB,CAACE,QAAQ,CAACC,KAAK,CAACC,OAAO,CAACC,IAAI,IAAI;MACnD,IAAIA,IAAI,CAACC,IAAI,KAAK,OAAO,IAAID,IAAI,CAACC,IAAI,KAAK,WAAW,EAAE;QACpDL,OAAO,CAACI,IAAI,CAACE,IAAI,CAAC,GAAGF,IAAI,CAACG,aAAa,CAACC,GAAG,CACvCC,gBAAgB,IAAIA,gBAAgB,CAACH,IACzC,CAAC;MACL;IACJ,CAAC,CAAC;IACF,OAAON,OAAO;EAClB;AACJ","ignoreList":[]}
@@ -1,3 +1,3 @@
1
- import * as React from "react";
2
- import { ImageProps } from "../types";
3
- export declare const Image: React.FC<ImageProps>;
1
+ /// <reference types="react" />
2
+ import type { ImageProps } from "../types";
3
+ export declare const Image: ({ preset: presetName, ...props }: ImageProps) => import("react").ReactElement<any, string | import("react").JSXElementConstructor<any>>;
@@ -1,28 +1,23 @@
1
- import _objectWithoutProperties from "@babel/runtime/helpers/objectWithoutProperties";
2
- import _get from "lodash/get";
3
- var _excluded = ["preset"];
4
1
  import invariant from "invariant";
5
2
  import { plugins } from "@webiny/plugins";
6
- export var Image = function Image(_ref) {
7
- var presetName = _ref.preset,
8
- props = _objectWithoutProperties(_ref, _excluded);
9
-
10
- var plugin = plugins.byName("image-component");
11
-
3
+ import get from "lodash/get";
4
+ export const Image = ({
5
+ preset: presetName,
6
+ ...props
7
+ }) => {
8
+ const plugin = plugins.byName("image-component");
12
9
  if (!plugin) {
13
- throw new Error("Image component plugin (type \"image-component\") not defined.");
10
+ throw new Error(`Image component plugin (type "image-component") not defined.`);
14
11
  }
15
-
16
12
  if (presetName) {
17
- var preset = _get(plugin, "presets.".concat(presetName));
18
-
19
- invariant(preset, "Transform preset \"".concat(presetName, "\" not found."));
13
+ const preset = get(plugin, `presets.${presetName}`);
14
+ invariant(preset, `Transform preset "${presetName}" not found.`);
20
15
  props.transform = preset;
21
16
  }
22
-
23
17
  if (props.transform) {
24
18
  props.src = plugin.getImageSrc(props);
25
19
  }
26
-
27
20
  return plugin.render(props);
28
- };
21
+ };
22
+
23
+ //# sourceMappingURL=Image.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["invariant","plugins","get","Image","preset","presetName","props","plugin","byName","Error","transform","src","getImageSrc","render"],"sources":["Image.tsx"],"sourcesContent":["import invariant from \"invariant\";\nimport { plugins } from \"@webiny/plugins\";\nimport get from \"lodash/get\";\nimport type { ImageComponentPlugin, ImageProps } from \"~/types\";\n\nexport const Image = ({ preset: presetName, ...props }: ImageProps) => {\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":"AAAA,OAAOA,SAAS,MAAM,WAAW;AACjC,SAASC,OAAO,QAAQ,iBAAiB;AACzC,OAAOC,GAAG,MAAM,YAAY;AAG5B,OAAO,MAAMC,KAAK,GAAGA,CAAC;EAAEC,MAAM,EAAEC,UAAU;EAAE,GAAGC;AAAkB,CAAC,KAAK;EACnE,MAAMC,MAAM,GAAGN,OAAO,CAACO,MAAM,CAAuB,iBAAiB,CAAC;EACtE,IAAI,CAACD,MAAM,EAAE;IACT,MAAM,IAAIE,KAAK,CAAC,8DAA8D,CAAC;EACnF;EAEA,IAAIJ,UAAU,EAAE;IACZ,MAAMD,MAAM,GAAGF,GAAG,CAACK,MAAM,EAAE,WAAWF,UAAU,EAAE,CAAC;IACnDL,SAAS,CAACI,MAAM,EAAE,qBAAqBC,UAAU,cAAc,CAAC;IAChEC,KAAK,CAACI,SAAS,GAAGN,MAAM;EAC5B;EAEA,IAAIE,KAAK,CAACI,SAAS,EAAE;IACjBJ,KAAK,CAACK,GAAG,GAAGJ,MAAM,CAACK,WAAW,CAACN,KAAK,CAAC;EACzC;EAEA,OAAOC,MAAM,CAACM,MAAM,CAACP,KAAK,CAAC;AAC/B,CAAC","ignoreList":[]}
@@ -1,2 +1,2 @@
1
- /// <reference types="react" />
2
- export declare const Routes: () => JSX.Element;
1
+ import React from "react";
2
+ export declare const Routes: () => React.JSX.Element;
@@ -1,35 +1,36 @@
1
- import _toConsumableArray from "@babel/runtime/helpers/toConsumableArray";
1
+ // This file is necessary only for backwards compatibility.
2
+ // We'll remove this once the legacy rendering engine is removed.
2
3
  import React from "react";
3
4
  import { plugins } from "@webiny/plugins";
4
- import { Switch } from "@webiny/react-router";
5
- export var Routes = function Routes() {
5
+ import { Routes as ReactRouterRoutes } from "@webiny/react-router";
6
+ export const Routes = () => {
6
7
  // We cannot call `sort` on the array returned by the `plugins.byType` call - it is read-only.
7
- var routes = _toConsumableArray(plugins.byType("route")).sort(function (a, b) {
8
- var pathA = a.route.props.path || "*";
9
- var pathB = b.route.props.path || "*"; // This will sort paths at the very bottom of the list
8
+ const routes = [...plugins.byType("route")].sort((a, b) => {
9
+ const pathA = a.route.props.path || "*";
10
+ const pathB = b.route.props.path || "*";
10
11
 
12
+ // This will sort paths at the very bottom of the list
11
13
  if (pathA === "/" && pathB === "*") {
12
14
  return -1;
13
- } // This will push * and / to the bottom of the list
14
-
15
+ }
15
16
 
17
+ // This will push * and / to the bottom of the list
16
18
  if (pathA === "*" || pathA === "/") {
17
19
  return 1;
18
- } // This will push * and / to the bottom of the list
19
-
20
+ }
20
21
 
22
+ // This will push * and / to the bottom of the list
21
23
  if (["*", "/"].includes(pathB)) {
22
24
  return -1;
23
25
  }
24
-
25
26
  return 0;
26
27
  });
28
+ return /*#__PURE__*/React.createElement(ReactRouterRoutes, null, routes.map(({
29
+ route,
30
+ name
31
+ }) => /*#__PURE__*/React.cloneElement(route, {
32
+ key: name
33
+ })));
34
+ };
27
35
 
28
- return /*#__PURE__*/React.createElement(Switch, null, routes.map(function (_ref) {
29
- var route = _ref.route,
30
- name = _ref.name;
31
- return /*#__PURE__*/React.cloneElement(route, {
32
- key: name
33
- });
34
- }));
35
- };
36
+ //# sourceMappingURL=Routes.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["React","plugins","Routes","ReactRouterRoutes","routes","byType","sort","a","b","pathA","route","props","path","pathB","includes","createElement","map","name","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 type { 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":"AAAA;AACA;AACA,OAAOA,KAAK,MAAM,OAAO;AACzB,SAASC,OAAO,QAAQ,iBAAiB;AACzC,SAASC,MAAM,IAAIC,iBAAiB,QAAQ,sBAAsB;AAGlE,OAAO,MAAMD,MAAM,GAAGA,CAAA,KAAM;EACxB;EACA,MAAME,MAAM,GAAG,CAAC,GAAGH,OAAO,CAACI,MAAM,CAAc,OAAO,CAAC,CAAC,CAACC,IAAI,CAAC,CAACC,CAAC,EAAEC,CAAC,KAAK;IACpE,MAAMC,KAAK,GAAGF,CAAC,CAACG,KAAK,CAACC,KAAK,CAACC,IAAI,IAAI,GAAG;IACvC,MAAMC,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,oBACIb,KAAA,CAAAe,aAAA,CAACZ,iBAAiB,QACbC,MAAM,CAACY,GAAG,CAAC,CAAC;IAAEN,KAAK;IAAEO;EAAK,CAAC,kBAAKjB,KAAK,CAACkB,YAAY,CAACR,KAAK,EAAE;IAAES,GAAG,EAAEF;EAAK,CAAC,CAAC,CAC1D,CAAC;AAE5B,CAAC","ignoreList":[]}
@@ -4,5 +4,5 @@ interface Props {
4
4
  props?: Record<string, any>;
5
5
  children?: React.ReactNode;
6
6
  }
7
- export declare const View: ({ name, children, props }: Props) => JSX.Element;
7
+ export declare const View: ({ name, children, props }: Props) => React.JSX.Element;
8
8
  export {};
@@ -1,23 +1,19 @@
1
- import _objectSpread from "@babel/runtime/helpers/objectSpread2";
2
1
  import React, { Fragment } from "react";
3
2
  import { plugins } from "@webiny/plugins";
4
3
  import { ViewPlugin } from "../plugins/ViewPlugin";
5
- export var View = function View(_ref) {
6
- var name = _ref.name,
7
- children = _ref.children,
8
- _ref$props = _ref.props,
9
- props = _ref$props === void 0 ? {} : _ref$props;
10
- var viewPlugins = plugins.byType(ViewPlugin.type).filter(function (pl) {
11
- return pl.key === name;
12
- });
13
-
4
+ export const View = ({
5
+ name,
6
+ children,
7
+ props = {}
8
+ }) => {
9
+ const viewPlugins = plugins.byType(ViewPlugin.type).filter(pl => pl.key === name);
14
10
  if (viewPlugins.length) {
15
- children = viewPlugins.reduce(function (el, pl) {
16
- return pl.render(_objectSpread({
17
- children: el
18
- }, props));
19
- }, children);
11
+ children = viewPlugins.reduce((el, pl) => pl.render({
12
+ children: el,
13
+ ...props
14
+ }), children);
20
15
  }
21
-
22
16
  return /*#__PURE__*/React.createElement(Fragment, null, children || null);
23
- };
17
+ };
18
+
19
+ //# sourceMappingURL=View.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["React","Fragment","plugins","ViewPlugin","View","name","children","props","viewPlugins","byType","type","filter","pl","key","length","reduce","el","render","createElement"],"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,OAAOA,KAAK,IAAIC,QAAQ,QAAQ,OAAO;AACvC,SAASC,OAAO,QAAQ,iBAAiB;AACzC,SAASC,UAAU;AAQnB,OAAO,MAAMC,IAAI,GAAGA,CAAC;EAAEC,IAAI;EAAEC,QAAQ;EAAEC,KAAK,GAAG,CAAC;AAAS,CAAC,KAAK;EAC3D,MAAMC,WAAW,GAAGN,OAAO,CAACO,MAAM,CAAaN,UAAU,CAACO,IAAI,CAAC,CAACC,MAAM,CAACC,EAAE,IAAIA,EAAE,CAACC,GAAG,KAAKR,IAAI,CAAC;EAE7F,IAAIG,WAAW,CAACM,MAAM,EAAE;IACpBR,QAAQ,GAAGE,WAAW,CAACO,MAAM,CAAC,CAACC,EAAE,EAAEJ,EAAE,KAAKA,EAAE,CAACK,MAAM,CAAC;MAAEX,QAAQ,EAAEU,EAAE;MAAE,GAAGT;IAAM,CAAC,CAAC,EAAED,QAAQ,CAAC;EAC9F;EAEA,oBAAON,KAAA,CAAAkB,aAAA,CAACjB,QAAQ,QAAEK,QAAQ,IAAI,IAAe,CAAC;AAClD,CAAC","ignoreList":[]}
@@ -1 +1,2 @@
1
1
  export { Image } from "./Image";
2
+ export { Routes } from "./Routes";
@@ -1 +1,4 @@
1
- export { Image } from "./Image";
1
+ export { Image } from "./Image";
2
+ export { Routes } from "./Routes";
3
+
4
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["Image","Routes"],"sources":["index.ts"],"sourcesContent":["export { Image } from \"./Image\";\nexport { Routes } from \"./Routes\";\n"],"mappings":"AAAA,SAASA,KAAK;AACd,SAASC,MAAM","ignoreList":[]}
@@ -0,0 +1,30 @@
1
+ import React from "react";
2
+ export interface RouteProps {
3
+ name: string;
4
+ path: string;
5
+ exact?: boolean;
6
+ element: React.ReactElement;
7
+ remove?: boolean;
8
+ before?: string;
9
+ after?: string;
10
+ }
11
+ export type RouteConfig = Pick<RouteProps, "name" | "path" | "element">;
12
+ export declare const Route: (({ name, path, element, exact, remove, before, after }: RouteProps) => React.JSX.Element) & {
13
+ original: ({ name, path, element, exact, remove, before, after }: RouteProps) => React.JSX.Element;
14
+ originalName: string;
15
+ displayName: string;
16
+ } & {
17
+ original: (({ name, path, element, exact, remove, before, after }: RouteProps) => React.JSX.Element) & {
18
+ original: ({ name, path, element, exact, remove, before, after }: RouteProps) => React.JSX.Element;
19
+ originalName: string;
20
+ displayName: string;
21
+ };
22
+ originalName: string;
23
+ displayName: string;
24
+ } & {
25
+ createDecorator: (decorator: import("@webiny/react-composition").ComponentDecorator<(({ name, path, element, exact, remove, before, after }: RouteProps) => React.JSX.Element) & {
26
+ original: ({ name, path, element, exact, remove, before, after }: RouteProps) => React.JSX.Element;
27
+ originalName: string;
28
+ displayName: string;
29
+ }>) => (props: unknown) => React.JSX.Element;
30
+ };
@@ -0,0 +1,42 @@
1
+ import React from "react";
2
+ import { makeDecoratable } from "@webiny/react-composition";
3
+ import { Property, useIdGenerator } from "@webiny/react-properties";
4
+ export const Route = makeDecoratable("Route", ({
5
+ name,
6
+ path,
7
+ element,
8
+ exact,
9
+ remove,
10
+ before,
11
+ after
12
+ }) => {
13
+ const getId = useIdGenerator("Route");
14
+ const placeAfter = after !== undefined ? getId(after) : undefined;
15
+ const placeBefore = before !== undefined ? getId(before) : undefined;
16
+ return /*#__PURE__*/React.createElement(Property, {
17
+ id: getId(name),
18
+ name: "routes",
19
+ remove: remove,
20
+ array: true,
21
+ before: placeBefore,
22
+ after: placeAfter
23
+ }, /*#__PURE__*/React.createElement(Property, {
24
+ id: getId(name, "name"),
25
+ name: "name",
26
+ value: name
27
+ }), /*#__PURE__*/React.createElement(Property, {
28
+ id: getId(name, "path"),
29
+ name: "path",
30
+ value: path
31
+ }), /*#__PURE__*/React.createElement(Property, {
32
+ id: getId(name, "exact"),
33
+ name: "exact",
34
+ value: exact
35
+ }), /*#__PURE__*/React.createElement(Property, {
36
+ id: getId(name, "element"),
37
+ name: "element",
38
+ value: element
39
+ }));
40
+ });
41
+
42
+ //# sourceMappingURL=Route.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["React","makeDecoratable","Property","useIdGenerator","Route","name","path","element","exact","remove","before","after","getId","placeAfter","undefined","placeBefore","createElement","id","array","value"],"sources":["Route.tsx"],"sourcesContent":["import React from \"react\";\nimport { makeDecoratable } from \"@webiny/react-composition\";\nimport { Property, useIdGenerator } from \"@webiny/react-properties\";\n\nexport interface RouteProps {\n name: string;\n path: string;\n exact?: boolean;\n element: React.ReactElement;\n remove?: boolean;\n before?: string;\n after?: string;\n}\n\nexport type RouteConfig = Pick<RouteProps, \"name\" | \"path\" | \"element\">;\n\nexport const Route = makeDecoratable(\n \"Route\",\n ({ name, path, element, exact, remove, before, after }: RouteProps) => {\n const getId = useIdGenerator(\"Route\");\n\n const placeAfter = after !== undefined ? getId(after) : undefined;\n const placeBefore = before !== undefined ? getId(before) : undefined;\n\n return (\n <Property\n id={getId(name)}\n name={\"routes\"}\n remove={remove}\n array={true}\n before={placeBefore}\n after={placeAfter}\n >\n <Property id={getId(name, \"name\")} name={\"name\"} value={name} />\n <Property id={getId(name, \"path\")} name={\"path\"} value={path} />\n <Property id={getId(name, \"exact\")} name={\"exact\"} value={exact} />\n <Property id={getId(name, \"element\")} name={\"element\"} value={element} />\n </Property>\n );\n }\n);\n"],"mappings":"AAAA,OAAOA,KAAK,MAAM,OAAO;AACzB,SAASC,eAAe,QAAQ,2BAA2B;AAC3D,SAASC,QAAQ,EAAEC,cAAc,QAAQ,0BAA0B;AAcnE,OAAO,MAAMC,KAAK,GAAGH,eAAe,CAChC,OAAO,EACP,CAAC;EAAEI,IAAI;EAAEC,IAAI;EAAEC,OAAO;EAAEC,KAAK;EAAEC,MAAM;EAAEC,MAAM;EAAEC;AAAkB,CAAC,KAAK;EACnE,MAAMC,KAAK,GAAGT,cAAc,CAAC,OAAO,CAAC;EAErC,MAAMU,UAAU,GAAGF,KAAK,KAAKG,SAAS,GAAGF,KAAK,CAACD,KAAK,CAAC,GAAGG,SAAS;EACjE,MAAMC,WAAW,GAAGL,MAAM,KAAKI,SAAS,GAAGF,KAAK,CAACF,MAAM,CAAC,GAAGI,SAAS;EAEpE,oBACId,KAAA,CAAAgB,aAAA,CAACd,QAAQ;IACLe,EAAE,EAAEL,KAAK,CAACP,IAAI,CAAE;IAChBA,IAAI,EAAE,QAAS;IACfI,MAAM,EAAEA,MAAO;IACfS,KAAK,EAAE,IAAK;IACZR,MAAM,EAAEK,WAAY;IACpBJ,KAAK,EAAEE;EAAW,gBAElBb,KAAA,CAAAgB,aAAA,CAACd,QAAQ;IAACe,EAAE,EAAEL,KAAK,CAACP,IAAI,EAAE,MAAM,CAAE;IAACA,IAAI,EAAE,MAAO;IAACc,KAAK,EAAEd;EAAK,CAAE,CAAC,eAChEL,KAAA,CAAAgB,aAAA,CAACd,QAAQ;IAACe,EAAE,EAAEL,KAAK,CAACP,IAAI,EAAE,MAAM,CAAE;IAACA,IAAI,EAAE,MAAO;IAACc,KAAK,EAAEb;EAAK,CAAE,CAAC,eAChEN,KAAA,CAAAgB,aAAA,CAACd,QAAQ;IAACe,EAAE,EAAEL,KAAK,CAACP,IAAI,EAAE,OAAO,CAAE;IAACA,IAAI,EAAE,OAAQ;IAACc,KAAK,EAAEX;EAAM,CAAE,CAAC,eACnER,KAAA,CAAAgB,aAAA,CAACd,QAAQ;IAACe,EAAE,EAAEL,KAAK,CAACP,IAAI,EAAE,SAAS,CAAE;IAACA,IAAI,EAAE,SAAU;IAACc,KAAK,EAAEZ;EAAQ,CAAE,CAClE,CAAC;AAEnB,CACJ,CAAC","ignoreList":[]}