@webiny/app 0.0.0-unstable.fcdad0bc61 → 0.0.0-unstable.fdd9228b5d

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 (203) 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 +3 -2
  8. package/apollo-client/InMemoryCache.js +17 -76
  9. package/apollo-client/InMemoryCache.js.map +1 -1
  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 -32
  15. package/components/Image.js.map +1 -1
  16. package/components/Routes.d.ts +2 -2
  17. package/components/Routes.js +21 -34
  18. package/components/Routes.js.map +1 -1
  19. package/components/View.d.ts +1 -1
  20. package/components/View.js +15 -37
  21. package/components/View.js.map +1 -1
  22. package/components/index.js +3 -20
  23. package/components/index.js.map +1 -1
  24. package/config/RouterConfig/Route.d.ts +30 -0
  25. package/config/RouterConfig/Route.js +42 -0
  26. package/config/RouterConfig/Route.js.map +1 -0
  27. package/config/RouterConfig.d.ts +32 -0
  28. package/config/RouterConfig.js +18 -0
  29. package/config/RouterConfig.js.map +1 -0
  30. package/config.d.ts +1 -1
  31. package/config.js +8 -16
  32. package/config.js.map +1 -1
  33. package/contexts/Ui/index.d.ts +4 -8
  34. package/contexts/Ui/index.js +29 -89
  35. package/contexts/Ui/index.js.map +1 -1
  36. package/core/DebounceRender.d.ts +12 -0
  37. package/core/DebounceRender.js +31 -0
  38. package/core/DebounceRender.js.map +1 -0
  39. package/core/Plugin.d.ts +8 -0
  40. package/core/Plugin.js +14 -0
  41. package/core/Plugin.js.map +1 -0
  42. package/core/Plugins.d.ts +15 -0
  43. package/core/Plugins.js +39 -0
  44. package/core/Plugins.js.map +1 -0
  45. package/core/Provider.d.ts +8 -0
  46. package/core/Provider.js +18 -0
  47. package/core/Provider.js.map +1 -0
  48. package/core/Routes.d.ts +6 -0
  49. package/core/Routes.js +34 -0
  50. package/core/Routes.js.map +1 -0
  51. package/core/createProvider.d.ts +10 -0
  52. package/core/createProvider.js +9 -0
  53. package/core/createProvider.js.map +1 -0
  54. package/core/createProviderPlugin.d.ts +8 -0
  55. package/core/createProviderPlugin.js +17 -0
  56. package/core/createProviderPlugin.js.map +1 -0
  57. package/hooks/useAutocomplete/index.js +2 -12
  58. package/hooks/useAutocomplete/index.js.map +1 -1
  59. package/hooks/useAutocomplete/useAutocomplete.d.ts +1 -1
  60. package/hooks/useAutocomplete/useAutocomplete.js +10 -25
  61. package/hooks/useAutocomplete/useAutocomplete.js.map +1 -1
  62. package/hooks/useDataList/functions/getData.js +3 -15
  63. package/hooks/useDataList/functions/getData.js.map +1 -1
  64. package/hooks/useDataList/functions/getError.js +3 -15
  65. package/hooks/useDataList/functions/getError.js.map +1 -1
  66. package/hooks/useDataList/functions/getMeta.js +3 -15
  67. package/hooks/useDataList/functions/getMeta.js.map +1 -1
  68. package/hooks/useDataList/functions/index.js +4 -30
  69. package/hooks/useDataList/functions/index.js.map +1 -1
  70. package/hooks/useDataList/functions/searchDataByKey.js +5 -16
  71. package/hooks/useDataList/functions/searchDataByKey.js.map +1 -1
  72. package/hooks/useDataList/index.js +2 -12
  73. package/hooks/useDataList/index.js.map +1 -1
  74. package/hooks/useDataList/useDataList.d.ts +2 -2
  75. package/hooks/useDataList/useDataList.js +82 -107
  76. package/hooks/useDataList/useDataList.js.map +1 -1
  77. package/hooks/useDataList/utils/index.js +3 -22
  78. package/hooks/useDataList/utils/index.js.map +1 -1
  79. package/hooks/useDataList/utils/prepareLoadListParams.d.ts +1 -2
  80. package/hooks/useDataList/utils/prepareLoadListParams.js +33 -43
  81. package/hooks/useDataList/utils/prepareLoadListParams.js.map +1 -1
  82. package/hooks/useDataList/utils/redirectToRouteWithQueryParams.js +11 -16
  83. package/hooks/useDataList/utils/redirectToRouteWithQueryParams.js.map +1 -1
  84. package/hooks/useDataList/utils/types.d.ts +21 -15
  85. package/hooks/useDataList/utils/types.js +2 -4
  86. package/hooks/useDataList/utils/types.js.map +1 -1
  87. package/hooks/useHandler.js +13 -14
  88. package/hooks/useHandler.js.map +1 -1
  89. package/hooks/useHandlers.d.ts +3 -3
  90. package/hooks/useHandlers.js +14 -21
  91. package/hooks/useHandlers.js.map +1 -1
  92. package/hooks/useRegisterLegacyPlugin.d.ts +2 -0
  93. package/hooks/useRegisterLegacyPlugin.js +11 -0
  94. package/hooks/useRegisterLegacyPlugin.js.map +1 -0
  95. package/hooks/useUi.d.ts +1 -1
  96. package/hooks/useUi.js +5 -14
  97. package/hooks/useUi.js.map +1 -1
  98. package/i18n/i18n.js +6 -20
  99. package/i18n/i18n.js.map +1 -1
  100. package/i18n/index.js +2 -14
  101. package/i18n/index.js.map +1 -1
  102. package/index.d.ts +14 -1
  103. package/index.js +18 -35
  104. package/index.js.map +1 -1
  105. package/package.json +25 -30
  106. package/plugins/AddQuerySelectionPlugin.d.ts +9 -2
  107. package/plugins/AddQuerySelectionPlugin.js +64 -124
  108. package/plugins/AddQuerySelectionPlugin.js.map +1 -1
  109. package/plugins/ApolloCacheObjectIdPlugin.js +13 -50
  110. package/plugins/ApolloCacheObjectIdPlugin.js.map +1 -1
  111. package/plugins/ApolloDynamicLink.d.ts +3 -2
  112. package/plugins/ApolloDynamicLink.js +20 -72
  113. package/plugins/ApolloDynamicLink.js.map +1 -1
  114. package/plugins/ApolloLinkPlugin.d.ts +1 -1
  115. package/plugins/ApolloLinkPlugin.js +19 -60
  116. package/plugins/ApolloLinkPlugin.js.map +1 -1
  117. package/plugins/ConsoleLinkPlugin.js +21 -58
  118. package/plugins/ConsoleLinkPlugin.js.map +1 -1
  119. package/plugins/LocaleHeaderLinkPlugin.d.ts +1 -6
  120. package/plugins/LocaleHeaderLinkPlugin.js +24 -69
  121. package/plugins/LocaleHeaderLinkPlugin.js.map +1 -1
  122. package/plugins/NetworkErrorLinkPlugin/ErrorOverlay.d.ts +1 -1
  123. package/plugins/NetworkErrorLinkPlugin/ErrorOverlay.js +41 -72
  124. package/plugins/NetworkErrorLinkPlugin/ErrorOverlay.js.map +1 -1
  125. package/plugins/NetworkErrorLinkPlugin/StyledComponents.d.ts +8 -4
  126. package/plugins/NetworkErrorLinkPlugin/StyledComponents.js +76 -19
  127. package/plugins/NetworkErrorLinkPlugin/StyledComponents.js.map +1 -1
  128. package/plugins/NetworkErrorLinkPlugin/createErrorOverlay.d.ts +1 -1
  129. package/plugins/NetworkErrorLinkPlugin/createErrorOverlay.js +24 -31
  130. package/plugins/NetworkErrorLinkPlugin/createErrorOverlay.js.map +1 -1
  131. package/plugins/NetworkErrorLinkPlugin.js +24 -59
  132. package/plugins/NetworkErrorLinkPlugin.js.map +1 -1
  133. package/plugins/OmitTypenameLinkPlugin.js +13 -47
  134. package/plugins/OmitTypenameLinkPlugin.js.map +1 -1
  135. package/plugins/RoutePlugin.d.ts +1 -1
  136. package/plugins/RoutePlugin.js +13 -50
  137. package/plugins/RoutePlugin.js.map +1 -1
  138. package/plugins/TenantHeaderLinkPlugin.d.ts +1 -6
  139. package/plugins/TenantHeaderLinkPlugin.js +31 -77
  140. package/plugins/TenantHeaderLinkPlugin.js.map +1 -1
  141. package/plugins/ViewPlugin.d.ts +1 -1
  142. package/plugins/ViewPlugin.js +16 -55
  143. package/plugins/ViewPlugin.js.map +1 -1
  144. package/plugins/image.d.ts +1 -1
  145. package/plugins/image.js +55 -94
  146. package/plugins/image.js.map +1 -1
  147. package/plugins/index.d.ts +3 -3
  148. package/plugins/index.js +34 -78
  149. package/plugins/index.js.map +1 -1
  150. package/react-butterfiles/Files.d.ts +69 -0
  151. package/react-butterfiles/Files.js +227 -0
  152. package/react-butterfiles/Files.js.map +1 -0
  153. package/react-butterfiles/index.d.ts +2 -0
  154. package/react-butterfiles/index.js +4 -0
  155. package/react-butterfiles/index.js.map +1 -0
  156. package/react-butterfiles/utils/generateId.d.ts +1 -0
  157. package/react-butterfiles/utils/generateId.js +5 -0
  158. package/react-butterfiles/utils/generateId.js.map +1 -0
  159. package/react-butterfiles/utils/readFileContent.d.ts +1 -0
  160. package/react-butterfiles/utils/readFileContent.js +15 -0
  161. package/react-butterfiles/utils/readFileContent.js.map +1 -0
  162. package/renderApp.d.ts +2 -0
  163. package/renderApp.js +9 -0
  164. package/renderApp.js.map +1 -0
  165. package/types.d.ts +24 -27
  166. package/types.js +12 -11
  167. package/types.js.map +1 -1
  168. package/utils/createGenericContext.d.ts +13 -0
  169. package/utils/createGenericContext.js +25 -0
  170. package/utils/createGenericContext.js.map +1 -0
  171. package/utils/createHashing.d.ts +2 -0
  172. package/utils/createHashing.js +18 -0
  173. package/utils/createHashing.js.map +1 -0
  174. package/utils/getApiUrl.d.ts +1 -0
  175. package/utils/getApiUrl.js +5 -0
  176. package/utils/getApiUrl.js.map +1 -0
  177. package/utils/getGqlApiUrl.d.ts +1 -0
  178. package/utils/getGqlApiUrl.js +6 -0
  179. package/utils/getGqlApiUrl.js.map +1 -0
  180. package/utils/getHeadlessCmsGqlApiUrl.d.ts +5 -0
  181. package/utils/getHeadlessCmsGqlApiUrl.js +12 -0
  182. package/utils/getHeadlessCmsGqlApiUrl.js.map +1 -0
  183. package/utils/getLocaleCode.d.ts +6 -0
  184. package/utils/getLocaleCode.js +33 -0
  185. package/utils/getLocaleCode.js.map +1 -0
  186. package/utils/getPrerenderId.d.ts +6 -0
  187. package/utils/getPrerenderId.js +5 -0
  188. package/utils/getPrerenderId.js.map +1 -0
  189. package/utils/getTenantId.d.ts +6 -0
  190. package/utils/getTenantId.js +45 -0
  191. package/utils/getTenantId.js.map +1 -0
  192. package/utils/index.d.ts +10 -0
  193. package/utils/index.js +12 -0
  194. package/utils/index.js.map +1 -0
  195. package/utils/isLocalhost.d.ts +1 -0
  196. package/utils/isLocalhost.js +7 -0
  197. package/utils/isLocalhost.js.map +1 -0
  198. package/utils/isPrerendering.d.ts +1 -0
  199. package/utils/isPrerendering.js +5 -0
  200. package/utils/isPrerendering.js.map +1 -0
  201. package/utils/legacyPluginToReactComponent.d.ts +7 -0
  202. package/utils/legacyPluginToReactComponent.js +14 -0
  203. package/utils/legacyPluginToReactComponent.js.map +1 -0
@@ -1 +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,IAAO,OAA2C;EAAA,IAAxCC,IAAwC,QAAxCA,IAAwC;EAAA,IAAlCC,QAAkC,QAAlCA,QAAkC;EAAA,sBAAxBC,KAAwB;EAAA,IAAxBA,KAAwB,2BAAhB,EAAgB;;EAC3D,IAAMC,WAAW,GAAGC,gBAAA,CAAQC,MAAR,CAA2BC,sBAAA,CAAWC,IAAtC,EAA4CC,MAA5C,CAAmD,UAAAC,EAAE;IAAA,OAAIA,EAAE,CAACC,GAAH,KAAWV,IAAf;EAAA,CAArD,CAApB;;EAEA,IAAIG,WAAW,CAACQ,MAAhB,EAAwB;IACpBV,QAAQ,GAAGE,WAAW,CAACS,MAAZ,CAAmB,UAACC,EAAD,EAAKJ,EAAL;MAAA,OAAYA,EAAE,CAACK,MAAH;QAAYb,QAAQ,EAAEY;MAAtB,GAA6BX,KAA7B,EAAZ;IAAA,CAAnB,EAAsED,QAAtE,CAAX;EACH;;EAED,oBAAO,6BAAC,eAAD,QAAWA,QAAQ,IAAI,IAAvB,CAAP;AACH,CARM"}
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,21 +1,4 @@
1
- "use strict";
1
+ export { Image } from "./Image";
2
+ export { Routes } from "./Routes";
2
3
 
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
-
19
- var _Image = require("./Image");
20
-
21
- var _Routes = require("./Routes");
4
+ //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"names":[],"sources":["index.ts"],"sourcesContent":["export { Image } from \"./Image\";\nexport { Routes } from \"./Routes\";\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;;AACA"}
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":[]}
@@ -0,0 +1,32 @@
1
+ /// <reference types="react" />
2
+ import { type RouteConfig } from "./RouterConfig/Route";
3
+ export declare const RouterWithConfig: (({ onProperties, children }: import("@webiny/react-properties").WithConfigProps) => import("react").JSX.Element) & {
4
+ displayName: string;
5
+ };
6
+ export declare const useRouterConfig: () => {
7
+ routes: RouteConfig[];
8
+ };
9
+ export declare const RouterConfig: (({ priority, children }: import("@webiny/react-properties").ConfigProps) => import("react").JSX.Element) & {
10
+ Route: (({ name, path, element, exact, remove, before, after }: import("./RouterConfig/Route").RouteProps) => import("react").JSX.Element) & {
11
+ original: ({ name, path, element, exact, remove, before, after }: import("./RouterConfig/Route").RouteProps) => import("react").JSX.Element;
12
+ originalName: string;
13
+ displayName: string;
14
+ } & {
15
+ original: (({ name, path, element, exact, remove, before, after }: import("./RouterConfig/Route").RouteProps) => import("react").JSX.Element) & {
16
+ original: ({ name, path, element, exact, remove, before, after }: import("./RouterConfig/Route").RouteProps) => import("react").JSX.Element;
17
+ originalName: string;
18
+ displayName: string;
19
+ };
20
+ originalName: string;
21
+ displayName: string;
22
+ } & {
23
+ createDecorator: (decorator: import("@webiny/react-composition").ComponentDecorator<(({ name, path, element, exact, remove, before, after }: import("./RouterConfig/Route").RouteProps) => import("react").JSX.Element) & {
24
+ original: ({ name, path, element, exact, remove, before, after }: import("./RouterConfig/Route").RouteProps) => import("react").JSX.Element;
25
+ originalName: string;
26
+ displayName: string;
27
+ }>) => (props: unknown) => import("react").JSX.Element;
28
+ };
29
+ useRouterConfig: () => {
30
+ routes: RouteConfig[];
31
+ };
32
+ };
@@ -0,0 +1,18 @@
1
+ import { createConfigurableComponent } from "@webiny/react-properties";
2
+ import { Route } from "./RouterConfig/Route";
3
+ const base = createConfigurableComponent("RouterConfig");
4
+ export const RouterWithConfig = Object.assign(base.WithConfig, {
5
+ displayName: "RouterWithConfig"
6
+ });
7
+ export const useRouterConfig = () => {
8
+ const baseConfig = base.useConfig();
9
+ return {
10
+ routes: baseConfig.routes ?? []
11
+ };
12
+ };
13
+ export const RouterConfig = Object.assign(base.Config, {
14
+ Route,
15
+ useRouterConfig
16
+ });
17
+
18
+ //# sourceMappingURL=RouterConfig.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["createConfigurableComponent","Route","base","RouterWithConfig","Object","assign","WithConfig","displayName","useRouterConfig","baseConfig","useConfig","routes","RouterConfig","Config"],"sources":["RouterConfig.tsx"],"sourcesContent":["import { createConfigurableComponent } from \"@webiny/react-properties\";\nimport { Route, type RouteConfig } from \"./RouterConfig/Route\";\n\nconst base = createConfigurableComponent<RouterConfig>(\"RouterConfig\");\n\nexport const RouterWithConfig = Object.assign(base.WithConfig, {\n displayName: \"RouterWithConfig\"\n});\n\ninterface RouterConfig {\n routes: RouteConfig[];\n}\n\nexport const useRouterConfig = () => {\n const baseConfig = base.useConfig();\n\n return {\n routes: baseConfig.routes ?? []\n };\n};\n\nexport const RouterConfig = Object.assign(base.Config, {\n Route,\n useRouterConfig\n});\n"],"mappings":"AAAA,SAASA,2BAA2B,QAAQ,0BAA0B;AACtE,SAASC,KAAK;AAEd,MAAMC,IAAI,GAAGF,2BAA2B,CAAe,cAAc,CAAC;AAEtE,OAAO,MAAMG,gBAAgB,GAAGC,MAAM,CAACC,MAAM,CAACH,IAAI,CAACI,UAAU,EAAE;EAC3DC,WAAW,EAAE;AACjB,CAAC,CAAC;AAMF,OAAO,MAAMC,eAAe,GAAGA,CAAA,KAAM;EACjC,MAAMC,UAAU,GAAGP,IAAI,CAACQ,SAAS,CAAC,CAAC;EAEnC,OAAO;IACHC,MAAM,EAAEF,UAAU,CAACE,MAAM,IAAI;EACjC,CAAC;AACL,CAAC;AAED,OAAO,MAAMC,YAAY,GAAGR,MAAM,CAACC,MAAM,CAACH,IAAI,CAACW,MAAM,EAAE;EACnDZ,KAAK;EACLO;AACJ,CAAC,CAAC","ignoreList":[]}
package/config.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- export declare type Config = Record<string, any>;
1
+ export type Config = Record<string, any>;
2
2
  interface AppConfig {
3
3
  set(config: Config): void;
4
4
  get(): Config;
package/config.js CHANGED
@@ -1,33 +1,25 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.config = void 0;
7
-
8
- var deepFreeze = function deepFreeze(obj) {
9
- Object.keys(obj).forEach(function (prop) {
1
+ const deepFreeze = obj => {
2
+ Object.keys(obj).forEach(prop => {
10
3
  if (typeof obj[prop] === "object" && !Object.isFrozen(obj[prop])) {
11
4
  deepFreeze(obj[prop]);
12
5
  }
13
6
  });
14
7
  return Object.freeze(obj);
15
8
  };
16
-
17
9
  function createConfig() {
18
- var _config = {};
10
+ let _config = {};
19
11
  return {
20
- set: function set(config) {
12
+ set(config) {
21
13
  _config = deepFreeze(config);
22
14
  },
23
- get: function get() {
15
+ get() {
24
16
  return _config;
25
17
  },
26
- getKey: function getKey(key, defaultValue) {
18
+ getKey(key, defaultValue) {
27
19
  return key in _config ? _config[key] : defaultValue;
28
20
  }
29
21
  };
30
22
  }
23
+ export const config = createConfig();
31
24
 
32
- var config = createConfig();
33
- exports.config = config;
25
+ //# sourceMappingURL=config.js.map
package/config.js.map CHANGED
@@ -1 +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,UAAa,CAACC,GAAD,EAAmD;EAClEC,MAAM,CAACC,IAAP,CAAYF,GAAZ,EAAiBG,OAAjB,CAAyB,UAAAC,IAAI,EAAI;IAC7B,IAAI,OAAOJ,GAAG,CAACI,IAAD,CAAV,KAAqB,QAArB,IAAiC,CAACH,MAAM,CAACI,QAAP,CAAgBL,GAAG,CAACI,IAAD,CAAnB,CAAtC,EAAkE;MAC9DL,UAAU,CAACC,GAAG,CAACI,IAAD,CAAJ,CAAV;IACH;EACJ,CAJD;EAKA,OAAOH,MAAM,CAACK,MAAP,CAAcN,GAAd,CAAP;AACH,CAPD;;AASA,SAASO,YAAT,GAAmC;EAC/B,IAAIC,OAA4B,GAAG,EAAnC;EAEA,OAAO;IACHC,GADG,eACCC,MADD,EACiB;MAChBF,OAAO,GAAGT,UAAU,CAACW,MAAD,CAApB;IACH,CAHE;IAIHC,GAJG,iBAIG;MACF,OAAOH,OAAP;IACH,CANE;IAOHI,MAPG,kBAOIC,GAPJ,EAOSC,YAPT,EAOuB;MACtB,OAAOD,GAAG,IAAIL,OAAP,GAAiBA,OAAO,CAACK,GAAD,CAAxB,GAAgCC,YAAvC;IACH;EATE,CAAP;AAWH;;AAEM,IAAMJ,MAAM,GAAGH,YAAY,EAA3B"}
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,MAAMA,UAAU,GAAIC,GAAwB,IAA0B;EAClEC,MAAM,CAACC,IAAI,CAACF,GAAG,CAAC,CAACG,OAAO,CAACC,IAAI,IAAI;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,YAAYA,CAAA,EAAc;EAC/B,IAAIC,OAA4B,GAAG,CAAC,CAAC;EAErC,OAAO;IACHC,GAAGA,CAACC,MAAc,EAAE;MAChBF,OAAO,GAAGT,UAAU,CAACW,MAAM,CAAC;IAChC,CAAC;IACDC,GAAGA,CAAA,EAAG;MACF,OAAOH,OAAO;IAClB,CAAC;IACDI,MAAMA,CAACC,GAAG,EAAEC,YAAY,EAAE;MACtB,OAAOD,GAAG,IAAIL,OAAO,GAAGA,OAAO,CAACK,GAAG,CAAC,GAAGC,YAAY;IACvD;EACJ,CAAC;AACL;AAEA,OAAO,MAAMJ,MAAM,GAAGH,YAAY,CAAC,CAAC","ignoreList":[]}
@@ -1,7 +1,7 @@
1
1
  import React from "react";
2
- export declare const UiContext: React.Context<{}>;
3
- declare type Props = {};
4
- declare type State = {
2
+ export declare const UiContext: React.Context<Record<string, any>>;
3
+ type Props = Record<string, any>;
4
+ type State = {
5
5
  ui: {
6
6
  [key: string]: any;
7
7
  };
@@ -19,10 +19,6 @@ export interface UiContextValue {
19
19
  export declare class UiProvider extends React.Component<Props, State> {
20
20
  state: State;
21
21
  private readonly setData;
22
- render(): JSX.Element;
22
+ render(): React.JSX.Element;
23
23
  }
24
- export interface UiConsumerProps {
25
- children: React.ReactElement;
26
- }
27
- export declare const UiConsumer: React.FC<UiConsumerProps>;
28
24
  export {};
@@ -1,92 +1,32 @@
1
- "use strict";
2
-
3
- var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
4
-
5
- Object.defineProperty(exports, "__esModule", {
6
- value: true
7
- });
8
- exports.UiProvider = exports.UiContext = exports.UiConsumer = void 0;
9
-
10
- var _objectSpread2 = _interopRequireDefault(require("@babel/runtime/helpers/objectSpread2"));
11
-
12
- var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/classCallCheck"));
13
-
14
- var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/createClass"));
15
-
16
- var _assertThisInitialized2 = _interopRequireDefault(require("@babel/runtime/helpers/assertThisInitialized"));
17
-
18
- var _inherits2 = _interopRequireDefault(require("@babel/runtime/helpers/inherits"));
19
-
20
- var _createSuper2 = _interopRequireDefault(require("@babel/runtime/helpers/createSuper"));
21
-
22
- var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
23
-
24
- var _react = _interopRequireDefault(require("react"));
25
-
26
- var _plugins = require("@webiny/plugins");
27
-
28
- var UiContext = /*#__PURE__*/_react.default.createContext({});
29
-
30
- exports.UiContext = UiContext;
31
-
32
- var UiProvider = /*#__PURE__*/function (_React$Component) {
33
- (0, _inherits2.default)(UiProvider, _React$Component);
34
-
35
- var _super = (0, _createSuper2.default)(UiProvider);
36
-
37
- function UiProvider() {
38
- var _this;
39
-
40
- (0, _classCallCheck2.default)(this, UiProvider);
41
-
42
- for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
43
- args[_key] = arguments[_key];
44
- }
45
-
46
- _this = _super.call.apply(_super, [this].concat(args));
47
- (0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "state", {
48
- ui: {}
49
- });
50
- (0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "setData", function (setter) {
51
- return _this.setState(function (state) {
52
- return {
53
- ui: (0, _objectSpread2.default)((0, _objectSpread2.default)({}, state.ui), setter(state.ui))
54
- };
55
- });
1
+ import React from "react";
2
+ import { plugins } from "@webiny/plugins";
3
+ export const UiContext = /*#__PURE__*/React.createContext({});
4
+ export class UiProvider extends React.Component {
5
+ state = {
6
+ ui: {}
7
+ };
8
+ setData = setter => {
9
+ return this.setState(state => {
10
+ return {
11
+ ui: {
12
+ ...state.ui,
13
+ ...setter(state.ui)
14
+ }
15
+ };
56
16
  });
57
- return _this;
17
+ };
18
+ render() {
19
+ const value = {
20
+ ...this.state.ui,
21
+ setState: this.setData
22
+ };
23
+ const uiStatePlugins = plugins.byType("ui-state");
24
+ return /*#__PURE__*/React.createElement(UiContext.Provider, {
25
+ value: value
26
+ }, uiStatePlugins.map(pl => /*#__PURE__*/React.cloneElement(pl.render(), {
27
+ key: pl.name
28
+ })), this.props.children);
58
29
  }
30
+ }
59
31
 
60
- (0, _createClass2.default)(UiProvider, [{
61
- key: "render",
62
- value: function render() {
63
- var value = (0, _objectSpread2.default)((0, _objectSpread2.default)({}, this.state.ui), {}, {
64
- setState: this.setData
65
- });
66
-
67
- var uiStatePlugins = _plugins.plugins.byType("ui-state");
68
-
69
- return /*#__PURE__*/_react.default.createElement(UiContext.Provider, {
70
- value: value
71
- }, uiStatePlugins.map(function (pl) {
72
- return /*#__PURE__*/_react.default.cloneElement(pl.render(), {
73
- key: pl.name
74
- });
75
- }), this.props.children);
76
- }
77
- }]);
78
- return UiProvider;
79
- }(_react.default.Component);
80
-
81
- exports.UiProvider = UiProvider;
82
-
83
- var UiConsumer = function UiConsumer(_ref) {
84
- var children = _ref.children;
85
- return /*#__PURE__*/_react.default.createElement(UiContext.Consumer, null, function (ui) {
86
- return /*#__PURE__*/_react.default.cloneElement(children, {
87
- ui: ui
88
- });
89
- });
90
- };
91
-
92
- exports.UiConsumer = UiConsumer;
32
+ //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"names":["UiContext","React","createContext","UiProvider","ui","setter","setState","state","value","setData","uiStatePlugins","plugins","byType","map","pl","cloneElement","render","key","name","props","children","Component","UiConsumer"],"sources":["index.tsx"],"sourcesContent":["import React from \"react\";\nimport { UiStatePlugin } from \"~/types\";\nimport { plugins } from \"@webiny/plugins\";\n\nexport const UiContext = React.createContext({});\n\ntype Props = {};\n\ntype State = {\n ui: { [key: string]: any };\n};\n\ninterface UiData {\n [key: string]: any;\n}\n\ninterface UiDataSetter {\n (ui: UiData): UiData;\n}\n\nexport interface UiContextValue {\n setState: (setter: UiDataSetter) => void;\n [key: string]: any;\n}\n\nexport class UiProvider extends React.Component<Props, State> {\n public override state: State = {\n ui: {}\n };\n\n private readonly setData = (setter: Function): void => {\n return this.setState((state: State) => {\n return { ui: { ...state.ui, ...setter(state.ui) } };\n });\n };\n\n public override render() {\n const value: UiContextValue = { ...this.state.ui, setState: this.setData };\n const uiStatePlugins = plugins.byType<UiStatePlugin>(\"ui-state\");\n return (\n <UiContext.Provider value={value}>\n {uiStatePlugins.map(pl => React.cloneElement(pl.render(), { key: pl.name }))}\n {this.props.children}\n </UiContext.Provider>\n );\n }\n}\n\nexport interface UiConsumerProps {\n children: React.ReactElement;\n}\nexport const UiConsumer: React.FC<UiConsumerProps> = ({ children }) => {\n return <UiContext.Consumer>{ui => React.cloneElement(children, { ui })}</UiContext.Consumer>;\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;AAAA;;AAEA;;AAEO,IAAMA,SAAS,gBAAGC,cAAA,CAAMC,aAAN,CAAoB,EAApB,CAAlB;;;;IAqBMC,U;;;;;;;;;;;;;;;wFACsB;MAC3BC,EAAE,EAAE;IADuB,C;0FAIJ,UAACC,MAAD,EAA4B;MACnD,OAAO,MAAKC,QAAL,CAAc,UAACC,KAAD,EAAkB;QACnC,OAAO;UAAEH,EAAE,8DAAOG,KAAK,CAACH,EAAb,GAAoBC,MAAM,CAACE,KAAK,CAACH,EAAP,CAA1B;QAAJ,CAAP;MACH,CAFM,CAAP;IAGH,C;;;;;;WAED,kBAAyB;MACrB,IAAMI,KAAqB,+DAAQ,KAAKD,KAAL,CAAWH,EAAnB;QAAuBE,QAAQ,EAAE,KAAKG;MAAtC,EAA3B;;MACA,IAAMC,cAAc,GAAGC,gBAAA,CAAQC,MAAR,CAA8B,UAA9B,CAAvB;;MACA,oBACI,6BAAC,SAAD,CAAW,QAAX;QAAoB,KAAK,EAAEJ;MAA3B,GACKE,cAAc,CAACG,GAAf,CAAmB,UAAAC,EAAE;QAAA,oBAAIb,cAAA,CAAMc,YAAN,CAAmBD,EAAE,CAACE,MAAH,EAAnB,EAAgC;UAAEC,GAAG,EAAEH,EAAE,CAACI;QAAV,CAAhC,CAAJ;MAAA,CAArB,CADL,EAEK,KAAKC,KAAL,CAAWC,QAFhB,CADJ;IAMH;;;EApB2BnB,cAAA,CAAMoB,S;;;;AA0B/B,IAAMC,UAAqC,GAAG,SAAxCA,UAAwC,OAAkB;EAAA,IAAfF,QAAe,QAAfA,QAAe;EACnE,oBAAO,6BAAC,SAAD,CAAW,QAAX,QAAqB,UAAAhB,EAAE;IAAA,oBAAIH,cAAA,CAAMc,YAAN,CAAmBK,QAAnB,EAA6B;MAAEhB,EAAE,EAAFA;IAAF,CAA7B,CAAJ;EAAA,CAAvB,CAAP;AACH,CAFM"}
1
+ {"version":3,"names":["React","plugins","UiContext","createContext","UiProvider","Component","state","ui","setData","setter","setState","render","value","uiStatePlugins","byType","createElement","Provider","map","pl","cloneElement","key","name","props","children"],"sources":["index.tsx"],"sourcesContent":["import React from \"react\";\nimport type { UiStatePlugin } from \"~/types\";\nimport { plugins } from \"@webiny/plugins\";\n\nexport const UiContext = React.createContext<Record<string, any>>({});\n\ntype Props = Record<string, any>;\n\ntype State = {\n ui: { [key: string]: any };\n};\n\ninterface UiData {\n [key: string]: any;\n}\n\ninterface UiDataSetter {\n (ui: UiData): UiData;\n}\n\nexport interface UiContextValue {\n setState: (setter: UiDataSetter) => void;\n [key: string]: any;\n}\n\nexport class UiProvider extends React.Component<Props, State> {\n public override state: State = {\n ui: {}\n };\n\n private readonly setData = (setter: UiDataSetter): void => {\n return this.setState((state: State) => {\n return { ui: { ...state.ui, ...setter(state.ui) } };\n });\n };\n\n public override render() {\n const value: UiContextValue = { ...this.state.ui, setState: this.setData };\n const uiStatePlugins = plugins.byType<UiStatePlugin>(\"ui-state\");\n return (\n <UiContext.Provider value={value}>\n {uiStatePlugins.map(pl => React.cloneElement(pl.render(), { key: pl.name }))}\n {this.props.children}\n </UiContext.Provider>\n );\n }\n}\n"],"mappings":"AAAA,OAAOA,KAAK,MAAM,OAAO;AAEzB,SAASC,OAAO,QAAQ,iBAAiB;AAEzC,OAAO,MAAMC,SAAS,gBAAGF,KAAK,CAACG,aAAa,CAAsB,CAAC,CAAC,CAAC;AAqBrE,OAAO,MAAMC,UAAU,SAASJ,KAAK,CAACK,SAAS,CAAe;EAC1CC,KAAK,GAAU;IAC3BC,EAAE,EAAE,CAAC;EACT,CAAC;EAEgBC,OAAO,GAAIC,MAAoB,IAAW;IACvD,OAAO,IAAI,CAACC,QAAQ,CAAEJ,KAAY,IAAK;MACnC,OAAO;QAAEC,EAAE,EAAE;UAAE,GAAGD,KAAK,CAACC,EAAE;UAAE,GAAGE,MAAM,CAACH,KAAK,CAACC,EAAE;QAAE;MAAE,CAAC;IACvD,CAAC,CAAC;EACN,CAAC;EAEeI,MAAMA,CAAA,EAAG;IACrB,MAAMC,KAAqB,GAAG;MAAE,GAAG,IAAI,CAACN,KAAK,CAACC,EAAE;MAAEG,QAAQ,EAAE,IAAI,CAACF;IAAQ,CAAC;IAC1E,MAAMK,cAAc,GAAGZ,OAAO,CAACa,MAAM,CAAgB,UAAU,CAAC;IAChE,oBACId,KAAA,CAAAe,aAAA,CAACb,SAAS,CAACc,QAAQ;MAACJ,KAAK,EAAEA;IAAM,GAC5BC,cAAc,CAACI,GAAG,CAACC,EAAE,iBAAIlB,KAAK,CAACmB,YAAY,CAACD,EAAE,CAACP,MAAM,CAAC,CAAC,EAAE;MAAES,GAAG,EAAEF,EAAE,CAACG;IAAK,CAAC,CAAC,CAAC,EAC3E,IAAI,CAACC,KAAK,CAACC,QACI,CAAC;EAE7B;AACJ","ignoreList":[]}
@@ -0,0 +1,12 @@
1
+ import React from "react";
2
+ interface Props {
3
+ wait?: number;
4
+ children?: React.ReactNode;
5
+ }
6
+ /**
7
+ * We need to debounce the rendering of children during app bootstrap, since many plugins
8
+ * can add more and more Providers which will recompose the entire hierarchy of React Context providers.
9
+ * During this stage, we don't want to render anything.
10
+ */
11
+ export declare const DebounceRender: ({ wait, children }: Props) => React.JSX.Element;
12
+ export {};
@@ -0,0 +1,31 @@
1
+ import React from "react";
2
+ import { useEffect, useMemo, useState } from "react";
3
+ import debounce from "lodash/debounce";
4
+ /**
5
+ * We need to debounce the rendering of children during app bootstrap, since many plugins
6
+ * can add more and more Providers which will recompose the entire hierarchy of React Context providers.
7
+ * During this stage, we don't want to render anything.
8
+ */
9
+ export const DebounceRender = ({
10
+ wait = 50,
11
+ children
12
+ }) => {
13
+ const [render, setRender] = useState(wait === 0);
14
+ const debouncedRender = useMemo(() => {
15
+ return debounce(() => {
16
+ setRender(true);
17
+ }, wait);
18
+ }, [setRender]);
19
+ useEffect(() => {
20
+ if (render) {
21
+ return;
22
+ }
23
+ debouncedRender();
24
+ return () => {
25
+ debouncedRender.cancel();
26
+ };
27
+ }, []);
28
+ return /*#__PURE__*/React.createElement(React.Fragment, null, render ? children : null);
29
+ };
30
+
31
+ //# sourceMappingURL=DebounceRender.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["React","useEffect","useMemo","useState","debounce","DebounceRender","wait","children","render","setRender","debouncedRender","cancel","createElement","Fragment"],"sources":["DebounceRender.tsx"],"sourcesContent":["import React from \"react\";\nimport { useEffect, useMemo, useState } from \"react\";\nimport debounce from \"lodash/debounce\";\n\ninterface Props {\n wait?: number;\n children?: React.ReactNode;\n}\n/**\n * We need to debounce the rendering of children during app bootstrap, since many plugins\n * can add more and more Providers which will recompose the entire hierarchy of React Context providers.\n * During this stage, we don't want to render anything.\n */\nexport const DebounceRender = ({ wait = 50, children }: Props) => {\n const [render, setRender] = useState(wait === 0);\n\n const debouncedRender = useMemo(() => {\n return debounce(() => {\n setRender(true);\n }, wait);\n }, [setRender]);\n\n useEffect(() => {\n if (render) {\n return;\n }\n\n debouncedRender();\n\n return () => {\n debouncedRender.cancel();\n };\n }, []);\n\n return <>{render ? children : null}</>;\n};\n"],"mappings":"AAAA,OAAOA,KAAK,MAAM,OAAO;AACzB,SAASC,SAAS,EAAEC,OAAO,EAAEC,QAAQ,QAAQ,OAAO;AACpD,OAAOC,QAAQ,MAAM,iBAAiB;AAMtC;AACA;AACA;AACA;AACA;AACA,OAAO,MAAMC,cAAc,GAAGA,CAAC;EAAEC,IAAI,GAAG,EAAE;EAAEC;AAAgB,CAAC,KAAK;EAC9D,MAAM,CAACC,MAAM,EAAEC,SAAS,CAAC,GAAGN,QAAQ,CAACG,IAAI,KAAK,CAAC,CAAC;EAEhD,MAAMI,eAAe,GAAGR,OAAO,CAAC,MAAM;IAClC,OAAOE,QAAQ,CAAC,MAAM;MAClBK,SAAS,CAAC,IAAI,CAAC;IACnB,CAAC,EAAEH,IAAI,CAAC;EACZ,CAAC,EAAE,CAACG,SAAS,CAAC,CAAC;EAEfR,SAAS,CAAC,MAAM;IACZ,IAAIO,MAAM,EAAE;MACR;IACJ;IAEAE,eAAe,CAAC,CAAC;IAEjB,OAAO,MAAM;MACTA,eAAe,CAACC,MAAM,CAAC,CAAC;IAC5B,CAAC;EACL,CAAC,EAAE,EAAE,CAAC;EAEN,oBAAOX,KAAA,CAAAY,aAAA,CAAAZ,KAAA,CAAAa,QAAA,QAAGL,MAAM,GAAGD,QAAQ,GAAG,IAAO,CAAC;AAC1C,CAAC","ignoreList":[]}
@@ -0,0 +1,8 @@
1
+ import React from "react";
2
+ import type { GenericComponent, Decorator } from "@webiny/react-composition";
3
+ interface PluginProps {
4
+ providers?: Decorator<GenericComponent>[];
5
+ children?: React.ReactNode;
6
+ }
7
+ export declare const Plugin: React.NamedExoticComponent<PluginProps>;
8
+ export {};
package/core/Plugin.js ADDED
@@ -0,0 +1,14 @@
1
+ import React from "react";
2
+ import { Provider } from "./Provider";
3
+ import { Plugins } from "./Plugins";
4
+ export const Plugin = /*#__PURE__*/React.memo(function Plugin({
5
+ providers,
6
+ children
7
+ }) {
8
+ return /*#__PURE__*/React.createElement(React.Fragment, null, (providers || []).map((provider, index) => /*#__PURE__*/React.createElement(Provider, {
9
+ key: index,
10
+ hoc: provider
11
+ })), children ? /*#__PURE__*/React.createElement(Plugins, null, children) : null);
12
+ });
13
+
14
+ //# sourceMappingURL=Plugin.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["React","Provider","Plugins","Plugin","memo","providers","children","createElement","Fragment","map","provider","index","key","hoc"],"sources":["Plugin.tsx"],"sourcesContent":["import React from \"react\";\nimport { Provider } from \"./Provider\";\nimport { Plugins } from \"./Plugins\";\nimport type { GenericComponent, Decorator } from \"@webiny/react-composition\";\n\ninterface PluginProps {\n providers?: Decorator<GenericComponent>[];\n children?: React.ReactNode;\n}\n\nexport const Plugin = React.memo(function Plugin({ providers, children }: PluginProps) {\n return (\n <>\n {(providers || []).map((provider, index) => (\n <Provider key={index} hoc={provider} />\n ))}\n {children ? <Plugins>{children}</Plugins> : null}\n </>\n );\n});\n"],"mappings":"AAAA,OAAOA,KAAK,MAAM,OAAO;AACzB,SAASC,QAAQ;AACjB,SAASC,OAAO;AAQhB,OAAO,MAAMC,MAAM,gBAAGH,KAAK,CAACI,IAAI,CAAC,SAASD,MAAMA,CAAC;EAAEE,SAAS;EAAEC;AAAsB,CAAC,EAAE;EACnF,oBACIN,KAAA,CAAAO,aAAA,CAAAP,KAAA,CAAAQ,QAAA,QACK,CAACH,SAAS,IAAI,EAAE,EAAEI,GAAG,CAAC,CAACC,QAAQ,EAAEC,KAAK,kBACnCX,KAAA,CAAAO,aAAA,CAACN,QAAQ;IAACW,GAAG,EAAED,KAAM;IAACE,GAAG,EAAEH;EAAS,CAAE,CACzC,CAAC,EACDJ,QAAQ,gBAAGN,KAAA,CAAAO,aAAA,CAACL,OAAO,QAAEI,QAAkB,CAAC,GAAG,IAC9C,CAAC;AAEX,CAAC,CAAC","ignoreList":[]}
@@ -0,0 +1,15 @@
1
+ import React from "react";
2
+ export declare const PluginsContext: React.Context<boolean>;
3
+ interface PluginsProviderComponentProps {
4
+ children: JSX.Element[];
5
+ }
6
+ export declare const PluginsProvider: React.MemoExoticComponent<({ children }: PluginsProviderComponentProps) => React.JSX.Element>;
7
+ /**
8
+ * @param children
9
+ * @deprecated This component should not be used directly. Use the <Plugin> component to create plugins.
10
+ */
11
+ interface PluginsComponentsProps {
12
+ children: React.ReactNode;
13
+ }
14
+ export declare const Plugins: ({ children }: PluginsComponentsProps) => React.JSX.Element | null;
15
+ export {};
@@ -0,0 +1,39 @@
1
+ import React, { Fragment, Children, createContext, useContext, useEffect, memo } from "react";
2
+ import { useApp } from "../App";
3
+ export const PluginsContext = /*#__PURE__*/createContext(false);
4
+ PluginsContext.displayName = "PluginsContext";
5
+ const PluginsProviderComponent = ({
6
+ children
7
+ }) => {
8
+ /**
9
+ * This context only serves as a safeguard. We need to warn users when they mount a plugin without using
10
+ * the <Plugins> component. In that case, the context will not be available, and we can log warnings.
11
+ */
12
+ return /*#__PURE__*/React.createElement(PluginsContext.Provider, {
13
+ value: true
14
+ }, children);
15
+ };
16
+ export const PluginsProvider = /*#__PURE__*/memo(PluginsProviderComponent);
17
+
18
+ /**
19
+ * @param children
20
+ * @deprecated This component should not be used directly. Use the <Plugin> component to create plugins.
21
+ */
22
+
23
+ export const Plugins = ({
24
+ children
25
+ }) => {
26
+ const {
27
+ addPlugin
28
+ } = useApp();
29
+ const hasParentPlugin = useContext(PluginsContext);
30
+ useEffect(() => {
31
+ if (hasParentPlugin) {
32
+ return;
33
+ }
34
+ Children.forEach(children, child => addPlugin(child));
35
+ }, []);
36
+ return hasParentPlugin ? /*#__PURE__*/React.createElement(Fragment, null, children) : null;
37
+ };
38
+
39
+ //# sourceMappingURL=Plugins.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["React","Fragment","Children","createContext","useContext","useEffect","memo","useApp","PluginsContext","displayName","PluginsProviderComponent","children","createElement","Provider","value","PluginsProvider","Plugins","addPlugin","hasParentPlugin","forEach","child"],"sources":["Plugins.tsx"],"sourcesContent":["import React, { Fragment, Children, createContext, useContext, useEffect, memo } from \"react\";\nimport { useApp } from \"~/App\";\n\nexport const PluginsContext = createContext<boolean>(false);\nPluginsContext.displayName = \"PluginsContext\";\n\ninterface PluginsProviderComponentProps {\n children: JSX.Element[];\n}\nconst PluginsProviderComponent = ({ children }: PluginsProviderComponentProps) => {\n /**\n * This context only serves as a safeguard. We need to warn users when they mount a plugin without using\n * the <Plugins> component. In that case, the context will not be available, and we can log warnings.\n */\n return <PluginsContext.Provider value={true}>{children}</PluginsContext.Provider>;\n};\n\nexport const PluginsProvider = memo(PluginsProviderComponent);\n\n/**\n * @param children\n * @deprecated This component should not be used directly. Use the <Plugin> component to create plugins.\n */\ninterface PluginsComponentsProps {\n children: React.ReactNode;\n}\nexport const Plugins = ({ children }: PluginsComponentsProps) => {\n const { addPlugin } = useApp();\n const hasParentPlugin = useContext(PluginsContext);\n\n useEffect(() => {\n if (hasParentPlugin) {\n return;\n }\n\n Children.forEach(children, child => addPlugin(child));\n }, []);\n\n return hasParentPlugin ? <Fragment>{children}</Fragment> : null;\n};\n"],"mappings":"AAAA,OAAOA,KAAK,IAAIC,QAAQ,EAAEC,QAAQ,EAAEC,aAAa,EAAEC,UAAU,EAAEC,SAAS,EAAEC,IAAI,QAAQ,OAAO;AAC7F,SAASC,MAAM;AAEf,OAAO,MAAMC,cAAc,gBAAGL,aAAa,CAAU,KAAK,CAAC;AAC3DK,cAAc,CAACC,WAAW,GAAG,gBAAgB;AAK7C,MAAMC,wBAAwB,GAAGA,CAAC;EAAEC;AAAwC,CAAC,KAAK;EAC9E;AACJ;AACA;AACA;EACI,oBAAOX,KAAA,CAAAY,aAAA,CAACJ,cAAc,CAACK,QAAQ;IAACC,KAAK,EAAE;EAAK,GAAEH,QAAkC,CAAC;AACrF,CAAC;AAED,OAAO,MAAMI,eAAe,gBAAGT,IAAI,CAACI,wBAAwB,CAAC;;AAE7D;AACA;AACA;AACA;;AAIA,OAAO,MAAMM,OAAO,GAAGA,CAAC;EAAEL;AAAiC,CAAC,KAAK;EAC7D,MAAM;IAAEM;EAAU,CAAC,GAAGV,MAAM,CAAC,CAAC;EAC9B,MAAMW,eAAe,GAAGd,UAAU,CAACI,cAAc,CAAC;EAElDH,SAAS,CAAC,MAAM;IACZ,IAAIa,eAAe,EAAE;MACjB;IACJ;IAEAhB,QAAQ,CAACiB,OAAO,CAACR,QAAQ,EAAES,KAAK,IAAIH,SAAS,CAACG,KAAK,CAAC,CAAC;EACzD,CAAC,EAAE,EAAE,CAAC;EAEN,OAAOF,eAAe,gBAAGlB,KAAA,CAAAY,aAAA,CAACX,QAAQ,QAAEU,QAAmB,CAAC,GAAG,IAAI;AACnE,CAAC","ignoreList":[]}
@@ -0,0 +1,8 @@
1
+ import type { GenericComponent, Decorator } from "../index";
2
+ export interface ProviderProps {
3
+ hoc: Decorator<GenericComponent>;
4
+ }
5
+ /**
6
+ * Register a new React context provider.
7
+ */
8
+ export declare const Provider: ({ hoc }: ProviderProps) => null;
@@ -0,0 +1,18 @@
1
+ import { useEffect } from "react";
2
+ import { useApp } from "./..";
3
+ /**
4
+ * Register a new React context provider.
5
+ */
6
+ export const Provider = ({
7
+ hoc
8
+ }) => {
9
+ const {
10
+ addProvider
11
+ } = useApp();
12
+ useEffect(() => {
13
+ return addProvider(hoc);
14
+ }, []);
15
+ return null;
16
+ };
17
+
18
+ //# sourceMappingURL=Provider.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["useEffect","useApp","Provider","hoc","addProvider"],"sources":["Provider.tsx"],"sourcesContent":["import { useEffect } from \"react\";\nimport type { GenericComponent, Decorator } from \"~/index\";\nimport { useApp } from \"~/index\";\n\nexport interface ProviderProps {\n hoc: Decorator<GenericComponent>;\n}\n\n/**\n * Register a new React context provider.\n */\nexport const Provider = ({ hoc }: ProviderProps) => {\n const { addProvider } = useApp();\n\n useEffect(() => {\n return addProvider(hoc);\n }, []);\n\n return null;\n};\n"],"mappings":"AAAA,SAASA,SAAS,QAAQ,OAAO;AAEjC,SAASC,MAAM;AAMf;AACA;AACA;AACA,OAAO,MAAMC,QAAQ,GAAGA,CAAC;EAAEC;AAAmB,CAAC,KAAK;EAChD,MAAM;IAAEC;EAAY,CAAC,GAAGH,MAAM,CAAC,CAAC;EAEhCD,SAAS,CAAC,MAAM;IACZ,OAAOI,WAAW,CAACD,GAAG,CAAC;EAC3B,CAAC,EAAE,EAAE,CAAC;EAEN,OAAO,IAAI;AACf,CAAC","ignoreList":[]}
@@ -0,0 +1,6 @@
1
+ import React from "react";
2
+ interface RoutesProps {
3
+ routes: JSX.Element[];
4
+ }
5
+ export declare const Routes: (props: RoutesProps) => React.JSX.Element;
6
+ export {};