@webiny/app 5.44.1-beta.0 → 5.45.0-beta.0
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 +5 -13
- package/App.js +70 -87
- package/App.js.map +1 -1
- package/AppContainer.d.ts +23 -0
- package/AppContainer.js +9 -0
- package/AppContainer.js.map +1 -0
- package/README.md +7 -15
- package/apollo-client/InMemoryCache.d.ts +3 -2
- package/apollo-client/InMemoryCache.js +16 -47
- package/apollo-client/InMemoryCache.js.map +1 -1
- package/apollo-client/IntrospectionFragmentMatcher.d.ts +2 -2
- package/apollo-client/IntrospectionFragmentMatcher.js +33 -50
- package/apollo-client/IntrospectionFragmentMatcher.js.map +1 -1
- package/components/Image.d.ts +1 -2
- package/components/Image.js +11 -19
- package/components/Image.js.map +1 -1
- package/components/index.d.ts +1 -2
- package/components/index.js +1 -19
- package/components/index.js.map +1 -1
- package/config/RouterConfig/Route.d.ts +29 -0
- package/config/RouterConfig/Route.js +33 -0
- package/config/RouterConfig/Route.js.map +1 -0
- package/config/RouterConfig.d.ts +31 -0
- package/config/RouterConfig.js +18 -0
- package/config/RouterConfig.js.map +1 -0
- package/config.js +9 -15
- package/config.js.map +1 -1
- package/contexts/Ui/index.js +28 -52
- package/contexts/Ui/index.js.map +1 -1
- package/core/DebounceRender.js +13 -24
- package/core/DebounceRender.js.map +1 -1
- package/core/Plugin.d.ts +1 -1
- package/core/Plugin.js +11 -19
- package/core/Plugin.js.map +1 -1
- package/core/Plugins.d.ts +1 -1
- package/core/Plugins.js +20 -25
- package/core/Plugins.js.map +1 -1
- package/core/Provider.d.ts +1 -1
- package/core/Provider.js +9 -13
- package/core/Provider.js.map +1 -1
- package/core/Routes.d.ts +2 -1
- package/core/Routes.js +13 -23
- package/core/Routes.js.map +1 -1
- package/core/createProvider.d.ts +2 -2
- package/core/createProvider.js +1 -7
- package/core/createProvider.js.map +1 -1
- package/core/createProviderPlugin.d.ts +1 -1
- package/core/createProviderPlugin.js +4 -10
- 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/envConfig.d.ts +1 -0
- package/exports/admin/envConfig.js +3 -0
- package/exports/admin/envConfig.js.map +1 -0
- package/exports/admin/graphqlClient.d.ts +1 -0
- package/exports/admin/graphqlClient.js +3 -0
- package/exports/admin/graphqlClient.js.map +1 -0
- package/exports/admin/localStorage.d.ts +2 -0
- package/exports/admin/localStorage.js +4 -0
- package/exports/admin/localStorage.js.map +1 -0
- package/exports/admin/router.d.ts +4 -0
- package/exports/admin/router.js +6 -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 +3 -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 -12
- package/hooks/useAutocomplete/index.js.map +1 -1
- package/hooks/useAutocomplete/useAutocomplete.d.ts +1 -1
- package/hooks/useAutocomplete/useAutocomplete.js +6 -16
- package/hooks/useAutocomplete/useAutocomplete.js.map +1 -1
- package/hooks/useDataList/functions/getData.js +2 -11
- package/hooks/useDataList/functions/getData.js.map +1 -1
- package/hooks/useDataList/functions/getError.js +2 -11
- package/hooks/useDataList/functions/getError.js.map +1 -1
- package/hooks/useDataList/functions/getMeta.js +2 -11
- 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 -27
- package/hooks/useDataList/functions/index.js.map +1 -1
- package/hooks/useDataList/functions/searchDataByKey.js +4 -10
- package/hooks/useDataList/functions/searchDataByKey.js.map +1 -1
- package/hooks/useDataList/index.d.ts +1 -1
- package/hooks/useDataList/index.js +1 -12
- package/hooks/useDataList/index.js.map +1 -1
- package/hooks/useDataList/useDataList.d.ts +2 -3
- package/hooks/useDataList/useDataList.js +74 -94
- package/hooks/useDataList/useDataList.js.map +1 -1
- package/hooks/useDataList/utils/index.d.ts +1 -2
- package/hooks/useDataList/utils/index.js +1 -20
- package/hooks/useDataList/utils/index.js.map +1 -1
- package/hooks/useDataList/utils/prepareLoadListParams.js +10 -16
- package/hooks/useDataList/utils/prepareLoadListParams.js.map +1 -1
- package/hooks/useHandler.js +7 -12
- package/hooks/useHandler.js.map +1 -1
- package/hooks/useHandlers.js +11 -17
- package/hooks/useHandlers.js.map +1 -1
- package/hooks/useRegisterLegacyPlugin.d.ts +1 -1
- package/hooks/useRegisterLegacyPlugin.js +5 -11
- package/hooks/useRegisterLegacyPlugin.js.map +1 -1
- package/hooks/useUi.d.ts +1 -1
- package/hooks/useUi.js +4 -10
- package/hooks/useUi.js.map +1 -1
- package/i18n/i18n.js +5 -13
- package/i18n/i18n.js.map +1 -1
- package/i18n/index.d.ts +1 -1
- package/i18n/index.js +1 -13
- package/i18n/index.js.map +1 -1
- package/index.d.ts +23 -15
- package/index.js +25 -177
- package/index.js.map +1 -1
- package/package.json +25 -22
- package/plugins/AddQuerySelectionPlugin.d.ts +2 -2
- package/plugins/AddQuerySelectionPlugin.js +61 -107
- package/plugins/AddQuerySelectionPlugin.js.map +1 -1
- package/plugins/ApolloCacheObjectIdPlugin.js +12 -31
- package/plugins/ApolloCacheObjectIdPlugin.js.map +1 -1
- package/plugins/ApolloDynamicLink.d.ts +3 -2
- package/plugins/ApolloDynamicLink.js +19 -46
- package/plugins/ApolloDynamicLink.js.map +1 -1
- package/plugins/ApolloLinkPlugin.d.ts +1 -1
- package/plugins/ApolloLinkPlugin.js +18 -37
- package/plugins/ApolloLinkPlugin.js.map +1 -1
- package/plugins/ConsoleLinkPlugin.d.ts +1 -1
- package/plugins/ConsoleLinkPlugin.js +20 -41
- package/plugins/ConsoleLinkPlugin.js.map +1 -1
- package/plugins/NetworkErrorLinkPlugin/ErrorOverlay.d.ts +8 -13
- package/plugins/NetworkErrorLinkPlugin/ErrorOverlay.js +35 -58
- 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 +68 -12
- 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 +10 -25
- package/plugins/NetworkErrorLinkPlugin/createErrorOverlay.js.map +1 -1
- package/plugins/NetworkErrorLinkPlugin.d.ts +4 -1
- package/plugins/NetworkErrorLinkPlugin.js +60 -37
- package/plugins/NetworkErrorLinkPlugin.js.map +1 -1
- package/plugins/OmitTypenameLinkPlugin.d.ts +1 -1
- package/plugins/OmitTypenameLinkPlugin.js +11 -30
- package/plugins/OmitTypenameLinkPlugin.js.map +1 -1
- package/plugins/TenantHeaderLinkPlugin.d.ts +3 -3
- package/plugins/TenantHeaderLinkPlugin.js +29 -48
- 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 +46 -53
- package/plugins/image.js.map +1 -1
- package/plugins/index.d.ts +4 -4
- package/plugins/index.js +31 -53
- 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/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 +208 -235
- 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 +2 -8
- package/react-butterfiles/index.js.map +1 -1
- package/react-butterfiles/utils/generateId.js +1 -7
- package/react-butterfiles/utils/generateId.js.map +1 -1
- package/react-butterfiles/utils/readFileContent.js +4 -10
- package/react-butterfiles/utils/readFileContent.js.map +1 -1
- package/renderApp.d.ts +1 -1
- package/renderApp.js +4 -11
- package/renderApp.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 +9 -6
- package/types.js +1 -12
- package/types.js.map +1 -1
- package/utils/createGenericContext.js +13 -22
- package/utils/createGenericContext.js.map +1 -1
- package/utils/createHashing.js +9 -15
- package/utils/createHashing.js.map +1 -1
- package/utils/index.d.ts +2 -10
- package/utils/index.js +2 -115
- package/utils/index.js.map +1 -1
- package/utils/legacyPluginToReactComponent.d.ts +1 -1
- package/utils/legacyPluginToReactComponent.js +5 -11
- package/utils/legacyPluginToReactComponent.js.map +1 -1
- package/components/Routes.d.ts +0 -2
- package/components/Routes.js +0 -46
- package/components/Routes.js.map +0 -1
- package/components/View.d.ts +0 -8
- package/components/View.js +0 -31
- package/components/View.js.map +0 -1
- package/core/AddRoute.d.ts +0 -21
- package/core/AddRoute.js +0 -21
- package/core/AddRoute.js.map +0 -1
- package/hooks/useDataList/utils/redirectToRouteWithQueryParams.d.ts +0 -14
- package/hooks/useDataList/utils/redirectToRouteWithQueryParams.js +0 -30
- package/hooks/useDataList/utils/redirectToRouteWithQueryParams.js.map +0 -1
- package/hooks/useDataList/utils/types.d.ts +0 -40
- package/hooks/useDataList/utils/types.js +0 -7
- package/hooks/useDataList/utils/types.js.map +0 -1
- package/plugins/LocaleHeaderLinkPlugin.d.ts +0 -10
- package/plugins/LocaleHeaderLinkPlugin.js +0 -49
- package/plugins/LocaleHeaderLinkPlugin.js.map +0 -1
- package/plugins/RoutePlugin.d.ts +0 -12
- package/plugins/RoutePlugin.js +0 -35
- package/plugins/RoutePlugin.js.map +0 -1
- package/plugins/ViewPlugin.d.ts +0 -14
- package/plugins/ViewPlugin.js +0 -40
- package/plugins/ViewPlugin.js.map +0 -1
- package/utils/getApiUrl.d.ts +0 -1
- package/utils/getApiUrl.js +0 -12
- package/utils/getApiUrl.js.map +0 -1
- package/utils/getGqlApiUrl.d.ts +0 -1
- package/utils/getGqlApiUrl.js +0 -12
- package/utils/getGqlApiUrl.js.map +0 -1
- package/utils/getHeadlessCmsGqlApiUrl.d.ts +0 -5
- package/utils/getHeadlessCmsGqlApiUrl.js +0 -18
- package/utils/getHeadlessCmsGqlApiUrl.js.map +0 -1
- package/utils/getLocaleCode.d.ts +0 -6
- package/utils/getLocaleCode.js +0 -43
- package/utils/getLocaleCode.js.map +0 -1
- package/utils/getPrerenderId.d.ts +0 -6
- package/utils/getPrerenderId.js +0 -11
- package/utils/getPrerenderId.js.map +0 -1
- package/utils/getTenantId.d.ts +0 -6
- package/utils/getTenantId.js +0 -51
- package/utils/getTenantId.js.map +0 -1
- package/utils/isLocalhost.d.ts +0 -1
- package/utils/isLocalhost.js +0 -15
- package/utils/isLocalhost.js.map +0 -1
- package/utils/isPrerendering.d.ts +0 -1
- package/utils/isPrerendering.js +0 -11
- package/utils/isPrerendering.js.map +0 -1
|
@@ -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,254 +1,227 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
1
|
+
import React from "react";
|
|
2
|
+
import bytes from "bytes";
|
|
3
|
+
import { minimatch } from "minimatch";
|
|
4
|
+
import { readFileContent } from "./utils/readFileContent.js";
|
|
5
|
+
import { generateId } from "./utils/generateId.js";
|
|
6
|
+
export class Files extends React.Component {
|
|
7
|
+
static defaultProps = {
|
|
8
|
+
accept: [],
|
|
9
|
+
multiple: false,
|
|
10
|
+
maxSize: "2mb",
|
|
11
|
+
multipleMaxSize: "10mb",
|
|
12
|
+
multipleMaxCount: null,
|
|
13
|
+
convertToBase64: false
|
|
14
|
+
};
|
|
15
|
+
input = null;
|
|
16
|
+
browseFilesPassedParams = null;
|
|
17
|
+
id = generateId();
|
|
18
|
+
validateFiles = files => {
|
|
19
|
+
const {
|
|
20
|
+
multiple,
|
|
21
|
+
multipleMaxSize,
|
|
22
|
+
multipleMaxCount,
|
|
23
|
+
accept,
|
|
24
|
+
maxSize
|
|
25
|
+
} = this.props;
|
|
26
|
+
const errors = [];
|
|
27
|
+
let multipleFileSize = 0;
|
|
28
|
+
if (!multiple && files.length > 1) {
|
|
29
|
+
errors.push({
|
|
30
|
+
id: generateId(),
|
|
31
|
+
type: "multipleNotAllowed"
|
|
32
|
+
});
|
|
33
|
+
return errors;
|
|
28
34
|
}
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
(0, _defineProperty2.default)(_this, "id", (0, _generateId.generateId)());
|
|
33
|
-
(0, _defineProperty2.default)(_this, "validateFiles", function (files) {
|
|
34
|
-
var _this$props = _this.props,
|
|
35
|
-
multiple = _this$props.multiple,
|
|
36
|
-
multipleMaxSize = _this$props.multipleMaxSize,
|
|
37
|
-
multipleMaxCount = _this$props.multipleMaxCount,
|
|
38
|
-
accept = _this$props.accept,
|
|
39
|
-
maxSize = _this$props.maxSize;
|
|
40
|
-
var errors = [];
|
|
41
|
-
var multipleFileSize = 0;
|
|
42
|
-
if (!multiple && files.length > 1) {
|
|
35
|
+
for (let index = 0; index < files.length; index++) {
|
|
36
|
+
const file = files[index];
|
|
37
|
+
if (Array.isArray(accept) && accept.length && !accept.some(type => minimatch(file.type, type))) {
|
|
43
38
|
errors.push({
|
|
44
|
-
id:
|
|
45
|
-
|
|
39
|
+
id: generateId(),
|
|
40
|
+
index,
|
|
41
|
+
file,
|
|
42
|
+
type: "unsupportedFileType"
|
|
46
43
|
});
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
var file = files[index];
|
|
51
|
-
if (Array.isArray(accept) && accept.length && !accept.some(function (type) {
|
|
52
|
-
return (0, _minimatch.default)(file.type, type);
|
|
53
|
-
})) {
|
|
44
|
+
} else if (maxSize) {
|
|
45
|
+
const sizeAsBytes = bytes(maxSize);
|
|
46
|
+
if (sizeAsBytes && file.size > sizeAsBytes) {
|
|
54
47
|
errors.push({
|
|
55
|
-
id:
|
|
56
|
-
index
|
|
57
|
-
file
|
|
58
|
-
type: "
|
|
48
|
+
id: generateId(),
|
|
49
|
+
index,
|
|
50
|
+
file,
|
|
51
|
+
type: "maxSizeExceeded"
|
|
59
52
|
});
|
|
60
|
-
} else if (maxSize) {
|
|
61
|
-
var sizeAsBytes = (0, _bytes.default)(maxSize);
|
|
62
|
-
if (sizeAsBytes && file.size > sizeAsBytes) {
|
|
63
|
-
errors.push({
|
|
64
|
-
id: (0, _generateId.generateId)(),
|
|
65
|
-
index: index,
|
|
66
|
-
file: file,
|
|
67
|
-
type: "maxSizeExceeded"
|
|
68
|
-
});
|
|
69
|
-
}
|
|
70
53
|
}
|
|
71
|
-
if (multiple) {
|
|
72
|
-
multipleFileSize += file.size;
|
|
73
|
-
}
|
|
74
|
-
};
|
|
75
|
-
for (var index = 0; index < files.length; index++) {
|
|
76
|
-
_loop();
|
|
77
54
|
}
|
|
78
55
|
if (multiple) {
|
|
79
|
-
|
|
80
|
-
if (maxMultipleMaxSize && multipleMaxSize && multipleFileSize > maxMultipleMaxSize) {
|
|
81
|
-
errors.push({
|
|
82
|
-
id: (0, _generateId.generateId)(),
|
|
83
|
-
type: "multipleMaxSizeExceeded",
|
|
84
|
-
multipleFileSize: multipleFileSize,
|
|
85
|
-
multipleMaxSize: maxMultipleMaxSize
|
|
86
|
-
});
|
|
87
|
-
}
|
|
88
|
-
if (multipleMaxCount && files.length > multipleMaxCount) {
|
|
89
|
-
errors.push({
|
|
90
|
-
id: (0, _generateId.generateId)(),
|
|
91
|
-
type: "multipleMaxCountExceeded",
|
|
92
|
-
multipleCount: files.length,
|
|
93
|
-
multipleMaxCount: multipleMaxCount
|
|
94
|
-
});
|
|
95
|
-
}
|
|
56
|
+
multipleFileSize += file.size;
|
|
96
57
|
}
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
if (
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
var _this2 = _this,
|
|
108
|
-
browseFilesPassedParams = _this2.browseFilesPassedParams;
|
|
109
|
-
var callbacks = {
|
|
110
|
-
onSuccess: onSuccess,
|
|
111
|
-
onError: onError
|
|
112
|
-
};
|
|
113
|
-
if (browseFilesPassedParams && browseFilesPassedParams.onSuccess) {
|
|
114
|
-
callbacks.onSuccess = browseFilesPassedParams.onSuccess;
|
|
58
|
+
}
|
|
59
|
+
if (multiple) {
|
|
60
|
+
const maxMultipleMaxSize = bytes(multipleMaxSize);
|
|
61
|
+
if (maxMultipleMaxSize && multipleMaxSize && multipleFileSize > maxMultipleMaxSize) {
|
|
62
|
+
errors.push({
|
|
63
|
+
id: generateId(),
|
|
64
|
+
type: "multipleMaxSizeExceeded",
|
|
65
|
+
multipleFileSize,
|
|
66
|
+
multipleMaxSize: maxMultipleMaxSize
|
|
67
|
+
});
|
|
115
68
|
}
|
|
116
|
-
if (
|
|
117
|
-
|
|
69
|
+
if (multipleMaxCount && files.length > multipleMaxCount) {
|
|
70
|
+
errors.push({
|
|
71
|
+
id: generateId(),
|
|
72
|
+
type: "multipleMaxCountExceeded",
|
|
73
|
+
multipleCount: files.length,
|
|
74
|
+
multipleMaxCount
|
|
75
|
+
});
|
|
118
76
|
}
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
77
|
+
}
|
|
78
|
+
return errors;
|
|
79
|
+
};
|
|
80
|
+
processSelectedFiles = async eventFiles => {
|
|
81
|
+
if (eventFiles.length === 0) {
|
|
82
|
+
return;
|
|
83
|
+
}
|
|
84
|
+
const {
|
|
85
|
+
convertToBase64,
|
|
86
|
+
onSuccess,
|
|
87
|
+
onError
|
|
88
|
+
} = this.props;
|
|
89
|
+
const {
|
|
90
|
+
browseFilesPassedParams
|
|
91
|
+
} = this;
|
|
92
|
+
const callbacks = {
|
|
93
|
+
onSuccess,
|
|
94
|
+
onError
|
|
95
|
+
};
|
|
96
|
+
if (browseFilesPassedParams && browseFilesPassedParams.onSuccess) {
|
|
97
|
+
callbacks.onSuccess = browseFilesPassedParams.onSuccess;
|
|
98
|
+
}
|
|
99
|
+
if (browseFilesPassedParams && browseFilesPassedParams.onError) {
|
|
100
|
+
callbacks.onError = browseFilesPassedParams.onError;
|
|
101
|
+
}
|
|
102
|
+
const files = [...eventFiles].map(file => {
|
|
103
|
+
return {
|
|
104
|
+
id: generateId(),
|
|
105
|
+
name: file.name,
|
|
106
|
+
type: file.type,
|
|
107
|
+
size: file.size,
|
|
108
|
+
src: {
|
|
109
|
+
file,
|
|
110
|
+
base64: null
|
|
140
111
|
}
|
|
141
|
-
callbacks.onSuccess && callbacks.onSuccess(files);
|
|
142
|
-
}
|
|
143
|
-
|
|
144
|
-
// Reset the browseFiles arguments.
|
|
145
|
-
if (_this.input) {
|
|
146
|
-
_this.input.value = "";
|
|
147
|
-
}
|
|
148
|
-
_this.browseFilesPassedParams = null;
|
|
149
|
-
});
|
|
150
|
-
/**
|
|
151
|
-
* Extracted into a separate method just for testing purposes.
|
|
152
|
-
*/
|
|
153
|
-
(0, _defineProperty2.default)(_this, "onDropFilesHandler", async function (_ref) {
|
|
154
|
-
var e = _ref.e,
|
|
155
|
-
onSuccess = _ref.onSuccess,
|
|
156
|
-
onError = _ref.onError;
|
|
157
|
-
_this.browseFilesPassedParams = {
|
|
158
|
-
onSuccess: onSuccess,
|
|
159
|
-
onError: onError
|
|
160
112
|
};
|
|
161
|
-
e.dataTransfer && e.dataTransfer.files && (await _this.processSelectedFiles(e.dataTransfer.files));
|
|
162
113
|
});
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
onError: onError
|
|
172
|
-
};
|
|
173
|
-
_this.input && _this.input.click();
|
|
174
|
-
});
|
|
175
|
-
return _this;
|
|
176
|
-
}
|
|
177
|
-
(0, _inherits2.default)(Files, _React$Component);
|
|
178
|
-
return (0, _createClass2.default)(Files, [{
|
|
179
|
-
key: "render",
|
|
180
|
-
value: function render() {
|
|
181
|
-
var _this3 = this;
|
|
182
|
-
var _this$props3 = this.props,
|
|
183
|
-
multiple = _this$props3.multiple,
|
|
184
|
-
accept = _this$props3.accept,
|
|
185
|
-
id = _this$props3.id;
|
|
186
|
-
return /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, this.props.children({
|
|
187
|
-
getLabelProps: function getLabelProps(props) {
|
|
188
|
-
return (0, _objectSpread2.default)((0, _objectSpread2.default)({}, props), {}, {
|
|
189
|
-
htmlFor: id || _this3.id
|
|
190
|
-
});
|
|
191
|
-
},
|
|
192
|
-
validateFiles: this.validateFiles,
|
|
193
|
-
browseFiles: function browseFiles() {
|
|
194
|
-
var _ref3 = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {},
|
|
195
|
-
onSuccess = _ref3.onSuccess,
|
|
196
|
-
onError = _ref3.onError;
|
|
197
|
-
_this3.browseFilesHandler({
|
|
198
|
-
onSuccess: onSuccess,
|
|
199
|
-
onError: onError
|
|
200
|
-
});
|
|
201
|
-
},
|
|
202
|
-
getDropZoneProps: function getDropZoneProps() {
|
|
203
|
-
var _ref4 = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
204
|
-
var onSuccess = _ref4.onSuccess,
|
|
205
|
-
onError = _ref4.onError,
|
|
206
|
-
_onDragOver = _ref4.onDragOver,
|
|
207
|
-
_onDrop = _ref4.onDrop,
|
|
208
|
-
rest = (0, _objectWithoutProperties2.default)(_ref4, _excluded);
|
|
209
|
-
return (0, _objectSpread2.default)((0, _objectSpread2.default)({}, rest), {}, {
|
|
210
|
-
onDragOver: function onDragOver(e) {
|
|
211
|
-
e.preventDefault();
|
|
212
|
-
typeof _onDragOver === "function" && _onDragOver();
|
|
213
|
-
},
|
|
214
|
-
onDrop: async function onDrop(e) {
|
|
215
|
-
e.preventDefault();
|
|
216
|
-
typeof _onDrop === "function" && _onDrop();
|
|
217
|
-
_this3.onDropFilesHandler({
|
|
218
|
-
e: e,
|
|
219
|
-
onSuccess: onSuccess,
|
|
220
|
-
onError: onError
|
|
221
|
-
});
|
|
222
|
-
}
|
|
223
|
-
});
|
|
114
|
+
const errors = this.validateFiles(files);
|
|
115
|
+
if (errors.length) {
|
|
116
|
+
callbacks.onError && callbacks.onError(errors, files);
|
|
117
|
+
} else {
|
|
118
|
+
if (convertToBase64) {
|
|
119
|
+
for (let i = 0; i < files.length; i++) {
|
|
120
|
+
const file = files[i].src.file;
|
|
121
|
+
files[i].src.base64 = await readFileContent(file);
|
|
224
122
|
}
|
|
225
|
-
}
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
123
|
+
}
|
|
124
|
+
callbacks.onSuccess && callbacks.onSuccess(files);
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
// Reset the browseFiles arguments.
|
|
128
|
+
if (this.input) {
|
|
129
|
+
this.input.value = "";
|
|
130
|
+
}
|
|
131
|
+
this.browseFilesPassedParams = null;
|
|
132
|
+
};
|
|
133
|
+
|
|
134
|
+
/**
|
|
135
|
+
* Extracted into a separate method just for testing purposes.
|
|
136
|
+
*/
|
|
137
|
+
onDropFilesHandler = async ({
|
|
138
|
+
e,
|
|
139
|
+
onSuccess,
|
|
140
|
+
onError
|
|
141
|
+
}) => {
|
|
142
|
+
this.browseFilesPassedParams = {
|
|
143
|
+
onSuccess,
|
|
144
|
+
onError
|
|
145
|
+
};
|
|
146
|
+
e.dataTransfer && e.dataTransfer.files && (await this.processSelectedFiles(e.dataTransfer.files));
|
|
147
|
+
};
|
|
148
|
+
|
|
149
|
+
/**
|
|
150
|
+
* Extracted into a separate method just for testing purposes.
|
|
151
|
+
*/
|
|
152
|
+
browseFilesHandler = ({
|
|
153
|
+
onSuccess,
|
|
154
|
+
onError
|
|
155
|
+
}) => {
|
|
156
|
+
this.browseFilesPassedParams = {
|
|
157
|
+
onSuccess,
|
|
158
|
+
onError
|
|
159
|
+
};
|
|
160
|
+
this.input && this.input.click();
|
|
161
|
+
};
|
|
162
|
+
render() {
|
|
163
|
+
const {
|
|
164
|
+
multiple,
|
|
165
|
+
accept,
|
|
166
|
+
id
|
|
167
|
+
} = this.props;
|
|
168
|
+
return /*#__PURE__*/React.createElement(React.Fragment, null, this.props.children({
|
|
169
|
+
getLabelProps: props => {
|
|
170
|
+
return {
|
|
171
|
+
...props,
|
|
172
|
+
htmlFor: id || this.id
|
|
173
|
+
};
|
|
174
|
+
},
|
|
175
|
+
validateFiles: this.validateFiles,
|
|
176
|
+
browseFiles: ({
|
|
177
|
+
onSuccess,
|
|
178
|
+
onError
|
|
179
|
+
} = {}) => {
|
|
180
|
+
this.browseFilesHandler({
|
|
181
|
+
onSuccess,
|
|
182
|
+
onError
|
|
183
|
+
});
|
|
184
|
+
},
|
|
185
|
+
getDropZoneProps: ({
|
|
186
|
+
onSuccess,
|
|
187
|
+
onError,
|
|
188
|
+
onDragOver,
|
|
189
|
+
onDrop,
|
|
190
|
+
...rest
|
|
191
|
+
} = {}) => {
|
|
192
|
+
return {
|
|
193
|
+
...rest,
|
|
194
|
+
onDragOver: e => {
|
|
195
|
+
e.preventDefault();
|
|
196
|
+
typeof onDragOver === "function" && onDragOver();
|
|
197
|
+
},
|
|
198
|
+
onDrop: async e => {
|
|
199
|
+
e.preventDefault();
|
|
200
|
+
typeof onDrop === "function" && onDrop();
|
|
201
|
+
this.onDropFilesHandler({
|
|
202
|
+
e,
|
|
203
|
+
onSuccess,
|
|
204
|
+
onError
|
|
205
|
+
});
|
|
230
206
|
}
|
|
231
|
-
}
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
onChange: function onChange(e) {
|
|
239
|
-
return _this3.processSelectedFiles(e.target.files ?? []);
|
|
207
|
+
};
|
|
208
|
+
}
|
|
209
|
+
}), /*#__PURE__*/React.createElement("input", {
|
|
210
|
+
id: id || this.id,
|
|
211
|
+
ref: ref => {
|
|
212
|
+
if (ref) {
|
|
213
|
+
this.input = ref;
|
|
240
214
|
}
|
|
241
|
-
}
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
});
|
|
215
|
+
},
|
|
216
|
+
accept: accept.join(","),
|
|
217
|
+
style: {
|
|
218
|
+
display: "none"
|
|
219
|
+
},
|
|
220
|
+
type: "file",
|
|
221
|
+
multiple: multiple,
|
|
222
|
+
onChange: e => this.processSelectedFiles(e.target.files ?? [])
|
|
223
|
+
}));
|
|
224
|
+
}
|
|
225
|
+
}
|
|
253
226
|
|
|
254
227
|
//# sourceMappingURL=Files.js.map
|