@webiny/app 0.0.0-unstable.e6f0dc8ca7 → 0.0.0-unstable.e9333b3f0b

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 (362) hide show
  1. package/App.js +70 -77
  2. package/App.js.map +1 -1
  3. package/AppContainer.js +3 -6
  4. package/AppContainer.js.map +1 -1
  5. package/components/Image.js +11 -17
  6. package/components/Image.js.map +1 -1
  7. package/components/index.js +0 -2
  8. package/config/RouterConfig/Route.js +23 -28
  9. package/config/RouterConfig/Route.js.map +1 -1
  10. package/config/RouterConfig.d.ts +1 -3
  11. package/config/RouterConfig.js +11 -10
  12. package/config/RouterConfig.js.map +1 -1
  13. package/config.js +19 -20
  14. package/config.js.map +1 -1
  15. package/contexts/Ui/index.js +26 -28
  16. package/contexts/Ui/index.js.map +1 -1
  17. package/core/Plugin.js +7 -9
  18. package/core/Plugin.js.map +1 -1
  19. package/core/Plugins.d.ts +2 -1
  20. package/core/Plugins.js +15 -34
  21. package/core/Plugins.js.map +1 -1
  22. package/core/Provider.js +5 -13
  23. package/core/Provider.js.map +1 -1
  24. package/core/createProvider.js +3 -6
  25. package/core/createProvider.js.map +1 -1
  26. package/core/createProviderPlugin.js +8 -13
  27. package/core/createProviderPlugin.js.map +1 -1
  28. package/errors/AuthenticationErrorEvent.js +8 -5
  29. package/errors/AuthenticationErrorEvent.js.map +1 -1
  30. package/errors/NetworkErrorEvent.js +8 -5
  31. package/errors/NetworkErrorEvent.js.map +1 -1
  32. package/errors/abstractions.js +3 -2
  33. package/errors/abstractions.js.map +1 -1
  34. package/errors/index.js +1 -4
  35. package/errors/overlay/ErrorOverlay.js +43 -0
  36. package/errors/overlay/ErrorOverlay.js.map +1 -0
  37. package/errors/overlay/GqlErrorOverlay.js +27 -0
  38. package/errors/overlay/GqlErrorOverlay.js.map +1 -0
  39. package/errors/overlay/LocalAwsLambdaTimeoutMessage.js +20 -0
  40. package/errors/overlay/LocalAwsLambdaTimeoutMessage.js.map +1 -0
  41. package/errors/overlay/StyledComponents.d.ts +7 -0
  42. package/errors/overlay/StyledComponents.js +10 -0
  43. package/errors/overlay/StyledComponents.js.map +1 -0
  44. package/errors/overlay/Typography.js +13 -0
  45. package/errors/overlay/Typography.js.map +1 -0
  46. package/errors/overlay/assets/close_24px.js +19 -0
  47. package/errors/overlay/assets/close_24px.js.map +1 -0
  48. package/errors/overlay/createErrorOverlay.js +15 -0
  49. package/errors/overlay/createErrorOverlay.js.map +1 -0
  50. package/exports/admin/env-config.js +0 -2
  51. package/exports/admin/graphql-client.js +0 -2
  52. package/exports/admin/local-storage.js +0 -2
  53. package/exports/admin/router.js +0 -2
  54. package/exports/admin/security.js +0 -2
  55. package/exports/admin.d.ts +1 -0
  56. package/exports/admin.js +1 -2
  57. package/features/apiStreamClient/FetchApiStreamClient.d.ts +9 -0
  58. package/features/apiStreamClient/FetchApiStreamClient.js +63 -0
  59. package/features/apiStreamClient/FetchApiStreamClient.js.map +1 -0
  60. package/features/apiStreamClient/__tests__/FetchApiStreamClient.test.d.ts +1 -0
  61. package/features/apiStreamClient/__tests__/FetchApiStreamClient.test.js +170 -0
  62. package/features/apiStreamClient/__tests__/FetchApiStreamClient.test.js.map +1 -0
  63. package/features/apiStreamClient/__tests__/readServerSentEvents.test.d.ts +1 -0
  64. package/features/apiStreamClient/__tests__/readServerSentEvents.test.js +160 -0
  65. package/features/apiStreamClient/__tests__/readServerSentEvents.test.js.map +1 -0
  66. package/features/apiStreamClient/abstractions.d.ts +44 -0
  67. package/features/apiStreamClient/abstractions.js +10 -0
  68. package/features/apiStreamClient/abstractions.js.map +1 -0
  69. package/features/apiStreamClient/feature.d.ts +3 -0
  70. package/features/apiStreamClient/feature.js +17 -0
  71. package/features/apiStreamClient/feature.js.map +1 -0
  72. package/features/apiStreamClient/index.d.ts +5 -0
  73. package/features/apiStreamClient/index.js +5 -0
  74. package/features/apiStreamClient/readServerSentEvents.d.ts +10 -0
  75. package/features/apiStreamClient/readServerSentEvents.js +29 -0
  76. package/features/apiStreamClient/readServerSentEvents.js.map +1 -0
  77. package/features/apiStreamClient/toPayloadHash.d.ts +14 -0
  78. package/features/apiStreamClient/toPayloadHash.js +7 -0
  79. package/features/apiStreamClient/toPayloadHash.js.map +1 -0
  80. package/features/envConfig/EnvConfig.js +12 -13
  81. package/features/envConfig/EnvConfig.js.map +1 -1
  82. package/features/envConfig/abstractions.js +2 -1
  83. package/features/envConfig/abstractions.js.map +1 -1
  84. package/features/envConfig/feature.js +9 -8
  85. package/features/envConfig/feature.js.map +1 -1
  86. package/features/envConfig/index.js +0 -2
  87. package/features/eventPublisher/EventPublisher.js +13 -21
  88. package/features/eventPublisher/EventPublisher.js.map +1 -1
  89. package/features/eventPublisher/abstractions.js +7 -9
  90. package/features/eventPublisher/abstractions.js.map +1 -1
  91. package/features/eventPublisher/feature.js +13 -12
  92. package/features/eventPublisher/feature.js.map +1 -1
  93. package/features/eventPublisher/index.js +1 -3
  94. package/features/graphqlClient/AuthenticationErrorPublishing.js +26 -26
  95. package/features/graphqlClient/AuthenticationErrorPublishing.js.map +1 -1
  96. package/features/graphqlClient/BatchingGraphQLClient.js +104 -149
  97. package/features/graphqlClient/BatchingGraphQLClient.js.map +1 -1
  98. package/features/graphqlClient/FetchGraphQLClient.js +41 -48
  99. package/features/graphqlClient/FetchGraphQLClient.js.map +1 -1
  100. package/features/graphqlClient/NetworkErrorPublishing.js +35 -42
  101. package/features/graphqlClient/NetworkErrorPublishing.js.map +1 -1
  102. package/features/graphqlClient/RequestValue.js +42 -41
  103. package/features/graphqlClient/RequestValue.js.map +1 -1
  104. package/features/graphqlClient/RetryGraphQLClient.js +36 -45
  105. package/features/graphqlClient/RetryGraphQLClient.js.map +1 -1
  106. package/features/graphqlClient/__tests__/GraphQLClient.test.js +457 -356
  107. package/features/graphqlClient/__tests__/GraphQLClient.test.js.map +1 -1
  108. package/features/graphqlClient/abstractions.js +2 -1
  109. package/features/graphqlClient/abstractions.js.map +1 -1
  110. package/features/graphqlClient/feature.js +14 -20
  111. package/features/graphqlClient/feature.js.map +1 -1
  112. package/features/graphqlClient/index.js +0 -2
  113. package/features/graphqlClient/types.js +0 -3
  114. package/features/localStorage/BrowserLocalStorageGateway.js +56 -63
  115. package/features/localStorage/BrowserLocalStorageGateway.js.map +1 -1
  116. package/features/localStorage/LocalStorage.js +27 -24
  117. package/features/localStorage/LocalStorage.js.map +1 -1
  118. package/features/localStorage/LocalStorageRepository.js +75 -88
  119. package/features/localStorage/LocalStorageRepository.js.map +1 -1
  120. package/features/localStorage/abstractions.js +5 -16
  121. package/features/localStorage/abstractions.js.map +1 -1
  122. package/features/localStorage/feature.js +17 -28
  123. package/features/localStorage/feature.js.map +1 -1
  124. package/features/localStorage/index.js +1 -3
  125. package/features/mainGraphQLClient/MainGraphQLClient.js +18 -14
  126. package/features/mainGraphQLClient/MainGraphQLClient.js.map +1 -1
  127. package/features/mainGraphQLClient/abstractions.js +2 -1
  128. package/features/mainGraphQLClient/abstractions.js.map +1 -1
  129. package/features/mainGraphQLClient/feature.js +11 -10
  130. package/features/mainGraphQLClient/feature.js.map +1 -1
  131. package/features/mainGraphQLClient/index.js +0 -2
  132. package/features/router/HistoryRouterGateway.d.ts +3 -0
  133. package/features/router/HistoryRouterGateway.js +87 -105
  134. package/features/router/HistoryRouterGateway.js.map +1 -1
  135. package/features/router/HistoryRouterGateway.test.js +184 -193
  136. package/features/router/HistoryRouterGateway.test.js.map +1 -1
  137. package/features/router/Route.d.ts +1 -1
  138. package/features/router/Route.js +38 -54
  139. package/features/router/Route.js.map +1 -1
  140. package/features/router/RouteUrl.js +84 -217
  141. package/features/router/RouteUrl.js.map +1 -1
  142. package/features/router/Router.js +67 -124
  143. package/features/router/Router.js.map +1 -1
  144. package/features/router/RouterPresenter.d.ts +2 -0
  145. package/features/router/RouterPresenter.js +54 -49
  146. package/features/router/RouterPresenter.js.map +1 -1
  147. package/features/router/RouterRepository.d.ts +2 -0
  148. package/features/router/RouterRepository.js +109 -111
  149. package/features/router/RouterRepository.js.map +1 -1
  150. package/features/router/RouterRepository.test.js +119 -150
  151. package/features/router/RouterRepository.test.js.map +1 -1
  152. package/features/router/abstractions.d.ts +9 -0
  153. package/features/router/abstractions.js +4 -14
  154. package/features/router/abstractions.js.map +1 -1
  155. package/features/router/feature.js +13 -12
  156. package/features/router/feature.js.map +1 -1
  157. package/features/router/index.js +1 -3
  158. package/helpers/InterfaceGenerator/date.js +0 -3
  159. package/helpers/InterfaceGenerator/id.js +0 -3
  160. package/helpers/InterfaceGenerator/identity.js +0 -3
  161. package/helpers/InterfaceGenerator/index.js +0 -3
  162. package/helpers/InterfaceGenerator/numeric.js +0 -3
  163. package/helpers/InterfaceGenerator/truthful.js +0 -3
  164. package/hooks/useHandler.js +12 -16
  165. package/hooks/useHandler.js.map +1 -1
  166. package/hooks/useHandlers.js +18 -20
  167. package/hooks/useHandlers.js.map +1 -1
  168. package/hooks/useRegisterLegacyPlugin.js +7 -6
  169. package/hooks/useRegisterLegacyPlugin.js.map +1 -1
  170. package/hooks/useUi.js +2 -3
  171. package/hooks/useUi.js.map +1 -1
  172. package/i18n/i18n.js +8 -4
  173. package/i18n/i18n.js.map +1 -1
  174. package/i18n/index.js +0 -2
  175. package/index.d.ts +0 -3
  176. package/index.js +3 -11
  177. package/package.json +21 -34
  178. package/plugins/components/Image.js +8 -15
  179. package/plugins/components/Image.js.map +1 -1
  180. package/plugins/image.d.ts +1 -1
  181. package/plugins/image.js +94 -133
  182. package/plugins/image.js.map +1 -1
  183. package/plugins/index.js +35 -59
  184. package/plugins/index.js.map +1 -1
  185. package/presentation/envConfig/useEnvConfig.js +4 -8
  186. package/presentation/envConfig/useEnvConfig.js.map +1 -1
  187. package/presentation/localStorage/index.js +0 -2
  188. package/presentation/localStorage/useLocalStorage.js +10 -16
  189. package/presentation/localStorage/useLocalStorage.js.map +1 -1
  190. package/presentation/localStorage/useLocalStorageValue.js +15 -13
  191. package/presentation/localStorage/useLocalStorageValue.js.map +1 -1
  192. package/presentation/localStorage/useLocalStorageValues.js +23 -30
  193. package/presentation/localStorage/useLocalStorageValues.js.map +1 -1
  194. package/presentation/router/RouteElementRegistry.js +22 -25
  195. package/presentation/router/RouteElementRegistry.js.map +1 -1
  196. package/presentation/router/abstractions.js +2 -1
  197. package/presentation/router/abstractions.js.map +1 -1
  198. package/presentation/router/components/Redirect.js +8 -10
  199. package/presentation/router/components/Redirect.js.map +1 -1
  200. package/presentation/router/components/RouteContent.js +14 -17
  201. package/presentation/router/components/RouteContent.js.map +1 -1
  202. package/presentation/router/components/RouteLink.js +11 -16
  203. package/presentation/router/components/RouteLink.js.map +1 -1
  204. package/presentation/router/components/RouteParamsSync.d.ts +22 -0
  205. package/presentation/router/components/RouteParamsSync.js +53 -0
  206. package/presentation/router/components/RouteParamsSync.js.map +1 -0
  207. package/presentation/router/components/SimpleLink.js +18 -24
  208. package/presentation/router/components/SimpleLink.js.map +1 -1
  209. package/presentation/router/hooks/useRoute.d.ts +1 -0
  210. package/presentation/router/hooks/useRoute.js +16 -23
  211. package/presentation/router/hooks/useRoute.js.map +1 -1
  212. package/presentation/router/hooks/useRouter.d.ts +1 -0
  213. package/presentation/router/hooks/useRouter.js +23 -23
  214. package/presentation/router/hooks/useRouter.js.map +1 -1
  215. package/presentation/router/index.d.ts +2 -0
  216. package/presentation/router/index.js +1 -2
  217. package/presentation/router/types.js +0 -3
  218. package/renderApp.js +7 -6
  219. package/renderApp.js.map +1 -1
  220. package/router.js +0 -3
  221. package/rslib-runtime.js +14 -0
  222. package/rslib-runtime.js.map +1 -0
  223. package/shared/di/DiContainerProvider.js +8 -12
  224. package/shared/di/DiContainerProvider.js.map +1 -1
  225. package/shared/di/createFeature.js +7 -8
  226. package/shared/di/createFeature.js.map +1 -1
  227. package/shared/di/useFeature.js +7 -3
  228. package/shared/di/useFeature.js.map +1 -1
  229. package/static/svg/close_24px.33adaadc.svg +1 -0
  230. package/types.d.ts +0 -21
  231. package/types.js +0 -3
  232. package/utils/createGenericContext.js +17 -21
  233. package/utils/createGenericContext.js.map +1 -1
  234. package/utils/createHashing.js +13 -16
  235. package/utils/createHashing.js.map +1 -1
  236. package/utils/index.js +0 -2
  237. package/utils/legacyPluginToReactComponent.js +11 -10
  238. package/utils/legacyPluginToReactComponent.js.map +1 -1
  239. package/apollo-client/InMemoryCache.d.ts +0 -8
  240. package/apollo-client/InMemoryCache.js +0 -20
  241. package/apollo-client/InMemoryCache.js.map +0 -1
  242. package/apollo-client/IntrospectionFragmentMatcher.d.ts +0 -11
  243. package/apollo-client/IntrospectionFragmentMatcher.js +0 -45
  244. package/apollo-client/IntrospectionFragmentMatcher.js.map +0 -1
  245. package/components/index.js.map +0 -1
  246. package/errors/index.js.map +0 -1
  247. package/exports/admin/env-config.js.map +0 -1
  248. package/exports/admin/graphql-client.js.map +0 -1
  249. package/exports/admin/local-storage.js.map +0 -1
  250. package/exports/admin/router.js.map +0 -1
  251. package/exports/admin/security.js.map +0 -1
  252. package/exports/admin.js.map +0 -1
  253. package/features/envConfig/index.js.map +0 -1
  254. package/features/eventPublisher/index.js.map +0 -1
  255. package/features/graphqlClient/index.js.map +0 -1
  256. package/features/graphqlClient/types.js.map +0 -1
  257. package/features/localStorage/index.js.map +0 -1
  258. package/features/mainGraphQLClient/index.js.map +0 -1
  259. package/features/router/index.js.map +0 -1
  260. package/helpers/InterfaceGenerator/date.js.map +0 -1
  261. package/helpers/InterfaceGenerator/id.js.map +0 -1
  262. package/helpers/InterfaceGenerator/identity.js.map +0 -1
  263. package/helpers/InterfaceGenerator/index.js.map +0 -1
  264. package/helpers/InterfaceGenerator/numeric.js.map +0 -1
  265. package/helpers/InterfaceGenerator/truthful.js.map +0 -1
  266. package/hooks/useAutocomplete/index.d.ts +0 -1
  267. package/hooks/useAutocomplete/index.js +0 -3
  268. package/hooks/useAutocomplete/index.js.map +0 -1
  269. package/hooks/useAutocomplete/useAutocomplete.d.ts +0 -11
  270. package/hooks/useAutocomplete/useAutocomplete.js +0 -20
  271. package/hooks/useAutocomplete/useAutocomplete.js.map +0 -1
  272. package/hooks/useDataList/functions/getData.d.ts +0 -2
  273. package/hooks/useDataList/functions/getData.js +0 -4
  274. package/hooks/useDataList/functions/getData.js.map +0 -1
  275. package/hooks/useDataList/functions/getError.d.ts +0 -2
  276. package/hooks/useDataList/functions/getError.js +0 -4
  277. package/hooks/useDataList/functions/getError.js.map +0 -1
  278. package/hooks/useDataList/functions/getMeta.d.ts +0 -2
  279. package/hooks/useDataList/functions/getMeta.js +0 -4
  280. package/hooks/useDataList/functions/getMeta.js.map +0 -1
  281. package/hooks/useDataList/functions/index.d.ts +0 -3
  282. package/hooks/useDataList/functions/index.js +0 -5
  283. package/hooks/useDataList/functions/index.js.map +0 -1
  284. package/hooks/useDataList/functions/searchDataByKey.d.ts +0 -2
  285. package/hooks/useDataList/functions/searchDataByKey.js +0 -18
  286. package/hooks/useDataList/functions/searchDataByKey.js.map +0 -1
  287. package/hooks/useDataList/index.d.ts +0 -1
  288. package/hooks/useDataList/index.js +0 -3
  289. package/hooks/useDataList/index.js.map +0 -1
  290. package/hooks/useDataList/useDataList.d.ts +0 -35
  291. package/hooks/useDataList/useDataList.js +0 -163
  292. package/hooks/useDataList/useDataList.js.map +0 -1
  293. package/hooks/useDataList/utils/index.d.ts +0 -1
  294. package/hooks/useDataList/utils/index.js +0 -3
  295. package/hooks/useDataList/utils/index.js.map +0 -1
  296. package/hooks/useDataList/utils/prepareLoadListParams.d.ts +0 -10
  297. package/hooks/useDataList/utils/prepareLoadListParams.js +0 -38
  298. package/hooks/useDataList/utils/prepareLoadListParams.js.map +0 -1
  299. package/i18n/index.js.map +0 -1
  300. package/index.js.map +0 -1
  301. package/plugins/AddQuerySelectionPlugin.d.ts +0 -22
  302. package/plugins/AddQuerySelectionPlugin.js +0 -72
  303. package/plugins/AddQuerySelectionPlugin.js.map +0 -1
  304. package/plugins/ApolloCacheObjectIdPlugin.d.ts +0 -15
  305. package/plugins/ApolloCacheObjectIdPlugin.js +0 -16
  306. package/plugins/ApolloCacheObjectIdPlugin.js.map +0 -1
  307. package/plugins/ApolloDynamicLink.d.ts +0 -7
  308. package/plugins/ApolloDynamicLink.js +0 -31
  309. package/plugins/ApolloDynamicLink.js.map +0 -1
  310. package/plugins/ApolloLinkPlugin.d.ts +0 -13
  311. package/plugins/ApolloLinkPlugin.js +0 -22
  312. package/plugins/ApolloLinkPlugin.js.map +0 -1
  313. package/plugins/ConsoleLinkPlugin.d.ts +0 -8
  314. package/plugins/ConsoleLinkPlugin.js +0 -26
  315. package/plugins/ConsoleLinkPlugin.js.map +0 -1
  316. package/plugins/NetworkErrorLinkPlugin/ErrorOverlay.js +0 -55
  317. package/plugins/NetworkErrorLinkPlugin/ErrorOverlay.js.map +0 -1
  318. package/plugins/NetworkErrorLinkPlugin/GqlErrorOverlay.js +0 -31
  319. package/plugins/NetworkErrorLinkPlugin/GqlErrorOverlay.js.map +0 -1
  320. package/plugins/NetworkErrorLinkPlugin/LocalAwsLambdaTimeoutMessage.js +0 -31
  321. package/plugins/NetworkErrorLinkPlugin/LocalAwsLambdaTimeoutMessage.js.map +0 -1
  322. package/plugins/NetworkErrorLinkPlugin/StyledComponents.d.ts +0 -8
  323. package/plugins/NetworkErrorLinkPlugin/StyledComponents.js +0 -78
  324. package/plugins/NetworkErrorLinkPlugin/StyledComponents.js.map +0 -1
  325. package/plugins/NetworkErrorLinkPlugin/Typography.js +0 -18
  326. package/plugins/NetworkErrorLinkPlugin/Typography.js.map +0 -1
  327. package/plugins/NetworkErrorLinkPlugin/createErrorOverlay.js +0 -22
  328. package/plugins/NetworkErrorLinkPlugin/createErrorOverlay.js.map +0 -1
  329. package/plugins/NetworkErrorLinkPlugin.d.ts +0 -10
  330. package/plugins/NetworkErrorLinkPlugin.js +0 -70
  331. package/plugins/NetworkErrorLinkPlugin.js.map +0 -1
  332. package/plugins/OmitTypenameLinkPlugin.d.ts +0 -8
  333. package/plugins/OmitTypenameLinkPlugin.js +0 -21
  334. package/plugins/OmitTypenameLinkPlugin.js.map +0 -1
  335. package/plugins/TenantHeaderLinkPlugin.d.ts +0 -10
  336. package/plugins/TenantHeaderLinkPlugin.js +0 -37
  337. package/plugins/TenantHeaderLinkPlugin.js.map +0 -1
  338. package/presentation/localStorage/index.js.map +0 -1
  339. package/presentation/router/index.js.map +0 -1
  340. package/presentation/router/types.js.map +0 -1
  341. package/react-butterfiles/Files.d.ts +0 -69
  342. package/react-butterfiles/Files.js +0 -227
  343. package/react-butterfiles/Files.js.map +0 -1
  344. package/react-butterfiles/file.todo +0 -1
  345. package/react-butterfiles/index.d.ts +0 -2
  346. package/react-butterfiles/index.js +0 -4
  347. package/react-butterfiles/index.js.map +0 -1
  348. package/react-butterfiles/utils/generateId.d.ts +0 -1
  349. package/react-butterfiles/utils/generateId.js +0 -5
  350. package/react-butterfiles/utils/generateId.js.map +0 -1
  351. package/react-butterfiles/utils/readFileContent.d.ts +0 -1
  352. package/react-butterfiles/utils/readFileContent.js +0 -15
  353. package/react-butterfiles/utils/readFileContent.js.map +0 -1
  354. package/router.js.map +0 -1
  355. package/types.js.map +0 -1
  356. package/utils/index.js.map +0 -1
  357. /package/{plugins/NetworkErrorLinkPlugin → errors/overlay}/ErrorOverlay.d.ts +0 -0
  358. /package/{plugins/NetworkErrorLinkPlugin → errors/overlay}/GqlErrorOverlay.d.ts +0 -0
  359. /package/{plugins/NetworkErrorLinkPlugin → errors/overlay}/LocalAwsLambdaTimeoutMessage.d.ts +0 -0
  360. /package/{plugins/NetworkErrorLinkPlugin → errors/overlay}/Typography.d.ts +0 -0
  361. /package/{plugins/NetworkErrorLinkPlugin → errors/overlay}/assets/close_24px.svg +0 -0
  362. /package/{plugins/NetworkErrorLinkPlugin → errors/overlay}/createErrorOverlay.d.ts +0 -0
package/App.js CHANGED
@@ -1,89 +1,82 @@
1
- import React, { createContext, Fragment, useCallback, useContext, useEffect, useMemo, useState } from "react";
2
- import { compose, CompositionProvider } from "@webiny/react-composition";
1
+ import react, { Fragment, createContext, useCallback, useContext, useEffect, useMemo, useState } from "react";
2
+ import { CompositionProvider, compose } from "@webiny/react-composition";
3
3
  import { PluginsProvider } from "./core/Plugins.js";
4
4
  import { RouterWithConfig, useRouterConfig } from "./config/RouterConfig.js";
5
5
  import { AppContainer } from "./AppContainer.js";
6
6
  import { RouteContent } from "./presentation/router/components/RouteContent.js";
7
7
  import { useRouter } from "./router.js";
8
- const AppContext = /*#__PURE__*/createContext(undefined);
8
+ const AppContext = /*#__PURE__*/ createContext(void 0);
9
9
  AppContext.displayName = "AppContext";
10
- export const useApp = () => {
11
- const appContext = useContext(AppContext);
12
- if (!appContext) {
13
- throw Error(`AppContext provider was not found. Are you using the "useApp()" hook in the right place?`);
14
- }
15
- return appContext;
10
+ const useApp = ()=>{
11
+ const appContext = useContext(AppContext);
12
+ if (!appContext) throw Error('AppContext provider was not found. Are you using the "useApp()" hook in the right place?');
13
+ return appContext;
16
14
  };
17
- export const AppBase = /*#__PURE__*/React.memo(({
18
- routes = [],
19
- plugins = [],
20
- providers = [],
21
- children
22
- }) => {
23
- const [state, setState] = useState({
24
- plugins,
25
- providers
26
- });
27
- const addProvider = useCallback(component => {
28
- setState(state => {
29
- if (state.providers.findIndex(m => m === component) > -1) {
30
- return state;
31
- }
32
- return {
33
- ...state,
34
- providers: [...state.providers, component]
35
- };
15
+ const AppBase = /*#__PURE__*/ react.memo(({ routes = [], plugins = [], providers = [], children })=>{
16
+ const [state, setState] = useState({
17
+ plugins,
18
+ providers
36
19
  });
37
- }, []);
38
- const addPlugin = useCallback(element => {
39
- setState(state => {
40
- return {
41
- ...state,
42
- plugins: [...state.plugins, element]
43
- };
44
- });
45
- }, []);
46
- const appContext = useMemo(() => ({
47
- ...state,
48
- addProvider,
49
- addPlugin
50
- }), [state]);
51
- const AppRouter = useMemo(() => {
52
- return function AppRouter() {
53
- const router = useRouter();
54
- const routerConfig = useRouterConfig();
55
- const routesFromConfig = routerConfig.routes;
56
- const combinedRoutes = [...routes, ...routesFromConfig];
57
- useEffect(() => {
58
- router.setRoutes(combinedRoutes);
59
- }, [combinedRoutes.length]);
60
- return null;
61
- };
62
- }, []);
63
- const Providers = useMemo(() => {
64
- return /*#__PURE__*/React.memo(compose(...(state.providers || []))(({
65
- children
66
- }) => {
67
- return /*#__PURE__*/React.createElement(React.Fragment, null, children);
68
- }));
69
- }, [state.providers.length]);
70
- Providers.displayName = "Providers";
71
- return /*#__PURE__*/React.createElement(AppContext.Provider, {
72
- value: appContext
73
- }, children, /*#__PURE__*/React.createElement(AppContainer, null, /*#__PURE__*/React.createElement(Providers, null, /*#__PURE__*/React.createElement(PluginsProvider, null, state.plugins.map((plugin, index) => /*#__PURE__*/React.createElement(Fragment, {
74
- key: index
75
- }, plugin))), /*#__PURE__*/React.createElement(RouterWithConfig, null, /*#__PURE__*/React.createElement(AppRouter, null), /*#__PURE__*/React.createElement(RouteContent, null)))));
20
+ const addProvider = useCallback((component)=>{
21
+ setState((state)=>{
22
+ if (state.providers.findIndex((m)=>m === component) > -1) return state;
23
+ return {
24
+ ...state,
25
+ providers: [
26
+ ...state.providers,
27
+ component
28
+ ]
29
+ };
30
+ });
31
+ }, []);
32
+ const addPlugin = useCallback((element)=>{
33
+ setState((state)=>({
34
+ ...state,
35
+ plugins: [
36
+ ...state.plugins,
37
+ element
38
+ ]
39
+ }));
40
+ }, []);
41
+ const appContext = useMemo(()=>({
42
+ ...state,
43
+ addProvider,
44
+ addPlugin
45
+ }), [
46
+ state
47
+ ]);
48
+ const AppRouter = useMemo(()=>function() {
49
+ const router = useRouter();
50
+ const routerConfig = useRouterConfig();
51
+ const routesFromConfig = routerConfig.routes;
52
+ const combinedRoutes = [
53
+ ...routes,
54
+ ...routesFromConfig
55
+ ];
56
+ useEffect(()=>{
57
+ router.setRoutes(combinedRoutes);
58
+ }, [
59
+ combinedRoutes.length
60
+ ]);
61
+ return null;
62
+ }, []);
63
+ const Providers = useMemo(()=>/*#__PURE__*/ react.memo(compose(...state.providers || [])(({ children })=>/*#__PURE__*/ react.createElement(react.Fragment, null, children))), [
64
+ state.providers.length
65
+ ]);
66
+ Providers.displayName = "Providers";
67
+ return /*#__PURE__*/ react.createElement(AppContext.Provider, {
68
+ value: appContext
69
+ }, children, /*#__PURE__*/ react.createElement(AppContainer, null, /*#__PURE__*/ react.createElement(Providers, null, /*#__PURE__*/ react.createElement(PluginsProvider, null, state.plugins.map((plugin, index)=>/*#__PURE__*/ react.createElement(Fragment, {
70
+ key: index
71
+ }, plugin))), /*#__PURE__*/ react.createElement(RouterWithConfig, null, /*#__PURE__*/ react.createElement(AppRouter, null), /*#__PURE__*/ react.createElement(RouteContent, null)))));
76
72
  });
77
73
  AppBase.displayName = "AppBase";
78
- export const App = ({
79
- decorators,
80
- ...props
81
- }) => {
82
- return /*#__PURE__*/React.createElement(CompositionProvider, {
83
- decorators: decorators
84
- }, /*#__PURE__*/React.createElement(AppBase, Object.assign({
85
- decorators: decorators
86
- }, props)));
87
- };
74
+ const App = ({ decorators, ...props })=>/*#__PURE__*/ react.createElement(CompositionProvider, {
75
+ decorators: decorators
76
+ }, /*#__PURE__*/ react.createElement(AppBase, {
77
+ decorators: decorators,
78
+ ...props
79
+ }));
80
+ export { App, AppBase, useApp };
88
81
 
89
82
  //# sourceMappingURL=App.js.map
package/App.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"names":["React","createContext","Fragment","useCallback","useContext","useEffect","useMemo","useState","compose","CompositionProvider","PluginsProvider","RouterWithConfig","useRouterConfig","AppContainer","RouteContent","useRouter","AppContext","undefined","displayName","useApp","appContext","Error","AppBase","memo","routes","plugins","providers","children","state","setState","addProvider","component","findIndex","m","addPlugin","element","AppRouter","router","routerConfig","routesFromConfig","combinedRoutes","setRoutes","length","Providers","createElement","Provider","value","map","plugin","index","key","App","decorators","props","Object","assign"],"sources":["App.tsx"],"sourcesContent":["import React, {\n createContext,\n Fragment,\n useCallback,\n useContext,\n useEffect,\n useMemo,\n useState\n} from \"react\";\nimport {\n compose,\n CompositionProvider,\n Decorator,\n DecoratorsCollection,\n GenericComponent\n} from \"@webiny/react-composition\";\nimport { PluginsProvider } from \"./core/Plugins.js\";\nimport { RouterWithConfig, useRouterConfig } from \"./config/RouterConfig.js\";\nimport { AppContainer } from \"./AppContainer.js\";\nimport { RouteContent } from \"~/presentation/router/components/RouteContent.js\";\nimport { useRouter } from \"~/router.js\";\n\ninterface State {\n plugins: React.JSX.Element[];\n providers: Decorator<GenericComponent<ProviderProps>>[];\n}\n\ninterface AppContext extends State {\n addProvider(hoc: Decorator<GenericComponent<ProviderProps>>): void;\n addPlugin(plugin: React.ReactNode): void;\n}\n\nconst AppContext = createContext<AppContext | undefined>(undefined);\n\nAppContext.displayName = \"AppContext\";\n\nexport const useApp = () => {\n const appContext = useContext(AppContext);\n if (!appContext) {\n throw Error(\n `AppContext provider was not found. Are you using the \"useApp()\" hook in the right place?`\n );\n }\n return appContext;\n};\n\nexport interface AppProps {\n routes?: Array<any>;\n plugins?: any[];\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 = React.memo(\n ({ routes = [], plugins = [], providers = [], children }: 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: React.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 router = useRouter();\n const routerConfig = useRouterConfig();\n const routesFromConfig = routerConfig.routes;\n const combinedRoutes = [...routes, ...routesFromConfig];\n\n useEffect(() => {\n router.setRoutes(combinedRoutes);\n }, [combinedRoutes.length]);\n\n return null;\n };\n }, []);\n\n const Providers = useMemo(() => {\n return React.memo(\n compose(...(state.providers || []))(({ children }: ProviderProps) => {\n return <>{children}</>;\n })\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 <Providers>\n <PluginsProvider>\n {state.plugins.map((plugin, index) => (\n <Fragment key={index}>{plugin}</Fragment>\n ))}\n </PluginsProvider>\n <RouterWithConfig>\n <AppRouter />\n <RouteContent />\n </RouterWithConfig>\n </Providers>\n </AppContainer>\n </AppContext.Provider>\n );\n }\n);\n\nAppBase.displayName = \"AppBase\";\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":[]}
1
+ {"version":3,"file":"App.js","sources":["../src/App.tsx"],"sourcesContent":["import React, {\n createContext,\n Fragment,\n useCallback,\n useContext,\n useEffect,\n useMemo,\n useState\n} from \"react\";\nimport {\n compose,\n CompositionProvider,\n Decorator,\n DecoratorsCollection,\n GenericComponent\n} from \"@webiny/react-composition\";\nimport { PluginsProvider } from \"./core/Plugins.js\";\nimport { RouterWithConfig, useRouterConfig } from \"./config/RouterConfig.js\";\nimport { AppContainer } from \"./AppContainer.js\";\nimport { RouteContent } from \"~/presentation/router/components/RouteContent.js\";\nimport { useRouter } from \"~/router.js\";\n\ninterface State {\n plugins: React.JSX.Element[];\n providers: Decorator<GenericComponent<ProviderProps>>[];\n}\n\ninterface AppContext extends State {\n addProvider(hoc: Decorator<GenericComponent<ProviderProps>>): void;\n addPlugin(plugin: React.ReactNode): void;\n}\n\nconst AppContext = createContext<AppContext | undefined>(undefined);\n\nAppContext.displayName = \"AppContext\";\n\nexport const useApp = () => {\n const appContext = useContext(AppContext);\n if (!appContext) {\n throw Error(\n `AppContext provider was not found. Are you using the \"useApp()\" hook in the right place?`\n );\n }\n return appContext;\n};\n\nexport interface AppProps {\n routes?: Array<any>;\n plugins?: any[];\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 = React.memo(\n ({ routes = [], plugins = [], providers = [], children }: 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: React.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 router = useRouter();\n const routerConfig = useRouterConfig();\n const routesFromConfig = routerConfig.routes;\n const combinedRoutes = [...routes, ...routesFromConfig];\n\n useEffect(() => {\n router.setRoutes(combinedRoutes);\n }, [combinedRoutes.length]);\n\n return null;\n };\n }, []);\n\n const Providers = useMemo(() => {\n return React.memo(\n compose(...(state.providers || []))(({ children }: ProviderProps) => {\n return <>{children}</>;\n })\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 <Providers>\n <PluginsProvider>\n {state.plugins.map((plugin, index) => (\n <Fragment key={index}>{plugin}</Fragment>\n ))}\n </PluginsProvider>\n <RouterWithConfig>\n <AppRouter />\n <RouteContent />\n </RouterWithConfig>\n </Providers>\n </AppContainer>\n </AppContext.Provider>\n );\n }\n);\n\nAppBase.displayName = \"AppBase\";\n\nexport const App = ({ decorators, ...props }: AppProps) => {\n return (\n <CompositionProvider decorators={decorators}>\n <AppBase decorators={decorators} {...props} />\n </CompositionProvider>\n );\n};\n"],"names":["AppContext","createContext","undefined","useApp","appContext","useContext","Error","AppBase","React","routes","plugins","providers","children","state","setState","useState","addProvider","useCallback","component","m","addPlugin","element","useMemo","AppRouter","router","useRouter","routerConfig","useRouterConfig","routesFromConfig","combinedRoutes","useEffect","Providers","compose","AppContainer","PluginsProvider","plugin","index","Fragment","RouterWithConfig","RouteContent","App","decorators","props","CompositionProvider"],"mappings":";;;;;;;AAgCA,MAAMA,aAAa,WAAHA,GAAGC,cAAsCC;AAEzDF,WAAW,WAAW,GAAG;AAElB,MAAMG,SAAS;IAClB,MAAMC,aAAaC,WAAWL;IAC9B,IAAI,CAACI,YACD,MAAME,MACF;IAGR,OAAOF;AACX;AAgBO,MAAMG,UAAU,WAAHA,GAAGC,MAAAA,IAAU,CAC7B,CAAC,EAAEC,SAAS,EAAE,EAAEC,UAAU,EAAE,EAAEC,YAAY,EAAE,EAAEC,QAAQ,EAAY;IAC9D,MAAM,CAACC,OAAOC,SAAS,GAAGC,SAAgB;QACtCL;QACAC;IACJ;IAEA,MAAMK,cAAcC,YAAY,CAACC;QAC7BJ,SAASD,CAAAA;YACL,IAAIA,MAAM,SAAS,CAAC,SAAS,CAACM,CAAAA,IAAKA,MAAMD,aAAa,IAClD,OAAOL;YAGX,OAAO;gBACH,GAAGA,KAAK;gBACR,WAAW;uBAAIA,MAAM,SAAS;oBAAEK;iBAAU;YAC9C;QACJ;IACJ,GAAG,EAAE;IAEL,MAAME,YAAYH,YAAY,CAACI;QAC3BP,SAASD,CAAAA,QACE;gBACH,GAAGA,KAAK;gBACR,SAAS;uBAAIA,MAAM,OAAO;oBAAEQ;iBAAQ;YACxC;IAER,GAAG,EAAE;IAEL,MAAMjB,aAAakB,QACf,IAAO;YACH,GAAGT,KAAK;YACRG;YACAI;QACJ,IACA;QAACP;KAAM;IAGX,MAAMU,YAAYD,QAAQ,IACf;YACH,MAAME,SAASC;YACf,MAAMC,eAAeC;YACrB,MAAMC,mBAAmBF,aAAa,MAAM;YAC5C,MAAMG,iBAAiB;mBAAIpB;mBAAWmB;aAAiB;YAEvDE,UAAU;gBACNN,OAAO,SAAS,CAACK;YACrB,GAAG;gBAACA,eAAe,MAAM;aAAC;YAE1B,OAAO;QACX,GACD,EAAE;IAEL,MAAME,YAAYT,QAAQ,IACf,WAAP,GAAOd,MAAAA,IAAU,CACbwB,WAAYnB,MAAM,SAAS,IAAI,EAAE,EAAG,CAAC,EAAED,QAAQ,EAAiB,GACrD,WAAP,GAAO,0CAAGA,aAGnB;QAACC,MAAM,SAAS,CAAC,MAAM;KAAC;IAE3BkB,UAAU,WAAW,GAAG;IAExB,OAAO,WAAP,GACI,oBAAC/B,WAAW,QAAQ;QAAC,OAAOI;OACvBQ,UAAAA,WAAAA,GACD,oBAACqB,cAAYA,MAAAA,WAAAA,GACT,oBAACF,WAAAA,MAAAA,WAAAA,GACG,oBAACG,iBAAeA,MACXrB,MAAM,OAAO,CAAC,GAAG,CAAC,CAACsB,QAAQC,QAAAA,WAAAA,GACxB,oBAACC,UAAQA;YAAC,KAAKD;WAAQD,WAAAA,WAAAA,GAG/B,oBAACG,kBAAgBA,MAAAA,WAAAA,GACb,oBAACf,WAAAA,OAAAA,WAAAA,GACD,oBAACgB,cAAYA;AAMrC;AAGJhC,QAAQ,WAAW,GAAG;AAEf,MAAMiC,MAAM,CAAC,EAAEC,UAAU,EAAE,GAAGC,OAAiB,GAC3C,WAAP,GACI,oBAACC,qBAAmBA;QAAC,YAAYF;qBAC7B,oBAAClC,SAAOA;QAAC,YAAYkC;QAAa,GAAGC,KAAK"}
package/AppContainer.js CHANGED
@@ -1,9 +1,6 @@
1
- import React from "react";
1
+ import react from "react";
2
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
- });
3
+ const AppContainer = makeDecoratable("AppContainer", ({ children })=>/*#__PURE__*/ react.createElement(react.Fragment, null, children));
4
+ export { AppContainer };
8
5
 
9
6
  //# sourceMappingURL=AppContainer.js.map
@@ -1 +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
+ {"version":3,"file":"AppContainer.js","sources":["../src/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"],"names":["AppContainer","makeDecoratable","children"],"mappings":";;AAOO,MAAMA,eAAeC,gBAAgB,gBAAgB,CAAC,EAAEC,QAAQ,EAAmB,GAC/E,WAAP,GAAO,0CAAGA"}
@@ -1,23 +1,17 @@
1
1
  import invariant from "invariant";
2
2
  import { plugins } from "@webiny/plugins";
3
3
  import get from "lodash/get.js";
4
- export const Image = ({
5
- preset: presetName,
6
- ...props
7
- }) => {
8
- const plugin = plugins.byName("image-component");
9
- if (!plugin) {
10
- throw new Error(`Image component plugin (type "image-component") not defined.`);
11
- }
12
- if (presetName) {
13
- const preset = get(plugin, `presets.${presetName}`);
14
- invariant(preset, `Transform preset "${presetName}" not found.`);
15
- props.transform = preset;
16
- }
17
- if (props.transform) {
18
- props.src = plugin.getImageSrc(props);
19
- }
20
- return plugin.render(props);
4
+ const Image = ({ preset: presetName, ...props })=>{
5
+ const plugin = plugins.byName("image-component");
6
+ if (!plugin) throw new Error('Image component plugin (type "image-component") not defined.');
7
+ if (presetName) {
8
+ const preset = get(plugin, `presets.${presetName}`);
9
+ invariant(preset, `Transform preset "${presetName}" not found.`);
10
+ props.transform = preset;
11
+ }
12
+ if (props.transform) props.src = plugin.getImageSrc(props);
13
+ return plugin.render(props);
21
14
  };
15
+ export { Image };
22
16
 
23
17
  //# sourceMappingURL=Image.js.map
@@ -1 +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.js\";\nimport type { ImageComponentPlugin, ImageProps } from \"~/types.js\";\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,eAAe;AAG/B,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
+ {"version":3,"file":"components/Image.js","sources":["../../src/components/Image.tsx"],"sourcesContent":["import invariant from \"invariant\";\nimport { plugins } from \"@webiny/plugins\";\nimport get from \"lodash/get.js\";\nimport type { ImageComponentPlugin, ImageProps } from \"~/types.js\";\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"],"names":["Image","presetName","props","plugin","plugins","Error","preset","get","invariant"],"mappings":";;;AAKO,MAAMA,QAAQ,CAAC,EAAE,QAAQC,UAAU,EAAE,GAAGC,OAAmB;IAC9D,MAAMC,SAASC,QAAQ,MAAM,CAAuB;IACpD,IAAI,CAACD,QACD,MAAM,IAAIE,MAAM;IAGpB,IAAIJ,YAAY;QACZ,MAAMK,SAASC,IAAIJ,QAAQ,CAAC,QAAQ,EAAEF,YAAY;QAClDO,UAAUF,QAAQ,CAAC,kBAAkB,EAAEL,WAAW,YAAY,CAAC;QAC/DC,MAAM,SAAS,GAAGI;IACtB;IAEA,IAAIJ,MAAM,SAAS,EACfA,MAAM,GAAG,GAAGC,OAAO,WAAW,CAACD;IAGnC,OAAOC,OAAO,MAAM,CAACD;AACzB"}
@@ -1,3 +1 @@
1
1
  export { Image } from "./Image.js";
2
-
3
- //# sourceMappingURL=index.js.map
@@ -1,33 +1,28 @@
1
- import React from "react";
1
+ import react from "react";
2
2
  import { makeDecoratable } from "@webiny/react-composition";
3
3
  import { Property, useIdGenerator } from "@webiny/react-properties";
4
- export const Route = makeDecoratable("Route", ({
5
- route,
6
- element,
7
- remove,
8
- before,
9
- after
10
- }) => {
11
- const name = route.name;
12
- const getId = useIdGenerator("Route");
13
- const placeAfter = after !== undefined ? getId(after) : undefined;
14
- const placeBefore = before !== undefined ? getId(before) : undefined;
15
- return /*#__PURE__*/React.createElement(Property, {
16
- id: getId(name),
17
- name: "routes",
18
- remove: remove,
19
- array: true,
20
- before: placeBefore,
21
- after: placeAfter
22
- }, /*#__PURE__*/React.createElement(Property, {
23
- id: getId(name, "route"),
24
- name: "route",
25
- value: route
26
- }), /*#__PURE__*/React.createElement(Property, {
27
- id: getId(name, "element"),
28
- name: "element",
29
- value: element
30
- }));
4
+ const Route = makeDecoratable("Route", ({ route, element, remove, before, after })=>{
5
+ const name = route.name;
6
+ const getId = useIdGenerator("Route");
7
+ const placeAfter = void 0 !== after ? getId(after) : void 0;
8
+ const placeBefore = void 0 !== before ? getId(before) : void 0;
9
+ return /*#__PURE__*/ react.createElement(Property, {
10
+ id: getId(name),
11
+ name: "routes",
12
+ remove: remove,
13
+ array: true,
14
+ before: placeBefore,
15
+ after: placeAfter
16
+ }, /*#__PURE__*/ react.createElement(Property, {
17
+ id: getId(name, "route"),
18
+ name: "route",
19
+ value: route
20
+ }), /*#__PURE__*/ react.createElement(Property, {
21
+ id: getId(name, "element"),
22
+ name: "element",
23
+ value: element
24
+ }));
31
25
  });
26
+ export { Route };
32
27
 
33
28
  //# sourceMappingURL=Route.js.map
@@ -1 +1 @@
1
- {"version":3,"names":["React","makeDecoratable","Property","useIdGenerator","Route","route","element","remove","before","after","name","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\";\nimport type { Route as BaseRoute } from \"~/router.js\";\n\nexport interface RouteProps {\n route: BaseRoute<any>;\n element: React.ReactElement;\n remove?: boolean;\n before?: string;\n after?: string;\n}\n\nexport type RouteConfig = Pick<RouteProps, \"route\" | \"element\">;\n\nexport const Route = makeDecoratable(\n \"Route\",\n ({ route, element, remove, before, after }: RouteProps) => {\n const name = route.name;\n\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, \"route\")} name={\"route\"} value={route} />\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;AAanE,OAAO,MAAMC,KAAK,GAAGH,eAAe,CAChC,OAAO,EACP,CAAC;EAAEI,KAAK;EAAEC,OAAO;EAAEC,MAAM;EAAEC,MAAM;EAAEC;AAAkB,CAAC,KAAK;EACvD,MAAMC,IAAI,GAAGL,KAAK,CAACK,IAAI;EAEvB,MAAMC,KAAK,GAAGR,cAAc,CAAC,OAAO,CAAC;EAErC,MAAMS,UAAU,GAAGH,KAAK,KAAKI,SAAS,GAAGF,KAAK,CAACF,KAAK,CAAC,GAAGI,SAAS;EACjE,MAAMC,WAAW,GAAGN,MAAM,KAAKK,SAAS,GAAGF,KAAK,CAACH,MAAM,CAAC,GAAGK,SAAS;EAEpE,oBACIb,KAAA,CAAAe,aAAA,CAACb,QAAQ;IACLc,EAAE,EAAEL,KAAK,CAACD,IAAI,CAAE;IAChBA,IAAI,EAAE,QAAS;IACfH,MAAM,EAAEA,MAAO;IACfU,KAAK,EAAE,IAAK;IACZT,MAAM,EAAEM,WAAY;IACpBL,KAAK,EAAEG;EAAW,gBAElBZ,KAAA,CAAAe,aAAA,CAACb,QAAQ;IAACc,EAAE,EAAEL,KAAK,CAACD,IAAI,EAAE,OAAO,CAAE;IAACA,IAAI,EAAE,OAAQ;IAACQ,KAAK,EAAEb;EAAM,CAAE,CAAC,eACnEL,KAAA,CAAAe,aAAA,CAACb,QAAQ;IAACc,EAAE,EAAEL,KAAK,CAACD,IAAI,EAAE,SAAS,CAAE;IAACA,IAAI,EAAE,SAAU;IAACQ,KAAK,EAAEZ;EAAQ,CAAE,CAClE,CAAC;AAEnB,CACJ,CAAC","ignoreList":[]}
1
+ {"version":3,"file":"config/RouterConfig/Route.js","sources":["../../../src/config/RouterConfig/Route.tsx"],"sourcesContent":["import React from \"react\";\nimport { makeDecoratable } from \"@webiny/react-composition\";\nimport { Property, useIdGenerator } from \"@webiny/react-properties\";\nimport type { Route as BaseRoute } from \"~/router.js\";\n\nexport interface RouteProps {\n route: BaseRoute<any>;\n element: React.ReactElement;\n remove?: boolean;\n before?: string;\n after?: string;\n}\n\nexport type RouteConfig = Pick<RouteProps, \"route\" | \"element\">;\n\nexport const Route = makeDecoratable(\n \"Route\",\n ({ route, element, remove, before, after }: RouteProps) => {\n const name = route.name;\n\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, \"route\")} name={\"route\"} value={route} />\n <Property id={getId(name, \"element\")} name={\"element\"} value={element} />\n </Property>\n );\n }\n);\n"],"names":["Route","makeDecoratable","route","element","remove","before","after","name","getId","useIdGenerator","placeAfter","undefined","placeBefore","Property"],"mappings":";;;AAeO,MAAMA,QAAQC,gBACjB,SACA,CAAC,EAAEC,KAAK,EAAEC,OAAO,EAAEC,MAAM,EAAEC,MAAM,EAAEC,KAAK,EAAc;IAClD,MAAMC,OAAOL,MAAM,IAAI;IAEvB,MAAMM,QAAQC,eAAe;IAE7B,MAAMC,aAAaJ,AAAUK,WAAVL,QAAsBE,MAAMF,SAASK;IACxD,MAAMC,cAAcP,AAAWM,WAAXN,SAAuBG,MAAMH,UAAUM;IAE3D,OAAO,WAAP,GACI,oBAACE,UAAQA;QACL,IAAIL,MAAMD;QACV,MAAM;QACN,QAAQH;QACR,OAAO;QACP,QAAQQ;QACR,OAAOF;qBAEP,oBAACG,UAAQA;QAAC,IAAIL,MAAMD,MAAM;QAAU,MAAM;QAAS,OAAOL;sBAC1D,oBAACW,UAAQA;QAAC,IAAIL,MAAMD,MAAM;QAAY,MAAM;QAAW,OAAOJ;;AAG1E"}
@@ -25,7 +25,5 @@ export declare const RouterConfig: (({ priority, children }: import("@webiny/rea
25
25
  displayName: string;
26
26
  }>) => (props: unknown) => React.JSX.Element;
27
27
  };
28
- useRouterConfig: () => {
29
- routes: RouteConfig[];
30
- };
28
+ useRouterConfig: typeof useRouterConfig;
31
29
  };
@@ -1,18 +1,19 @@
1
1
  import { createConfigurableComponent } from "@webiny/react-properties";
2
2
  import { Route } from "./RouterConfig/Route.js";
3
3
  const base = createConfigurableComponent("RouterConfig");
4
- export const RouterWithConfig = Object.assign(base.WithConfig, {
5
- displayName: "RouterWithConfig"
4
+ const RouterWithConfig = Object.assign(base.WithConfig, {
5
+ displayName: "RouterWithConfig"
6
6
  });
7
- export const useRouterConfig = () => {
8
- const baseConfig = base.useConfig();
9
- return {
10
- routes: baseConfig.routes ?? []
11
- };
7
+ const useRouterConfig = ()=>{
8
+ const baseConfig = base.useConfig();
9
+ return {
10
+ routes: baseConfig.routes ?? []
11
+ };
12
12
  };
13
- export const RouterConfig = Object.assign(base.Config, {
14
- Route,
15
- useRouterConfig
13
+ const RouterConfig = Object.assign(base.Config, {
14
+ Route: Route,
15
+ useRouterConfig: useRouterConfig
16
16
  });
17
+ export { RouterConfig, RouterWithConfig, useRouterConfig };
17
18
 
18
19
  //# sourceMappingURL=RouterConfig.js.map
@@ -1 +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.js\";\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":[]}
1
+ {"version":3,"file":"config/RouterConfig.js","sources":["../../src/config/RouterConfig.tsx"],"sourcesContent":["import { createConfigurableComponent } from \"@webiny/react-properties\";\nimport { Route, type RouteConfig } from \"./RouterConfig/Route.js\";\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"],"names":["base","createConfigurableComponent","RouterWithConfig","Object","useRouterConfig","baseConfig","RouterConfig","Route"],"mappings":";;AAGA,MAAMA,OAAOC,4BAA0C;AAEhD,MAAMC,mBAAmBC,OAAO,MAAM,CAACH,KAAK,UAAU,EAAE;IAC3D,aAAa;AACjB;AAMO,MAAMI,kBAAkB;IAC3B,MAAMC,aAAaL,KAAK,SAAS;IAEjC,OAAO;QACH,QAAQK,WAAW,MAAM,IAAI,EAAE;IACnC;AACJ;AAEO,MAAMC,eAAeH,OAAO,MAAM,CAACH,KAAK,MAAM,EAAE;IACnDO,OAAKA;IACLH,iBAAAA;AACJ"}
package/config.js CHANGED
@@ -1,25 +1,24 @@
1
- const deepFreeze = obj => {
2
- Object.keys(obj).forEach(prop => {
3
- if (typeof obj[prop] === "object" && !Object.isFrozen(obj[prop])) {
4
- deepFreeze(obj[prop]);
5
- }
6
- });
7
- return Object.freeze(obj);
1
+ const deepFreeze = (obj)=>{
2
+ Object.keys(obj).forEach((prop)=>{
3
+ if ("object" == typeof obj[prop] && !Object.isFrozen(obj[prop])) deepFreeze(obj[prop]);
4
+ });
5
+ return Object.freeze(obj);
8
6
  };
9
7
  function createConfig() {
10
- let _config = {};
11
- return {
12
- set(config) {
13
- _config = deepFreeze(config);
14
- },
15
- get() {
16
- return _config;
17
- },
18
- getKey(key, defaultValue) {
19
- return key in _config ? _config[key] : defaultValue;
20
- }
21
- };
8
+ let _config = {};
9
+ return {
10
+ set (config) {
11
+ _config = deepFreeze(config);
12
+ },
13
+ get () {
14
+ return _config;
15
+ },
16
+ getKey (key, defaultValue) {
17
+ return key in _config ? _config[key] : defaultValue;
18
+ }
19
+ };
22
20
  }
23
- export const config = createConfig();
21
+ const config_config = createConfig();
22
+ export { config_config as config };
24
23
 
25
24
  //# 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,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
+ {"version":3,"file":"config.js","sources":["../src/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"],"names":["deepFreeze","obj","Object","prop","createConfig","_config","config","key","defaultValue"],"mappings":"AAQA,MAAMA,aAAa,CAACC;IAChBC,OAAO,IAAI,CAACD,KAAK,OAAO,CAACE,CAAAA;QACrB,IAAI,AAAqB,YAArB,OAAOF,GAAG,CAACE,KAAK,IAAiB,CAACD,OAAO,QAAQ,CAACD,GAAG,CAACE,KAAK,GAC3DH,WAAWC,GAAG,CAACE,KAAK;IAE5B;IACA,OAAOD,OAAO,MAAM,CAACD;AACzB;AAEA,SAASG;IACL,IAAIC,UAA+B,CAAC;IAEpC,OAAO;QACH,KAAIC,MAAc;YACdD,UAAUL,WAAWM;QACzB;QACA;YACI,OAAOD;QACX;QACA,QAAOE,GAAG,EAAEC,YAAY;YACpB,OAAOD,OAAOF,UAAUA,OAAO,CAACE,IAAI,GAAGC;QAC3C;IACJ;AACJ;AAEO,MAAMF,gBAASF"}
@@ -1,32 +1,30 @@
1
- import React from "react";
1
+ import react from "react";
2
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
- };
16
- });
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);
29
- }
3
+ const UiContext = /*#__PURE__*/ react.createContext({});
4
+ class UiProvider extends react.Component {
5
+ render() {
6
+ const value = {
7
+ ...this.state.ui,
8
+ setState: this.setData
9
+ };
10
+ const uiStatePlugins = plugins.byType("ui-state");
11
+ return /*#__PURE__*/ react.createElement(UiContext.Provider, {
12
+ value: value
13
+ }, uiStatePlugins.map((pl)=>/*#__PURE__*/ react.cloneElement(pl.render(), {
14
+ key: pl.name
15
+ })), this.props.children);
16
+ }
17
+ constructor(...args){
18
+ super(...args), this.state = {
19
+ ui: {}
20
+ }, this.setData = (setter)=>this.setState((state)=>({
21
+ ui: {
22
+ ...state.ui,
23
+ ...setter(state.ui)
24
+ }
25
+ }));
26
+ }
30
27
  }
28
+ export { UiContext, UiProvider };
31
29
 
32
30
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
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.js\";\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":[]}
1
+ {"version":3,"file":"contexts/Ui/index.js","sources":["../../../src/contexts/Ui/index.tsx"],"sourcesContent":["import React from \"react\";\nimport type { UiStatePlugin } from \"~/types.js\";\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"],"names":["UiContext","React","UiProvider","value","uiStatePlugins","plugins","pl","setter","state"],"mappings":";;AAIO,MAAMA,YAAY,WAAHA,GAAGC,MAAAA,aAAmB,CAAsB,CAAC;AAqB5D,MAAMC,mBAAmBD,MAAAA,SAAe;IAW3B,SAAS;QACrB,MAAME,QAAwB;YAAE,GAAG,IAAI,CAAC,KAAK,CAAC,EAAE;YAAE,UAAU,IAAI,CAAC,OAAO;QAAC;QACzE,MAAMC,iBAAiBC,QAAQ,MAAM,CAAgB;QACrD,OAAO,WAAP,GACI,oBAACL,UAAU,QAAQ;YAAC,OAAOG;WACtBC,eAAe,GAAG,CAACE,CAAAA,KAAAA,WAAAA,GAAML,MAAAA,YAAkB,CAACK,GAAG,MAAM,IAAI;gBAAE,KAAKA,GAAG,IAAI;YAAC,KACxE,IAAI,CAAC,KAAK,CAAC,QAAQ;IAGhC;;QApBG,qBACa,KAAK,GAAU;YAC3B,IAAI,CAAC;QACT,QAEiB,OAAO,GAAG,CAACC,SACjB,IAAI,CAAC,QAAQ,CAAC,CAACC,QACX;oBAAE,IAAI;wBAAE,GAAGA,MAAM,EAAE;wBAAE,GAAGD,OAAOC,MAAM,EAAE,CAAC;oBAAC;gBAAE;;AAc9D"}
package/core/Plugin.js CHANGED
@@ -1,14 +1,12 @@
1
- import React from "react";
1
+ import react from "react";
2
2
  import { Provider } from "./Provider.js";
3
3
  import { Plugins } from "./Plugins.js";
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);
4
+ const Plugin_Plugin = /*#__PURE__*/ react.memo(function({ providers, children }) {
5
+ return /*#__PURE__*/ react.createElement(react.Fragment, null, (providers || []).map((provider, index)=>/*#__PURE__*/ react.createElement(Provider, {
6
+ key: index,
7
+ hoc: provider
8
+ })), children ? /*#__PURE__*/ react.createElement(Plugins, null, children) : null);
12
9
  });
10
+ export { Plugin_Plugin as Plugin };
13
11
 
14
12
  //# sourceMappingURL=Plugin.js.map
@@ -1 +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.js\";\nimport { Plugins } from \"./Plugins.js\";\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":[]}
1
+ {"version":3,"file":"core/Plugin.js","sources":["../../src/core/Plugin.tsx"],"sourcesContent":["import React from \"react\";\nimport { Provider } from \"./Provider.js\";\nimport { Plugins } from \"./Plugins.js\";\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"],"names":["Plugin","React","providers","children","provider","index","Provider","Plugins"],"mappings":";;;AAUO,MAAMA,gBAAS,WAAHA,GAAGC,MAAAA,IAAU,CAAC,SAAgB,EAAEC,SAAS,EAAEC,QAAQ,EAAe;IACjF,OAAO,WAAP,GACI,0CACMD,AAAAA,CAAAA,aAAa,EAAC,EAAG,GAAG,CAAC,CAACE,UAAUC,QAAAA,WAAAA,GAC9B,oBAACC,UAAQA;YAAC,KAAKD;YAAO,KAAKD;aAE9BD,WAAW,WAAXA,GAAW,oBAACI,SAAOA,MAAEJ,YAAsB;AAGxD"}
package/core/Plugins.d.ts CHANGED
@@ -3,7 +3,8 @@ export declare const PluginsContext: React.Context<boolean>;
3
3
  interface PluginsProviderComponentProps {
4
4
  children: React.JSX.Element[];
5
5
  }
6
- export declare const PluginsProvider: React.MemoExoticComponent<({ children }: PluginsProviderComponentProps) => React.JSX.Element>;
6
+ declare const PluginsProviderComponent: ({ children }: PluginsProviderComponentProps) => React.JSX.Element;
7
+ export declare const PluginsProvider: React.MemoExoticComponent<typeof PluginsProviderComponent>;
7
8
  /**
8
9
  * @param children
9
10
  * @deprecated This component should not be used directly. Use the <Plugin> component to create plugins.