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

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (211) hide show
  1. package/App.d.ts +26 -0
  2. package/App.js +95 -0
  3. package/App.js.map +1 -0
  4. package/AppContainer.d.ts +23 -0
  5. package/AppContainer.js +9 -0
  6. package/AppContainer.js.map +1 -0
  7. package/apollo-client/InMemoryCache.d.ts +4 -3
  8. package/apollo-client/InMemoryCache.js +13 -52
  9. package/apollo-client/InMemoryCache.js.map +1 -0
  10. package/apollo-client/IntrospectionFragmentMatcher.d.ts +11 -0
  11. package/apollo-client/IntrospectionFragmentMatcher.js +45 -0
  12. package/apollo-client/IntrospectionFragmentMatcher.js.map +1 -0
  13. package/components/Image.d.ts +3 -3
  14. package/components/Image.js +12 -17
  15. package/components/Image.js.map +1 -0
  16. package/components/Routes.d.ts +2 -2
  17. package/components/Routes.js +20 -19
  18. package/components/Routes.js.map +1 -0
  19. package/components/View.d.ts +1 -1
  20. package/components/View.js +13 -17
  21. package/components/View.js.map +1 -0
  22. package/components/index.d.ts +1 -0
  23. package/components/index.js +4 -1
  24. package/components/index.js.map +1 -0
  25. package/config/RouterConfig/Route.d.ts +30 -0
  26. package/config/RouterConfig/Route.js +42 -0
  27. package/config/RouterConfig/Route.js.map +1 -0
  28. package/config/RouterConfig.d.ts +32 -0
  29. package/config/RouterConfig.js +18 -0
  30. package/config/RouterConfig.js.map +1 -0
  31. package/config.d.ts +8 -0
  32. package/config.js +25 -0
  33. package/config.js.map +1 -0
  34. package/contexts/Ui/index.d.ts +5 -8
  35. package/contexts/Ui/index.js +27 -64
  36. package/contexts/Ui/index.js.map +1 -0
  37. package/core/DebounceRender.d.ts +12 -0
  38. package/core/DebounceRender.js +31 -0
  39. package/core/DebounceRender.js.map +1 -0
  40. package/core/Plugin.d.ts +8 -0
  41. package/core/Plugin.js +14 -0
  42. package/core/Plugin.js.map +1 -0
  43. package/core/Plugins.d.ts +15 -0
  44. package/core/Plugins.js +39 -0
  45. package/core/Plugins.js.map +1 -0
  46. package/core/Provider.d.ts +8 -0
  47. package/core/Provider.js +18 -0
  48. package/core/Provider.js.map +1 -0
  49. package/core/Routes.d.ts +6 -0
  50. package/core/Routes.js +34 -0
  51. package/core/Routes.js.map +1 -0
  52. package/core/createProvider.d.ts +10 -0
  53. package/core/createProvider.js +9 -0
  54. package/core/createProvider.js.map +1 -0
  55. package/core/createProviderPlugin.d.ts +8 -0
  56. package/core/createProviderPlugin.js +17 -0
  57. package/core/createProviderPlugin.js.map +1 -0
  58. package/hooks/useAutocomplete/index.js +3 -1
  59. package/hooks/useAutocomplete/index.js.map +1 -0
  60. package/hooks/useAutocomplete/useAutocomplete.d.ts +6 -1
  61. package/hooks/useAutocomplete/useAutocomplete.js +11 -15
  62. package/hooks/useAutocomplete/useAutocomplete.js.map +1 -0
  63. package/hooks/useDataList/functions/getData.d.ts +1 -1
  64. package/hooks/useDataList/functions/getData.js +3 -3
  65. package/hooks/useDataList/functions/getData.js.map +1 -0
  66. package/hooks/useDataList/functions/getError.d.ts +1 -1
  67. package/hooks/useDataList/functions/getError.js +3 -3
  68. package/hooks/useDataList/functions/getError.js.map +1 -0
  69. package/hooks/useDataList/functions/getMeta.d.ts +1 -1
  70. package/hooks/useDataList/functions/getMeta.js +3 -3
  71. package/hooks/useDataList/functions/getMeta.js.map +1 -0
  72. package/hooks/useDataList/functions/index.js +3 -1
  73. package/hooks/useDataList/functions/index.js.map +1 -0
  74. package/hooks/useDataList/functions/searchDataByKey.d.ts +1 -1
  75. package/hooks/useDataList/functions/searchDataByKey.js +5 -8
  76. package/hooks/useDataList/functions/searchDataByKey.js.map +1 -0
  77. package/hooks/useDataList/index.js +3 -1
  78. package/hooks/useDataList/index.js.map +1 -0
  79. package/hooks/useDataList/useDataList.d.ts +6 -6
  80. package/hooks/useDataList/useDataList.js +80 -90
  81. package/hooks/useDataList/useDataList.js.map +1 -0
  82. package/hooks/useDataList/utils/index.js +3 -1
  83. package/hooks/useDataList/utils/index.js.map +1 -0
  84. package/hooks/useDataList/utils/prepareLoadListParams.d.ts +9 -3
  85. package/hooks/useDataList/utils/prepareLoadListParams.js +35 -31
  86. package/hooks/useDataList/utils/prepareLoadListParams.js.map +1 -0
  87. package/hooks/useDataList/utils/redirectToRouteWithQueryParams.d.ts +13 -4
  88. package/hooks/useDataList/utils/redirectToRouteWithQueryParams.js +13 -9
  89. package/hooks/useDataList/utils/redirectToRouteWithQueryParams.js.map +1 -0
  90. package/hooks/useDataList/utils/types.d.ts +21 -15
  91. package/hooks/useDataList/utils/types.js +3 -1
  92. package/hooks/useDataList/utils/types.js.map +1 -0
  93. package/hooks/useHandler.d.ts +11 -1
  94. package/hooks/useHandler.js +13 -6
  95. package/hooks/useHandler.js.map +1 -0
  96. package/hooks/useHandlers.d.ts +4 -4
  97. package/hooks/useHandlers.js +15 -11
  98. package/hooks/useHandlers.js.map +1 -0
  99. package/hooks/useRegisterLegacyPlugin.d.ts +2 -0
  100. package/hooks/useRegisterLegacyPlugin.js +11 -0
  101. package/hooks/useRegisterLegacyPlugin.js.map +1 -0
  102. package/hooks/useUi.d.ts +1 -1
  103. package/hooks/useUi.js +5 -3
  104. package/hooks/useUi.js.map +1 -0
  105. package/i18n/i18n.js +3 -1
  106. package/i18n/i18n.js.map +1 -0
  107. package/i18n/index.js +3 -1
  108. package/i18n/index.js.map +1 -0
  109. package/index.d.ts +17 -0
  110. package/index.js +20 -0
  111. package/index.js.map +1 -0
  112. package/package.json +27 -27
  113. package/plugins/AddQuerySelectionPlugin.d.ts +10 -3
  114. package/plugins/AddQuerySelectionPlugin.js +63 -92
  115. package/plugins/AddQuerySelectionPlugin.js.map +1 -0
  116. package/plugins/ApolloCacheObjectIdPlugin.d.ts +8 -8
  117. package/plugins/ApolloCacheObjectIdPlugin.js +12 -36
  118. package/plugins/ApolloCacheObjectIdPlugin.js.map +1 -0
  119. package/plugins/ApolloDynamicLink.d.ts +3 -1
  120. package/plugins/ApolloDynamicLink.js +19 -50
  121. package/plugins/ApolloDynamicLink.js.map +1 -0
  122. package/plugins/ApolloLinkPlugin.d.ts +6 -6
  123. package/plugins/ApolloLinkPlugin.js +18 -39
  124. package/plugins/ApolloLinkPlugin.js.map +1 -0
  125. package/plugins/ConsoleLinkPlugin.js +19 -40
  126. package/plugins/ConsoleLinkPlugin.js.map +1 -0
  127. package/plugins/LocaleHeaderLinkPlugin.d.ts +3 -7
  128. package/plugins/LocaleHeaderLinkPlugin.js +22 -51
  129. package/plugins/LocaleHeaderLinkPlugin.js.map +1 -0
  130. package/plugins/NetworkErrorLinkPlugin/ErrorOverlay.d.ts +13 -5
  131. package/plugins/NetworkErrorLinkPlugin/ErrorOverlay.js +21 -31
  132. package/plugins/NetworkErrorLinkPlugin/ErrorOverlay.js.map +1 -0
  133. package/plugins/NetworkErrorLinkPlugin/StyledComponents.d.ts +8 -2
  134. package/plugins/NetworkErrorLinkPlugin/StyledComponents.js +76 -7
  135. package/plugins/NetworkErrorLinkPlugin/StyledComponents.js.map +1 -0
  136. package/plugins/NetworkErrorLinkPlugin/createErrorOverlay.d.ts +6 -4
  137. package/plugins/NetworkErrorLinkPlugin/createErrorOverlay.js +20 -16
  138. package/plugins/NetworkErrorLinkPlugin/createErrorOverlay.js.map +1 -0
  139. package/plugins/NetworkErrorLinkPlugin.js +20 -35
  140. package/plugins/NetworkErrorLinkPlugin.js.map +1 -0
  141. package/plugins/OmitTypenameLinkPlugin.js +11 -31
  142. package/plugins/OmitTypenameLinkPlugin.js.map +1 -0
  143. package/plugins/RoutePlugin.d.ts +3 -3
  144. package/plugins/RoutePlugin.js +12 -32
  145. package/plugins/RoutePlugin.js.map +1 -0
  146. package/plugins/TenantHeaderLinkPlugin.d.ts +3 -7
  147. package/plugins/TenantHeaderLinkPlugin.js +29 -61
  148. package/plugins/TenantHeaderLinkPlugin.js.map +1 -0
  149. package/plugins/ViewPlugin.d.ts +5 -5
  150. package/plugins/ViewPlugin.js +15 -37
  151. package/plugins/ViewPlugin.js.map +1 -0
  152. package/plugins/image.d.ts +1 -1
  153. package/plugins/image.js +65 -85
  154. package/plugins/image.js.map +1 -0
  155. package/plugins/index.d.ts +3 -3
  156. package/plugins/index.js +35 -42
  157. package/plugins/index.js.map +1 -0
  158. package/react-butterfiles/Files.d.ts +69 -0
  159. package/react-butterfiles/Files.js +227 -0
  160. package/react-butterfiles/Files.js.map +1 -0
  161. package/react-butterfiles/index.d.ts +2 -0
  162. package/react-butterfiles/index.js +4 -0
  163. package/react-butterfiles/index.js.map +1 -0
  164. package/react-butterfiles/utils/generateId.d.ts +1 -0
  165. package/react-butterfiles/utils/generateId.js +5 -0
  166. package/react-butterfiles/utils/generateId.js.map +1 -0
  167. package/react-butterfiles/utils/readFileContent.d.ts +1 -0
  168. package/react-butterfiles/utils/readFileContent.js +15 -0
  169. package/react-butterfiles/utils/readFileContent.js.map +1 -0
  170. package/renderApp.d.ts +2 -0
  171. package/renderApp.js +9 -0
  172. package/renderApp.js.map +1 -0
  173. package/types.d.ts +29 -24
  174. package/types.js +13 -1
  175. package/types.js.map +1 -0
  176. package/utils/createGenericContext.d.ts +13 -0
  177. package/utils/createGenericContext.js +25 -0
  178. package/utils/createGenericContext.js.map +1 -0
  179. package/utils/createHashing.d.ts +2 -0
  180. package/utils/createHashing.js +18 -0
  181. package/utils/createHashing.js.map +1 -0
  182. package/utils/getApiUrl.d.ts +1 -0
  183. package/utils/getApiUrl.js +5 -0
  184. package/utils/getApiUrl.js.map +1 -0
  185. package/utils/getGqlApiUrl.d.ts +1 -0
  186. package/utils/getGqlApiUrl.js +6 -0
  187. package/utils/getGqlApiUrl.js.map +1 -0
  188. package/utils/getHeadlessCmsGqlApiUrl.d.ts +5 -0
  189. package/utils/getHeadlessCmsGqlApiUrl.js +12 -0
  190. package/utils/getHeadlessCmsGqlApiUrl.js.map +1 -0
  191. package/utils/getLocaleCode.d.ts +6 -0
  192. package/utils/getLocaleCode.js +33 -0
  193. package/utils/getLocaleCode.js.map +1 -0
  194. package/utils/getPrerenderId.d.ts +6 -0
  195. package/utils/getPrerenderId.js +5 -0
  196. package/utils/getPrerenderId.js.map +1 -0
  197. package/utils/getTenantId.d.ts +6 -0
  198. package/utils/getTenantId.js +45 -0
  199. package/utils/getTenantId.js.map +1 -0
  200. package/utils/index.d.ts +10 -0
  201. package/utils/index.js +12 -0
  202. package/utils/index.js.map +1 -0
  203. package/utils/isLocalhost.d.ts +1 -0
  204. package/utils/isLocalhost.js +7 -0
  205. package/utils/isLocalhost.js.map +1 -0
  206. package/utils/isPrerendering.d.ts +1 -0
  207. package/utils/isPrerendering.js +5 -0
  208. package/utils/isPrerendering.js.map +1 -0
  209. package/utils/legacyPluginToReactComponent.d.ts +7 -0
  210. package/utils/legacyPluginToReactComponent.js +14 -0
  211. package/utils/legacyPluginToReactComponent.js.map +1 -0
@@ -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 ADDED
@@ -0,0 +1,8 @@
1
+ export type Config = Record<string, any>;
2
+ interface AppConfig {
3
+ set(config: Config): void;
4
+ get(): Config;
5
+ getKey<T = string>(key: string, defaultValue: T): T;
6
+ }
7
+ export declare const config: AppConfig;
8
+ export {};
package/config.js ADDED
@@ -0,0 +1,25 @@
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);
8
+ };
9
+ 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
+ };
22
+ }
23
+ export const config = createConfig();
24
+
25
+ //# sourceMappingURL=config.js.map
package/config.js.map ADDED
@@ -0,0 +1 @@
1
+ {"version":3,"names":["deepFreeze","obj","Object","keys","forEach","prop","isFrozen","freeze","createConfig","_config","set","config","get","getKey","key","defaultValue"],"sources":["config.ts"],"sourcesContent":["export type Config = Record<string, any>;\n\ninterface AppConfig {\n set(config: Config): void;\n get(): Config;\n getKey<T = string>(key: string, defaultValue: T): T;\n}\n\nconst deepFreeze = (obj: Record<string, any>): Record<string, any> => {\n Object.keys(obj).forEach(prop => {\n if (typeof obj[prop] === \"object\" && !Object.isFrozen(obj[prop])) {\n deepFreeze(obj[prop]);\n }\n });\n return Object.freeze(obj);\n};\n\nfunction createConfig(): AppConfig {\n let _config: Record<string, any> = {};\n\n return {\n set(config: Config) {\n _config = deepFreeze(config);\n },\n get() {\n return _config;\n },\n getKey(key, defaultValue) {\n return key in _config ? _config[key] : defaultValue;\n }\n };\n}\n\nexport const config = createConfig();\n"],"mappings":"AAQA,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
  };
@@ -18,10 +18,7 @@ export interface UiContextValue {
18
18
  }
19
19
  export declare class UiProvider extends React.Component<Props, State> {
20
20
  state: State;
21
- setData: (setter: Function) => void;
22
- render(): JSX.Element;
21
+ private readonly setData;
22
+ render(): React.JSX.Element;
23
23
  }
24
- export declare const UiConsumer: ({ children }: {
25
- children: any;
26
- }) => JSX.Element;
27
24
  export {};
@@ -1,69 +1,32 @@
1
- import _objectSpread from "@babel/runtime/helpers/objectSpread2";
2
- import _classCallCheck from "@babel/runtime/helpers/classCallCheck";
3
- import _createClass from "@babel/runtime/helpers/createClass";
4
- import _assertThisInitialized from "@babel/runtime/helpers/assertThisInitialized";
5
- import _inherits from "@babel/runtime/helpers/inherits";
6
- import _createSuper from "@babel/runtime/helpers/createSuper";
7
- import _defineProperty from "@babel/runtime/helpers/defineProperty";
8
1
  import React from "react";
9
2
  import { plugins } from "@webiny/plugins";
10
- export var UiContext = /*#__PURE__*/React.createContext({});
11
- export var UiProvider = /*#__PURE__*/function (_React$Component) {
12
- _inherits(UiProvider, _React$Component);
13
-
14
- var _super = _createSuper(UiProvider);
15
-
16
- function UiProvider() {
17
- var _this;
18
-
19
- _classCallCheck(this, UiProvider);
20
-
21
- for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
22
- args[_key] = arguments[_key];
23
- }
24
-
25
- _this = _super.call.apply(_super, [this].concat(args));
26
-
27
- _defineProperty(_assertThisInitialized(_this), "state", {
28
- ui: {}
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
+ };
29
16
  });
30
-
31
- _defineProperty(_assertThisInitialized(_this), "setData", function (setter) {
32
- return _this.setState(function (state) {
33
- return {
34
- ui: _objectSpread(_objectSpread({}, state.ui), setter(state.ui))
35
- };
36
- });
37
- });
38
-
39
- 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);
40
29
  }
30
+ }
41
31
 
42
- _createClass(UiProvider, [{
43
- key: "render",
44
- value: function render() {
45
- var value = _objectSpread(_objectSpread({}, this.state.ui), {}, {
46
- setState: this.setData
47
- });
48
-
49
- var uiStatePlugins = plugins.byType("ui-state");
50
- return /*#__PURE__*/React.createElement(UiContext.Provider, {
51
- value: value
52
- }, uiStatePlugins.map(function (pl) {
53
- return /*#__PURE__*/React.cloneElement(pl.render(), {
54
- key: pl.name
55
- });
56
- }), this.props.children);
57
- }
58
- }]);
59
-
60
- return UiProvider;
61
- }(React.Component);
62
- export var UiConsumer = function UiConsumer(_ref) {
63
- var children = _ref.children;
64
- return /*#__PURE__*/React.createElement(UiContext.Consumer, null, function (ui) {
65
- return /*#__PURE__*/React.cloneElement(children, {
66
- ui: ui
67
- });
68
- });
69
- };
32
+ //# sourceMappingURL=index.js.map
@@ -0,0 +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\";\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 {};
package/core/Routes.js ADDED
@@ -0,0 +1,34 @@
1
+ import React from "react";
2
+ import { plugins } from "@webiny/plugins";
3
+ import { Routes as ReactRouterRoutes } from "@webiny/react-router";
4
+ export const Routes = props => {
5
+ const routes = [...props.routes,
6
+ // For backwards compatibility, we need to support the RoutePlugin routes as well.
7
+ ...plugins.byType("route").map(({
8
+ route
9
+ }) => route)].sort((a, b) => {
10
+ const pathA = a.props.path || "*";
11
+ const pathB = b.props.path || "*";
12
+
13
+ // This will sort paths at the very bottom of the list
14
+ if (pathA === "/" && pathB === "*") {
15
+ return -1;
16
+ }
17
+
18
+ // This will push * and / to the bottom of the list
19
+ if (pathA === "*" || pathA === "/") {
20
+ return 1;
21
+ }
22
+
23
+ // This will push * and / to the bottom of the list
24
+ if (["*", "/"].includes(pathB)) {
25
+ return -1;
26
+ }
27
+ return 0;
28
+ });
29
+ return /*#__PURE__*/React.createElement(ReactRouterRoutes, null, routes.map((route, index) => /*#__PURE__*/React.cloneElement(route, {
30
+ key: `${route.props.path}:${index}`
31
+ })));
32
+ };
33
+
34
+ //# sourceMappingURL=Routes.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["React","plugins","Routes","ReactRouterRoutes","props","routes","byType","map","route","sort","a","b","pathA","path","pathB","includes","createElement","index","cloneElement","key"],"sources":["Routes.tsx"],"sourcesContent":["import React from \"react\";\nimport { plugins } from \"@webiny/plugins\";\nimport { Routes as ReactRouterRoutes } from \"@webiny/react-router\";\nimport type { RoutePlugin } from \"~/types\";\n\ninterface RoutesProps {\n routes: JSX.Element[];\n}\n\nexport const Routes = (props: RoutesProps) => {\n const routes = [\n ...props.routes,\n // For backwards compatibility, we need to support the RoutePlugin routes as well.\n ...plugins.byType<RoutePlugin>(\"route\").map(({ route }) => route)\n ].sort((a, b) => {\n const pathA = a.props.path || \"*\";\n const pathB = b.props.path || \"*\";\n\n // This will sort paths at the very bottom of the list\n if (pathA === \"/\" && pathB === \"*\") {\n return -1;\n }\n\n // This will push * and / to the bottom of the list\n if (pathA === \"*\" || pathA === \"/\") {\n return 1;\n }\n\n // This will push * and / to the bottom of the list\n if ([\"*\", \"/\"].includes(pathB)) {\n return -1;\n }\n\n return 0;\n });\n\n return (\n <ReactRouterRoutes>\n {routes.map((route, index) =>\n React.cloneElement(route, { key: `${route.props.path}:${index}` })\n )}\n </ReactRouterRoutes>\n );\n};\n"],"mappings":"AAAA,OAAOA,KAAK,MAAM,OAAO;AACzB,SAASC,OAAO,QAAQ,iBAAiB;AACzC,SAASC,MAAM,IAAIC,iBAAiB,QAAQ,sBAAsB;AAOlE,OAAO,MAAMD,MAAM,GAAIE,KAAkB,IAAK;EAC1C,MAAMC,MAAM,GAAG,CACX,GAAGD,KAAK,CAACC,MAAM;EACf;EACA,GAAGJ,OAAO,CAACK,MAAM,CAAc,OAAO,CAAC,CAACC,GAAG,CAAC,CAAC;IAAEC;EAAM,CAAC,KAAKA,KAAK,CAAC,CACpE,CAACC,IAAI,CAAC,CAACC,CAAC,EAAEC,CAAC,KAAK;IACb,MAAMC,KAAK,GAAGF,CAAC,CAACN,KAAK,CAACS,IAAI,IAAI,GAAG;IACjC,MAAMC,KAAK,GAAGH,CAAC,CAACP,KAAK,CAACS,IAAI,IAAI,GAAG;;IAEjC;IACA,IAAID,KAAK,KAAK,GAAG,IAAIE,KAAK,KAAK,GAAG,EAAE;MAChC,OAAO,CAAC,CAAC;IACb;;IAEA;IACA,IAAIF,KAAK,KAAK,GAAG,IAAIA,KAAK,KAAK,GAAG,EAAE;MAChC,OAAO,CAAC;IACZ;;IAEA;IACA,IAAI,CAAC,GAAG,EAAE,GAAG,CAAC,CAACG,QAAQ,CAACD,KAAK,CAAC,EAAE;MAC5B,OAAO,CAAC,CAAC;IACb;IAEA,OAAO,CAAC;EACZ,CAAC,CAAC;EAEF,oBACId,KAAA,CAAAgB,aAAA,CAACb,iBAAiB,QACbE,MAAM,CAACE,GAAG,CAAC,CAACC,KAAK,EAAES,KAAK,kBACrBjB,KAAK,CAACkB,YAAY,CAACV,KAAK,EAAE;IAAEW,GAAG,EAAE,GAAGX,KAAK,CAACJ,KAAK,CAACS,IAAI,IAAII,KAAK;EAAG,CAAC,CACrE,CACe,CAAC;AAE5B,CAAC","ignoreList":[]}
@@ -0,0 +1,10 @@
1
+ import type React from "react";
2
+ import type { Decorator, GenericComponent } from "@webiny/react-composition";
3
+ export interface ChildrenProps {
4
+ children: React.ReactNode;
5
+ }
6
+ /**
7
+ * Creates a Higher Order Component which wraps the entire app content.
8
+ * This is mostly useful for adding React Context providers.
9
+ */
10
+ export declare function createProvider(decorator: Decorator<GenericComponent<ChildrenProps>>): Decorator<GenericComponent<ChildrenProps>>;
@@ -0,0 +1,9 @@
1
+ /**
2
+ * Creates a Higher Order Component which wraps the entire app content.
3
+ * This is mostly useful for adding React Context providers.
4
+ */
5
+ export function createProvider(decorator) {
6
+ return decorator;
7
+ }
8
+
9
+ //# sourceMappingURL=createProvider.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["createProvider","decorator"],"sources":["createProvider.tsx"],"sourcesContent":["import type React from \"react\";\nimport type { Decorator, GenericComponent } from \"@webiny/react-composition\";\n\nexport interface ChildrenProps {\n children: React.ReactNode;\n}\n\n/**\n * Creates a Higher Order Component which wraps the entire app content.\n * This is mostly useful for adding React Context providers.\n */\nexport function createProvider(\n decorator: Decorator<GenericComponent<ChildrenProps>>\n): Decorator<GenericComponent<ChildrenProps>> {\n return decorator;\n}\n"],"mappings":"AAOA;AACA;AACA;AACA;AACA,OAAO,SAASA,cAAcA,CAC1BC,SAAqD,EACX;EAC1C,OAAOA,SAAS;AACpB","ignoreList":[]}
@@ -0,0 +1,8 @@
1
+ import React from "react";
2
+ import type { GenericComponent, Decorator } from "@webiny/react-composition";
3
+ /**
4
+ * Creates a component, which, when mounted, will register an app provider.
5
+ * This is particularly useful for wrapping the entire app with custom React Context providers.
6
+ * For more information, visit https://www.webiny.com/docs/admin-area/basics/framework.
7
+ */
8
+ export declare function createProviderPlugin(decorator: Decorator<GenericComponent>): () => React.JSX.Element;
@@ -0,0 +1,17 @@
1
+ import React from "react";
2
+ import { Provider } from "./Provider";
3
+
4
+ /**
5
+ * Creates a component, which, when mounted, will register an app provider.
6
+ * This is particularly useful for wrapping the entire app with custom React Context providers.
7
+ * For more information, visit https://www.webiny.com/docs/admin-area/basics/framework.
8
+ */
9
+ export function createProviderPlugin(decorator) {
10
+ return function ProviderPlugin() {
11
+ return /*#__PURE__*/React.createElement(Provider, {
12
+ hoc: decorator
13
+ });
14
+ };
15
+ }
16
+
17
+ //# sourceMappingURL=createProviderPlugin.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["React","Provider","createProviderPlugin","decorator","ProviderPlugin","createElement","hoc"],"sources":["createProviderPlugin.tsx"],"sourcesContent":["import React from \"react\";\nimport type { GenericComponent, Decorator } from \"@webiny/react-composition\";\nimport { Provider } from \"./Provider\";\n\n/**\n * Creates a component, which, when mounted, will register an app provider.\n * This is particularly useful for wrapping the entire app with custom React Context providers.\n * For more information, visit https://www.webiny.com/docs/admin-area/basics/framework.\n */\nexport function createProviderPlugin(decorator: Decorator<GenericComponent>) {\n return function ProviderPlugin() {\n return <Provider hoc={decorator} />;\n };\n}\n"],"mappings":"AAAA,OAAOA,KAAK,MAAM,OAAO;AAEzB,SAASC,QAAQ;;AAEjB;AACA;AACA;AACA;AACA;AACA,OAAO,SAASC,oBAAoBA,CAACC,SAAsC,EAAE;EACzE,OAAO,SAASC,cAAcA,CAAA,EAAG;IAC7B,oBAAOJ,KAAA,CAAAK,aAAA,CAACJ,QAAQ;MAACK,GAAG,EAAEH;IAAU,CAAE,CAAC;EACvC,CAAC;AACL","ignoreList":[]}
@@ -1 +1,3 @@
1
- export { useAutocomplete } from "./useAutocomplete";
1
+ export { useAutocomplete } from "./useAutocomplete";
2
+
3
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["useAutocomplete"],"sources":["index.ts"],"sourcesContent":["export { useAutocomplete } from \"./useAutocomplete\";\n"],"mappings":"AAAA,SAASA,eAAe","ignoreList":[]}
@@ -1,6 +1,11 @@
1
+ import type { DocumentNode } from "graphql";
1
2
  interface UseAutocompleteHook {
2
3
  options: any[];
3
4
  onInput(value: string): void;
4
5
  }
5
- export declare const useAutocomplete: (props: any) => UseAutocompleteHook;
6
+ interface Props {
7
+ query: DocumentNode;
8
+ search?: string | ((value: string) => string);
9
+ }
10
+ export declare const useAutocomplete: (props: Props) => UseAutocompleteHook;
6
11
  export {};
@@ -1,27 +1,23 @@
1
- import _objectSpread from "@babel/runtime/helpers/objectSpread2";
2
- import _debounce from "lodash/debounce";
3
1
  import { useDataList } from "../useDataList";
4
- export var useAutocomplete = function useAutocomplete(props) {
5
- var useDataListProps = props.query ? props : {
6
- query: props
7
- };
8
- var dataList = useDataList(_objectSpread({
9
- useRouter: false
10
- }, useDataListProps));
2
+ import debounce from "lodash/debounce";
3
+ export const useAutocomplete = props => {
4
+ const dataList = useDataList({
5
+ useRouter: false,
6
+ ...props
7
+ });
11
8
  return {
12
9
  options: dataList.data || [],
13
- onInput: _debounce(function (query) {
10
+ onInput: debounce(query => {
14
11
  if (!query) {
15
12
  return;
16
13
  }
17
-
18
- var search = props.search || query;
19
-
14
+ let search = props.search || query;
20
15
  if (typeof search === "function") {
21
16
  search = search(query);
22
17
  }
23
-
24
18
  dataList.setSearch(search);
25
19
  }, 250)
26
20
  };
27
- };
21
+ };
22
+
23
+ //# sourceMappingURL=useAutocomplete.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["useDataList","debounce","useAutocomplete","props","dataList","useRouter","options","data","onInput","query","search","setSearch"],"sources":["useAutocomplete.ts"],"sourcesContent":["import { useDataList } from \"../useDataList\";\nimport debounce from \"lodash/debounce\";\nimport type { DocumentNode } from \"graphql\";\n\ninterface UseAutocompleteHook {\n options: any[];\n onInput(value: string): void;\n}\n\ninterface Props {\n query: DocumentNode;\n search?: string | ((value: string) => string);\n}\n\nexport const useAutocomplete = (props: Props): UseAutocompleteHook => {\n const dataList = useDataList({ useRouter: false, ...props });\n\n return {\n options: dataList.data || [],\n onInput: debounce(query => {\n if (!query) {\n return;\n }\n\n let search = props.search || query;\n if (typeof search === \"function\") {\n search = search(query);\n }\n\n dataList.setSearch(search);\n }, 250)\n };\n};\n"],"mappings":"AAAA,SAASA,WAAW;AACpB,OAAOC,QAAQ,MAAM,iBAAiB;AAatC,OAAO,MAAMC,eAAe,GAAIC,KAAY,IAA0B;EAClE,MAAMC,QAAQ,GAAGJ,WAAW,CAAC;IAAEK,SAAS,EAAE,KAAK;IAAE,GAAGF;EAAM,CAAC,CAAC;EAE5D,OAAO;IACHG,OAAO,EAAEF,QAAQ,CAACG,IAAI,IAAI,EAAE;IAC5BC,OAAO,EAAEP,QAAQ,CAACQ,KAAK,IAAI;MACvB,IAAI,CAACA,KAAK,EAAE;QACR;MACJ;MAEA,IAAIC,MAAM,GAAGP,KAAK,CAACO,MAAM,IAAID,KAAK;MAClC,IAAI,OAAOC,MAAM,KAAK,UAAU,EAAE;QAC9BA,MAAM,GAAGA,MAAM,CAACD,KAAK,CAAC;MAC1B;MAEAL,QAAQ,CAACO,SAAS,CAACD,MAAM,CAAC;IAC9B,CAAC,EAAE,GAAG;EACV,CAAC;AACL,CAAC","ignoreList":[]}
@@ -1,2 +1,2 @@
1
- declare const _default: (response: any) => any;
1
+ declare const _default: (response: Record<string, string>) => string | null;
2
2
  export default _default;
@@ -1,4 +1,4 @@
1
1
  import searchDataByKey from "./searchDataByKey";
2
- export default (function (response) {
3
- return searchDataByKey("data", response);
4
- });
2
+ export default response => searchDataByKey("data", response);
3
+
4
+ //# sourceMappingURL=getData.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["searchDataByKey","response"],"sources":["getData.ts"],"sourcesContent":["import searchDataByKey from \"./searchDataByKey\";\n\nexport default (response: Record<string, string>) => searchDataByKey(\"data\", response);\n"],"mappings":"AAAA,OAAOA,eAAe;AAEtB,eAAgBC,QAAgC,IAAKD,eAAe,CAAC,MAAM,EAAEC,QAAQ,CAAC","ignoreList":[]}
@@ -1,2 +1,2 @@
1
- declare const _default: (response: any) => any;
1
+ declare const _default: (response: Record<string, string>) => string | null;
2
2
  export default _default;
@@ -1,4 +1,4 @@
1
1
  import searchDataByKey from "./searchDataByKey";
2
- export default (function (response) {
3
- return searchDataByKey("error", response);
4
- });
2
+ export default response => searchDataByKey("error", response);
3
+
4
+ //# sourceMappingURL=getError.js.map