@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
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["
|
|
1
|
+
{"version":3,"names":["useAutocomplete"],"sources":["index.ts"],"sourcesContent":["export { useAutocomplete } from \"./useAutocomplete.js\";\n"],"mappings":"AAAA,SAASA,eAAe","ignoreList":[]}
|
|
@@ -1,24 +1,14 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
value: true
|
|
6
|
-
});
|
|
7
|
-
exports.useAutocomplete = void 0;
|
|
8
|
-
var _objectSpread2 = _interopRequireDefault(require("@babel/runtime/helpers/objectSpread2"));
|
|
9
|
-
var _useDataList = require("../useDataList");
|
|
10
|
-
var _debounce = _interopRequireDefault(require("lodash/debounce"));
|
|
11
|
-
var useAutocomplete = exports.useAutocomplete = function useAutocomplete(props) {
|
|
12
|
-
var dataList = (0, _useDataList.useDataList)((0, _objectSpread2.default)({
|
|
13
|
-
useRouter: false
|
|
14
|
-
}, props));
|
|
1
|
+
import { useDataList } from "../useDataList/index.js";
|
|
2
|
+
import debounce from "lodash/debounce.js";
|
|
3
|
+
export const useAutocomplete = props => {
|
|
4
|
+
const dataList = useDataList(props);
|
|
15
5
|
return {
|
|
16
6
|
options: dataList.data || [],
|
|
17
|
-
onInput: (
|
|
7
|
+
onInput: debounce(query => {
|
|
18
8
|
if (!query) {
|
|
19
9
|
return;
|
|
20
10
|
}
|
|
21
|
-
|
|
11
|
+
let search = props.search || query;
|
|
22
12
|
if (typeof search === "function") {
|
|
23
13
|
search = search(query);
|
|
24
14
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["
|
|
1
|
+
{"version":3,"names":["useDataList","debounce","useAutocomplete","props","dataList","options","data","onInput","query","search","setSearch"],"sources":["useAutocomplete.ts"],"sourcesContent":["import { useDataList } from \"../useDataList/index.js\";\nimport debounce from \"lodash/debounce.js\";\nimport type { DocumentNode } from \"graphql\";\n\ninterface UseAutocompleteHook {\n options: any[];\n onInput(value: string): void;\n}\n\ninterface Props {\n query: DocumentNode;\n search?: string | ((value: string) => string);\n}\n\nexport const useAutocomplete = (props: Props): UseAutocompleteHook => {\n const dataList = useDataList(props);\n\n return {\n options: dataList.data || [],\n onInput: debounce(query => {\n if (!query) {\n return;\n }\n\n let search = props.search || query;\n if (typeof search === \"function\") {\n search = search(query);\n }\n\n dataList.setSearch(search);\n }, 250)\n };\n};\n"],"mappings":"AAAA,SAASA,WAAW;AACpB,OAAOC,QAAQ,MAAM,oBAAoB;AAazC,OAAO,MAAMC,eAAe,GAAIC,KAAY,IAA0B;EAClE,MAAMC,QAAQ,GAAGJ,WAAW,CAACG,KAAK,CAAC;EAEnC,OAAO;IACHE,OAAO,EAAED,QAAQ,CAACE,IAAI,IAAI,EAAE;IAC5BC,OAAO,EAAEN,QAAQ,CAACO,KAAK,IAAI;MACvB,IAAI,CAACA,KAAK,EAAE;QACR;MACJ;MAEA,IAAIC,MAAM,GAAGN,KAAK,CAACM,MAAM,IAAID,KAAK;MAClC,IAAI,OAAOC,MAAM,KAAK,UAAU,EAAE;QAC9BA,MAAM,GAAGA,MAAM,CAACD,KAAK,CAAC;MAC1B;MAEAJ,QAAQ,CAACM,SAAS,CAACD,MAAM,CAAC;IAC9B,CAAC,EAAE,GAAG;EACV,CAAC;AACL,CAAC","ignoreList":[]}
|
|
@@ -1,13 +1,4 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
|
|
4
|
-
Object.defineProperty(exports, "__esModule", {
|
|
5
|
-
value: true
|
|
6
|
-
});
|
|
7
|
-
exports.default = void 0;
|
|
8
|
-
var _searchDataByKey = _interopRequireDefault(require("./searchDataByKey"));
|
|
9
|
-
var _default = exports.default = function _default(response) {
|
|
10
|
-
return (0, _searchDataByKey.default)("data", response);
|
|
11
|
-
};
|
|
1
|
+
import searchDataByKey from "./searchDataByKey.js";
|
|
2
|
+
export default response => searchDataByKey("data", response);
|
|
12
3
|
|
|
13
4
|
//# sourceMappingURL=getData.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["
|
|
1
|
+
{"version":3,"names":["searchDataByKey","response"],"sources":["getData.ts"],"sourcesContent":["import searchDataByKey from \"./searchDataByKey.js\";\n\nexport default (response: Record<string, string>) => searchDataByKey(\"data\", response);\n"],"mappings":"AAAA,OAAOA,eAAe;AAEtB,eAAgBC,QAAgC,IAAKD,eAAe,CAAC,MAAM,EAAEC,QAAQ,CAAC","ignoreList":[]}
|
|
@@ -1,13 +1,4 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
|
|
4
|
-
Object.defineProperty(exports, "__esModule", {
|
|
5
|
-
value: true
|
|
6
|
-
});
|
|
7
|
-
exports.default = void 0;
|
|
8
|
-
var _searchDataByKey = _interopRequireDefault(require("./searchDataByKey"));
|
|
9
|
-
var _default = exports.default = function _default(response) {
|
|
10
|
-
return (0, _searchDataByKey.default)("error", response);
|
|
11
|
-
};
|
|
1
|
+
import searchDataByKey from "./searchDataByKey.js";
|
|
2
|
+
export default response => searchDataByKey("error", response);
|
|
12
3
|
|
|
13
4
|
//# sourceMappingURL=getError.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["
|
|
1
|
+
{"version":3,"names":["searchDataByKey","response"],"sources":["getError.ts"],"sourcesContent":["import searchDataByKey from \"./searchDataByKey.js\";\n\nexport default (response: Record<string, string>) => searchDataByKey(\"error\", response);\n"],"mappings":"AAAA,OAAOA,eAAe;AAEtB,eAAgBC,QAAgC,IAAKD,eAAe,CAAC,OAAO,EAAEC,QAAQ,CAAC","ignoreList":[]}
|
|
@@ -1,13 +1,4 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
|
|
4
|
-
Object.defineProperty(exports, "__esModule", {
|
|
5
|
-
value: true
|
|
6
|
-
});
|
|
7
|
-
exports.default = void 0;
|
|
8
|
-
var _searchDataByKey = _interopRequireDefault(require("./searchDataByKey"));
|
|
9
|
-
var _default = exports.default = function _default(response) {
|
|
10
|
-
return (0, _searchDataByKey.default)("meta", response);
|
|
11
|
-
};
|
|
1
|
+
import searchDataByKey from "./searchDataByKey.js";
|
|
2
|
+
export default response => searchDataByKey("meta", response);
|
|
12
3
|
|
|
13
4
|
//# sourceMappingURL=getMeta.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["
|
|
1
|
+
{"version":3,"names":["searchDataByKey","response"],"sources":["getMeta.ts"],"sourcesContent":["import searchDataByKey from \"./searchDataByKey.js\";\n\nexport default (response: Record<string, string>) => searchDataByKey(\"meta\", response);\n"],"mappings":"AAAA,OAAOA,eAAe;AAEtB,eAAgBC,QAAgC,IAAKD,eAAe,CAAC,MAAM,EAAEC,QAAQ,CAAC","ignoreList":[]}
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
export { default as getData } from "./getData";
|
|
2
|
-
export { default as getError } from "./getError";
|
|
3
|
-
export { default as getMeta } from "./getMeta";
|
|
1
|
+
export { default as getData } from "./getData.js";
|
|
2
|
+
export { default as getError } from "./getError.js";
|
|
3
|
+
export { default as getMeta } from "./getMeta.js";
|
|
@@ -1,29 +1,5 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
Object.defineProperty(exports, "__esModule", {
|
|
5
|
-
value: true
|
|
6
|
-
});
|
|
7
|
-
Object.defineProperty(exports, "getData", {
|
|
8
|
-
enumerable: true,
|
|
9
|
-
get: function get() {
|
|
10
|
-
return _getData.default;
|
|
11
|
-
}
|
|
12
|
-
});
|
|
13
|
-
Object.defineProperty(exports, "getError", {
|
|
14
|
-
enumerable: true,
|
|
15
|
-
get: function get() {
|
|
16
|
-
return _getError.default;
|
|
17
|
-
}
|
|
18
|
-
});
|
|
19
|
-
Object.defineProperty(exports, "getMeta", {
|
|
20
|
-
enumerable: true,
|
|
21
|
-
get: function get() {
|
|
22
|
-
return _getMeta.default;
|
|
23
|
-
}
|
|
24
|
-
});
|
|
25
|
-
var _getData = _interopRequireDefault(require("./getData"));
|
|
26
|
-
var _getError = _interopRequireDefault(require("./getError"));
|
|
27
|
-
var _getMeta = _interopRequireDefault(require("./getMeta"));
|
|
1
|
+
export { default as getData } from "./getData.js";
|
|
2
|
+
export { default as getError } from "./getError.js";
|
|
3
|
+
export { default as getMeta } from "./getMeta.js";
|
|
28
4
|
|
|
29
5
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["
|
|
1
|
+
{"version":3,"names":["default","getData","getError","getMeta"],"sources":["index.ts"],"sourcesContent":["export { default as getData } from \"./getData.js\";\nexport { default as getError } from \"./getError.js\";\nexport { default as getMeta } from \"./getMeta.js\";\n"],"mappings":"AAAA,SAASA,OAAO,IAAIC,OAAO;AAC3B,SAASD,OAAO,IAAIE,QAAQ;AAC5B,SAASF,OAAO,IAAIG,OAAO","ignoreList":[]}
|
|
@@ -1,24 +1,18 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.default = void 0;
|
|
7
|
-
var _searchDataByKey = function searchDataByKey(searchKey, object) {
|
|
1
|
+
const searchDataByKey = (searchKey, object) => {
|
|
8
2
|
if (!object || typeof object !== "object") {
|
|
9
3
|
return null;
|
|
10
4
|
}
|
|
11
5
|
if (object[searchKey]) {
|
|
12
6
|
return object[searchKey];
|
|
13
7
|
}
|
|
14
|
-
for (
|
|
15
|
-
|
|
8
|
+
for (const key in object) {
|
|
9
|
+
const value = searchDataByKey(searchKey, object[key]);
|
|
16
10
|
if (value) {
|
|
17
11
|
return value;
|
|
18
12
|
}
|
|
19
13
|
}
|
|
20
14
|
return null;
|
|
21
15
|
};
|
|
22
|
-
|
|
16
|
+
export default searchDataByKey;
|
|
23
17
|
|
|
24
18
|
//# sourceMappingURL=searchDataByKey.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["searchDataByKey","searchKey","object","key","value"
|
|
1
|
+
{"version":3,"names":["searchDataByKey","searchKey","object","key","value"],"sources":["searchDataByKey.ts"],"sourcesContent":["const searchDataByKey = (searchKey: string, object: Record<string, any>): string | null => {\n if (!object || typeof object !== \"object\") {\n return null;\n }\n\n if (object[searchKey]) {\n return object[searchKey];\n }\n\n for (const key in object) {\n const value = searchDataByKey(searchKey, object[key]);\n if (value) {\n return value;\n }\n }\n\n return null;\n};\n\nexport default searchDataByKey;\n"],"mappings":"AAAA,MAAMA,eAAe,GAAGA,CAACC,SAAiB,EAAEC,MAA2B,KAAoB;EACvF,IAAI,CAACA,MAAM,IAAI,OAAOA,MAAM,KAAK,QAAQ,EAAE;IACvC,OAAO,IAAI;EACf;EAEA,IAAIA,MAAM,CAACD,SAAS,CAAC,EAAE;IACnB,OAAOC,MAAM,CAACD,SAAS,CAAC;EAC5B;EAEA,KAAK,MAAME,GAAG,IAAID,MAAM,EAAE;IACtB,MAAME,KAAK,GAAGJ,eAAe,CAACC,SAAS,EAAEC,MAAM,CAACC,GAAG,CAAC,CAAC;IACrD,IAAIC,KAAK,EAAE;MACP,OAAOA,KAAK;IAChB;EACJ;EAEA,OAAO,IAAI;AACf,CAAC;AAED,eAAeJ,eAAe","ignoreList":[]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export { useDataList } from "./useDataList";
|
|
1
|
+
export { useDataList } from "./useDataList.js";
|
|
@@ -1,14 +1,3 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
Object.defineProperty(exports, "useDataList", {
|
|
7
|
-
enumerable: true,
|
|
8
|
-
get: function get() {
|
|
9
|
-
return _useDataList.useDataList;
|
|
10
|
-
}
|
|
11
|
-
});
|
|
12
|
-
var _useDataList = require("./useDataList");
|
|
1
|
+
export { useDataList } from "./useDataList.js";
|
|
13
2
|
|
|
14
3
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["
|
|
1
|
+
{"version":3,"names":["useDataList"],"sources":["index.ts"],"sourcesContent":["export { useDataList } from \"./useDataList.js\";\n"],"mappings":"AAAA,SAASA,WAAW","ignoreList":[]}
|
|
@@ -1,7 +1,6 @@
|
|
|
1
|
-
import { DocumentNode } from "graphql";
|
|
2
|
-
import { ApolloClient } from "apollo-client";
|
|
1
|
+
import type { DocumentNode } from "graphql";
|
|
2
|
+
import type { ApolloClient } from "apollo-client";
|
|
3
3
|
export interface UseDataListParams {
|
|
4
|
-
useRouter?: boolean;
|
|
5
4
|
variables?: ((params: UseDataListParams) => any) | object;
|
|
6
5
|
client?: ApolloClient<any>;
|
|
7
6
|
query: DocumentNode;
|
|
@@ -1,123 +1,101 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
}
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
var _react = require("react");
|
|
12
|
-
var _reactHooks = require("@apollo/react-hooks");
|
|
13
|
-
var _reactRouter = require("@webiny/react-router");
|
|
14
|
-
var _get = _interopRequireDefault(require("lodash/get"));
|
|
15
|
-
var _isEqual = _interopRequireDefault(require("lodash/isEqual"));
|
|
16
|
-
var _utils = require("./utils");
|
|
17
|
-
var _functions = require("./functions");
|
|
18
|
-
var useDataList = exports.useDataList = function useDataList(params) {
|
|
19
|
-
var _useState = (0, _react.useState)([]),
|
|
20
|
-
_useState2 = (0, _slicedToArray2.default)(_useState, 2),
|
|
21
|
-
multiSelectedItems = _useState2[0],
|
|
22
|
-
_multiSelect = _useState2[1];
|
|
23
|
-
var history = null;
|
|
24
|
-
/**
|
|
25
|
-
* TODO: figure out the location type.
|
|
26
|
-
*/
|
|
27
|
-
var location = null;
|
|
28
|
-
var routerHook = (0, _reactRouter.useRouter)();
|
|
29
|
-
if (params.useRouter !== false) {
|
|
30
|
-
history = routerHook.history;
|
|
31
|
-
location = routerHook.location;
|
|
32
|
-
}
|
|
33
|
-
var getQueryOptions = (0, _react.useCallback)(function () {
|
|
34
|
-
var variables = params.variables;
|
|
1
|
+
import { useCallback, useEffect, useRef, useState } from "react";
|
|
2
|
+
import { useQuery } from "@apollo/react-hooks";
|
|
3
|
+
import get from "lodash/get.js";
|
|
4
|
+
import isEqual from "lodash/isEqual.js";
|
|
5
|
+
import { prepareLoadListParams } from "./utils/index.js";
|
|
6
|
+
import { getData, getError, getMeta } from "./functions/index.js";
|
|
7
|
+
const useDataList = params => {
|
|
8
|
+
const [multiSelectedItems, multiSelect] = useState([]);
|
|
9
|
+
const getQueryOptions = useCallback(() => {
|
|
10
|
+
let variables = params.variables;
|
|
35
11
|
if (typeof variables === "function") {
|
|
36
12
|
variables = variables(params);
|
|
37
13
|
}
|
|
38
14
|
return {
|
|
39
15
|
client: params.client,
|
|
40
|
-
variables:
|
|
16
|
+
variables: {
|
|
17
|
+
...variables,
|
|
18
|
+
...prepareLoadListParams()
|
|
19
|
+
}
|
|
41
20
|
};
|
|
42
21
|
}, []);
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
data: (
|
|
47
|
-
meta: (
|
|
48
|
-
error: (
|
|
22
|
+
const queryData = useQuery(params.query, getQueryOptions());
|
|
23
|
+
const prevLoadParamsRef = useRef({});
|
|
24
|
+
const dataListProps = {
|
|
25
|
+
data: get(params, "getData", getData)(queryData.data),
|
|
26
|
+
meta: get(params, "getMeta", getMeta)(queryData.data),
|
|
27
|
+
error: get(params, "getError", getError)(queryData.data),
|
|
49
28
|
loading: queryData.loading,
|
|
50
|
-
init
|
|
29
|
+
init() {
|
|
51
30
|
this.refresh();
|
|
52
31
|
},
|
|
53
|
-
refresh
|
|
54
|
-
var params = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : null;
|
|
32
|
+
refresh(params = null) {
|
|
55
33
|
// Refresh multi select first.
|
|
56
|
-
|
|
34
|
+
multiSelect([]);
|
|
57
35
|
if (!params) {
|
|
58
36
|
queryData.refetch(dataListProps.__loadParams);
|
|
59
37
|
return;
|
|
60
38
|
}
|
|
61
|
-
|
|
62
|
-
// if (history) {
|
|
63
|
-
// redirectToRouteWithQueryParams(params, { history, location });
|
|
64
|
-
// return;
|
|
65
|
-
// }
|
|
66
|
-
|
|
67
39
|
queryData.refetch(params);
|
|
68
40
|
},
|
|
69
|
-
setPerPage
|
|
70
|
-
|
|
41
|
+
setPerPage(perPage) {
|
|
42
|
+
const preparedParams = {
|
|
43
|
+
...dataListProps.__loadParams,
|
|
71
44
|
limit: parseInt("" + perPage),
|
|
72
45
|
after: undefined,
|
|
73
46
|
before: undefined
|
|
74
|
-
}
|
|
47
|
+
};
|
|
75
48
|
this.refresh(preparedParams);
|
|
76
49
|
},
|
|
77
|
-
setNextPage
|
|
78
|
-
|
|
50
|
+
setNextPage(cursor) {
|
|
51
|
+
const preparedParams = {
|
|
52
|
+
...dataListProps.__loadParams,
|
|
79
53
|
after: cursor,
|
|
80
54
|
before: undefined
|
|
81
|
-
}
|
|
55
|
+
};
|
|
82
56
|
this.refresh(preparedParams);
|
|
83
57
|
},
|
|
84
|
-
setPreviousPage
|
|
85
|
-
|
|
58
|
+
setPreviousPage(cursor) {
|
|
59
|
+
const preparedParams = {
|
|
60
|
+
...dataListProps.__loadParams,
|
|
86
61
|
after: undefined,
|
|
87
62
|
before: cursor
|
|
88
|
-
}
|
|
63
|
+
};
|
|
89
64
|
this.refresh(preparedParams);
|
|
90
65
|
},
|
|
91
|
-
setSearch
|
|
92
|
-
|
|
93
|
-
|
|
66
|
+
setSearch(search) {
|
|
67
|
+
const preparedParams = {
|
|
68
|
+
...dataListProps.__loadParams,
|
|
69
|
+
search,
|
|
94
70
|
after: undefined,
|
|
95
71
|
before: undefined
|
|
96
|
-
}
|
|
72
|
+
};
|
|
97
73
|
this.refresh(preparedParams);
|
|
98
74
|
},
|
|
99
|
-
setWhere
|
|
100
|
-
|
|
101
|
-
|
|
75
|
+
setWhere(where) {
|
|
76
|
+
const preparedParams = {
|
|
77
|
+
...dataListProps.__loadParams,
|
|
78
|
+
where,
|
|
102
79
|
after: undefined,
|
|
103
80
|
before: undefined
|
|
104
|
-
}
|
|
81
|
+
};
|
|
105
82
|
this.refresh(preparedParams);
|
|
106
83
|
},
|
|
107
|
-
setSorters
|
|
108
|
-
|
|
109
|
-
|
|
84
|
+
setSorters(sort) {
|
|
85
|
+
const preparedParams = {
|
|
86
|
+
...dataListProps.__loadParams,
|
|
87
|
+
sort,
|
|
110
88
|
after: undefined,
|
|
111
89
|
before: undefined
|
|
112
|
-
}
|
|
90
|
+
};
|
|
113
91
|
this.refresh(preparedParams);
|
|
114
92
|
},
|
|
115
|
-
multiSelect
|
|
93
|
+
multiSelect(items, value) {
|
|
116
94
|
if (!Array.isArray(items)) {
|
|
117
95
|
items = [items];
|
|
118
96
|
}
|
|
119
|
-
|
|
120
|
-
items.forEach(
|
|
97
|
+
const returnItems = [...multiSelectedItems];
|
|
98
|
+
items.forEach(item => {
|
|
121
99
|
if (value === undefined) {
|
|
122
100
|
returnItems.includes(item) ? returnItems.splice(returnItems.indexOf(item), 1) : returnItems.push(item);
|
|
123
101
|
} else {
|
|
@@ -128,56 +106,58 @@ var useDataList = exports.useDataList = function useDataList(params) {
|
|
|
128
106
|
}
|
|
129
107
|
}
|
|
130
108
|
});
|
|
131
|
-
|
|
109
|
+
multiSelect(returnItems);
|
|
132
110
|
},
|
|
133
|
-
isSelected
|
|
134
|
-
|
|
111
|
+
isSelected(item) {
|
|
112
|
+
const query = new URLSearchParams(location.search);
|
|
135
113
|
return query.get("id") === item.id;
|
|
136
114
|
},
|
|
137
|
-
select
|
|
138
|
-
|
|
115
|
+
select(item) {
|
|
116
|
+
const query = new URLSearchParams(location.search);
|
|
139
117
|
query.set("id", item.id);
|
|
140
|
-
history.push({
|
|
141
|
-
search: query.toString()
|
|
142
|
-
});
|
|
143
118
|
},
|
|
144
|
-
isMultiSelected
|
|
119
|
+
isMultiSelected(item) {
|
|
145
120
|
if (!Array.isArray(multiSelectedItems)) {
|
|
146
121
|
return false;
|
|
147
122
|
}
|
|
148
123
|
return multiSelectedItems.includes(item);
|
|
149
124
|
},
|
|
150
|
-
isNoneMultiSelected
|
|
125
|
+
isNoneMultiSelected() {
|
|
151
126
|
return multiSelectedItems.length === 0;
|
|
152
127
|
},
|
|
153
|
-
getMultiSelected
|
|
128
|
+
getMultiSelected() {
|
|
154
129
|
return multiSelectedItems;
|
|
155
130
|
},
|
|
156
|
-
multiSelectAll
|
|
157
|
-
|
|
131
|
+
multiSelectAll(value) {
|
|
132
|
+
const {
|
|
133
|
+
data
|
|
134
|
+
} = dataListProps;
|
|
158
135
|
if (Array.isArray(data)) {
|
|
159
136
|
dataListProps.multiSelect(data, value);
|
|
160
137
|
} else {
|
|
161
138
|
dataListProps.multiSelect([], value);
|
|
162
139
|
}
|
|
163
140
|
},
|
|
164
|
-
isAllMultiSelected
|
|
165
|
-
|
|
141
|
+
isAllMultiSelected() {
|
|
142
|
+
const {
|
|
143
|
+
data
|
|
144
|
+
} = dataListProps;
|
|
166
145
|
return Array.isArray(data) && multiSelectedItems.length === data.length;
|
|
167
146
|
},
|
|
168
|
-
__loadParams:
|
|
147
|
+
__loadParams: prepareLoadListParams(location)
|
|
169
148
|
};
|
|
170
|
-
|
|
171
|
-
|
|
149
|
+
useEffect(() => {
|
|
150
|
+
const params = {
|
|
172
151
|
prev: prevLoadParamsRef.current,
|
|
173
152
|
current: dataListProps.__loadParams
|
|
174
153
|
};
|
|
175
|
-
if (!(
|
|
154
|
+
if (!isEqual(params.prev, params.current)) {
|
|
176
155
|
dataListProps.init();
|
|
177
156
|
}
|
|
178
157
|
prevLoadParamsRef.current = params.current;
|
|
179
158
|
});
|
|
180
159
|
return dataListProps;
|
|
181
160
|
};
|
|
161
|
+
export { useDataList };
|
|
182
162
|
|
|
183
163
|
//# sourceMappingURL=useDataList.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["_react","require","_reactHooks","_reactRouter","_get","_interopRequireDefault","_isEqual","_utils","_functions","useDataList","exports","params","_useState","useState","_useState2","_slicedToArray2","default","multiSelectedItems","multiSelect","history","location","routerHook","useRouter","getQueryOptions","useCallback","variables","client","_objectSpread2","prepareLoadListParams","queryData","useQuery","query","prevLoadParamsRef","useRef","dataListProps","data","get","getData","meta","getMeta","error","getError","loading","init","refresh","arguments","length","undefined","refetch","__loadParams","setPerPage","perPage","preparedParams","limit","parseInt","after","before","setNextPage","cursor","setPreviousPage","setSearch","search","setWhere","where","setSorters","sort","items","value","Array","isArray","returnItems","_toConsumableArray2","forEach","item","includes","splice","indexOf","push","isSelected","URLSearchParams","id","select","set","toString","isMultiSelected","isNoneMultiSelected","getMultiSelected","multiSelectAll","isAllMultiSelected","useEffect","prev","current","isEqual"],"sources":["useDataList.ts"],"sourcesContent":["import { useState, useEffect, useRef, useCallback } from \"react\";\nimport { useQuery } from \"@apollo/react-hooks\";\nimport { useRouter } from \"@webiny/react-router\";\nimport get from \"lodash/get\";\nimport isEqual from \"lodash/isEqual\";\nimport { prepareLoadListParams } from \"./utils\";\nimport { getData, getError, getMeta } from \"./functions\";\n\nimport { DocumentNode } from \"graphql\";\nimport { ApolloClient } from \"apollo-client\";\n\nexport interface UseDataListParams {\n useRouter?: boolean;\n variables?: ((params: UseDataListParams) => any) | object;\n client?: ApolloClient<any>;\n query: DocumentNode;\n getData?: (data: any) => any;\n getMeta?: (data: any) => any;\n getError?: (data: any) => any;\n}\n\nexport interface DataListProps {\n __loadParams: any;\n refresh: (params?: any) => void;\n data: any[];\n meta: any;\n error: any;\n loading: boolean;\n isSelected: (item: any) => boolean;\n select: (item: any) => void;\n isMultiSelected: (item: any) => boolean;\n isNoneMultiSelected: () => boolean;\n isAllMultiSelected: () => boolean;\n multiSelectAll: (value: boolean) => void;\n getMultiSelected: () => any[];\n setSearch: (search: any) => void;\n setWhere: (where: any) => void;\n setSorters: (sort: any) => void;\n setPerPage: (perPage: number) => void;\n setPreviousPage: (cursor: string) => void;\n setNextPage: (cursor: string) => void;\n multiSelect: (items: string | string[], value?: boolean) => void;\n init: () => void;\n}\n\nconst useDataList = (params: UseDataListParams) => {\n const [multiSelectedItems, multiSelect] = useState<string[]>([]);\n\n let history = null;\n /**\n * TODO: figure out the location type.\n */\n let location: any = null;\n const routerHook = useRouter();\n\n if (params.useRouter !== false) {\n history = routerHook.history;\n location = routerHook.location;\n }\n\n const getQueryOptions = useCallback(() => {\n let variables = params.variables;\n if (typeof variables === \"function\") {\n variables = variables(params);\n }\n\n return {\n client: params.client,\n variables: {\n ...variables,\n ...prepareLoadListParams(location)\n }\n };\n }, []);\n\n const queryData = useQuery(params.query, getQueryOptions());\n const prevLoadParamsRef = useRef({});\n\n const dataListProps: DataListProps = {\n data: get(params, \"getData\", getData)(queryData.data),\n meta: get(params, \"getMeta\", getMeta)(queryData.data),\n error: get(params, \"getError\", getError)(queryData.data),\n\n loading: queryData.loading,\n init() {\n this.refresh();\n },\n refresh(params = null): void {\n // Refresh multi select first.\n multiSelect([]);\n\n if (!params) {\n queryData.refetch(dataListProps.__loadParams);\n return;\n }\n\n // if (history) {\n // redirectToRouteWithQueryParams(params, { history, location });\n // return;\n // }\n\n queryData.refetch(params);\n },\n setPerPage(perPage: number): void {\n const preparedParams = {\n ...dataListProps.__loadParams,\n limit: parseInt(\"\" + perPage),\n after: undefined,\n before: undefined\n };\n this.refresh(preparedParams);\n },\n setNextPage(cursor: string): void {\n const preparedParams = {\n ...dataListProps.__loadParams,\n after: cursor,\n before: undefined\n };\n this.refresh(preparedParams);\n },\n setPreviousPage(cursor: string): void {\n const preparedParams = {\n ...dataListProps.__loadParams,\n after: undefined,\n before: cursor\n };\n this.refresh(preparedParams);\n },\n setSearch(search): void {\n const preparedParams = {\n ...dataListProps.__loadParams,\n search,\n after: undefined,\n before: undefined\n };\n this.refresh(preparedParams);\n },\n setWhere(where): void {\n const preparedParams = {\n ...dataListProps.__loadParams,\n where,\n after: undefined,\n before: undefined\n };\n this.refresh(preparedParams);\n },\n setSorters(sort): void {\n const preparedParams = {\n ...dataListProps.__loadParams,\n sort,\n after: undefined,\n before: undefined\n };\n this.refresh(preparedParams);\n },\n multiSelect(items, value): void {\n if (!Array.isArray(items)) {\n items = [items];\n }\n\n const returnItems = [...multiSelectedItems];\n\n items.forEach(item => {\n if (value === undefined) {\n returnItems.includes(item)\n ? returnItems.splice(returnItems.indexOf(item), 1)\n : returnItems.push(item);\n } else {\n if (value === true) {\n !returnItems.includes(item) && returnItems.push(item);\n } else {\n returnItems.includes(item) &&\n returnItems.splice(returnItems.indexOf(item), 1);\n }\n }\n });\n\n multiSelect(returnItems);\n },\n isSelected(item) {\n const query = new URLSearchParams(location.search);\n return query.get(\"id\") === item.id;\n },\n select(item) {\n const query = new URLSearchParams(location.search);\n query.set(\"id\", item.id);\n history.push({ search: query.toString() });\n },\n isMultiSelected(item) {\n if (!Array.isArray(multiSelectedItems)) {\n return false;\n }\n\n return multiSelectedItems.includes(item);\n },\n isNoneMultiSelected() {\n return multiSelectedItems.length === 0;\n },\n getMultiSelected() {\n return multiSelectedItems;\n },\n multiSelectAll(value: boolean): void {\n const { data } = dataListProps;\n if (Array.isArray(data)) {\n dataListProps.multiSelect(data, value);\n } else {\n dataListProps.multiSelect([], value);\n }\n },\n isAllMultiSelected(): boolean {\n const { data } = dataListProps;\n\n return Array.isArray(data) && multiSelectedItems.length === data.length;\n },\n\n __loadParams: prepareLoadListParams(location)\n };\n\n useEffect(() => {\n const params = {\n prev: prevLoadParamsRef.current,\n current: dataListProps.__loadParams\n };\n\n if (!isEqual(params.prev, params.current)) {\n dataListProps.init();\n }\n\n prevLoadParamsRef.current = params.current;\n });\n\n return dataListProps;\n};\n\nexport { useDataList };\n"],"mappings":";;;;;;;;;;AAAA,IAAAA,MAAA,GAAAC,OAAA;AACA,IAAAC,WAAA,GAAAD,OAAA;AACA,IAAAE,YAAA,GAAAF,OAAA;AACA,IAAAG,IAAA,GAAAC,sBAAA,CAAAJ,OAAA;AACA,IAAAK,QAAA,GAAAD,sBAAA,CAAAJ,OAAA;AACA,IAAAM,MAAA,GAAAN,OAAA;AACA,IAAAO,UAAA,GAAAP,OAAA;AAuCA,IAAMQ,WAAW,GAAAC,OAAA,CAAAD,WAAA,GAAG,SAAdA,WAAWA,CAAIE,MAAyB,EAAK;EAC/C,IAAAC,SAAA,GAA0C,IAAAC,eAAQ,EAAW,EAAE,CAAC;IAAAC,UAAA,OAAAC,eAAA,CAAAC,OAAA,EAAAJ,SAAA;IAAzDK,kBAAkB,GAAAH,UAAA;IAAEI,YAAW,GAAAJ,UAAA;EAEtC,IAAIK,OAAO,GAAG,IAAI;EAClB;AACJ;AACA;EACI,IAAIC,QAAa,GAAG,IAAI;EACxB,IAAMC,UAAU,GAAG,IAAAC,sBAAS,EAAC,CAAC;EAE9B,IAAIX,MAAM,CAACW,SAAS,KAAK,KAAK,EAAE;IAC5BH,OAAO,GAAGE,UAAU,CAACF,OAAO;IAC5BC,QAAQ,GAAGC,UAAU,CAACD,QAAQ;EAClC;EAEA,IAAMG,eAAe,GAAG,IAAAC,kBAAW,EAAC,Y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K,CAACC,OAAO,CAAClC,IAAI,CAAC,EAAE;QACrBD,aAAa,CAAChB,WAAW,CAACiB,IAAI,EAAEgC,KAAK,CAAC;MAC1C,CAAC,MAAM;QACHjC,aAAa,CAAChB,WAAW,CAAC,EAAE,EAAEiD,KAAK,CAAC;MACxC;IACJ,CAAC;IACDqB,kBAAkB,WAAlBA,kBAAkBA,CAAA,EAAY;MAC1B,IAAQrD,IAAI,GAAKD,aAAa,CAAtBC,IAAI;MAEZ,OAAOiC,KAAK,CAACC,OAAO,CAAClC,IAAI,CAAC,IAAIlB,kBAAkB,CAAC6B,MAAM,KAAKX,IAAI,CAACW,MAAM;IAC3E,CAAC;IAEDG,YAAY,EAAE,IAAArB,4BAAqB,EAACR,QAAQ;EAChD,CAAC;EAED,IAAAqE,gBAAS,EAAC,YAAM;IACZ,IAAM9E,MAAM,GAAG;MACX+E,IAAI,EAAE1D,iBAAiB,CAAC2D,OAAO;MAC/BA,OAAO,EAAEzD,aAAa,CAACe;IAC3B,CAAC;IAED,IAAI,CAAC,IAAA2C,gBAAO,EAACjF,MAAM,CAAC+E,IAAI,EAAE/E,MAAM,CAACgF,OAAO,CAAC,EAAE;MACvCzD,aAAa,CAACS,IAAI,CAAC,CAAC;IACxB;IAEAX,iBAAiB,CAAC2D,OAAO,GAAGhF,MAAM,CAACgF,OAAO;EAC9C,CAAC,CAAC;EAEF,OAAOzD,aAAa;AACxB,CAAC","ignoreList":[]}
|
|
1
|
+
{"version":3,"names":["useCallback","useEffect","useRef","useState","useQuery","get","isEqual","prepareLoadListParams","getData","getError","getMeta","useDataList","params","multiSelectedItems","multiSelect","getQueryOptions","variables","client","queryData","query","prevLoadParamsRef","dataListProps","data","meta","error","loading","init","refresh","refetch","__loadParams","setPerPage","perPage","preparedParams","limit","parseInt","after","undefined","before","setNextPage","cursor","setPreviousPage","setSearch","search","setWhere","where","setSorters","sort","items","value","Array","isArray","returnItems","forEach","item","includes","splice","indexOf","push","isSelected","URLSearchParams","location","id","select","set","isMultiSelected","isNoneMultiSelected","length","getMultiSelected","multiSelectAll","isAllMultiSelected","prev","current"],"sources":["useDataList.ts"],"sourcesContent":["import { useCallback, useEffect, useRef, useState } from \"react\";\nimport { useQuery } from \"@apollo/react-hooks\";\nimport get from \"lodash/get.js\";\nimport isEqual from \"lodash/isEqual.js\";\nimport { prepareLoadListParams } from \"./utils/index.js\";\nimport { getData, getError, getMeta } from \"./functions/index.js\";\n\nimport type { DocumentNode } from \"graphql\";\nimport type { ApolloClient } from \"apollo-client\";\n\nexport interface UseDataListParams {\n variables?: ((params: UseDataListParams) => any) | object;\n client?: ApolloClient<any>;\n query: DocumentNode;\n getData?: (data: any) => any;\n getMeta?: (data: any) => any;\n getError?: (data: any) => any;\n}\n\nexport interface DataListProps {\n __loadParams: any;\n refresh: (params?: any) => void;\n data: any[];\n meta: any;\n error: any;\n loading: boolean;\n isSelected: (item: any) => boolean;\n select: (item: any) => void;\n isMultiSelected: (item: any) => boolean;\n isNoneMultiSelected: () => boolean;\n isAllMultiSelected: () => boolean;\n multiSelectAll: (value: boolean) => void;\n getMultiSelected: () => any[];\n setSearch: (search: any) => void;\n setWhere: (where: any) => void;\n setSorters: (sort: any) => void;\n setPerPage: (perPage: number) => void;\n setPreviousPage: (cursor: string) => void;\n setNextPage: (cursor: string) => void;\n multiSelect: (items: string | string[], value?: boolean) => void;\n init: () => void;\n}\n\nconst useDataList = (params: UseDataListParams) => {\n const [multiSelectedItems, multiSelect] = useState<string[]>([]);\n\n const getQueryOptions = useCallback(() => {\n let variables = params.variables;\n if (typeof variables === \"function\") {\n variables = variables(params);\n }\n\n return {\n client: params.client,\n variables: {\n ...variables,\n ...prepareLoadListParams()\n }\n };\n }, []);\n\n const queryData = useQuery(params.query, getQueryOptions());\n const prevLoadParamsRef = useRef({});\n\n const dataListProps: DataListProps = {\n data: get(params, \"getData\", getData)(queryData.data),\n meta: get(params, \"getMeta\", getMeta)(queryData.data),\n error: get(params, \"getError\", getError)(queryData.data),\n\n loading: queryData.loading,\n init() {\n this.refresh();\n },\n refresh(params = null): void {\n // Refresh multi select first.\n multiSelect([]);\n\n if (!params) {\n queryData.refetch(dataListProps.__loadParams);\n return;\n }\n\n queryData.refetch(params);\n },\n setPerPage(perPage: number): void {\n const preparedParams = {\n ...dataListProps.__loadParams,\n limit: parseInt(\"\" + perPage),\n after: undefined,\n before: undefined\n };\n this.refresh(preparedParams);\n },\n setNextPage(cursor: string): void {\n const preparedParams = {\n ...dataListProps.__loadParams,\n after: cursor,\n before: undefined\n };\n this.refresh(preparedParams);\n },\n setPreviousPage(cursor: string): void {\n const preparedParams = {\n ...dataListProps.__loadParams,\n after: undefined,\n before: cursor\n };\n this.refresh(preparedParams);\n },\n setSearch(search): void {\n const preparedParams = {\n ...dataListProps.__loadParams,\n search,\n after: undefined,\n before: undefined\n };\n this.refresh(preparedParams);\n },\n setWhere(where): void {\n const preparedParams = {\n ...dataListProps.__loadParams,\n where,\n after: undefined,\n before: undefined\n };\n this.refresh(preparedParams);\n },\n setSorters(sort): void {\n const preparedParams = {\n ...dataListProps.__loadParams,\n sort,\n after: undefined,\n before: undefined\n };\n this.refresh(preparedParams);\n },\n multiSelect(items, value): void {\n if (!Array.isArray(items)) {\n items = [items];\n }\n\n const returnItems = [...multiSelectedItems];\n\n items.forEach(item => {\n if (value === undefined) {\n returnItems.includes(item)\n ? returnItems.splice(returnItems.indexOf(item), 1)\n : returnItems.push(item);\n } else {\n if (value === true) {\n !returnItems.includes(item) && returnItems.push(item);\n } else {\n returnItems.includes(item) &&\n returnItems.splice(returnItems.indexOf(item), 1);\n }\n }\n });\n\n multiSelect(returnItems);\n },\n isSelected(item) {\n const query = new URLSearchParams(location.search);\n return query.get(\"id\") === item.id;\n },\n select(item) {\n const query = new URLSearchParams(location.search);\n query.set(\"id\", item.id);\n },\n isMultiSelected(item) {\n if (!Array.isArray(multiSelectedItems)) {\n return false;\n }\n\n return multiSelectedItems.includes(item);\n },\n isNoneMultiSelected() {\n return multiSelectedItems.length === 0;\n },\n getMultiSelected() {\n return multiSelectedItems;\n },\n multiSelectAll(value: boolean): void {\n const { data } = dataListProps;\n if (Array.isArray(data)) {\n dataListProps.multiSelect(data, value);\n } else {\n dataListProps.multiSelect([], value);\n }\n },\n isAllMultiSelected(): boolean {\n const { data } = dataListProps;\n\n return Array.isArray(data) && multiSelectedItems.length === data.length;\n },\n\n __loadParams: prepareLoadListParams(location)\n };\n\n useEffect(() => {\n const params = {\n prev: prevLoadParamsRef.current,\n current: dataListProps.__loadParams\n };\n\n if (!isEqual(params.prev, params.current)) {\n dataListProps.init();\n }\n\n prevLoadParamsRef.current = params.current;\n });\n\n return dataListProps;\n};\n\nexport { useDataList };\n"],"mappings":"AAAA,SAASA,WAAW,EAAEC,SAAS,EAAEC,MAAM,EAAEC,QAAQ,QAAQ,OAAO;AAChE,SAASC,QAAQ,QAAQ,qBAAqB;AAC9C,OAAOC,GAAG,MAAM,eAAe;AAC/B,OAAOC,OAAO,MAAM,mBAAmB;AACvC,SAASC,qBAAqB;AAC9B,SAASC,OAAO,EAAEC,QAAQ,EAAEC,OAAO;AAsCnC,MAAMC,WAAW,GAAIC,MAAyB,IAAK;EAC/C,MAAM,CAACC,kBAAkB,EAAEC,WAAW,CAAC,GAAGX,QAAQ,CAAW,EAAE,CAAC;EAEhE,MAAMY,eAAe,GAAGf,WAAW,CAAC,MAAM;IACtC,IAAIgB,SAAS,GAAGJ,MAAM,CAACI,SAAS;IAChC,IAAI,OAAOA,SAAS,KAAK,UAAU,EAAE;MACjCA,SAAS,GAAGA,SAAS,CAACJ,MAAM,CAAC;IACjC;IAEA,OAAO;MACHK,MAAM,EAAEL,MAAM,CAACK,MAAM;MACrBD,SAAS,EAAE;QACP,GAAGA,SAAS;QACZ,GAAGT,qBAAqB,CAAC;MAC7B;IACJ,CAAC;EACL,CAAC,EAAE,EAAE,CAAC;EAEN,MAAMW,SAAS,GAAGd,QAAQ,CAACQ,MAAM,CAACO,KAAK,EAAEJ,eAAe,CAAC,CAAC,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AAC,GAAGD,aAAa;MAC9B,IAAI4B,KAAK,CAACC,OAAO,CAAC5B,IAAI,CAAC,EAAE;QACrBD,aAAa,CAACP,WAAW,CAACQ,IAAI,EAAE0B,KAAK,CAAC;MAC1C,CAAC,MAAM;QACH3B,aAAa,CAACP,WAAW,CAAC,EAAE,EAAEkC,KAAK,CAAC;MACxC;IACJ,CAAC;IACDqB,kBAAkBA,CAAA,EAAY;MAC1B,MAAM;QAAE/C;MAAK,CAAC,GAAGD,aAAa;MAE9B,OAAO4B,KAAK,CAACC,OAAO,CAAC5B,IAAI,CAAC,IAAIT,kBAAkB,CAACqD,MAAM,KAAK5C,IAAI,CAAC4C,MAAM;IAC3E,CAAC;IAEDrC,YAAY,EAAEtB,qBAAqB,CAACqD,QAAQ;EAChD,CAAC;EAED3D,SAAS,CAAC,MAAM;IACZ,MAAMW,MAAM,GAAG;MACX0D,IAAI,EAAElD,iBAAiB,CAACmD,OAAO;MAC/BA,OAAO,EAAElD,aAAa,CAACQ;IAC3B,CAAC;IAED,IAAI,CAACvB,OAAO,CAACM,MAAM,CAAC0D,IAAI,EAAE1D,MAAM,CAAC2D,OAAO,CAAC,EAAE;MACvClD,aAAa,CAACK,IAAI,CAAC,CAAC;IACxB;IAEAN,iBAAiB,CAACmD,OAAO,GAAG3D,MAAM,CAAC2D,OAAO;EAC9C,CAAC,CAAC;EAEF,OAAOlD,aAAa;AACxB,CAAC;AAED,SAASV,WAAW","ignoreList":[]}
|
|
@@ -1,2 +1 @@
|
|
|
1
|
-
export { default as prepareLoadListParams } from "./prepareLoadListParams";
|
|
2
|
-
export { default as redirectToRouteWithQueryParams } from "./redirectToRouteWithQueryParams";
|
|
1
|
+
export { default as prepareLoadListParams } from "./prepareLoadListParams.js";
|
|
@@ -1,22 +1,3 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
|
|
4
|
-
Object.defineProperty(exports, "__esModule", {
|
|
5
|
-
value: true
|
|
6
|
-
});
|
|
7
|
-
Object.defineProperty(exports, "prepareLoadListParams", {
|
|
8
|
-
enumerable: true,
|
|
9
|
-
get: function get() {
|
|
10
|
-
return _prepareLoadListParams.default;
|
|
11
|
-
}
|
|
12
|
-
});
|
|
13
|
-
Object.defineProperty(exports, "redirectToRouteWithQueryParams", {
|
|
14
|
-
enumerable: true,
|
|
15
|
-
get: function get() {
|
|
16
|
-
return _redirectToRouteWithQueryParams.default;
|
|
17
|
-
}
|
|
18
|
-
});
|
|
19
|
-
var _prepareLoadListParams = _interopRequireDefault(require("./prepareLoadListParams"));
|
|
20
|
-
var _redirectToRouteWithQueryParams = _interopRequireDefault(require("./redirectToRouteWithQueryParams"));
|
|
1
|
+
export { default as prepareLoadListParams } from "./prepareLoadListParams.js";
|
|
21
2
|
|
|
22
3
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["
|
|
1
|
+
{"version":3,"names":["default","prepareLoadListParams"],"sources":["index.ts"],"sourcesContent":["export { default as prepareLoadListParams } from \"./prepareLoadListParams.js\";\n"],"mappings":"AAAA,SAASA,OAAO,IAAIC,qBAAqB","ignoreList":[]}
|