@webiny/app 0.0.0-unstable.eb196ccd2f → 0.0.0-unstable.f6dc066313
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 +4 -5
- package/App.js +26 -32
- package/App.js.map +1 -1
- package/README.md +7 -15
- package/apollo-client/InMemoryCache.js +2 -2
- package/apollo-client/InMemoryCache.js.map +1 -1
- package/components/Image.d.ts +1 -2
- package/components/Image.js +1 -1
- package/components/Image.js.map +1 -1
- package/components/index.d.ts +1 -2
- package/components/index.js +1 -2
- package/components/index.js.map +1 -1
- package/config/RouterConfig/Route.d.ts +9 -10
- package/config/RouterConfig/Route.js +5 -14
- package/config/RouterConfig/Route.js.map +1 -1
- package/config/RouterConfig.d.ts +10 -11
- package/config/RouterConfig.js +1 -1
- package/config/RouterConfig.js.map +1 -1
- package/contexts/Ui/index.js.map +1 -1
- package/core/Plugin.js +2 -2
- package/core/Plugin.js.map +1 -1
- package/core/Plugins.d.ts +1 -1
- package/core/Plugins.js +5 -4
- package/core/Plugins.js.map +1 -1
- package/core/Provider.d.ts +1 -1
- package/core/Provider.js +1 -1
- package/core/Provider.js.map +1 -1
- package/core/createProviderPlugin.js +1 -1
- package/core/createProviderPlugin.js.map +1 -1
- package/errors/AuthenticationErrorEvent.d.ts +9 -0
- package/errors/AuthenticationErrorEvent.js +10 -0
- package/errors/AuthenticationErrorEvent.js.map +1 -0
- package/errors/NetworkErrorEvent.d.ts +15 -0
- package/errors/NetworkErrorEvent.js +10 -0
- package/errors/NetworkErrorEvent.js.map +1 -0
- package/errors/abstractions.d.ts +12 -0
- package/errors/abstractions.js +5 -0
- package/errors/abstractions.js.map +1 -0
- package/errors/index.d.ts +6 -0
- package/errors/index.js +6 -0
- package/errors/index.js.map +1 -0
- package/exports/admin/env-config.d.ts +1 -0
- package/exports/admin/env-config.js +3 -0
- package/exports/admin/env-config.js.map +1 -0
- package/exports/admin/graphql-client.d.ts +1 -0
- package/exports/admin/graphql-client.js +3 -0
- package/exports/admin/graphql-client.js.map +1 -0
- package/exports/admin/local-storage.d.ts +2 -0
- package/exports/admin/local-storage.js +4 -0
- package/exports/admin/local-storage.js.map +1 -0
- package/exports/admin/router.d.ts +5 -0
- package/exports/admin/router.js +7 -0
- package/exports/admin/router.js.map +1 -0
- package/exports/admin/security.d.ts +1 -0
- package/exports/admin/security.js +3 -0
- package/exports/admin/security.js.map +1 -0
- package/exports/admin.d.ts +6 -0
- package/exports/admin.js +8 -0
- package/exports/admin.js.map +1 -0
- package/features/envConfig/EnvConfig.d.ts +6 -0
- package/features/envConfig/EnvConfig.js +14 -0
- package/features/envConfig/EnvConfig.js.map +1 -0
- package/features/envConfig/abstractions.d.ts +27 -0
- package/features/envConfig/abstractions.js +4 -0
- package/features/envConfig/abstractions.js.map +1 -0
- package/features/envConfig/feature.d.ts +17 -0
- package/features/envConfig/feature.js +14 -0
- package/features/envConfig/feature.js.map +1 -0
- package/features/envConfig/index.d.ts +1 -0
- package/features/envConfig/index.js +3 -0
- package/features/envConfig/index.js.map +1 -0
- package/features/eventPublisher/EventPublisher.d.ts +8 -0
- package/features/eventPublisher/EventPublisher.js +27 -0
- package/features/eventPublisher/EventPublisher.js.map +1 -0
- package/features/eventPublisher/abstractions.d.ts +18 -0
- package/features/eventPublisher/abstractions.js +14 -0
- package/features/eventPublisher/abstractions.js.map +1 -0
- package/features/eventPublisher/feature.d.ts +1 -0
- package/features/eventPublisher/feature.js +11 -0
- package/features/eventPublisher/feature.js.map +1 -0
- package/features/eventPublisher/index.d.ts +3 -0
- package/features/eventPublisher/index.js +4 -0
- package/features/eventPublisher/index.js.map +1 -0
- package/features/graphqlClient/AuthenticationErrorPublishing.d.ts +13 -0
- package/features/graphqlClient/AuthenticationErrorPublishing.js +35 -0
- package/features/graphqlClient/AuthenticationErrorPublishing.js.map +1 -0
- package/features/graphqlClient/BatchingGraphQLClient.d.ts +18 -0
- package/features/graphqlClient/BatchingGraphQLClient.js +164 -0
- package/features/graphqlClient/BatchingGraphQLClient.js.map +1 -0
- package/features/graphqlClient/FetchGraphQLClient.d.ts +10 -0
- package/features/graphqlClient/FetchGraphQLClient.js +62 -0
- package/features/graphqlClient/FetchGraphQLClient.js.map +1 -0
- package/features/graphqlClient/NetworkErrorPublishing.d.ts +14 -0
- package/features/graphqlClient/NetworkErrorPublishing.js +55 -0
- package/features/graphqlClient/NetworkErrorPublishing.js.map +1 -0
- package/features/graphqlClient/RequestValue.d.ts +20 -0
- package/features/graphqlClient/RequestValue.js +42 -0
- package/features/graphqlClient/RequestValue.js.map +1 -0
- package/features/graphqlClient/RetryGraphQLClient.d.ts +18 -0
- package/features/graphqlClient/RetryGraphQLClient.js +54 -0
- package/features/graphqlClient/RetryGraphQLClient.js.map +1 -0
- package/features/graphqlClient/__tests__/GraphQLClient.test.d.ts +1 -0
- package/features/graphqlClient/__tests__/GraphQLClient.test.js +350 -0
- package/features/graphqlClient/__tests__/GraphQLClient.test.js.map +1 -0
- package/features/graphqlClient/abstractions.d.ts +17 -0
- package/features/graphqlClient/abstractions.js +4 -0
- package/features/graphqlClient/abstractions.js.map +1 -0
- package/features/graphqlClient/feature.d.ts +6 -0
- package/features/graphqlClient/feature.js +31 -0
- package/features/graphqlClient/feature.js.map +1 -0
- package/features/graphqlClient/index.d.ts +1 -0
- package/features/graphqlClient/index.js +3 -0
- package/features/graphqlClient/index.js.map +1 -0
- package/features/graphqlClient/types.d.ts +5 -0
- package/features/graphqlClient/types.js.map +1 -0
- package/features/localStorage/BrowserLocalStorageGateway.d.ts +9 -0
- package/features/localStorage/BrowserLocalStorageGateway.js +68 -0
- package/features/localStorage/BrowserLocalStorageGateway.js.map +1 -0
- package/features/localStorage/LocalStorage.d.ts +12 -0
- package/features/localStorage/LocalStorage.js +31 -0
- package/features/localStorage/LocalStorage.js.map +1 -0
- package/features/localStorage/LocalStorageRepository.d.ts +20 -0
- package/features/localStorage/LocalStorageRepository.js +95 -0
- package/features/localStorage/LocalStorageRepository.js.map +1 -0
- package/features/localStorage/abstractions.d.ts +48 -0
- package/features/localStorage/abstractions.js +19 -0
- package/features/localStorage/abstractions.js.map +1 -0
- package/features/localStorage/feature.d.ts +12 -0
- package/features/localStorage/feature.js +34 -0
- package/features/localStorage/feature.js.map +1 -0
- package/features/localStorage/index.d.ts +1 -0
- package/features/localStorage/index.js +3 -0
- package/features/localStorage/index.js.map +1 -0
- package/features/router/HistoryRouterGateway.d.ts +18 -0
- package/features/router/HistoryRouterGateway.js +82 -0
- package/features/router/HistoryRouterGateway.js.map +1 -0
- package/features/router/HistoryRouterGateway.test.d.ts +1 -0
- package/features/router/HistoryRouterGateway.test.js +204 -0
- package/features/router/HistoryRouterGateway.test.js.map +1 -0
- package/features/router/Route.d.ts +19 -0
- package/features/router/Route.js +59 -0
- package/features/router/Route.js.map +1 -0
- package/features/router/RouteUrl.d.ts +85 -0
- package/features/router/RouteUrl.js +232 -0
- package/features/router/RouteUrl.js.map +1 -0
- package/features/router/Router.d.ts +45 -0
- package/features/router/Router.js +129 -0
- package/features/router/Router.js.map +1 -0
- package/features/router/RouterPresenter.d.ts +17 -0
- package/features/router/RouterPresenter.js +45 -0
- package/features/router/RouterPresenter.js.map +1 -0
- package/features/router/RouterRepository.d.ts +21 -0
- package/features/router/RouterRepository.js +71 -0
- package/features/router/RouterRepository.js.map +1 -0
- package/features/router/RouterRepository.test.d.ts +1 -0
- package/features/router/RouterRepository.test.js +154 -0
- package/features/router/RouterRepository.test.js.map +1 -0
- package/features/router/abstractions.d.ts +68 -0
- package/features/router/abstractions.js +15 -0
- package/features/router/abstractions.js.map +1 -0
- package/features/router/feature.d.ts +4 -0
- package/features/router/feature.js +18 -0
- package/features/router/feature.js.map +1 -0
- package/features/router/index.d.ts +1 -0
- package/features/router/index.js +3 -0
- package/features/router/index.js.map +1 -0
- package/helpers/InterfaceGenerator/date.d.ts +15 -0
- package/helpers/InterfaceGenerator/date.js +3 -0
- package/helpers/InterfaceGenerator/date.js.map +1 -0
- package/helpers/InterfaceGenerator/id.d.ts +23 -0
- package/helpers/InterfaceGenerator/id.js +3 -0
- package/helpers/InterfaceGenerator/id.js.map +1 -0
- package/helpers/InterfaceGenerator/identity.d.ts +10 -0
- package/helpers/InterfaceGenerator/identity.js +3 -0
- package/helpers/InterfaceGenerator/identity.js.map +1 -0
- package/helpers/InterfaceGenerator/index.d.ts +5 -0
- package/helpers/InterfaceGenerator/index.js +3 -0
- package/helpers/InterfaceGenerator/index.js.map +1 -0
- package/helpers/InterfaceGenerator/numeric.d.ts +12 -0
- package/helpers/InterfaceGenerator/numeric.js +3 -0
- package/helpers/InterfaceGenerator/numeric.js.map +1 -0
- package/helpers/InterfaceGenerator/truthful.d.ts +7 -0
- package/helpers/InterfaceGenerator/truthful.js +3 -0
- package/helpers/InterfaceGenerator/truthful.js.map +1 -0
- package/hooks/useAutocomplete/index.d.ts +1 -1
- package/hooks/useAutocomplete/index.js +1 -1
- package/hooks/useAutocomplete/index.js.map +1 -1
- package/hooks/useAutocomplete/useAutocomplete.js +3 -6
- package/hooks/useAutocomplete/useAutocomplete.js.map +1 -1
- package/hooks/useDataList/functions/getData.js +1 -1
- package/hooks/useDataList/functions/getData.js.map +1 -1
- package/hooks/useDataList/functions/getError.js +1 -1
- package/hooks/useDataList/functions/getError.js.map +1 -1
- package/hooks/useDataList/functions/getMeta.js +1 -1
- package/hooks/useDataList/functions/getMeta.js.map +1 -1
- package/hooks/useDataList/functions/index.d.ts +3 -3
- package/hooks/useDataList/functions/index.js +3 -3
- package/hooks/useDataList/functions/index.js.map +1 -1
- package/hooks/useDataList/index.d.ts +1 -1
- package/hooks/useDataList/index.js +1 -1
- package/hooks/useDataList/index.js.map +1 -1
- package/hooks/useDataList/useDataList.d.ts +0 -1
- package/hooks/useDataList/useDataList.js +6 -26
- package/hooks/useDataList/useDataList.js.map +1 -1
- package/hooks/useDataList/utils/index.d.ts +1 -2
- package/hooks/useDataList/utils/index.js +1 -2
- package/hooks/useDataList/utils/index.js.map +1 -1
- package/hooks/useDataList/utils/prepareLoadListParams.js +1 -1
- package/hooks/useDataList/utils/prepareLoadListParams.js.map +1 -1
- package/hooks/useHandlers.js.map +1 -1
- package/hooks/useRegisterLegacyPlugin.d.ts +1 -1
- package/hooks/useRegisterLegacyPlugin.js.map +1 -1
- package/hooks/useUi.d.ts +1 -1
- package/hooks/useUi.js +1 -1
- package/hooks/useUi.js.map +1 -1
- package/i18n/index.d.ts +1 -1
- package/i18n/index.js +1 -1
- package/i18n/index.js.map +1 -1
- package/index.d.ts +22 -15
- package/index.js +21 -14
- package/index.js.map +1 -1
- package/package.json +25 -23
- package/plugins/AddQuerySelectionPlugin.d.ts +1 -1
- package/plugins/AddQuerySelectionPlugin.js +1 -1
- package/plugins/AddQuerySelectionPlugin.js.map +1 -1
- package/plugins/ApolloDynamicLink.d.ts +1 -1
- package/plugins/ApolloDynamicLink.js.map +1 -1
- package/plugins/ConsoleLinkPlugin.d.ts +1 -1
- package/plugins/ConsoleLinkPlugin.js +1 -1
- package/plugins/ConsoleLinkPlugin.js.map +1 -1
- package/plugins/NetworkErrorLinkPlugin/ErrorOverlay.d.ts +8 -13
- package/plugins/NetworkErrorLinkPlugin/ErrorOverlay.js +15 -26
- package/plugins/NetworkErrorLinkPlugin/ErrorOverlay.js.map +1 -1
- package/plugins/NetworkErrorLinkPlugin/GqlErrorOverlay.d.ts +14 -0
- package/plugins/NetworkErrorLinkPlugin/GqlErrorOverlay.js +31 -0
- package/plugins/NetworkErrorLinkPlugin/GqlErrorOverlay.js.map +1 -0
- package/plugins/NetworkErrorLinkPlugin/LocalAwsLambdaTimeoutMessage.d.ts +2 -0
- package/plugins/NetworkErrorLinkPlugin/LocalAwsLambdaTimeoutMessage.js +31 -0
- package/plugins/NetworkErrorLinkPlugin/LocalAwsLambdaTimeoutMessage.js.map +1 -0
- package/plugins/NetworkErrorLinkPlugin/StyledComponents.d.ts +4 -5
- package/plugins/NetworkErrorLinkPlugin/StyledComponents.js +3 -3
- package/plugins/NetworkErrorLinkPlugin/StyledComponents.js.map +1 -1
- package/plugins/NetworkErrorLinkPlugin/Typography.d.ts +8 -0
- package/plugins/NetworkErrorLinkPlugin/Typography.js +18 -0
- package/plugins/NetworkErrorLinkPlugin/Typography.js.map +1 -0
- package/plugins/NetworkErrorLinkPlugin/createErrorOverlay.d.ts +3 -3
- package/plugins/NetworkErrorLinkPlugin/createErrorOverlay.js +4 -13
- package/plugins/NetworkErrorLinkPlugin/createErrorOverlay.js.map +1 -1
- package/plugins/NetworkErrorLinkPlugin.d.ts +4 -1
- package/plugins/NetworkErrorLinkPlugin.js +47 -7
- package/plugins/NetworkErrorLinkPlugin.js.map +1 -1
- package/plugins/OmitTypenameLinkPlugin.d.ts +1 -1
- package/plugins/OmitTypenameLinkPlugin.js +1 -1
- package/plugins/OmitTypenameLinkPlugin.js.map +1 -1
- package/plugins/TenantHeaderLinkPlugin.d.ts +2 -2
- package/plugins/TenantHeaderLinkPlugin.js +2 -4
- package/plugins/TenantHeaderLinkPlugin.js.map +1 -1
- package/plugins/components/Image.d.ts +6 -0
- package/plugins/components/Image.js +19 -0
- package/plugins/components/Image.js.map +1 -0
- package/plugins/image.d.ts +1 -1
- package/plugins/image.js +2 -2
- package/plugins/image.js.map +1 -1
- package/plugins/index.d.ts +3 -3
- package/plugins/index.js +1 -1
- package/plugins/index.js.map +1 -1
- package/presentation/localStorage/index.d.ts +3 -0
- package/presentation/localStorage/index.js +5 -0
- package/presentation/localStorage/index.js.map +1 -0
- package/presentation/localStorage/useLocalStorage.d.ts +6 -0
- package/presentation/localStorage/useLocalStorage.js +21 -0
- package/presentation/localStorage/useLocalStorage.js.map +1 -0
- package/presentation/localStorage/useLocalStorageValue.d.ts +1 -0
- package/presentation/localStorage/useLocalStorageValue.js +20 -0
- package/presentation/localStorage/useLocalStorageValue.js.map +1 -0
- package/presentation/localStorage/useLocalStorageValues.d.ts +5 -0
- package/presentation/localStorage/useLocalStorageValues.js +39 -0
- package/presentation/localStorage/useLocalStorageValues.js.map +1 -0
- package/presentation/router/RouteElementRegistry.d.ts +14 -0
- package/presentation/router/RouteElementRegistry.js +32 -0
- package/presentation/router/RouteElementRegistry.js.map +1 -0
- package/presentation/router/abstractions.d.ts +13 -0
- package/presentation/router/abstractions.js +4 -0
- package/presentation/router/abstractions.js.map +1 -0
- 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/presentation/router/components/RouteContent.d.ts +2 -0
- package/presentation/router/components/RouteContent.js +17 -0
- package/presentation/router/components/RouteContent.js.map +1 -0
- package/presentation/router/components/RouteLink.d.ts +50 -0
- package/presentation/router/components/RouteLink.js +22 -0
- package/presentation/router/components/RouteLink.js.map +1 -0
- package/presentation/router/components/SimpleLink.d.ts +44 -0
- package/presentation/router/components/SimpleLink.js +30 -0
- package/presentation/router/components/SimpleLink.js.map +1 -0
- package/presentation/router/hooks/useRoute.d.ts +6 -0
- package/presentation/router/hooks/useRoute.js +30 -0
- package/presentation/router/hooks/useRoute.js.map +1 -0
- package/presentation/router/hooks/useRouter.d.ts +7 -0
- package/presentation/router/hooks/useRouter.js +26 -0
- package/presentation/router/hooks/useRouter.js.map +1 -0
- package/presentation/router/index.d.ts +4 -0
- package/presentation/router/index.js +5 -0
- package/presentation/router/index.js.map +1 -0
- package/presentation/router/types.d.ts +5 -0
- package/presentation/router/types.js +3 -0
- package/presentation/router/types.js.map +1 -0
- package/react-butterfiles/Files.js +3 -3
- package/react-butterfiles/Files.js.map +1 -1
- package/react-butterfiles/file.todo +1 -0
- package/react-butterfiles/index.d.ts +1 -1
- package/react-butterfiles/index.js +1 -1
- package/react-butterfiles/index.js.map +1 -1
- package/router.d.ts +5 -0
- package/router.js +8 -0
- package/router.js.map +1 -0
- package/shared/di/DiContainerProvider.d.ts +8 -0
- package/shared/di/DiContainerProvider.js +17 -0
- package/shared/di/DiContainerProvider.js.map +1 -0
- package/shared/di/createFeature.d.ts +11 -0
- package/shared/di/createFeature.js +11 -0
- package/shared/di/createFeature.js.map +1 -0
- package/shared/di/useFeature.d.ts +2 -0
- package/shared/di/useFeature.js +18 -0
- package/shared/di/useFeature.js.map +1 -0
- package/types.d.ts +7 -4
- package/types.js +1 -12
- package/types.js.map +1 -1
- package/utils/index.d.ts +2 -10
- package/utils/index.js +2 -10
- package/utils/index.js.map +1 -1
- package/utils/legacyPluginToReactComponent.js +1 -1
- package/utils/legacyPluginToReactComponent.js.map +1 -1
- package/components/Routes.d.ts +0 -2
- package/components/Routes.js +0 -36
- package/components/Routes.js.map +0 -1
- package/components/View.d.ts +0 -8
- package/components/View.js +0 -19
- package/components/View.js.map +0 -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 -6
- package/core/Routes.js +0 -34
- package/core/Routes.js.map +0 -1
- package/hooks/useDataList/utils/redirectToRouteWithQueryParams.d.ts +0 -14
- package/hooks/useDataList/utils/redirectToRouteWithQueryParams.js +0 -26
- package/hooks/useDataList/utils/redirectToRouteWithQueryParams.js.map +0 -1
- package/hooks/useDataList/utils/types.d.ts +0 -40
- package/hooks/useDataList/utils/types.js.map +0 -1
- package/plugins/LocaleHeaderLinkPlugin.d.ts +0 -10
- package/plugins/LocaleHeaderLinkPlugin.js +0 -32
- package/plugins/LocaleHeaderLinkPlugin.js.map +0 -1
- package/plugins/RoutePlugin.d.ts +0 -12
- package/plugins/RoutePlugin.js +0 -16
- package/plugins/RoutePlugin.js.map +0 -1
- package/plugins/ViewPlugin.d.ts +0 -14
- package/plugins/ViewPlugin.js +0 -19
- package/plugins/ViewPlugin.js.map +0 -1
- package/utils/getApiUrl.d.ts +0 -1
- package/utils/getApiUrl.js +0 -5
- package/utils/getApiUrl.js.map +0 -1
- package/utils/getGqlApiUrl.d.ts +0 -1
- package/utils/getGqlApiUrl.js +0 -6
- package/utils/getGqlApiUrl.js.map +0 -1
- package/utils/getHeadlessCmsGqlApiUrl.d.ts +0 -5
- package/utils/getHeadlessCmsGqlApiUrl.js +0 -12
- package/utils/getHeadlessCmsGqlApiUrl.js.map +0 -1
- package/utils/getLocaleCode.d.ts +0 -6
- package/utils/getLocaleCode.js +0 -33
- package/utils/getLocaleCode.js.map +0 -1
- package/utils/getPrerenderId.d.ts +0 -6
- package/utils/getPrerenderId.js +0 -5
- package/utils/getPrerenderId.js.map +0 -1
- package/utils/getTenantId.d.ts +0 -6
- package/utils/getTenantId.js +0 -45
- package/utils/getTenantId.js.map +0 -1
- package/utils/isLocalhost.d.ts +0 -1
- package/utils/isLocalhost.js +0 -7
- package/utils/isLocalhost.js.map +0 -1
- package/utils/isPrerendering.d.ts +0 -1
- package/utils/isPrerendering.js +0 -5
- package/utils/isPrerendering.js.map +0 -1
- /package/{hooks/useDataList/utils → features/graphqlClient}/types.js +0 -0
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import { makeDecoratable } from "@webiny/react-composition";
|
|
3
|
+
import { RouterGateway } from "../../../features/router/abstractions.js";
|
|
4
|
+
import { useContainer } from "../../../shared/di/DiContainerProvider.js";
|
|
5
|
+
export const SimpleLink = makeDecoratable("SimpleLink", ({
|
|
6
|
+
children,
|
|
7
|
+
to,
|
|
8
|
+
...rest
|
|
9
|
+
}) => {
|
|
10
|
+
const container = useContainer();
|
|
11
|
+
const routerGateway = container.resolve(RouterGateway);
|
|
12
|
+
const handleClick = event => {
|
|
13
|
+
// Respect cmd+click / ctrl+click / middle click → open in new tab
|
|
14
|
+
if (event.defaultPrevented || event.button !== 0 || event.metaKey || event.altKey || event.ctrlKey || event.shiftKey || rest.target === "_blank") {
|
|
15
|
+
return;
|
|
16
|
+
}
|
|
17
|
+
event.preventDefault();
|
|
18
|
+
routerGateway.pushState(to);
|
|
19
|
+
};
|
|
20
|
+
const onClick = rest.onClick ?? handleClick;
|
|
21
|
+
return /*#__PURE__*/React.createElement("a", Object.assign({
|
|
22
|
+
href: to,
|
|
23
|
+
rel: "noreferrer noopener"
|
|
24
|
+
}, rest, {
|
|
25
|
+
onClick: onClick
|
|
26
|
+
}), children);
|
|
27
|
+
});
|
|
28
|
+
export const LinkComponent = SimpleLink;
|
|
29
|
+
|
|
30
|
+
//# sourceMappingURL=SimpleLink.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["React","makeDecoratable","RouterGateway","useContainer","SimpleLink","children","to","rest","container","routerGateway","resolve","handleClick","event","defaultPrevented","button","metaKey","altKey","ctrlKey","shiftKey","target","preventDefault","pushState","onClick","createElement","Object","assign","href","rel","LinkComponent"],"sources":["SimpleLink.tsx"],"sourcesContent":["import React from \"react\";\nimport { makeDecoratable } from \"@webiny/react-composition\";\nimport { RouterGateway } from \"~/features/router/abstractions.js\";\nimport { useContainer } from \"~/shared/di/DiContainerProvider.js\";\n\ntype BaseAnchorAttributes = Omit<React.AnchorHTMLAttributes<HTMLAnchorElement>, \"href\">;\n\nexport type SimpleLinkProps = BaseAnchorAttributes & {\n to: string;\n};\n\nexport const SimpleLink = makeDecoratable(\n \"SimpleLink\",\n ({ children, to, ...rest }: SimpleLinkProps) => {\n const container = useContainer();\n\n const routerGateway = container.resolve(RouterGateway);\n\n const handleClick = (event: React.MouseEvent<HTMLAnchorElement>) => {\n // Respect cmd+click / ctrl+click / middle click → open in new tab\n if (\n event.defaultPrevented ||\n event.button !== 0 ||\n event.metaKey ||\n event.altKey ||\n event.ctrlKey ||\n event.shiftKey ||\n rest.target === \"_blank\"\n ) {\n return;\n }\n\n event.preventDefault();\n routerGateway.pushState(to);\n };\n\n const onClick = rest.onClick ?? handleClick;\n\n return (\n <a href={to} rel=\"noreferrer noopener\" {...rest} onClick={onClick}>\n {children}\n </a>\n );\n }\n);\n\nexport const LinkComponent = SimpleLink;\n"],"mappings":"AAAA,OAAOA,KAAK,MAAM,OAAO;AACzB,SAASC,eAAe,QAAQ,2BAA2B;AAC3D,SAASC,aAAa;AACtB,SAASC,YAAY;AAQrB,OAAO,MAAMC,UAAU,GAAGH,eAAe,CACrC,YAAY,EACZ,CAAC;EAAEI,QAAQ;EAAEC,EAAE;EAAE,GAAGC;AAAsB,CAAC,KAAK;EAC5C,MAAMC,SAAS,GAAGL,YAAY,CAAC,CAAC;EAEhC,MAAMM,aAAa,GAAGD,SAAS,CAACE,OAAO,CAACR,aAAa,CAAC;EAEtD,MAAMS,WAAW,GAAIC,KAA0C,IAAK;IAChE;IACA,IACIA,KAAK,CAACC,gBAAgB,IACtBD,KAAK,CAACE,MAAM,KAAK,CAAC,IAClBF,KAAK,CAACG,OAAO,IACbH,KAAK,CAACI,MAAM,IACZJ,KAAK,CAACK,OAAO,IACbL,KAAK,CAACM,QAAQ,IACdX,IAAI,CAACY,MAAM,KAAK,QAAQ,EAC1B;MACE;IACJ;IAEAP,KAAK,CAACQ,cAAc,CAAC,CAAC;IACtBX,aAAa,CAACY,SAAS,CAACf,EAAE,CAAC;EAC/B,CAAC;EAED,MAAMgB,OAAO,GAAGf,IAAI,CAACe,OAAO,IAAIX,WAAW;EAE3C,oBACIX,KAAA,CAAAuB,aAAA,MAAAC,MAAA,CAAAC,MAAA;IAAGC,IAAI,EAAEpB,EAAG;IAACqB,GAAG,EAAC;EAAqB,GAAKpB,IAAI;IAAEe,OAAO,EAAEA;EAAQ,IAC7DjB,QACF,CAAC;AAEZ,CACJ,CAAC;AAED,OAAO,MAAMuB,aAAa,GAAGxB,UAAU","ignoreList":[]}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import type { Route, RouteParamsDefinition, RouteParamsInfer } from "../../../features/router/Route.js";
|
|
2
|
+
import { MatchedRoute } from "../../../features/router/abstractions.js";
|
|
3
|
+
export declare function useRoute<TParams extends RouteParamsDefinition | undefined = undefined>(route?: Route<TParams>): {
|
|
4
|
+
route: MatchedRoute<TParams extends RouteParamsDefinition ? RouteParamsInfer<TParams> : undefined>;
|
|
5
|
+
setRouteParams: <T extends Record<string, any>>(cb: (params: T) => T) => void;
|
|
6
|
+
};
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { useEffect, useState } from "react";
|
|
2
|
+
import { autorun } from "mobx";
|
|
3
|
+
import { RouterFeature } from "../../../features/router/feature.js";
|
|
4
|
+
import { useFeature } from "../../../shared/di/useFeature.js";
|
|
5
|
+
export function useRoute(
|
|
6
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
7
|
+
route) {
|
|
8
|
+
const {
|
|
9
|
+
presenter
|
|
10
|
+
} = useFeature(RouterFeature);
|
|
11
|
+
const [currentRoute, setCurrentRoute] = useState(presenter.vm.currentRoute);
|
|
12
|
+
useEffect(() => {
|
|
13
|
+
autorun(() => {
|
|
14
|
+
const route = presenter.vm.currentRoute;
|
|
15
|
+
if (!route) {
|
|
16
|
+
return;
|
|
17
|
+
}
|
|
18
|
+
setCurrentRoute(route);
|
|
19
|
+
});
|
|
20
|
+
}, []);
|
|
21
|
+
|
|
22
|
+
// TODO: add validation (the requested route must match the current route)
|
|
23
|
+
|
|
24
|
+
return {
|
|
25
|
+
route: currentRoute,
|
|
26
|
+
setRouteParams: presenter.setRouteParams.bind(presenter)
|
|
27
|
+
};
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
//# sourceMappingURL=useRoute.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["useEffect","useState","autorun","RouterFeature","useFeature","useRoute","route","presenter","currentRoute","setCurrentRoute","vm","setRouteParams","bind"],"sources":["useRoute.ts"],"sourcesContent":["import { useEffect, useState } from \"react\";\nimport { autorun } from \"mobx\";\nimport type { Route, RouteParamsDefinition, RouteParamsInfer } from \"~/features/router/Route.js\";\nimport { MatchedRoute } from \"~/features/router/abstractions.js\";\nimport { RouterFeature } from \"~/features/router/feature.js\";\nimport { useFeature } from \"~/shared/di/useFeature.js\";\n\nexport function useRoute<TParams extends RouteParamsDefinition | undefined = undefined>(\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\n route?: Route<TParams>\n) {\n const { presenter } = useFeature(RouterFeature);\n const [currentRoute, setCurrentRoute] = useState<MatchedRoute | undefined>(\n presenter.vm.currentRoute\n );\n\n useEffect(() => {\n autorun(() => {\n const route = presenter.vm.currentRoute;\n\n if (!route) {\n return;\n }\n\n setCurrentRoute(route);\n });\n }, []);\n\n // TODO: add validation (the requested route must match the current route)\n\n return {\n route: currentRoute as MatchedRoute<\n TParams extends RouteParamsDefinition ? RouteParamsInfer<TParams> : undefined\n >,\n setRouteParams: presenter.setRouteParams.bind(presenter)\n };\n}\n"],"mappings":"AAAA,SAASA,SAAS,EAAEC,QAAQ,QAAQ,OAAO;AAC3C,SAASC,OAAO,QAAQ,MAAM;AAG9B,SAASC,aAAa;AACtB,SAASC,UAAU;AAEnB,OAAO,SAASC,QAAQA;AACpB;AACAC,KAAsB,EACxB;EACE,MAAM;IAAEC;EAAU,CAAC,GAAGH,UAAU,CAACD,aAAa,CAAC;EAC/C,MAAM,CAACK,YAAY,EAAEC,eAAe,CAAC,GAAGR,QAAQ,CAC5CM,SAAS,CAACG,EAAE,CAACF,YACjB,CAAC;EAEDR,SAAS,CAAC,MAAM;IACZE,OAAO,CAAC,MAAM;MACV,MAAMI,KAAK,GAAGC,SAAS,CAACG,EAAE,CAACF,YAAY;MAEvC,IAAI,CAACF,KAAK,EAAE;QACR;MACJ;MAEAG,eAAe,CAACH,KAAK,CAAC;IAC1B,CAAC,CAAC;EACN,CAAC,EAAE,EAAE,CAAC;;EAEN;;EAEA,OAAO;IACHA,KAAK,EAAEE,YAEN;IACDG,cAAc,EAAEJ,SAAS,CAACI,cAAc,CAACC,IAAI,CAACL,SAAS;EAC3D,CAAC;AACL","ignoreList":[]}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { type ReactRoute } from "../../../presentation/router/index.js";
|
|
2
|
+
export declare const useRouter: () => {
|
|
3
|
+
goToRoute: <TParams extends import("../../../features/router/Route").RouteParamsDefinition | undefined>(route: import("../../..").Route<TParams>, ...args: import("../../../features/router/abstractions").RouteParamsArgs<TParams>) => void;
|
|
4
|
+
getLink: <TParams extends import("../../../features/router/Route").RouteParamsDefinition | undefined>(route: import("../../..").Route<TParams>, ...args: import("../../../features/router/abstractions").RouteParamsArgs<TParams>) => string;
|
|
5
|
+
onRouteExit: (cb: import("../../../features/router/abstractions").OnRouteExit) => void;
|
|
6
|
+
setRoutes: (routes: ReactRoute[]) => void;
|
|
7
|
+
};
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { RouteElementRegistry } from "../index.js";
|
|
2
|
+
import { RouterFeature } from "../../../features/router/feature.js";
|
|
3
|
+
import { useFeature } from "../../../shared/di/useFeature.js";
|
|
4
|
+
import { useContainer } from "../../../shared/di/DiContainerProvider.js";
|
|
5
|
+
export const useRouter = () => {
|
|
6
|
+
const {
|
|
7
|
+
presenter
|
|
8
|
+
} = useFeature(RouterFeature);
|
|
9
|
+
const container = useContainer();
|
|
10
|
+
const registry = container.resolve(RouteElementRegistry);
|
|
11
|
+
return {
|
|
12
|
+
goToRoute: presenter.goToRoute.bind(presenter),
|
|
13
|
+
getLink: presenter.getLink.bind(presenter),
|
|
14
|
+
onRouteExit: presenter.onRouteExit.bind(presenter),
|
|
15
|
+
setRoutes: routes => {
|
|
16
|
+
const cleanRoutes = [];
|
|
17
|
+
for (const route of routes) {
|
|
18
|
+
cleanRoutes.push(route.route);
|
|
19
|
+
registry.register(route.route.name, route.element);
|
|
20
|
+
}
|
|
21
|
+
presenter.bootstrap(cleanRoutes);
|
|
22
|
+
}
|
|
23
|
+
};
|
|
24
|
+
};
|
|
25
|
+
|
|
26
|
+
//# sourceMappingURL=useRouter.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["RouteElementRegistry","RouterFeature","useFeature","useContainer","useRouter","presenter","container","registry","resolve","goToRoute","bind","getLink","onRouteExit","setRoutes","routes","cleanRoutes","route","push","register","name","element","bootstrap"],"sources":["useRouter.ts"],"sourcesContent":["import { type ReactRoute, RouteElementRegistry } from \"~/presentation/router/index.js\";\nimport { RouterFeature } from \"~/features/router/feature.js\";\nimport { useFeature } from \"~/shared/di/useFeature.js\";\nimport { useContainer } from \"~/shared/di/DiContainerProvider.js\";\n\nexport const useRouter = () => {\n const { presenter } = useFeature(RouterFeature);\n const container = useContainer();\n const registry = container.resolve(RouteElementRegistry);\n\n return {\n goToRoute: presenter.goToRoute.bind(presenter),\n getLink: presenter.getLink.bind(presenter),\n onRouteExit: presenter.onRouteExit.bind(presenter),\n setRoutes: (routes: ReactRoute[]) => {\n const cleanRoutes = [];\n\n for (const route of routes) {\n cleanRoutes.push(route.route);\n registry.register(route.route.name, route.element);\n }\n\n presenter.bootstrap(cleanRoutes);\n }\n };\n};\n"],"mappings":"AAAA,SAA0BA,oBAAoB;AAC9C,SAASC,aAAa;AACtB,SAASC,UAAU;AACnB,SAASC,YAAY;AAErB,OAAO,MAAMC,SAAS,GAAGA,CAAA,KAAM;EAC3B,MAAM;IAAEC;EAAU,CAAC,GAAGH,UAAU,CAACD,aAAa,CAAC;EAC/C,MAAMK,SAAS,GAAGH,YAAY,CAAC,CAAC;EAChC,MAAMI,QAAQ,GAAGD,SAAS,CAACE,OAAO,CAACR,oBAAoB,CAAC;EAExD,OAAO;IACHS,SAAS,EAAEJ,SAAS,CAACI,SAAS,CAACC,IAAI,CAACL,SAAS,CAAC;IAC9CM,OAAO,EAAEN,SAAS,CAACM,OAAO,CAACD,IAAI,CAACL,SAAS,CAAC;IAC1CO,WAAW,EAAEP,SAAS,CAACO,WAAW,CAACF,IAAI,CAACL,SAAS,CAAC;IAClDQ,SAAS,EAAGC,MAAoB,IAAK;MACjC,MAAMC,WAAW,GAAG,EAAE;MAEtB,KAAK,MAAMC,KAAK,IAAIF,MAAM,EAAE;QACxBC,WAAW,CAACE,IAAI,CAACD,KAAK,CAACA,KAAK,CAAC;QAC7BT,QAAQ,CAACW,QAAQ,CAACF,KAAK,CAACA,KAAK,CAACG,IAAI,EAAEH,KAAK,CAACI,OAAO,CAAC;MACtD;MAEAf,SAAS,CAACgB,SAAS,CAACN,WAAW,CAAC;IACpC;EACJ,CAAC;AACL,CAAC","ignoreList":[]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["useRouter","useRoute","RouteElementRegistry"],"sources":["index.ts"],"sourcesContent":["export { useRouter } from \"./hooks/useRouter.js\";\nexport { useRoute } from \"./hooks/useRoute.js\";\nexport { RouteElementRegistry } from \"./abstractions.js\";\nexport type { ReactRoute } from \"./types.js\";\n"],"mappings":"AAAA,SAASA,SAAS;AAClB,SAASC,QAAQ;AACjB,SAASC,oBAAoB","ignoreList":[]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":[],"sources":["types.ts"],"sourcesContent":["import type { Route } from \"~/features/router/Route.js\";\n\nexport type ReactRoute = {\n route: Route<any>;\n element: JSX.Element;\n};\n"],"mappings":"","ignoreList":[]}
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import React from "react";
|
|
2
2
|
import bytes from "bytes";
|
|
3
|
-
import minimatch from "minimatch";
|
|
4
|
-
import { readFileContent } from "./utils/readFileContent";
|
|
5
|
-
import { generateId } from "./utils/generateId";
|
|
3
|
+
import { minimatch } from "minimatch";
|
|
4
|
+
import { readFileContent } from "./utils/readFileContent.js";
|
|
5
|
+
import { generateId } from "./utils/generateId.js";
|
|
6
6
|
export class Files extends React.Component {
|
|
7
7
|
static defaultProps = {
|
|
8
8
|
accept: [],
|
|
@@ -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\";\nimport { generateId } from \"./utils/generateId\";\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,OAA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;QAC7D,IAAI,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;MAEz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A,QAAS;MACnByD,QAAQ,EAAEpB,CAAC,IACP,IAAI,CAACZ,oBAAoB,CAAEY,CAAC,CAACqB,MAAM,CAACjD,KAAK,IAA2B,EAAE;IACzE,CACJ,CACW,CAAC;EAEzB;AACJ","ignoreList":[]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
delete this folder?
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { Files } from "./Files";
|
|
1
|
+
import { Files } from "./Files.js";
|
|
2
2
|
export default Files;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["Files"],"sources":["index.ts"],"sourcesContent":["import { Files } from \"./Files\";\n\nexport default Files;\n"],"mappings":"AAAA,SAASA,KAAK;AAEd,eAAeA,KAAK","ignoreList":[]}
|
|
1
|
+
{"version":3,"names":["Files"],"sources":["index.ts"],"sourcesContent":["import { Files } from \"./Files.js\";\n\nexport default Files;\n"],"mappings":"AAAA,SAASA,KAAK;AAEd,eAAeA,KAAK","ignoreList":[]}
|
package/router.d.ts
ADDED
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
export { Route } from "./features/router/Route.js";
|
|
2
|
+
export { useRouter } from "./presentation/router/hooks/useRouter.js";
|
|
3
|
+
export { useRoute } from "./presentation/router/hooks/useRoute.js";
|
|
4
|
+
export { RouteLink, type RouteLinkProps } from "./presentation/router/components/RouteLink.js";
|
|
5
|
+
export { SimpleLink, type SimpleLinkProps } from "./presentation/router/components/SimpleLink.js";
|
package/router.js
ADDED
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
// Router
|
|
2
|
+
export { Route } from "./features/router/Route.js";
|
|
3
|
+
export { useRouter } from "./presentation/router/hooks/useRouter.js";
|
|
4
|
+
export { useRoute } from "./presentation/router/hooks/useRoute.js";
|
|
5
|
+
export { RouteLink } from "./presentation/router/components/RouteLink.js";
|
|
6
|
+
export { SimpleLink } from "./presentation/router/components/SimpleLink.js";
|
|
7
|
+
|
|
8
|
+
//# sourceMappingURL=router.js.map
|
package/router.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["Route","useRouter","useRoute","RouteLink","SimpleLink"],"sources":["router.ts"],"sourcesContent":["// Router\nexport { Route } from \"./features/router/Route.js\";\nexport { useRouter } from \"./presentation/router/hooks/useRouter.js\";\nexport { useRoute } from \"./presentation/router/hooks/useRoute.js\";\nexport { RouteLink, type RouteLinkProps } from \"./presentation/router/components/RouteLink.js\";\nexport { SimpleLink, type SimpleLinkProps } from \"./presentation/router/components/SimpleLink.js\";\n"],"mappings":"AAAA;AACA,SAASA,KAAK;AACd,SAASC,SAAS;AAClB,SAASC,QAAQ;AACjB,SAASC,SAAS;AAClB,SAASC,UAAU","ignoreList":[]}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import { Container } from "@webiny/di";
|
|
3
|
+
export interface DiContainerProviderProps {
|
|
4
|
+
container: Container;
|
|
5
|
+
children: React.ReactNode;
|
|
6
|
+
}
|
|
7
|
+
export declare const DiContainerProvider: ({ container, children }: DiContainerProviderProps) => React.JSX.Element;
|
|
8
|
+
export declare const useContainer: () => Container;
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import { createGenericContext } from "../../utils/createGenericContext.js";
|
|
3
|
+
const DiContainerContext = createGenericContext("DiContainer");
|
|
4
|
+
export const DiContainerProvider = ({
|
|
5
|
+
container,
|
|
6
|
+
children
|
|
7
|
+
}) => {
|
|
8
|
+
return /*#__PURE__*/React.createElement(DiContainerContext.Provider, {
|
|
9
|
+
container: container
|
|
10
|
+
}, children);
|
|
11
|
+
};
|
|
12
|
+
export const useContainer = () => {
|
|
13
|
+
const context = DiContainerContext.useHook();
|
|
14
|
+
return context.container;
|
|
15
|
+
};
|
|
16
|
+
|
|
17
|
+
//# sourceMappingURL=DiContainerProvider.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["React","createGenericContext","DiContainerContext","DiContainerProvider","container","children","createElement","Provider","useContainer","context","useHook"],"sources":["DiContainerProvider.tsx"],"sourcesContent":["import React from \"react\";\nimport { Container } from \"@webiny/di\";\nimport { createGenericContext } from \"~/utils/createGenericContext.js\";\n\ntype DiContainerContext = { container: Container };\n\nconst DiContainerContext = createGenericContext<DiContainerContext>(\"DiContainer\");\n\nexport interface DiContainerProviderProps {\n container: Container;\n children: React.ReactNode;\n}\n\nexport const DiContainerProvider = ({ container, children }: DiContainerProviderProps) => {\n return (\n <DiContainerContext.Provider container={container}>{children}</DiContainerContext.Provider>\n );\n};\n\nexport const useContainer = () => {\n const context = DiContainerContext.useHook();\n\n return context.container;\n};\n"],"mappings":"AAAA,OAAOA,KAAK,MAAM,OAAO;AAEzB,SAASC,oBAAoB;AAI7B,MAAMC,kBAAkB,GAAGD,oBAAoB,CAAqB,aAAa,CAAC;AAOlF,OAAO,MAAME,mBAAmB,GAAGA,CAAC;EAAEC,SAAS;EAAEC;AAAmC,CAAC,KAAK;EACtF,oBACIL,KAAA,CAAAM,aAAA,CAACJ,kBAAkB,CAACK,QAAQ;IAACH,SAAS,EAAEA;EAAU,GAAEC,QAAsC,CAAC;AAEnG,CAAC;AAED,OAAO,MAAMG,YAAY,GAAGA,CAAA,KAAM;EAC9B,MAAMC,OAAO,GAAGP,kBAAkB,CAACQ,OAAO,CAAC,CAAC;EAE5C,OAAOD,OAAO,CAACL,SAAS;AAC5B,CAAC","ignoreList":[]}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { Container } from "@webiny/di";
|
|
2
|
+
export interface FeatureDefinition<TExports = any, TParams extends any[] = []> {
|
|
3
|
+
name: string;
|
|
4
|
+
register: (container: Container, ...args: TParams) => void;
|
|
5
|
+
resolve: (container: Container) => TExports;
|
|
6
|
+
}
|
|
7
|
+
export declare function createFeature<TExports = any, TParams extends any[] = []>(def: {
|
|
8
|
+
name: string;
|
|
9
|
+
register: (container: Container, ...args: TParams) => void;
|
|
10
|
+
resolve: (container: Container) => TExports;
|
|
11
|
+
}): FeatureDefinition<TExports, TParams>;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["createFeature","def","name","register","resolve","container"],"sources":["createFeature.ts"],"sourcesContent":["import { Container } from \"@webiny/di\";\n\nexport interface FeatureDefinition<TExports = any, TParams extends any[] = []> {\n name: string;\n register: (container: Container, ...args: TParams) => void;\n resolve: (container: Container) => TExports;\n}\n\nexport function createFeature<\n TExports = any,\n TParams extends any[] = [] // tuple for extra args\n>(def: {\n name: string;\n register: (container: Container, ...args: TParams) => void;\n resolve: (container: Container) => TExports;\n}): FeatureDefinition<TExports, TParams> {\n return {\n name: def.name,\n register: def.register,\n resolve: (container: Container): TExports => {\n return def.resolve(container);\n }\n };\n}\n"],"mappings":"AAQA,OAAO,SAASA,aAAaA,CAG3BC,GAID,EAAwC;EACrC,OAAO;IACHC,IAAI,EAAED,GAAG,CAACC,IAAI;IACdC,QAAQ,EAAEF,GAAG,CAACE,QAAQ;IACtBC,OAAO,EAAGC,SAAoB,IAAe;MACzC,OAAOJ,GAAG,CAACG,OAAO,CAACC,SAAS,CAAC;IACjC;EACJ,CAAC;AACL","ignoreList":[]}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { useContainer } from "./DiContainerProvider.js";
|
|
2
|
+
const featureCache = new WeakMap();
|
|
3
|
+
export function useFeature(feature) {
|
|
4
|
+
const container = useContainer();
|
|
5
|
+
let featureMap = featureCache.get(container);
|
|
6
|
+
if (!featureMap) {
|
|
7
|
+
featureMap = new Map();
|
|
8
|
+
featureCache.set(container, featureMap);
|
|
9
|
+
}
|
|
10
|
+
if (featureMap.has(feature.name)) {
|
|
11
|
+
return featureMap.get(feature.name);
|
|
12
|
+
}
|
|
13
|
+
const exports = feature.resolve(container);
|
|
14
|
+
featureMap.set(feature.name, exports);
|
|
15
|
+
return exports;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
//# sourceMappingURL=useFeature.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["useContainer","featureCache","WeakMap","useFeature","feature","container","featureMap","get","Map","set","has","name","exports","resolve"],"sources":["useFeature.ts"],"sourcesContent":["import type { Container } from \"@webiny/di\";\nimport { useContainer } from \"./DiContainerProvider.js\";\nimport { FeatureDefinition } from \"./createFeature.js\";\n\nconst featureCache = new WeakMap<Container, Map<string, unknown>>();\n\nexport function useFeature<TExports>(feature: FeatureDefinition<TExports, any[]>): TExports {\n const container = useContainer();\n\n let featureMap = featureCache.get(container);\n if (!featureMap) {\n featureMap = new Map();\n featureCache.set(container, featureMap);\n }\n\n if (featureMap.has(feature.name)) {\n return featureMap.get(feature.name) as TExports;\n }\n\n const exports = feature.resolve(container);\n featureMap.set(feature.name, exports);\n return exports;\n}\n"],"mappings":"AACA,SAASA,YAAY;AAGrB,MAAMC,YAAY,GAAG,IAAIC,OAAO,CAAkC,CAAC;AAEnE,OAAO,SAASC,UAAUA,CAAWC,OAA2C,EAAY;EACxF,MAAMC,SAAS,GAAGL,YAAY,CAAC,CAAC;EAEhC,IAAIM,UAAU,GAAGL,YAAY,CAACM,GAAG,CAACF,SAAS,CAAC;EAC5C,IAAI,CAACC,UAAU,EAAE;IACbA,UAAU,GAAG,IAAIE,GAAG,CAAC,CAAC;IACtBP,YAAY,CAACQ,GAAG,CAACJ,SAAS,EAAEC,UAAU,CAAC;EAC3C;EAEA,IAAIA,UAAU,CAACI,GAAG,CAACN,OAAO,CAACO,IAAI,CAAC,EAAE;IAC9B,OAAOL,UAAU,CAACC,GAAG,CAACH,OAAO,CAACO,IAAI,CAAC;EACvC;EAEA,MAAMC,OAAO,GAAGR,OAAO,CAACS,OAAO,CAACR,SAAS,CAAC;EAC1CC,UAAU,CAACG,GAAG,CAACL,OAAO,CAACO,IAAI,EAAEC,OAAO,CAAC;EACrC,OAAOA,OAAO;AAClB","ignoreList":[]}
|
package/types.d.ts
CHANGED
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
import type * as React from "react";
|
|
2
|
-
import { Plugin } from "@webiny/plugins/types";
|
|
3
|
-
import type { ApolloClient } from "apollo-client";
|
|
4
2
|
import type { CSSProperties } from "react";
|
|
3
|
+
import { Plugin } from "@webiny/plugins/types.js";
|
|
4
|
+
import type { ApolloClient } from "apollo-client";
|
|
5
5
|
export type GenericRecordKey = string | number | symbol;
|
|
6
6
|
export type GenericRecord<K extends GenericRecordKey = GenericRecordKey, V = any> = Record<K, V>;
|
|
7
|
+
export type NonEmptyArray<T> = [T, ...T[]];
|
|
7
8
|
export type UploadOptions = {
|
|
8
9
|
apolloClient: ApolloClient<object>;
|
|
9
10
|
onProgress?: (params: {
|
|
@@ -28,7 +29,7 @@ export type FileUploaderPlugin = Plugin & {
|
|
|
28
29
|
name: "file-uploader";
|
|
29
30
|
upload(file: File, options: UploadOptions): Promise<UploadedFile>;
|
|
30
31
|
};
|
|
31
|
-
export { Plugin };
|
|
32
|
+
export type { Plugin };
|
|
32
33
|
export interface ImageProps {
|
|
33
34
|
src: string;
|
|
34
35
|
preset?: string;
|
|
@@ -63,5 +64,7 @@ export type ImageComponentPlugin = Plugin & {
|
|
|
63
64
|
*/
|
|
64
65
|
export type RoutePlugin = Plugin & {
|
|
65
66
|
type: "route";
|
|
66
|
-
route: React.ReactElement
|
|
67
|
+
route: React.ReactElement<{
|
|
68
|
+
path: string;
|
|
69
|
+
}>;
|
|
67
70
|
};
|
package/types.js
CHANGED
|
@@ -1,14 +1,3 @@
|
|
|
1
|
-
|
|
2
|
-
export { Plugin };
|
|
3
|
-
|
|
4
|
-
/**
|
|
5
|
-
* "getImageSrc" has to be defined as a separate property, so its functionality can be reused outside of
|
|
6
|
-
* the Image component. This is ideal in cases where manual creation of image src is needed.
|
|
7
|
-
*/
|
|
8
|
-
|
|
9
|
-
/**
|
|
10
|
-
* Enables registering new routes.
|
|
11
|
-
* @see https://docs.webiny.com/docs/webiny-apps/admin/development/plugins-reference/app#route
|
|
12
|
-
*/
|
|
1
|
+
export {};
|
|
13
2
|
|
|
14
3
|
//# sourceMappingURL=types.js.map
|
package/types.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":[
|
|
1
|
+
{"version":3,"names":[],"sources":["types.ts"],"sourcesContent":["import type * as React from \"react\";\nimport type { CSSProperties } from \"react\";\nimport { Plugin } from \"@webiny/plugins/types.js\";\nimport type { ApolloClient } from \"apollo-client\";\n\nexport type GenericRecordKey = string | number | symbol;\n\nexport type GenericRecord<K extends GenericRecordKey = GenericRecordKey, V = any> = Record<K, V>;\n\nexport type NonEmptyArray<T> = [T, ...T[]];\n\nexport type UploadOptions = {\n apolloClient: ApolloClient<object>;\n onProgress?: (params: { sent: number; total: number; percentage: number }) => void;\n};\n\nexport type UiStatePlugin = Plugin & {\n type: \"ui-state\";\n render(): React.ReactElement;\n};\n\nexport interface UploadedFile {\n id: string;\n name: string;\n type: string;\n size: number;\n key: string;\n}\n\nexport type FileUploaderPlugin = Plugin & {\n type: \"file-uploader\";\n name: \"file-uploader\";\n upload(file: File, options: UploadOptions): Promise<UploadedFile>;\n};\n\nexport type { Plugin };\n\nexport interface ImageProps {\n src: string;\n preset?: string;\n transform?: {\n [key: string]: any;\n };\n // \"auto\" is a special keyword - if present, plugins insert their own srcSet.\n srcSet?: { [key: string]: any } | \"auto\";\n className?: string;\n title?: string;\n alt?: string;\n style?: CSSProperties;\n width?: string | number;\n height?: string | number;\n}\n\n/**\n * \"getImageSrc\" has to be defined as a separate property, so its functionality can be reused outside of\n * the Image component. This is ideal in cases where manual creation of image src is needed.\n */\nexport type ImageComponentPlugin = Plugin & {\n type: \"image-component\";\n render: (props: ImageProps) => React.ReactElement;\n getImageSrc: (props?: Record<string, any>) => string;\n presets: { [key: string]: any };\n};\n\n/**\n * Enables registering new routes.\n * @see https://docs.webiny.com/docs/webiny-apps/admin/development/plugins-reference/app#route\n */\nexport type RoutePlugin = Plugin & {\n type: \"route\";\n route: React.ReactElement<{ path: string }>;\n};\n"],"mappings":"","ignoreList":[]}
|
package/utils/index.d.ts
CHANGED
|
@@ -1,10 +1,2 @@
|
|
|
1
|
-
export * from "./createHashing";
|
|
2
|
-
export * from "./
|
|
3
|
-
export * from "./getGqlApiUrl";
|
|
4
|
-
export * from "./getHeadlessCmsGqlApiUrl";
|
|
5
|
-
export * from "./getLocaleCode";
|
|
6
|
-
export * from "./getPrerenderId";
|
|
7
|
-
export * from "./getTenantId";
|
|
8
|
-
export * from "./isLocalhost";
|
|
9
|
-
export * from "./isPrerendering";
|
|
10
|
-
export * from "./legacyPluginToReactComponent";
|
|
1
|
+
export * from "./createHashing.js";
|
|
2
|
+
export * from "./legacyPluginToReactComponent.js";
|
package/utils/index.js
CHANGED
|
@@ -1,12 +1,4 @@
|
|
|
1
|
-
export * from "./createHashing";
|
|
2
|
-
export * from "./
|
|
3
|
-
export * from "./getGqlApiUrl";
|
|
4
|
-
export * from "./getHeadlessCmsGqlApiUrl";
|
|
5
|
-
export * from "./getLocaleCode";
|
|
6
|
-
export * from "./getPrerenderId";
|
|
7
|
-
export * from "./getTenantId";
|
|
8
|
-
export * from "./isLocalhost";
|
|
9
|
-
export * from "./isPrerendering";
|
|
10
|
-
export * from "./legacyPluginToReactComponent";
|
|
1
|
+
export * from "./createHashing.js";
|
|
2
|
+
export * from "./legacyPluginToReactComponent.js";
|
|
11
3
|
|
|
12
4
|
//# sourceMappingURL=index.js.map
|
package/utils/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":[],"sources":["index.ts"],"sourcesContent":["export * from \"./createHashing\";\nexport * from \"./
|
|
1
|
+
{"version":3,"names":[],"sources":["index.ts"],"sourcesContent":["export * from \"./createHashing.js\";\nexport * from \"./legacyPluginToReactComponent.js\";\n"],"mappings":"AAAA;AACA","ignoreList":[]}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { useRegisterLegacyPlugin } from "../hooks/useRegisterLegacyPlugin";
|
|
1
|
+
import { useRegisterLegacyPlugin } from "../hooks/useRegisterLegacyPlugin.js";
|
|
2
2
|
export const legacyPluginToReactComponent = function (params) {
|
|
3
3
|
const Component = props => {
|
|
4
4
|
const plugin = Object.assign({
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["useRegisterLegacyPlugin","legacyPluginToReactComponent","params","Component","props","plugin","Object","assign","type","pluginType","mapProps","displayName","componentDisplayName"],"sources":["legacyPluginToReactComponent.ts"],"sourcesContent":["import type React from \"react\";\nimport { useRegisterLegacyPlugin } from \"~/hooks/useRegisterLegacyPlugin\";\n\nexport interface LegacyPluginToReactComponentParams<TProps extends Record<string, any>> {\n pluginType: string;\n componentDisplayName: string;\n mapProps?: (props: TProps) => TProps;\n}\n\nexport const legacyPluginToReactComponent = function <TProps extends Record<string, any>>(\n params: LegacyPluginToReactComponentParams<TProps>\n) {\n const Component: React.ComponentType<TProps> = props => {\n const plugin = Object.assign(\n { type: params.pluginType },\n params.mapProps ? params.mapProps(props) : props\n );\n useRegisterLegacyPlugin(plugin);\n return null;\n };\n\n Component.displayName = params.componentDisplayName;\n\n return Component;\n};\n"],"mappings":"AACA,SAASA,uBAAuB;AAQhC,OAAO,MAAMC,4BAA4B,GAAG,SAAAA,CACxCC,MAAkD,EACpD;EACE,MAAMC,SAAsC,GAAGC,KAAK,IAAI;IACpD,MAAMC,MAAM,GAAGC,MAAM,CAACC,MAAM,CACxB;MAAEC,IAAI,EAAEN,MAAM,CAACO;IAAW,CAAC,EAC3BP,MAAM,CAACQ,QAAQ,GAAGR,MAAM,CAACQ,QAAQ,CAACN,KAAK,CAAC,GAAGA,KAC/C,CAAC;IACDJ,uBAAuB,CAACK,MAAM,CAAC;IAC/B,OAAO,IAAI;EACf,CAAC;EAEDF,SAAS,CAACQ,WAAW,GAAGT,MAAM,CAACU,oBAAoB;EAEnD,OAAOT,SAAS;AACpB,CAAC","ignoreList":[]}
|
|
1
|
+
{"version":3,"names":["useRegisterLegacyPlugin","legacyPluginToReactComponent","params","Component","props","plugin","Object","assign","type","pluginType","mapProps","displayName","componentDisplayName"],"sources":["legacyPluginToReactComponent.ts"],"sourcesContent":["import type React from \"react\";\nimport { useRegisterLegacyPlugin } from \"~/hooks/useRegisterLegacyPlugin.js\";\n\nexport interface LegacyPluginToReactComponentParams<TProps extends Record<string, any>> {\n pluginType: string;\n componentDisplayName: string;\n mapProps?: (props: TProps) => TProps;\n}\n\nexport const legacyPluginToReactComponent = function <TProps extends Record<string, any>>(\n params: LegacyPluginToReactComponentParams<TProps>\n) {\n const Component: React.ComponentType<TProps> = props => {\n const plugin = Object.assign(\n { type: params.pluginType },\n params.mapProps ? params.mapProps(props) : props\n );\n useRegisterLegacyPlugin(plugin);\n return null;\n };\n\n Component.displayName = params.componentDisplayName;\n\n return Component;\n};\n"],"mappings":"AACA,SAASA,uBAAuB;AAQhC,OAAO,MAAMC,4BAA4B,GAAG,SAAAA,CACxCC,MAAkD,EACpD;EACE,MAAMC,SAAsC,GAAGC,KAAK,IAAI;IACpD,MAAMC,MAAM,GAAGC,MAAM,CAACC,MAAM,CACxB;MAAEC,IAAI,EAAEN,MAAM,CAACO;IAAW,CAAC,EAC3BP,MAAM,CAACQ,QAAQ,GAAGR,MAAM,CAACQ,QAAQ,CAACN,KAAK,CAAC,GAAGA,KAC/C,CAAC;IACDJ,uBAAuB,CAACK,MAAM,CAAC;IAC/B,OAAO,IAAI;EACf,CAAC;EAEDF,SAAS,CAACQ,WAAW,GAAGT,MAAM,CAACU,oBAAoB;EAEnD,OAAOT,SAAS;AACpB,CAAC","ignoreList":[]}
|
package/components/Routes.d.ts
DELETED
package/components/Routes.js
DELETED
|
@@ -1,36 +0,0 @@
|
|
|
1
|
-
// This file is necessary only for backwards compatibility.
|
|
2
|
-
// We'll remove this once the legacy rendering engine is removed.
|
|
3
|
-
import React from "react";
|
|
4
|
-
import { plugins } from "@webiny/plugins";
|
|
5
|
-
import { Routes as ReactRouterRoutes } from "@webiny/react-router";
|
|
6
|
-
export const Routes = () => {
|
|
7
|
-
// We cannot call `sort` on the array returned by the `plugins.byType` call - it is read-only.
|
|
8
|
-
const routes = [...plugins.byType("route")].sort((a, b) => {
|
|
9
|
-
const pathA = a.route.props.path || "*";
|
|
10
|
-
const pathB = b.route.props.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
|
-
return /*#__PURE__*/React.createElement(ReactRouterRoutes, null, routes.map(({
|
|
29
|
-
route,
|
|
30
|
-
name
|
|
31
|
-
}) => /*#__PURE__*/React.cloneElement(route, {
|
|
32
|
-
key: name
|
|
33
|
-
})));
|
|
34
|
-
};
|
|
35
|
-
|
|
36
|
-
//# sourceMappingURL=Routes.js.map
|
package/components/Routes.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"names":["React","plugins","Routes","ReactRouterRoutes","routes","byType","sort","a","b","pathA","route","props","path","pathB","includes","createElement","map","name","cloneElement","key"],"sources":["Routes.tsx"],"sourcesContent":["// This file is necessary only for backwards compatibility.\n// We'll remove this once the legacy rendering engine is removed.\nimport React from \"react\";\nimport { plugins } from \"@webiny/plugins\";\nimport { Routes as ReactRouterRoutes } from \"@webiny/react-router\";\nimport type { RoutePlugin } from \"../types\";\n\nexport const Routes = () => {\n // We cannot call `sort` on the array returned by the `plugins.byType` call - it is read-only.\n const routes = [...plugins.byType<RoutePlugin>(\"route\")].sort((a, b) => {\n const pathA = a.route.props.path || \"*\";\n const pathB = b.route.props.path || \"*\";\n\n // This will sort paths at the very bottom of the list\n if (pathA === \"/\" && pathB === \"*\") {\n return -1;\n }\n\n // This will push * and / to the bottom of the list\n if (pathA === \"*\" || pathA === \"/\") {\n return 1;\n }\n\n // This will push * and / to the bottom of the list\n if ([\"*\", \"/\"].includes(pathB)) {\n return -1;\n }\n\n return 0;\n });\n\n return (\n <ReactRouterRoutes>\n {routes.map(({ route, name }) => React.cloneElement(route, { key: name }))}\n </ReactRouterRoutes>\n );\n};\n"],"mappings":"AAAA;AACA;AACA,OAAOA,KAAK,MAAM,OAAO;AACzB,SAASC,OAAO,QAAQ,iBAAiB;AACzC,SAASC,MAAM,IAAIC,iBAAiB,QAAQ,sBAAsB;AAGlE,OAAO,MAAMD,MAAM,GAAGA,CAAA,KAAM;EACxB;EACA,MAAME,MAAM,GAAG,CAAC,GAAGH,OAAO,CAACI,MAAM,CAAc,OAAO,CAAC,CAAC,CAACC,IAAI,CAAC,CAACC,CAAC,EAAEC,CAAC,KAAK;IACpE,MAAMC,KAAK,GAAGF,CAAC,CAACG,KAAK,CAACC,KAAK,CAACC,IAAI,IAAI,GAAG;IACvC,MAAMC,KAAK,GAAGL,CAAC,CAACE,KAAK,CAACC,KAAK,CAACC,IAAI,IAAI,GAAG;;IAEvC;IACA,IAAIH,KAAK,KAAK,GAAG,IAAII,KAAK,KAAK,GAAG,EAAE;MAChC,OAAO,CAAC,CAAC;IACb;;IAEA;IACA,IAAIJ,KAAK,KAAK,GAAG,IAAIA,KAAK,KAAK,GAAG,EAAE;MAChC,OAAO,CAAC;IACZ;;IAEA;IACA,IAAI,CAAC,GAAG,EAAE,GAAG,CAAC,CAACK,QAAQ,CAACD,KAAK,CAAC,EAAE;MAC5B,OAAO,CAAC,CAAC;IACb;IAEA,OAAO,CAAC;EACZ,CAAC,CAAC;EAEF,oBACIb,KAAA,CAAAe,aAAA,CAACZ,iBAAiB,QACbC,MAAM,CAACY,GAAG,CAAC,CAAC;IAAEN,KAAK;IAAEO;EAAK,CAAC,kBAAKjB,KAAK,CAACkB,YAAY,CAACR,KAAK,EAAE;IAAES,GAAG,EAAEF;EAAK,CAAC,CAAC,CAC1D,CAAC;AAE5B,CAAC","ignoreList":[]}
|
package/components/View.d.ts
DELETED
package/components/View.js
DELETED
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
import React, { Fragment } from "react";
|
|
2
|
-
import { plugins } from "@webiny/plugins";
|
|
3
|
-
import { ViewPlugin } from "../plugins/ViewPlugin";
|
|
4
|
-
export const View = ({
|
|
5
|
-
name,
|
|
6
|
-
children,
|
|
7
|
-
props = {}
|
|
8
|
-
}) => {
|
|
9
|
-
const viewPlugins = plugins.byType(ViewPlugin.type).filter(pl => pl.key === name);
|
|
10
|
-
if (viewPlugins.length) {
|
|
11
|
-
children = viewPlugins.reduce((el, pl) => pl.render({
|
|
12
|
-
children: el,
|
|
13
|
-
...props
|
|
14
|
-
}), children);
|
|
15
|
-
}
|
|
16
|
-
return /*#__PURE__*/React.createElement(Fragment, null, children || null);
|
|
17
|
-
};
|
|
18
|
-
|
|
19
|
-
//# sourceMappingURL=View.js.map
|
package/components/View.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"names":["React","Fragment","plugins","ViewPlugin","View","name","children","props","viewPlugins","byType","type","filter","pl","key","length","reduce","el","render","createElement"],"sources":["View.tsx"],"sourcesContent":["import React, { Fragment } from \"react\";\nimport { plugins } from \"@webiny/plugins\";\nimport { ViewPlugin } from \"../plugins/ViewPlugin\";\n\ninterface Props {\n name: string;\n props?: Record<string, any>;\n children?: React.ReactNode;\n}\n\nexport const View = ({ name, children, props = {} }: Props) => {\n const viewPlugins = plugins.byType<ViewPlugin>(ViewPlugin.type).filter(pl => pl.key === name);\n\n if (viewPlugins.length) {\n children = viewPlugins.reduce((el, pl) => pl.render({ children: el, ...props }), children);\n }\n\n return <Fragment>{children || null}</Fragment>;\n};\n"],"mappings":"AAAA,OAAOA,KAAK,IAAIC,QAAQ,QAAQ,OAAO;AACvC,SAASC,OAAO,QAAQ,iBAAiB;AACzC,SAASC,UAAU;AAQnB,OAAO,MAAMC,IAAI,GAAGA,CAAC;EAAEC,IAAI;EAAEC,QAAQ;EAAEC,KAAK,GAAG,CAAC;AAAS,CAAC,KAAK;EAC3D,MAAMC,WAAW,GAAGN,OAAO,CAACO,MAAM,CAAaN,UAAU,CAACO,IAAI,CAAC,CAACC,MAAM,CAACC,EAAE,IAAIA,EAAE,CAACC,GAAG,KAAKR,IAAI,CAAC;EAE7F,IAAIG,WAAW,CAACM,MAAM,EAAE;IACpBR,QAAQ,GAAGE,WAAW,CAACO,MAAM,CAAC,CAACC,EAAE,EAAEJ,EAAE,KAAKA,EAAE,CAACK,MAAM,CAAC;MAAEX,QAAQ,EAAEU,EAAE;MAAE,GAAGT;IAAM,CAAC,CAAC,EAAED,QAAQ,CAAC;EAC9F;EAEA,oBAAON,KAAA,CAAAkB,aAAA,CAACjB,QAAQ,QAAEK,QAAQ,IAAI,IAAe,CAAC;AAClD,CAAC","ignoreList":[]}
|