@webiny/app 0.0.0-unstable.df7a8bb475 → 0.0.0-unstable.e2758ee1cf
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/App.d.ts +2 -2
- package/App.js +7 -10
- package/App.js.map +1 -1
- package/exports/admin/{envConfig.js → env-config.js} +1 -1
- package/exports/admin/env-config.js.map +1 -0
- package/exports/admin/{graphqlClient.js → graphql-client.js} +1 -1
- package/exports/admin/graphql-client.js.map +1 -0
- package/exports/admin/{localStorage.js → local-storage.js} +1 -1
- package/exports/admin/local-storage.js.map +1 -0
- package/exports/admin/router.d.ts +1 -0
- package/exports/admin/router.js +1 -0
- package/exports/admin/router.js.map +1 -1
- package/index.d.ts +0 -1
- package/index.js +0 -1
- package/index.js.map +1 -1
- package/package.json +13 -13
- package/presentation/router/components/Redirect.d.ts +14 -0
- package/presentation/router/components/Redirect.js +15 -0
- package/presentation/router/components/Redirect.js.map +1 -0
- package/react-butterfiles/Files.js +1 -1
- package/react-butterfiles/Files.js.map +1 -1
- package/core/DebounceRender.d.ts +0 -12
- package/core/DebounceRender.js +0 -31
- package/core/DebounceRender.js.map +0 -1
- package/core/Routes.d.ts +0 -7
- package/core/Routes.js +0 -33
- package/core/Routes.js.map +0 -1
- package/exports/admin/envConfig.js.map +0 -1
- package/exports/admin/graphqlClient.js.map +0 -1
- package/exports/admin/localStorage.js.map +0 -1
- /package/exports/admin/{envConfig.d.ts → env-config.d.ts} +0 -0
- /package/exports/admin/{graphqlClient.d.ts → graphql-client.d.ts} +0 -0
- /package/exports/admin/{localStorage.d.ts → local-storage.d.ts} +0 -0
package/App.d.ts
CHANGED
|
@@ -11,8 +11,8 @@ interface AppContext extends State {
|
|
|
11
11
|
declare const AppContext: React.Context<AppContext | undefined>;
|
|
12
12
|
export declare const useApp: () => AppContext;
|
|
13
13
|
export interface AppProps {
|
|
14
|
-
debounceRender?: number;
|
|
15
14
|
routes?: Array<any>;
|
|
15
|
+
plugins?: any[];
|
|
16
16
|
providers?: Array<Decorator<GenericComponent<ProviderProps>>>;
|
|
17
17
|
decorators?: DecoratorsCollection;
|
|
18
18
|
children?: React.ReactNode | React.ReactNode[];
|
|
@@ -20,6 +20,6 @@ export interface AppProps {
|
|
|
20
20
|
interface ProviderProps {
|
|
21
21
|
children: React.ReactNode;
|
|
22
22
|
}
|
|
23
|
-
export declare const AppBase: React.MemoExoticComponent<({
|
|
23
|
+
export declare const AppBase: React.MemoExoticComponent<({ routes, plugins, providers, children }: AppProps) => React.JSX.Element>;
|
|
24
24
|
export declare const App: ({ decorators, ...props }: AppProps) => React.JSX.Element;
|
|
25
25
|
export {};
|
package/App.js
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
|
-
import React, { createContext, useCallback, useContext, useEffect, useMemo, useState } from "react";
|
|
1
|
+
import React, { createContext, Fragment, useCallback, useContext, useEffect, useMemo, useState } from "react";
|
|
2
2
|
import { compose, CompositionProvider } from "@webiny/react-composition";
|
|
3
|
-
import { DebounceRender } from "./core/DebounceRender.js";
|
|
4
3
|
import { PluginsProvider } from "./core/Plugins.js";
|
|
5
4
|
import { RouterWithConfig, useRouterConfig } from "./config/RouterConfig.js";
|
|
6
5
|
import { AppContainer } from "./AppContainer.js";
|
|
@@ -16,13 +15,13 @@ export const useApp = () => {
|
|
|
16
15
|
return appContext;
|
|
17
16
|
};
|
|
18
17
|
export const AppBase = /*#__PURE__*/React.memo(({
|
|
19
|
-
debounceRender = 50,
|
|
20
18
|
routes = [],
|
|
19
|
+
plugins = [],
|
|
21
20
|
providers = [],
|
|
22
21
|
children
|
|
23
22
|
}) => {
|
|
24
23
|
const [state, setState] = useState({
|
|
25
|
-
plugins
|
|
24
|
+
plugins,
|
|
26
25
|
providers
|
|
27
26
|
});
|
|
28
27
|
const addProvider = useCallback(component => {
|
|
@@ -65,17 +64,15 @@ export const AppBase = /*#__PURE__*/React.memo(({
|
|
|
65
64
|
return /*#__PURE__*/React.memo(compose(...(state.providers || []))(({
|
|
66
65
|
children
|
|
67
66
|
}) => {
|
|
68
|
-
return /*#__PURE__*/React.createElement(
|
|
69
|
-
wait: debounceRender
|
|
70
|
-
}, children);
|
|
67
|
+
return /*#__PURE__*/React.createElement(React.Fragment, null, children);
|
|
71
68
|
}));
|
|
72
69
|
}, [state.providers.length]);
|
|
73
70
|
Providers.displayName = "Providers";
|
|
74
71
|
return /*#__PURE__*/React.createElement(AppContext.Provider, {
|
|
75
72
|
value: appContext
|
|
76
|
-
}, children, /*#__PURE__*/React.createElement(AppContainer, null, /*#__PURE__*/React.createElement(Providers, null, /*#__PURE__*/React.createElement(PluginsProvider, null, state.plugins
|
|
77
|
-
|
|
78
|
-
}, /*#__PURE__*/React.createElement(RouterWithConfig, null, /*#__PURE__*/React.createElement(AppRouter, null), /*#__PURE__*/React.createElement(RouteContent, null)))))
|
|
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)))));
|
|
79
76
|
});
|
|
80
77
|
AppBase.displayName = "AppBase";
|
|
81
78
|
export const App = ({
|
package/App.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["React","createContext","useCallback","useContext","useEffect","useMemo","useState","compose","CompositionProvider","
|
|
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: 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: 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":"AAAA,OAAOA,KAAK,IACRC,aAAa,EACbC,QAAQ,EACRC,WAAW,EACXC,UAAU,EACVC,SAAS,EACTC,OAAO,EACPC,QAAQ,QACL,OAAO;AACd,SACIC,OAAO,EACPC,mBAAmB,QAIhB,2BAA2B;AAClC,SAASC,eAAe;AACxB,SAASC,gBAAgB,EAAEC,eAAe;AAC1C,SAASC,YAAY;AACrB,SAASC,YAAY;AACrB,SAASC,SAAS;AAYlB,MAAMC,UAAU,gBAAGf,aAAa,CAAyBgB,SAAS,CAAC;AAEnED,UAAU,CAACE,WAAW,GAAG,YAAY;AAErC,OAAO,MAAMC,MAAM,GAAGA,CAAA,KAAM;EACxB,MAAMC,UAAU,GAAGhB,UAAU,CA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AAgB,qBACbX,KAAA,CAAA4C,aAAA,CAACR,SAAS,MAAE,CAAC,eACbpC,KAAA,CAAA4C,aAAA,CAAC9B,YAAY,MAAE,CACD,CACX,CACD,CACG,CAAC;AAE9B,CACJ,CAAC;AAEDQ,OAAO,CAACJ,WAAW,GAAG,SAAS;AAE/B,OAAO,MAAMiC,GAAG,GAAGA,CAAC;EAAEC,UAAU;EAAE,GAAGC;AAAgB,CAAC,KAAK;EACvD,oBACIrD,KAAA,CAAA4C,aAAA,CAACnC,mBAAmB;IAAC2C,UAAU,EAAEA;EAAW,gBACxCpD,KAAA,CAAA4C,aAAA,CAACtB,OAAO,EAAAgC,MAAA,CAAAC,MAAA;IAACH,UAAU,EAAEA;EAAW,GAAKC,KAAK,CAAG,CAC5B,CAAC;AAE9B,CAAC","ignoreList":[]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["EnvConfig"],"sources":["env-config.ts"],"sourcesContent":["export { EnvConfig } from \"~/features/envConfig/index.js\";\n"],"mappings":"AAAA,SAASA,SAAS","ignoreList":[]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["GraphQLClient"],"sources":["graphql-client.ts"],"sourcesContent":["export { GraphQLClient } from \"~/features/graphqlClient/abstractions.js\";\n"],"mappings":"AAAA,SAASA,aAAa","ignoreList":[]}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
export { LocalStorage } from "../../features/localStorage/abstractions.js";
|
|
2
2
|
export { useLocalStorage, useLocalStorageValue, useLocalStorageValues } from "../../presentation/localStorage/index.js";
|
|
3
3
|
|
|
4
|
-
//# sourceMappingURL=
|
|
4
|
+
//# sourceMappingURL=local-storage.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["LocalStorage","useLocalStorage","useLocalStorageValue","useLocalStorageValues"],"sources":["local-storage.ts"],"sourcesContent":["export { LocalStorage } from \"~/features/localStorage/abstractions.js\";\nexport {\n useLocalStorage,\n useLocalStorageValue,\n useLocalStorageValues\n} from \"~/presentation/localStorage/index.js\";\n"],"mappings":"AAAA,SAASA,YAAY;AACrB,SACIC,eAAe,EACfC,oBAAoB,EACpBC,qBAAqB","ignoreList":[]}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
export { Route } from "../../features/router/Route.js";
|
|
2
2
|
export { RouteLinkComponent } from "../../presentation/router/components/RouteLink.js";
|
|
3
3
|
export { LinkComponent } from "../../presentation/router/components/SimpleLink.js";
|
|
4
|
+
export { RedirectComponent } from "../../presentation/router/components/Redirect.js";
|
|
4
5
|
export { useRoute, useRouter } from "../../presentation/router/index.js";
|
package/exports/admin/router.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
export { Route } from "../../features/router/Route.js";
|
|
2
2
|
export { RouteLinkComponent } from "../../presentation/router/components/RouteLink.js";
|
|
3
3
|
export { LinkComponent } from "../../presentation/router/components/SimpleLink.js";
|
|
4
|
+
export { RedirectComponent } from "../../presentation/router/components/Redirect.js";
|
|
4
5
|
export { useRoute, useRouter } from "../../presentation/router/index.js";
|
|
5
6
|
|
|
6
7
|
//# sourceMappingURL=router.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["Route","RouteLinkComponent","LinkComponent","useRoute","useRouter"],"sources":["router.ts"],"sourcesContent":["export { Route } from \"~/features/router/Route.js\";\nexport { RouteLinkComponent } from \"~/presentation/router/components/RouteLink.js\";\nexport { LinkComponent } from \"~/presentation/router/components/SimpleLink.js\";\nexport { useRoute, useRouter } from \"~/presentation/router/index.js\";\n"],"mappings":"AAAA,SAASA,KAAK;AACd,SAASC,kBAAkB;AAC3B,SAASC,aAAa;AACtB,SAASC,QAAQ,EAAEC,SAAS","ignoreList":[]}
|
|
1
|
+
{"version":3,"names":["Route","RouteLinkComponent","LinkComponent","RedirectComponent","useRoute","useRouter"],"sources":["router.ts"],"sourcesContent":["export { Route } from \"~/features/router/Route.js\";\nexport { RouteLinkComponent } from \"~/presentation/router/components/RouteLink.js\";\nexport { LinkComponent } from \"~/presentation/router/components/SimpleLink.js\";\nexport { RedirectComponent } from \"~/presentation/router/components/Redirect.js\";\nexport { useRoute, useRouter } from \"~/presentation/router/index.js\";\n"],"mappings":"AAAA,SAASA,KAAK;AACd,SAASC,kBAAkB;AAC3B,SAASC,aAAa;AACtB,SAASC,iBAAiB;AAC1B,SAASC,QAAQ,EAAEC,SAAS","ignoreList":[]}
|
package/index.d.ts
CHANGED
|
@@ -9,7 +9,6 @@ export type { AppProps } from "./App.js";
|
|
|
9
9
|
export * from "./core/Plugins.js";
|
|
10
10
|
export * from "./core/Plugin.js";
|
|
11
11
|
export * from "./core/Provider.js";
|
|
12
|
-
export * from "./core/DebounceRender.js";
|
|
13
12
|
export * from "./core/createProvider.js";
|
|
14
13
|
export * from "./core/createProviderPlugin.js";
|
|
15
14
|
export * from "./renderApp.js";
|
package/index.js
CHANGED
|
@@ -10,7 +10,6 @@ export * from "./AppContainer.js";
|
|
|
10
10
|
export * from "./core/Plugins.js";
|
|
11
11
|
export * from "./core/Plugin.js";
|
|
12
12
|
export * from "./core/Provider.js";
|
|
13
|
-
export * from "./core/DebounceRender.js";
|
|
14
13
|
export * from "./core/createProvider.js";
|
|
15
14
|
export * from "./core/createProviderPlugin.js";
|
|
16
15
|
export * from "./renderApp.js";
|
package/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["AddQuerySelectionPlugin","ApolloLinkPlugin","ApolloCacheObjectIdPlugin","useContainer","DiContainerProvider","useFeature","createFeature","Route","RouteLink","SimpleLink","useRouter","useRoute","useLocalStorage","useLocalStorageValue","useLocalStorageValues"],"sources":["index.ts"],"sourcesContent":["export { AddQuerySelectionPlugin } from \"./plugins/AddQuerySelectionPlugin.js\";\nexport { ApolloLinkPlugin } from \"./plugins/ApolloLinkPlugin.js\";\nexport {\n ApolloCacheObjectIdPlugin,\n type ApolloCacheObject\n} from \"./plugins/ApolloCacheObjectIdPlugin.js\";\n\n// Composition - we re-export this for ease of use\nexport * from \"@webiny/react-composition\";\nexport type { HigherOrderComponent, ComposeProps, ComposableFC } from \"@webiny/react-composition\";\n\n// App framework\nexport * from \"./App.js\";\nexport * from \"./AppContainer.js\";\nexport type { AppProps } from \"./App.js\";\nexport * from \"./core/Plugins.js\";\nexport * from \"./core/Plugin.js\";\nexport * from \"./core/Provider.js\";\nexport * from \"./core/
|
|
1
|
+
{"version":3,"names":["AddQuerySelectionPlugin","ApolloLinkPlugin","ApolloCacheObjectIdPlugin","useContainer","DiContainerProvider","useFeature","createFeature","Route","RouteLink","SimpleLink","useRouter","useRoute","useLocalStorage","useLocalStorageValue","useLocalStorageValues"],"sources":["index.ts"],"sourcesContent":["export { AddQuerySelectionPlugin } from \"./plugins/AddQuerySelectionPlugin.js\";\nexport { ApolloLinkPlugin } from \"./plugins/ApolloLinkPlugin.js\";\nexport {\n ApolloCacheObjectIdPlugin,\n type ApolloCacheObject\n} from \"./plugins/ApolloCacheObjectIdPlugin.js\";\n\n// Composition - we re-export this for ease of use\nexport * from \"@webiny/react-composition\";\nexport type { HigherOrderComponent, ComposeProps, ComposableFC } from \"@webiny/react-composition\";\n\n// App framework\nexport * from \"./App.js\";\nexport * from \"./AppContainer.js\";\nexport type { AppProps } from \"./App.js\";\nexport * from \"./core/Plugins.js\";\nexport * from \"./core/Plugin.js\";\nexport * from \"./core/Provider.js\";\nexport * from \"./core/createProvider.js\";\nexport * from \"./core/createProviderPlugin.js\";\nexport * from \"./renderApp.js\";\nexport * from \"./utils/createGenericContext.js\";\nexport { useContainer, DiContainerProvider } from \"./shared/di/DiContainerProvider.js\";\nexport { useFeature } from \"./shared/di/useFeature.js\";\nexport { createFeature } from \"./shared/di/createFeature.js\";\n\nexport { Route } from \"./features/router/Route.js\";\nexport { RouteLink, type RouteLinkProps } from \"./presentation/router/components/RouteLink.js\";\nexport { SimpleLink, type SimpleLinkProps } from \"./presentation/router/components/SimpleLink.js\";\n\nexport { useRouter, useRoute } from \"./presentation/router/index.js\";\nexport {\n useLocalStorage,\n useLocalStorageValue,\n useLocalStorageValues\n} from \"./presentation/localStorage/index.js\";\n\nexport * from \"./helpers/InterfaceGenerator/index.js\";\n"],"mappings":"AAAA,SAASA,uBAAuB;AAChC,SAASC,gBAAgB;AACzB,SACIC,yBAAyB;;AAI7B;AACA,cAAc,2BAA2B;AAGzC;AACA;AACA;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,SAASC,YAAY,EAAEC,mBAAmB;AAC1C,SAASC,UAAU;AACnB,SAASC,aAAa;AAEtB,SAASC,KAAK;AACd,SAASC,SAAS;AAClB,SAASC,UAAU;AAEnB,SAASC,SAAS,EAAEC,QAAQ;AAC5B,SACIC,eAAe,EACfC,oBAAoB,EACpBC,qBAAqB;AAGzB","ignoreList":[]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@webiny/app",
|
|
3
|
-
"version": "0.0.0-unstable.
|
|
3
|
+
"version": "0.0.0-unstable.e2758ee1cf",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"repository": {
|
|
@@ -19,12 +19,12 @@
|
|
|
19
19
|
"@emotion/styled": "11.10.6",
|
|
20
20
|
"@types/react": "18.2.79",
|
|
21
21
|
"@webiny/di": "0.2.3",
|
|
22
|
-
"@webiny/feature": "0.0.0-unstable.
|
|
23
|
-
"@webiny/i18n": "0.0.0-unstable.
|
|
24
|
-
"@webiny/i18n-react": "0.0.0-unstable.
|
|
25
|
-
"@webiny/plugins": "0.0.0-unstable.
|
|
26
|
-
"@webiny/react-composition": "0.0.0-unstable.
|
|
27
|
-
"@webiny/react-properties": "0.0.0-unstable.
|
|
22
|
+
"@webiny/feature": "0.0.0-unstable.e2758ee1cf",
|
|
23
|
+
"@webiny/i18n": "0.0.0-unstable.e2758ee1cf",
|
|
24
|
+
"@webiny/i18n-react": "0.0.0-unstable.e2758ee1cf",
|
|
25
|
+
"@webiny/plugins": "0.0.0-unstable.e2758ee1cf",
|
|
26
|
+
"@webiny/react-composition": "0.0.0-unstable.e2758ee1cf",
|
|
27
|
+
"@webiny/react-properties": "0.0.0-unstable.e2758ee1cf",
|
|
28
28
|
"apollo-cache": "1.3.5",
|
|
29
29
|
"apollo-cache-inmemory": "1.6.6",
|
|
30
30
|
"apollo-client": "2.6.10",
|
|
@@ -35,11 +35,11 @@
|
|
|
35
35
|
"apollo-utilities": "1.3.4",
|
|
36
36
|
"boolean": "3.2.0",
|
|
37
37
|
"bytes": "3.1.2",
|
|
38
|
-
"graphql": "16.
|
|
38
|
+
"graphql": "16.13.0",
|
|
39
39
|
"history": "5.3.0",
|
|
40
40
|
"invariant": "2.2.4",
|
|
41
41
|
"lodash": "4.17.23",
|
|
42
|
-
"minimatch": "
|
|
42
|
+
"minimatch": "10.2.4",
|
|
43
43
|
"mobx": "6.15.0",
|
|
44
44
|
"nanoid": "5.1.6",
|
|
45
45
|
"react": "18.2.0",
|
|
@@ -49,13 +49,13 @@
|
|
|
49
49
|
"zod": "3.25.76"
|
|
50
50
|
},
|
|
51
51
|
"devDependencies": {
|
|
52
|
-
"@types/lodash": "4.17.
|
|
52
|
+
"@types/lodash": "4.17.24",
|
|
53
53
|
"@types/warning": "3.0.3",
|
|
54
|
-
"@webiny/build-tools": "0.0.0-unstable.
|
|
54
|
+
"@webiny/build-tools": "0.0.0-unstable.e2758ee1cf",
|
|
55
55
|
"rimraf": "6.1.3",
|
|
56
56
|
"type-fest": "5.4.4",
|
|
57
57
|
"typescript": "5.9.3",
|
|
58
|
-
"vitest": "
|
|
58
|
+
"vitest": "4.0.18"
|
|
59
59
|
},
|
|
60
60
|
"publishConfig": {
|
|
61
61
|
"access": "public",
|
|
@@ -68,5 +68,5 @@
|
|
|
68
68
|
]
|
|
69
69
|
}
|
|
70
70
|
},
|
|
71
|
-
"gitHead": "
|
|
71
|
+
"gitHead": "e2758ee1cfa3b9a7152e9bb995a90ccabd33266f"
|
|
72
72
|
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import type { Route, RouteParamsDefinition, RouteParamsInfer } from "../../../features/router/Route.js";
|
|
2
|
+
import type { RequiredKeysOf } from "type-fest";
|
|
3
|
+
export type RedirectProps<TParams extends RouteParamsDefinition | undefined> = [
|
|
4
|
+
TParams extends RouteParamsDefinition ? RequiredKeysOf<RouteParamsInfer<TParams>> extends never ? {
|
|
5
|
+
route: Route<TParams>;
|
|
6
|
+
params?: RouteParamsInfer<TParams>;
|
|
7
|
+
} : {
|
|
8
|
+
route: Route<TParams>;
|
|
9
|
+
params: RouteParamsInfer<TParams>;
|
|
10
|
+
} : {
|
|
11
|
+
route: Route<TParams>;
|
|
12
|
+
}
|
|
13
|
+
][0];
|
|
14
|
+
export declare const RedirectComponent: <TParams extends RouteParamsDefinition | undefined>(props: RedirectProps<TParams>) => null;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { useEffect } from "react";
|
|
2
|
+
import { useRouter } from "../../../router.js";
|
|
3
|
+
export const RedirectComponent = props => {
|
|
4
|
+
const router = useRouter();
|
|
5
|
+
const {
|
|
6
|
+
route,
|
|
7
|
+
...rest
|
|
8
|
+
} = props;
|
|
9
|
+
useEffect(() => {
|
|
10
|
+
router.goToRoute(route, rest.params);
|
|
11
|
+
}, []);
|
|
12
|
+
return null;
|
|
13
|
+
};
|
|
14
|
+
|
|
15
|
+
//# sourceMappingURL=Redirect.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["useEffect","useRouter","RedirectComponent","props","router","route","rest","goToRoute","params"],"sources":["Redirect.tsx"],"sourcesContent":["import { useEffect } from \"react\";\nimport type { Route, RouteParamsDefinition, RouteParamsInfer } from \"~/features/router/Route.js\";\nimport { useRouter } from \"~/router.js\";\nimport type { RequiredKeysOf } from \"type-fest\";\n\nexport type RedirectProps<TParams extends RouteParamsDefinition | undefined> = [\n TParams extends RouteParamsDefinition\n ? RequiredKeysOf<RouteParamsInfer<TParams>> extends never\n ? { route: Route<TParams>; params?: RouteParamsInfer<TParams> }\n : { route: Route<TParams>; params: RouteParamsInfer<TParams> }\n : { route: Route<TParams> }\n][0];\n\nexport const RedirectComponent = <TParams extends RouteParamsDefinition | undefined>(\n props: RedirectProps<TParams>\n) => {\n const router = useRouter();\n const { route, ...rest } = props as any;\n\n useEffect(() => {\n router.goToRoute(route, rest.params);\n }, []);\n\n return null;\n};\n"],"mappings":"AAAA,SAASA,SAAS,QAAQ,OAAO;AAEjC,SAASC,SAAS;AAWlB,OAAO,MAAMC,iBAAiB,GAC1BC,KAA6B,IAC5B;EACD,MAAMC,MAAM,GAAGH,SAAS,CAAC,CAAC;EAC1B,MAAM;IAAEI,KAAK;IAAE,GAAGC;EAAK,CAAC,GAAGH,KAAY;EAEvCH,SAAS,CAAC,MAAM;IACZI,MAAM,CAACG,SAAS,CAACF,KAAK,EAAEC,IAAI,CAACE,MAAM,CAAC;EACxC,CAAC,EAAE,EAAE,CAAC;EAEN,OAAO,IAAI;AACf,CAAC","ignoreList":[]}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import React from "react";
|
|
2
2
|
import bytes from "bytes";
|
|
3
|
-
import minimatch from "minimatch";
|
|
3
|
+
import { minimatch } from "minimatch";
|
|
4
4
|
import { readFileContent } from "./utils/readFileContent.js";
|
|
5
5
|
import { generateId } from "./utils/generateId.js";
|
|
6
6
|
export class Files extends React.Component {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["React","bytes","minimatch","readFileContent","generateId","Files","Component","defaultProps","accept","multiple","maxSize","multipleMaxSize","multipleMaxCount","convertToBase64","input","browseFilesPassedParams","id","validateFiles","files","props","errors","multipleFileSize","length","push","type","index","file","Array","isArray","some","sizeAsBytes","size","maxMultipleMaxSize","multipleCount","processSelectedFiles","eventFiles","onSuccess","onError","callbacks","map","name","src","base64","i","value","onDropFilesHandler","e","dataTransfer","browseFilesHandler","click","render","createElement","Fragment","children","getLabelProps","htmlFor","browseFiles","getDropZoneProps","onDragOver","onDrop","rest","preventDefault","ref","join","style","display","onChange","target"],"sources":["Files.tsx"],"sourcesContent":["import React from \"react\";\nimport bytes from \"bytes\";\nimport minimatch from \"minimatch\";\nimport { readFileContent } from \"./utils/readFileContent.js\";\nimport { generateId } from \"./utils/generateId.js\";\n\nexport type SelectedFile = {\n id: string;\n name: string;\n type: string;\n size: number;\n src: {\n file: File;\n base64: string | null;\n };\n};\n\nexport type FileError = {\n id: string;\n type:\n | \"unsupportedFileType\"\n | \"maxSizeExceeded\"\n | \"multipleMaxSizeExceeded\"\n | \"multipleMaxCountExceeded\"\n | \"multipleNotAllowed\";\n index?: number;\n file?: SelectedFile | File;\n multipleFileSize?: number;\n multipleMaxSize?: number;\n multipleMaxCount?: number;\n multipleCount?: number;\n};\n\nexport type BrowseFilesParams = {\n onSuccess?: (files: SelectedFile[]) => void;\n onError?: (errors: FileError[], files: SelectedFile[]) => void;\n};\n\nexport type RenderPropParams = {\n browseFiles: (params: BrowseFilesParams) => void;\n getDropZoneProps: (additionalProps: any) => any;\n getLabelProps: (additionalProps: any) => any;\n validateFiles: (files: SelectedFile[] | File[]) => FileError[];\n};\n\nexport type FilesRules = {\n accept: string[];\n multiple: boolean;\n maxSize: string;\n multipleMaxSize: string;\n multipleMaxCount: number | null;\n convertToBase64: boolean;\n onSuccess?: (files: SelectedFile[]) => void;\n onError?: (errors: FileError[], files: SelectedFile[]) => void;\n};\n\nexport type Props = FilesRules & {\n children: (params: RenderPropParams) => React.ReactNode;\n id?: string;\n};\n\nexport class Files extends React.Component<Props> {\n static defaultProps = {\n accept: [],\n multiple: false,\n maxSize: \"2mb\",\n multipleMaxSize: \"10mb\",\n multipleMaxCount: null,\n convertToBase64: false\n };\n\n input: HTMLInputElement | null = null;\n browseFilesPassedParams: BrowseFilesParams | null = null;\n id: string = generateId();\n\n validateFiles = (files: SelectedFile[] | File[]): FileError[] => {\n const { multiple, multipleMaxSize, multipleMaxCount, accept, maxSize } = this.props;\n\n const errors: FileError[] = [];\n let multipleFileSize = 0;\n\n if (!multiple && files.length > 1) {\n errors.push({\n id: generateId(),\n type: \"multipleNotAllowed\"\n });\n\n return errors;\n }\n\n for (let index = 0; index < files.length; index++) {\n const file = files[index];\n\n if (\n Array.isArray(accept) &&\n accept.length &&\n !accept.some(type => minimatch(file.type, type))\n ) {\n errors.push({\n id: generateId(),\n index,\n file,\n type: \"unsupportedFileType\"\n });\n } else if (maxSize) {\n const sizeAsBytes = bytes(maxSize);\n if (sizeAsBytes && file.size > sizeAsBytes) {\n errors.push({\n id: generateId(),\n index,\n file,\n type: \"maxSizeExceeded\"\n });\n }\n }\n\n if (multiple) {\n multipleFileSize += file.size;\n }\n }\n\n if (multiple) {\n const maxMultipleMaxSize = bytes(multipleMaxSize);\n\n if (maxMultipleMaxSize && multipleMaxSize && multipleFileSize > maxMultipleMaxSize) {\n errors.push({\n id: generateId(),\n type: \"multipleMaxSizeExceeded\",\n multipleFileSize,\n multipleMaxSize: maxMultipleMaxSize\n });\n }\n\n if (multipleMaxCount && files.length > multipleMaxCount) {\n errors.push({\n id: generateId(),\n type: \"multipleMaxCountExceeded\",\n multipleCount: files.length,\n multipleMaxCount\n });\n }\n }\n\n return errors;\n };\n\n processSelectedFiles = async (eventFiles: Array<File>) => {\n if (eventFiles.length === 0) {\n return;\n }\n\n const { convertToBase64, onSuccess, onError } = this.props;\n const { browseFilesPassedParams } = this;\n const callbacks = {\n onSuccess,\n onError\n };\n\n if (browseFilesPassedParams && browseFilesPassedParams.onSuccess) {\n callbacks.onSuccess = browseFilesPassedParams.onSuccess;\n }\n\n if (browseFilesPassedParams && browseFilesPassedParams.onError) {\n callbacks.onError = browseFilesPassedParams.onError;\n }\n\n const files: SelectedFile[] = [...eventFiles].map(file => {\n return {\n id: generateId(),\n name: file.name,\n type: file.type,\n size: file.size,\n src: {\n file,\n base64: null\n }\n };\n });\n\n const errors = this.validateFiles(files);\n\n if (errors.length) {\n callbacks.onError && callbacks.onError(errors, files);\n } else {\n if (convertToBase64) {\n for (let i = 0; i < files.length; i++) {\n const file = files[i].src.file;\n files[i].src.base64 = await readFileContent(file);\n }\n }\n\n callbacks.onSuccess && callbacks.onSuccess(files);\n }\n\n // Reset the browseFiles arguments.\n if (this.input) {\n this.input.value = \"\";\n }\n this.browseFilesPassedParams = null;\n };\n\n /**\n * Extracted into a separate method just for testing purposes.\n */\n onDropFilesHandler = async ({ e, onSuccess, onError }: any) => {\n this.browseFilesPassedParams = { onSuccess, onError };\n e.dataTransfer &&\n e.dataTransfer.files &&\n (await this.processSelectedFiles(e.dataTransfer.files));\n };\n\n /**\n * Extracted into a separate method just for testing purposes.\n */\n browseFilesHandler = ({ onSuccess, onError }: any) => {\n this.browseFilesPassedParams = { onSuccess, onError };\n this.input && this.input.click();\n };\n\n override render() {\n const { multiple, accept, id } = this.props;\n return (\n <React.Fragment>\n {this.props.children({\n getLabelProps: (props: any) => {\n return {\n ...props,\n htmlFor: id || this.id\n };\n },\n validateFiles: this.validateFiles,\n browseFiles: ({ onSuccess, onError }: BrowseFilesParams = {}) => {\n this.browseFilesHandler({ onSuccess, onError });\n },\n getDropZoneProps: ({\n onSuccess,\n onError,\n onDragOver,\n onDrop,\n ...rest\n }: any = {}) => {\n return {\n ...rest,\n onDragOver: (e: DragEvent) => {\n e.preventDefault();\n typeof onDragOver === \"function\" && onDragOver();\n },\n onDrop: async (e: DragEvent) => {\n e.preventDefault();\n typeof onDrop === \"function\" && onDrop();\n this.onDropFilesHandler({ e, onSuccess, onError });\n }\n };\n }\n })}\n\n <input\n id={id || this.id}\n ref={ref => {\n if (ref) {\n this.input = ref;\n }\n }}\n accept={accept.join(\",\")}\n style={{ display: \"none\" }}\n type=\"file\"\n multiple={multiple}\n onChange={e =>\n this.processSelectedFiles((e.target.files as any as Array<File>) ?? [])\n }\n />\n </React.Fragment>\n );\n }\n}\n"],"mappings":"AAAA,OAAOA,KAAK,MAAM,OAAO;AACzB,OAAOC,KAAK,MAAM,OAAO;AACzB,OAAOC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CAACW,kBAAkB,CAAC;UAAEZ,SAAS;UAAEC;QAAQ,CAAC,CAAC;MACnD,CAAC;MACDoB,gBAAgB,EAAEA,CAAC;QACfrB,SAAS;QACTC,OAAO;QACPqB,UAAU;QACVC,MAAM;QACN,GAAGC;MACF,CAAC,GAAG,CAAC,CAAC,KAAK;QACZ,OAAO;UACH,GAAGA,IAAI;UACPF,UAAU,EAAGZ,CAAY,IAAK;YAC1BA,CAAC,CAACe,cAAc,CAAC,CAAC;YAClB,OAAOH,UAAU,KAAK,UAAU,IAAIA,UAAU,CAAC,CAAC;UACpD,CAAC;UACDC,MAAM,EAAE,MAAOb,CAAY,IAAK;YAC5BA,CAAC,CAACe,cAAc,CAAC,CAAC;YAClB,OAAOF,MAAM,KAAK,UAAU,IAAIA,MAAM,CAAC,CAAC;YACxC,IAAI,CAACd,kBAAkB,CAAC;cAAEC,CAAC;cAAEV,SAAS;cAAEC;YAAQ,CAAC,CAAC;UACtD;QACJ,CAAC;MACL;IACJ,CAAC,CAAC,eAEFrC,KAAA,CAAAmD,aAAA;MACInC,EAAE,EAAEA,EAAE,IAAI,IAAI,CAACA,EAAG;MAClB8C,GAAG,EAAEA,GAAG,IAAI;QACR,IAAIA,GAAG,EAAE;UACL,IAAI,CAAChD,KAAK,GAAGgD,GAAG;QACpB;MACJ,CAAE;MACFtD,MAAM,EAAEA,MAAM,CAACuD,IAAI,CAAC,GAAG,CAAE;MACzBC,KAAK,EAAE;QAAEC,OAAO,EAAE;MAAO,CAAE;MAC3BzC,IAAI,EAAC,MAAM;MACXf,QAAQ,EAAEA,QAAS;MACnByD,QAAQ,EAAEpB,CAAC,IACP,IAAI,CAACZ,oBAAoB,CAAEY,CAAC,CAACqB,MAAM,CAACjD,KAAK,IAA2B,EAAE;IACzE,CACJ,CACW,CAAC;EAEzB;AACJ","ignoreList":[]}
|
|
1
|
+
{"version":3,"names":["React","bytes","minimatch","readFileContent","generateId","Files","Component","defaultProps","accept","multiple","maxSize","multipleMaxSize","multipleMaxCount","convertToBase64","input","browseFilesPassedParams","id","validateFiles","files","props","errors","multipleFileSize","length","push","type","index","file","Array","isArray","some","sizeAsBytes","size","maxMultipleMaxSize","multipleCount","processSelectedFiles","eventFiles","onSuccess","onError","callbacks","map","name","src","base64","i","value","onDropFilesHandler","e","dataTransfer","browseFilesHandler","click","render","createElement","Fragment","children","getLabelProps","htmlFor","browseFiles","getDropZoneProps","onDragOver","onDrop","rest","preventDefault","ref","join","style","display","onChange","target"],"sources":["Files.tsx"],"sourcesContent":["import React from \"react\";\nimport bytes from \"bytes\";\nimport { minimatch } from \"minimatch\";\nimport { readFileContent } from \"./utils/readFileContent.js\";\nimport { generateId } from \"./utils/generateId.js\";\n\nexport type SelectedFile = {\n id: string;\n name: string;\n type: string;\n size: number;\n src: {\n file: File;\n base64: string | null;\n };\n};\n\nexport type FileError = {\n id: string;\n type:\n | \"unsupportedFileType\"\n | \"maxSizeExceeded\"\n | \"multipleMaxSizeExceeded\"\n | \"multipleMaxCountExceeded\"\n | \"multipleNotAllowed\";\n index?: number;\n file?: SelectedFile | File;\n multipleFileSize?: number;\n multipleMaxSize?: number;\n multipleMaxCount?: number;\n multipleCount?: number;\n};\n\nexport type BrowseFilesParams = {\n onSuccess?: (files: SelectedFile[]) => void;\n onError?: (errors: FileError[], files: SelectedFile[]) => void;\n};\n\nexport type RenderPropParams = {\n browseFiles: (params: BrowseFilesParams) => void;\n getDropZoneProps: (additionalProps: any) => any;\n getLabelProps: (additionalProps: any) => any;\n validateFiles: (files: SelectedFile[] | File[]) => FileError[];\n};\n\nexport type FilesRules = {\n accept: string[];\n multiple: boolean;\n maxSize: string;\n multipleMaxSize: string;\n multipleMaxCount: number | null;\n convertToBase64: boolean;\n onSuccess?: (files: SelectedFile[]) => void;\n onError?: (errors: FileError[], files: SelectedFile[]) => void;\n};\n\nexport type Props = FilesRules & {\n children: (params: RenderPropParams) => React.ReactNode;\n id?: string;\n};\n\nexport class Files extends React.Component<Props> {\n static defaultProps = {\n accept: [],\n multiple: false,\n maxSize: \"2mb\",\n multipleMaxSize: \"10mb\",\n multipleMaxCount: null,\n convertToBase64: false\n };\n\n input: HTMLInputElement | null = null;\n browseFilesPassedParams: BrowseFilesParams | null = null;\n id: string = generateId();\n\n validateFiles = (files: SelectedFile[] | File[]): FileError[] => {\n const { multiple, multipleMaxSize, multipleMaxCount, accept, maxSize } = this.props;\n\n const errors: FileError[] = [];\n let multipleFileSize = 0;\n\n if (!multiple && files.length > 1) {\n errors.push({\n id: generateId(),\n type: \"multipleNotAllowed\"\n });\n\n return errors;\n }\n\n for (let index = 0; index < files.length; index++) {\n const file = files[index];\n\n if (\n Array.isArray(accept) &&\n accept.length &&\n !accept.some(type => minimatch(file.type, type))\n ) {\n errors.push({\n id: generateId(),\n index,\n file,\n type: \"unsupportedFileType\"\n });\n } else if (maxSize) {\n const sizeAsBytes = bytes(maxSize);\n if (sizeAsBytes && file.size > sizeAsBytes) {\n errors.push({\n id: generateId(),\n index,\n file,\n type: \"maxSizeExceeded\"\n });\n }\n }\n\n if (multiple) {\n multipleFileSize += file.size;\n }\n }\n\n if (multiple) {\n const maxMultipleMaxSize = bytes(multipleMaxSize);\n\n if (maxMultipleMaxSize && multipleMaxSize && multipleFileSize > maxMultipleMaxSize) {\n errors.push({\n id: generateId(),\n type: \"multipleMaxSizeExceeded\",\n multipleFileSize,\n multipleMaxSize: maxMultipleMaxSize\n });\n }\n\n if (multipleMaxCount && files.length > multipleMaxCount) {\n errors.push({\n id: generateId(),\n type: \"multipleMaxCountExceeded\",\n multipleCount: files.length,\n multipleMaxCount\n });\n }\n }\n\n return errors;\n };\n\n processSelectedFiles = async (eventFiles: Array<File>) => {\n if (eventFiles.length === 0) {\n return;\n }\n\n const { convertToBase64, onSuccess, onError } = this.props;\n const { browseFilesPassedParams } = this;\n const callbacks = {\n onSuccess,\n onError\n };\n\n if (browseFilesPassedParams && browseFilesPassedParams.onSuccess) {\n callbacks.onSuccess = browseFilesPassedParams.onSuccess;\n }\n\n if (browseFilesPassedParams && browseFilesPassedParams.onError) {\n callbacks.onError = browseFilesPassedParams.onError;\n }\n\n const files: SelectedFile[] = [...eventFiles].map(file => {\n return {\n id: generateId(),\n name: file.name,\n type: file.type,\n size: file.size,\n src: {\n file,\n base64: null\n }\n };\n });\n\n const errors = this.validateFiles(files);\n\n if (errors.length) {\n callbacks.onError && callbacks.onError(errors, files);\n } else {\n if (convertToBase64) {\n for (let i = 0; i < files.length; i++) {\n const file = files[i].src.file;\n files[i].src.base64 = await readFileContent(file);\n }\n }\n\n callbacks.onSuccess && callbacks.onSuccess(files);\n }\n\n // Reset the browseFiles arguments.\n if (this.input) {\n this.input.value = \"\";\n }\n this.browseFilesPassedParams = null;\n };\n\n /**\n * Extracted into a separate method just for testing purposes.\n */\n onDropFilesHandler = async ({ e, onSuccess, onError }: any) => {\n this.browseFilesPassedParams = { onSuccess, onError };\n e.dataTransfer &&\n e.dataTransfer.files &&\n (await this.processSelectedFiles(e.dataTransfer.files));\n };\n\n /**\n * Extracted into a separate method just for testing purposes.\n */\n browseFilesHandler = ({ onSuccess, onError }: any) => {\n this.browseFilesPassedParams = { onSuccess, onError };\n this.input && this.input.click();\n };\n\n override render() {\n const { multiple, accept, id } = this.props;\n return (\n <React.Fragment>\n {this.props.children({\n getLabelProps: (props: any) => {\n return {\n ...props,\n htmlFor: id || this.id\n };\n },\n validateFiles: this.validateFiles,\n browseFiles: ({ onSuccess, onError }: BrowseFilesParams = {}) => {\n this.browseFilesHandler({ onSuccess, onError });\n },\n getDropZoneProps: ({\n onSuccess,\n onError,\n onDragOver,\n onDrop,\n ...rest\n }: any = {}) => {\n return {\n ...rest,\n onDragOver: (e: DragEvent) => {\n e.preventDefault();\n typeof onDragOver === \"function\" && onDragOver();\n },\n onDrop: async (e: DragEvent) => {\n e.preventDefault();\n typeof onDrop === \"function\" && onDrop();\n this.onDropFilesHandler({ e, onSuccess, onError });\n }\n };\n }\n })}\n\n <input\n id={id || this.id}\n ref={ref => {\n if (ref) {\n this.input = ref;\n }\n }}\n accept={accept.join(\",\")}\n style={{ display: \"none\" }}\n type=\"file\"\n multiple={multiple}\n onChange={e =>\n this.processSelectedFiles((e.target.files as any as Array<File>) ?? [])\n }\n />\n </React.Fragment>\n );\n }\n}\n"],"mappings":"AAAA,OAAOA,KAAK,MAAM,OAAO;AACzB,OAAOC,KAAK,MAAM,OAAO;AACzB,SAASC,SAAS,QAAQ,WAAW;AACrC,SAASC,eAAe;AACxB,SAASC,UAAU;AAyDnB,OAAO,MAAMC,KAAK,SAASL,KAAK,CAACM,SAAS,CAAQ;EAC9C,OAAOC,YAAY,GAAG;IAClBC,MAAM,EAAE,EAAE;IACVC,QAAQ,EAAE,KAAK;IACfC,OAAO,EAAE,KAAK;IACdC,eAAe,EAAE,MAAM;IACvBC,gBAAgB,EAAE,IAAI;IACtBC,eAAe,EAAE;EACrB,CAAC;EAEDC,KAAK,GAA4B,IAAI;EACrCC,uBAAuB,GAA6B,IAAI;EACxDC,EAAE,GAAWZ,UAAU,CAAC,CAAC;EAEzBa,aAAa,GAAIC,KAA8B,IAAkB;IAC7D,MAAM;MAAET,QAAQ;MAAEE,eAAe;MAAEC,gBAAgB;MAAEJ,MAAM;MAAEE;IAAQ,CAAC,GAAG,IAAI,CAACS,KAAK;IAEnF,MAAMC,MAAmB,GAAG,EAAE;IAC9B,IAAIC,gBAAgB,GAAG,CAAC;IAExB,IAAI,CAACZ,QAAQ,IAAIS,KAAK,CAACI,MAAM,GAAG,CAAC,EAAE;MAC/BF,MAAM,CAACG,IAAI,CAAC;QACRP,EAAE,EAAEZ,UAAU,CAAC,CAAC;QAChBoB,IAAI,EAAE;MACV,CAAC,CAAC;MAEF,OAAOJ,MAAM;IACjB;IAEA,KAAK,IAAIK,KAAK,GAAG,CAAC,EAAEA,KAAK,GAAGP,KAAK,CAACI,MAAM,EAAEG,KAAK,EAAE,EAAE;MAC/C,MAAMC,IAAI,GAAGR,KAAK,CAACO,KAAK,CAAC;MAEzB,IACIE,KAAK,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,QAAQ,EAAEpB,CAAC,IACP,IAAI,CAACZ,oBAAoB,CAAEY,CAAC,CAACqB,MAAM,CAACjD,KAAK,IAA2B,EAAE;IACzE,CACJ,CACW,CAAC;EAEzB;AACJ","ignoreList":[]}
|
package/core/DebounceRender.d.ts
DELETED
|
@@ -1,12 +0,0 @@
|
|
|
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 {};
|
package/core/DebounceRender.js
DELETED
|
@@ -1,31 +0,0 @@
|
|
|
1
|
-
import React from "react";
|
|
2
|
-
import { useEffect, useMemo, useState } from "react";
|
|
3
|
-
import debounce from "lodash/debounce.js";
|
|
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
|
|
@@ -1 +0,0 @@
|
|
|
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.js\";\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,oBAAoB;AAMzC;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":[]}
|
package/core/Routes.d.ts
DELETED
package/core/Routes.js
DELETED
|
@@ -1,33 +0,0 @@
|
|
|
1
|
-
import React from "react";
|
|
2
|
-
import { useRouter } from "../router.js";
|
|
3
|
-
import { RouteContent } from "../presentation/router/components/RouteContent.js";
|
|
4
|
-
export const Routes = props => {
|
|
5
|
-
const {
|
|
6
|
-
setRoutes
|
|
7
|
-
} = useRouter();
|
|
8
|
-
const routes = props.routes.sort((a, b) => {
|
|
9
|
-
const pathA = a.route.path || "*";
|
|
10
|
-
const pathB = b.route.path || "*";
|
|
11
|
-
|
|
12
|
-
// This will sort paths at the very bottom of the list
|
|
13
|
-
if (pathA === "/" && pathB === "*") {
|
|
14
|
-
return -1;
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
// This will push * and / to the bottom of the list
|
|
18
|
-
if (pathA === "*" || pathA === "/") {
|
|
19
|
-
return 1;
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
// This will push * and / to the bottom of the list
|
|
23
|
-
if (["*", "/"].includes(pathB)) {
|
|
24
|
-
return -1;
|
|
25
|
-
}
|
|
26
|
-
return 0;
|
|
27
|
-
});
|
|
28
|
-
console.log("Call to setRoutes");
|
|
29
|
-
setRoutes(routes);
|
|
30
|
-
return /*#__PURE__*/React.createElement(RouteContent, null);
|
|
31
|
-
};
|
|
32
|
-
|
|
33
|
-
//# sourceMappingURL=Routes.js.map
|
package/core/Routes.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"names":["React","useRouter","RouteContent","Routes","props","setRoutes","routes","sort","a","b","pathA","route","path","pathB","includes","console","log","createElement"],"sources":["Routes.tsx"],"sourcesContent":["import React from \"react\";\nimport { useRouter } from \"~/router.js\";\nimport type { ReactRoute } from \"~/presentation/router/index.js\";\nimport { RouteContent } from \"~/presentation/router/components/RouteContent.js\";\n\ninterface RoutesProps {\n routes: ReactRoute[];\n}\n\nexport const Routes = (props: RoutesProps) => {\n const { setRoutes } = useRouter();\n\n const routes = props.routes.sort((a, b) => {\n const pathA: string = a.route.path || \"*\";\n const pathB: string = b.route.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 console.log(\"Call to setRoutes\");\n setRoutes(routes);\n\n return <RouteContent />;\n};\n"],"mappings":"AAAA,OAAOA,KAAK,MAAM,OAAO;AACzB,SAASC,SAAS;AAElB,SAASC,YAAY;AAMrB,OAAO,MAAMC,MAAM,GAAIC,KAAkB,IAAK;EAC1C,MAAM;IAAEC;EAAU,CAAC,GAAGJ,SAAS,CAAC,CAAC;EAEjC,MAAMK,MAAM,GAAGF,KAAK,CAACE,MAAM,CAACC,IAAI,CAAC,CAACC,CAAC,EAAEC,CAAC,KAAK;IACvC,MAAMC,KAAa,GAAGF,CAAC,CAACG,KAAK,CAACC,IAAI,IAAI,GAAG;IACzC,MAAMC,KAAa,GAAGJ,CAAC,CAACE,KAAK,CAACC,IAAI,IAAI,GAAG;;IAEzC;IACA,IAAIF,KAAK,KAAK,GAAG,IAAIG,KAAK,KAAK,GAAG,EAAE;MAChC,OAAO,CAAC,CAAC;IACb;;IAEA;IACA,IAAIH,KAAK,KAAK,GAAG,IAAIA,KAAK,KAAK,GAAG,EAAE;MAChC,OAAO,CAAC;IACZ;;IAEA;IACA,IAAI,CAAC,GAAG,EAAE,GAAG,CAAC,CAACI,QAAQ,CAACD,KAAK,CAAC,EAAE;MAC5B,OAAO,CAAC,CAAC;IACb;IAEA,OAAO,CAAC;EACZ,CAAC,CAAC;EAEFE,OAAO,CAACC,GAAG,CAAC,mBAAmB,CAAC;EAChCX,SAAS,CAACC,MAAM,CAAC;EAEjB,oBAAON,KAAA,CAAAiB,aAAA,CAACf,YAAY,MAAE,CAAC;AAC3B,CAAC","ignoreList":[]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"names":["EnvConfig"],"sources":["envConfig.ts"],"sourcesContent":["export { EnvConfig } from \"~/features/envConfig/index.js\";\n"],"mappings":"AAAA,SAASA,SAAS","ignoreList":[]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"names":["GraphQLClient"],"sources":["graphqlClient.ts"],"sourcesContent":["export { GraphQLClient } from \"~/features/graphqlClient/abstractions.js\";\n"],"mappings":"AAAA,SAASA,aAAa","ignoreList":[]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"names":["LocalStorage","useLocalStorage","useLocalStorageValue","useLocalStorageValues"],"sources":["localStorage.ts"],"sourcesContent":["export { LocalStorage } from \"~/features/localStorage/abstractions.js\";\nexport {\n useLocalStorage,\n useLocalStorageValue,\n useLocalStorageValues\n} from \"~/presentation/localStorage/index.js\";\n"],"mappings":"AAAA,SAASA,YAAY;AACrB,SACIC,eAAe,EACfC,oBAAoB,EACpBC,qBAAqB","ignoreList":[]}
|
|
File without changes
|
|
File without changes
|
|
File without changes
|