@webiny/app 0.0.0-unstable.eb196ccd2f → 0.0.0-unstable.f6dc066313
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/App.d.ts +4 -5
- package/App.js +26 -32
- package/App.js.map +1 -1
- package/README.md +7 -15
- package/apollo-client/InMemoryCache.js +2 -2
- package/apollo-client/InMemoryCache.js.map +1 -1
- package/components/Image.d.ts +1 -2
- package/components/Image.js +1 -1
- package/components/Image.js.map +1 -1
- package/components/index.d.ts +1 -2
- package/components/index.js +1 -2
- package/components/index.js.map +1 -1
- package/config/RouterConfig/Route.d.ts +9 -10
- package/config/RouterConfig/Route.js +5 -14
- package/config/RouterConfig/Route.js.map +1 -1
- package/config/RouterConfig.d.ts +10 -11
- package/config/RouterConfig.js +1 -1
- package/config/RouterConfig.js.map +1 -1
- package/contexts/Ui/index.js.map +1 -1
- package/core/Plugin.js +2 -2
- package/core/Plugin.js.map +1 -1
- package/core/Plugins.d.ts +1 -1
- package/core/Plugins.js +5 -4
- package/core/Plugins.js.map +1 -1
- package/core/Provider.d.ts +1 -1
- package/core/Provider.js +1 -1
- package/core/Provider.js.map +1 -1
- package/core/createProviderPlugin.js +1 -1
- package/core/createProviderPlugin.js.map +1 -1
- package/errors/AuthenticationErrorEvent.d.ts +9 -0
- package/errors/AuthenticationErrorEvent.js +10 -0
- package/errors/AuthenticationErrorEvent.js.map +1 -0
- package/errors/NetworkErrorEvent.d.ts +15 -0
- package/errors/NetworkErrorEvent.js +10 -0
- package/errors/NetworkErrorEvent.js.map +1 -0
- package/errors/abstractions.d.ts +12 -0
- package/errors/abstractions.js +5 -0
- package/errors/abstractions.js.map +1 -0
- package/errors/index.d.ts +6 -0
- package/errors/index.js +6 -0
- package/errors/index.js.map +1 -0
- package/exports/admin/env-config.d.ts +1 -0
- package/exports/admin/env-config.js +3 -0
- package/exports/admin/env-config.js.map +1 -0
- package/exports/admin/graphql-client.d.ts +1 -0
- package/exports/admin/graphql-client.js +3 -0
- package/exports/admin/graphql-client.js.map +1 -0
- package/exports/admin/local-storage.d.ts +2 -0
- package/exports/admin/local-storage.js +4 -0
- package/exports/admin/local-storage.js.map +1 -0
- package/exports/admin/router.d.ts +5 -0
- package/exports/admin/router.js +7 -0
- package/exports/admin/router.js.map +1 -0
- package/exports/admin/security.d.ts +1 -0
- package/exports/admin/security.js +3 -0
- package/exports/admin/security.js.map +1 -0
- package/exports/admin.d.ts +6 -0
- package/exports/admin.js +8 -0
- package/exports/admin.js.map +1 -0
- package/features/envConfig/EnvConfig.d.ts +6 -0
- package/features/envConfig/EnvConfig.js +14 -0
- package/features/envConfig/EnvConfig.js.map +1 -0
- package/features/envConfig/abstractions.d.ts +27 -0
- package/features/envConfig/abstractions.js +4 -0
- package/features/envConfig/abstractions.js.map +1 -0
- package/features/envConfig/feature.d.ts +17 -0
- package/features/envConfig/feature.js +14 -0
- package/features/envConfig/feature.js.map +1 -0
- package/features/envConfig/index.d.ts +1 -0
- package/features/envConfig/index.js +3 -0
- package/features/envConfig/index.js.map +1 -0
- package/features/eventPublisher/EventPublisher.d.ts +8 -0
- package/features/eventPublisher/EventPublisher.js +27 -0
- package/features/eventPublisher/EventPublisher.js.map +1 -0
- package/features/eventPublisher/abstractions.d.ts +18 -0
- package/features/eventPublisher/abstractions.js +14 -0
- package/features/eventPublisher/abstractions.js.map +1 -0
- package/features/eventPublisher/feature.d.ts +1 -0
- package/features/eventPublisher/feature.js +11 -0
- package/features/eventPublisher/feature.js.map +1 -0
- package/features/eventPublisher/index.d.ts +3 -0
- package/features/eventPublisher/index.js +4 -0
- package/features/eventPublisher/index.js.map +1 -0
- package/features/graphqlClient/AuthenticationErrorPublishing.d.ts +13 -0
- package/features/graphqlClient/AuthenticationErrorPublishing.js +35 -0
- package/features/graphqlClient/AuthenticationErrorPublishing.js.map +1 -0
- package/features/graphqlClient/BatchingGraphQLClient.d.ts +18 -0
- package/features/graphqlClient/BatchingGraphQLClient.js +164 -0
- package/features/graphqlClient/BatchingGraphQLClient.js.map +1 -0
- package/features/graphqlClient/FetchGraphQLClient.d.ts +10 -0
- package/features/graphqlClient/FetchGraphQLClient.js +62 -0
- package/features/graphqlClient/FetchGraphQLClient.js.map +1 -0
- package/features/graphqlClient/NetworkErrorPublishing.d.ts +14 -0
- package/features/graphqlClient/NetworkErrorPublishing.js +55 -0
- package/features/graphqlClient/NetworkErrorPublishing.js.map +1 -0
- package/features/graphqlClient/RequestValue.d.ts +20 -0
- package/features/graphqlClient/RequestValue.js +42 -0
- package/features/graphqlClient/RequestValue.js.map +1 -0
- package/features/graphqlClient/RetryGraphQLClient.d.ts +18 -0
- package/features/graphqlClient/RetryGraphQLClient.js +54 -0
- package/features/graphqlClient/RetryGraphQLClient.js.map +1 -0
- package/features/graphqlClient/__tests__/GraphQLClient.test.d.ts +1 -0
- package/features/graphqlClient/__tests__/GraphQLClient.test.js +350 -0
- package/features/graphqlClient/__tests__/GraphQLClient.test.js.map +1 -0
- package/features/graphqlClient/abstractions.d.ts +17 -0
- package/features/graphqlClient/abstractions.js +4 -0
- package/features/graphqlClient/abstractions.js.map +1 -0
- package/features/graphqlClient/feature.d.ts +6 -0
- package/features/graphqlClient/feature.js +31 -0
- package/features/graphqlClient/feature.js.map +1 -0
- package/features/graphqlClient/index.d.ts +1 -0
- package/features/graphqlClient/index.js +3 -0
- package/features/graphqlClient/index.js.map +1 -0
- package/features/graphqlClient/types.d.ts +5 -0
- package/features/graphqlClient/types.js.map +1 -0
- package/features/localStorage/BrowserLocalStorageGateway.d.ts +9 -0
- package/features/localStorage/BrowserLocalStorageGateway.js +68 -0
- package/features/localStorage/BrowserLocalStorageGateway.js.map +1 -0
- package/features/localStorage/LocalStorage.d.ts +12 -0
- package/features/localStorage/LocalStorage.js +31 -0
- package/features/localStorage/LocalStorage.js.map +1 -0
- package/features/localStorage/LocalStorageRepository.d.ts +20 -0
- package/features/localStorage/LocalStorageRepository.js +95 -0
- package/features/localStorage/LocalStorageRepository.js.map +1 -0
- package/features/localStorage/abstractions.d.ts +48 -0
- package/features/localStorage/abstractions.js +19 -0
- package/features/localStorage/abstractions.js.map +1 -0
- package/features/localStorage/feature.d.ts +12 -0
- package/features/localStorage/feature.js +34 -0
- package/features/localStorage/feature.js.map +1 -0
- package/features/localStorage/index.d.ts +1 -0
- package/features/localStorage/index.js +3 -0
- package/features/localStorage/index.js.map +1 -0
- package/features/router/HistoryRouterGateway.d.ts +18 -0
- package/features/router/HistoryRouterGateway.js +82 -0
- package/features/router/HistoryRouterGateway.js.map +1 -0
- package/features/router/HistoryRouterGateway.test.d.ts +1 -0
- package/features/router/HistoryRouterGateway.test.js +204 -0
- package/features/router/HistoryRouterGateway.test.js.map +1 -0
- package/features/router/Route.d.ts +19 -0
- package/features/router/Route.js +59 -0
- package/features/router/Route.js.map +1 -0
- package/features/router/RouteUrl.d.ts +85 -0
- package/features/router/RouteUrl.js +232 -0
- package/features/router/RouteUrl.js.map +1 -0
- package/features/router/Router.d.ts +45 -0
- package/features/router/Router.js +129 -0
- package/features/router/Router.js.map +1 -0
- package/features/router/RouterPresenter.d.ts +17 -0
- package/features/router/RouterPresenter.js +45 -0
- package/features/router/RouterPresenter.js.map +1 -0
- package/features/router/RouterRepository.d.ts +21 -0
- package/features/router/RouterRepository.js +71 -0
- package/features/router/RouterRepository.js.map +1 -0
- package/features/router/RouterRepository.test.d.ts +1 -0
- package/features/router/RouterRepository.test.js +154 -0
- package/features/router/RouterRepository.test.js.map +1 -0
- package/features/router/abstractions.d.ts +68 -0
- package/features/router/abstractions.js +15 -0
- package/features/router/abstractions.js.map +1 -0
- package/features/router/feature.d.ts +4 -0
- package/features/router/feature.js +18 -0
- package/features/router/feature.js.map +1 -0
- package/features/router/index.d.ts +1 -0
- package/features/router/index.js +3 -0
- package/features/router/index.js.map +1 -0
- package/helpers/InterfaceGenerator/date.d.ts +15 -0
- package/helpers/InterfaceGenerator/date.js +3 -0
- package/helpers/InterfaceGenerator/date.js.map +1 -0
- package/helpers/InterfaceGenerator/id.d.ts +23 -0
- package/helpers/InterfaceGenerator/id.js +3 -0
- package/helpers/InterfaceGenerator/id.js.map +1 -0
- package/helpers/InterfaceGenerator/identity.d.ts +10 -0
- package/helpers/InterfaceGenerator/identity.js +3 -0
- package/helpers/InterfaceGenerator/identity.js.map +1 -0
- package/helpers/InterfaceGenerator/index.d.ts +5 -0
- package/helpers/InterfaceGenerator/index.js +3 -0
- package/helpers/InterfaceGenerator/index.js.map +1 -0
- package/helpers/InterfaceGenerator/numeric.d.ts +12 -0
- package/helpers/InterfaceGenerator/numeric.js +3 -0
- package/helpers/InterfaceGenerator/numeric.js.map +1 -0
- package/helpers/InterfaceGenerator/truthful.d.ts +7 -0
- package/helpers/InterfaceGenerator/truthful.js +3 -0
- package/helpers/InterfaceGenerator/truthful.js.map +1 -0
- package/hooks/useAutocomplete/index.d.ts +1 -1
- package/hooks/useAutocomplete/index.js +1 -1
- package/hooks/useAutocomplete/index.js.map +1 -1
- package/hooks/useAutocomplete/useAutocomplete.js +3 -6
- package/hooks/useAutocomplete/useAutocomplete.js.map +1 -1
- package/hooks/useDataList/functions/getData.js +1 -1
- package/hooks/useDataList/functions/getData.js.map +1 -1
- package/hooks/useDataList/functions/getError.js +1 -1
- package/hooks/useDataList/functions/getError.js.map +1 -1
- package/hooks/useDataList/functions/getMeta.js +1 -1
- package/hooks/useDataList/functions/getMeta.js.map +1 -1
- package/hooks/useDataList/functions/index.d.ts +3 -3
- package/hooks/useDataList/functions/index.js +3 -3
- package/hooks/useDataList/functions/index.js.map +1 -1
- package/hooks/useDataList/index.d.ts +1 -1
- package/hooks/useDataList/index.js +1 -1
- package/hooks/useDataList/index.js.map +1 -1
- package/hooks/useDataList/useDataList.d.ts +0 -1
- package/hooks/useDataList/useDataList.js +6 -26
- package/hooks/useDataList/useDataList.js.map +1 -1
- package/hooks/useDataList/utils/index.d.ts +1 -2
- package/hooks/useDataList/utils/index.js +1 -2
- package/hooks/useDataList/utils/index.js.map +1 -1
- package/hooks/useDataList/utils/prepareLoadListParams.js +1 -1
- package/hooks/useDataList/utils/prepareLoadListParams.js.map +1 -1
- package/hooks/useHandlers.js.map +1 -1
- package/hooks/useRegisterLegacyPlugin.d.ts +1 -1
- package/hooks/useRegisterLegacyPlugin.js.map +1 -1
- package/hooks/useUi.d.ts +1 -1
- package/hooks/useUi.js +1 -1
- package/hooks/useUi.js.map +1 -1
- package/i18n/index.d.ts +1 -1
- package/i18n/index.js +1 -1
- package/i18n/index.js.map +1 -1
- package/index.d.ts +22 -15
- package/index.js +21 -14
- package/index.js.map +1 -1
- package/package.json +25 -23
- package/plugins/AddQuerySelectionPlugin.d.ts +1 -1
- package/plugins/AddQuerySelectionPlugin.js +1 -1
- package/plugins/AddQuerySelectionPlugin.js.map +1 -1
- package/plugins/ApolloDynamicLink.d.ts +1 -1
- package/plugins/ApolloDynamicLink.js.map +1 -1
- package/plugins/ConsoleLinkPlugin.d.ts +1 -1
- package/plugins/ConsoleLinkPlugin.js +1 -1
- package/plugins/ConsoleLinkPlugin.js.map +1 -1
- package/plugins/NetworkErrorLinkPlugin/ErrorOverlay.d.ts +8 -13
- package/plugins/NetworkErrorLinkPlugin/ErrorOverlay.js +15 -26
- package/plugins/NetworkErrorLinkPlugin/ErrorOverlay.js.map +1 -1
- package/plugins/NetworkErrorLinkPlugin/GqlErrorOverlay.d.ts +14 -0
- package/plugins/NetworkErrorLinkPlugin/GqlErrorOverlay.js +31 -0
- package/plugins/NetworkErrorLinkPlugin/GqlErrorOverlay.js.map +1 -0
- package/plugins/NetworkErrorLinkPlugin/LocalAwsLambdaTimeoutMessage.d.ts +2 -0
- package/plugins/NetworkErrorLinkPlugin/LocalAwsLambdaTimeoutMessage.js +31 -0
- package/plugins/NetworkErrorLinkPlugin/LocalAwsLambdaTimeoutMessage.js.map +1 -0
- package/plugins/NetworkErrorLinkPlugin/StyledComponents.d.ts +4 -5
- package/plugins/NetworkErrorLinkPlugin/StyledComponents.js +3 -3
- package/plugins/NetworkErrorLinkPlugin/StyledComponents.js.map +1 -1
- package/plugins/NetworkErrorLinkPlugin/Typography.d.ts +8 -0
- package/plugins/NetworkErrorLinkPlugin/Typography.js +18 -0
- package/plugins/NetworkErrorLinkPlugin/Typography.js.map +1 -0
- package/plugins/NetworkErrorLinkPlugin/createErrorOverlay.d.ts +3 -3
- package/plugins/NetworkErrorLinkPlugin/createErrorOverlay.js +4 -13
- package/plugins/NetworkErrorLinkPlugin/createErrorOverlay.js.map +1 -1
- package/plugins/NetworkErrorLinkPlugin.d.ts +4 -1
- package/plugins/NetworkErrorLinkPlugin.js +47 -7
- package/plugins/NetworkErrorLinkPlugin.js.map +1 -1
- package/plugins/OmitTypenameLinkPlugin.d.ts +1 -1
- package/plugins/OmitTypenameLinkPlugin.js +1 -1
- package/plugins/OmitTypenameLinkPlugin.js.map +1 -1
- package/plugins/TenantHeaderLinkPlugin.d.ts +2 -2
- package/plugins/TenantHeaderLinkPlugin.js +2 -4
- package/plugins/TenantHeaderLinkPlugin.js.map +1 -1
- package/plugins/components/Image.d.ts +6 -0
- package/plugins/components/Image.js +19 -0
- package/plugins/components/Image.js.map +1 -0
- package/plugins/image.d.ts +1 -1
- package/plugins/image.js +2 -2
- package/plugins/image.js.map +1 -1
- package/plugins/index.d.ts +3 -3
- package/plugins/index.js +1 -1
- package/plugins/index.js.map +1 -1
- package/presentation/localStorage/index.d.ts +3 -0
- package/presentation/localStorage/index.js +5 -0
- package/presentation/localStorage/index.js.map +1 -0
- package/presentation/localStorage/useLocalStorage.d.ts +6 -0
- package/presentation/localStorage/useLocalStorage.js +21 -0
- package/presentation/localStorage/useLocalStorage.js.map +1 -0
- package/presentation/localStorage/useLocalStorageValue.d.ts +1 -0
- package/presentation/localStorage/useLocalStorageValue.js +20 -0
- package/presentation/localStorage/useLocalStorageValue.js.map +1 -0
- package/presentation/localStorage/useLocalStorageValues.d.ts +5 -0
- package/presentation/localStorage/useLocalStorageValues.js +39 -0
- package/presentation/localStorage/useLocalStorageValues.js.map +1 -0
- package/presentation/router/RouteElementRegistry.d.ts +14 -0
- package/presentation/router/RouteElementRegistry.js +32 -0
- package/presentation/router/RouteElementRegistry.js.map +1 -0
- package/presentation/router/abstractions.d.ts +13 -0
- package/presentation/router/abstractions.js +4 -0
- package/presentation/router/abstractions.js.map +1 -0
- package/presentation/router/components/Redirect.d.ts +14 -0
- package/presentation/router/components/Redirect.js +15 -0
- package/presentation/router/components/Redirect.js.map +1 -0
- package/presentation/router/components/RouteContent.d.ts +2 -0
- package/presentation/router/components/RouteContent.js +17 -0
- package/presentation/router/components/RouteContent.js.map +1 -0
- package/presentation/router/components/RouteLink.d.ts +50 -0
- package/presentation/router/components/RouteLink.js +22 -0
- package/presentation/router/components/RouteLink.js.map +1 -0
- package/presentation/router/components/SimpleLink.d.ts +44 -0
- package/presentation/router/components/SimpleLink.js +30 -0
- package/presentation/router/components/SimpleLink.js.map +1 -0
- package/presentation/router/hooks/useRoute.d.ts +6 -0
- package/presentation/router/hooks/useRoute.js +30 -0
- package/presentation/router/hooks/useRoute.js.map +1 -0
- package/presentation/router/hooks/useRouter.d.ts +7 -0
- package/presentation/router/hooks/useRouter.js +26 -0
- package/presentation/router/hooks/useRouter.js.map +1 -0
- package/presentation/router/index.d.ts +4 -0
- package/presentation/router/index.js +5 -0
- package/presentation/router/index.js.map +1 -0
- package/presentation/router/types.d.ts +5 -0
- package/presentation/router/types.js +3 -0
- package/presentation/router/types.js.map +1 -0
- package/react-butterfiles/Files.js +3 -3
- package/react-butterfiles/Files.js.map +1 -1
- package/react-butterfiles/file.todo +1 -0
- package/react-butterfiles/index.d.ts +1 -1
- package/react-butterfiles/index.js +1 -1
- package/react-butterfiles/index.js.map +1 -1
- package/router.d.ts +5 -0
- package/router.js +8 -0
- package/router.js.map +1 -0
- package/shared/di/DiContainerProvider.d.ts +8 -0
- package/shared/di/DiContainerProvider.js +17 -0
- package/shared/di/DiContainerProvider.js.map +1 -0
- package/shared/di/createFeature.d.ts +11 -0
- package/shared/di/createFeature.js +11 -0
- package/shared/di/createFeature.js.map +1 -0
- package/shared/di/useFeature.d.ts +2 -0
- package/shared/di/useFeature.js +18 -0
- package/shared/di/useFeature.js.map +1 -0
- package/types.d.ts +7 -4
- package/types.js +1 -12
- package/types.js.map +1 -1
- package/utils/index.d.ts +2 -10
- package/utils/index.js +2 -10
- package/utils/index.js.map +1 -1
- package/utils/legacyPluginToReactComponent.js +1 -1
- package/utils/legacyPluginToReactComponent.js.map +1 -1
- package/components/Routes.d.ts +0 -2
- package/components/Routes.js +0 -36
- package/components/Routes.js.map +0 -1
- package/components/View.d.ts +0 -8
- package/components/View.js +0 -19
- package/components/View.js.map +0 -1
- package/core/DebounceRender.d.ts +0 -12
- package/core/DebounceRender.js +0 -31
- package/core/DebounceRender.js.map +0 -1
- package/core/Routes.d.ts +0 -6
- package/core/Routes.js +0 -34
- package/core/Routes.js.map +0 -1
- package/hooks/useDataList/utils/redirectToRouteWithQueryParams.d.ts +0 -14
- package/hooks/useDataList/utils/redirectToRouteWithQueryParams.js +0 -26
- package/hooks/useDataList/utils/redirectToRouteWithQueryParams.js.map +0 -1
- package/hooks/useDataList/utils/types.d.ts +0 -40
- package/hooks/useDataList/utils/types.js.map +0 -1
- package/plugins/LocaleHeaderLinkPlugin.d.ts +0 -10
- package/plugins/LocaleHeaderLinkPlugin.js +0 -32
- package/plugins/LocaleHeaderLinkPlugin.js.map +0 -1
- package/plugins/RoutePlugin.d.ts +0 -12
- package/plugins/RoutePlugin.js +0 -16
- package/plugins/RoutePlugin.js.map +0 -1
- package/plugins/ViewPlugin.d.ts +0 -14
- package/plugins/ViewPlugin.js +0 -19
- package/plugins/ViewPlugin.js.map +0 -1
- package/utils/getApiUrl.d.ts +0 -1
- package/utils/getApiUrl.js +0 -5
- package/utils/getApiUrl.js.map +0 -1
- package/utils/getGqlApiUrl.d.ts +0 -1
- package/utils/getGqlApiUrl.js +0 -6
- package/utils/getGqlApiUrl.js.map +0 -1
- package/utils/getHeadlessCmsGqlApiUrl.d.ts +0 -5
- package/utils/getHeadlessCmsGqlApiUrl.js +0 -12
- package/utils/getHeadlessCmsGqlApiUrl.js.map +0 -1
- package/utils/getLocaleCode.d.ts +0 -6
- package/utils/getLocaleCode.js +0 -33
- package/utils/getLocaleCode.js.map +0 -1
- package/utils/getPrerenderId.d.ts +0 -6
- package/utils/getPrerenderId.js +0 -5
- package/utils/getPrerenderId.js.map +0 -1
- package/utils/getTenantId.d.ts +0 -6
- package/utils/getTenantId.js +0 -45
- package/utils/getTenantId.js.map +0 -1
- package/utils/isLocalhost.d.ts +0 -1
- package/utils/isLocalhost.js +0 -7
- package/utils/isLocalhost.js.map +0 -1
- package/utils/isPrerendering.d.ts +0 -1
- package/utils/isPrerendering.js +0 -5
- package/utils/isPrerendering.js.map +0 -1
- /package/{hooks/useDataList/utils → features/graphqlClient}/types.js +0 -0
|
@@ -1,10 +1,7 @@
|
|
|
1
|
-
import { useDataList } from "../useDataList";
|
|
2
|
-
import debounce from "lodash/debounce";
|
|
1
|
+
import { useDataList } from "../useDataList/index.js";
|
|
2
|
+
import debounce from "lodash/debounce.js";
|
|
3
3
|
export const useAutocomplete = props => {
|
|
4
|
-
const dataList = useDataList(
|
|
5
|
-
useRouter: false,
|
|
6
|
-
...props
|
|
7
|
-
});
|
|
4
|
+
const dataList = useDataList(props);
|
|
8
5
|
return {
|
|
9
6
|
options: dataList.data || [],
|
|
10
7
|
onInput: debounce(query => {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["useDataList","debounce","useAutocomplete","props","dataList","
|
|
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 +1 @@
|
|
|
1
|
-
{"version":3,"names":["searchDataByKey","response"],"sources":["getData.ts"],"sourcesContent":["import searchDataByKey from \"./searchDataByKey\";\n\nexport default (response: Record<string, string>) => searchDataByKey(\"data\", response);\n"],"mappings":"AAAA,OAAOA,eAAe;AAEtB,eAAgBC,QAAgC,IAAKD,eAAe,CAAC,MAAM,EAAEC,QAAQ,CAAC","ignoreList":[]}
|
|
1
|
+
{"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 +1 @@
|
|
|
1
|
-
{"version":3,"names":["searchDataByKey","response"],"sources":["getError.ts"],"sourcesContent":["import searchDataByKey from \"./searchDataByKey\";\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
|
+
{"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 +1 @@
|
|
|
1
|
-
{"version":3,"names":["searchDataByKey","response"],"sources":["getMeta.ts"],"sourcesContent":["import searchDataByKey from \"./searchDataByKey\";\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
|
+
{"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,5 +1,5 @@
|
|
|
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";
|
|
4
4
|
|
|
5
5
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["default","getData","getError","getMeta"],"sources":["index.ts"],"sourcesContent":["export { default as getData } from \"./getData\";\nexport { default as getError } from \"./getError\";\nexport { default as getMeta } from \"./getMeta\";\n"],"mappings":"AAAA,SAASA,OAAO,IAAIC,OAAO;AAC3B,SAASD,OAAO,IAAIE,QAAQ;AAC5B,SAASF,OAAO,IAAIG,OAAO","ignoreList":[]}
|
|
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 +1 @@
|
|
|
1
|
-
export { useDataList } from "./useDataList";
|
|
1
|
+
export { useDataList } from "./useDataList.js";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["useDataList"],"sources":["index.ts"],"sourcesContent":["export { useDataList } from \"./useDataList\";\n"],"mappings":"AAAA,SAASA,WAAW","ignoreList":[]}
|
|
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
1
|
import type { DocumentNode } from "graphql";
|
|
2
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,22 +1,11 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { useCallback, useEffect, useRef, useState } from "react";
|
|
2
2
|
import { useQuery } from "@apollo/react-hooks";
|
|
3
|
-
import
|
|
4
|
-
import
|
|
5
|
-
import
|
|
6
|
-
import {
|
|
7
|
-
import { getData, getError, getMeta } from "./functions";
|
|
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";
|
|
8
7
|
const useDataList = params => {
|
|
9
8
|
const [multiSelectedItems, multiSelect] = useState([]);
|
|
10
|
-
let history = null;
|
|
11
|
-
/**
|
|
12
|
-
* TODO: figure out the location type.
|
|
13
|
-
*/
|
|
14
|
-
let location = null;
|
|
15
|
-
const routerHook = useRouter();
|
|
16
|
-
if (params.useRouter !== false) {
|
|
17
|
-
history = routerHook.history;
|
|
18
|
-
location = routerHook.location;
|
|
19
|
-
}
|
|
20
9
|
const getQueryOptions = useCallback(() => {
|
|
21
10
|
let variables = params.variables;
|
|
22
11
|
if (typeof variables === "function") {
|
|
@@ -26,7 +15,7 @@ const useDataList = params => {
|
|
|
26
15
|
client: params.client,
|
|
27
16
|
variables: {
|
|
28
17
|
...variables,
|
|
29
|
-
...prepareLoadListParams(
|
|
18
|
+
...prepareLoadListParams()
|
|
30
19
|
}
|
|
31
20
|
};
|
|
32
21
|
}, []);
|
|
@@ -47,12 +36,6 @@ const useDataList = params => {
|
|
|
47
36
|
queryData.refetch(dataListProps.__loadParams);
|
|
48
37
|
return;
|
|
49
38
|
}
|
|
50
|
-
|
|
51
|
-
// if (history) {
|
|
52
|
-
// redirectToRouteWithQueryParams(params, { history, location });
|
|
53
|
-
// return;
|
|
54
|
-
// }
|
|
55
|
-
|
|
56
39
|
queryData.refetch(params);
|
|
57
40
|
},
|
|
58
41
|
setPerPage(perPage) {
|
|
@@ -132,9 +115,6 @@ const useDataList = params => {
|
|
|
132
115
|
select(item) {
|
|
133
116
|
const query = new URLSearchParams(location.search);
|
|
134
117
|
query.set("id", item.id);
|
|
135
|
-
history.push({
|
|
136
|
-
search: query.toString()
|
|
137
|
-
});
|
|
138
118
|
},
|
|
139
119
|
isMultiSelected(item) {
|
|
140
120
|
if (!Array.isArray(multiSelectedItems)) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["useState","useEffect","useRef","useCallback","useQuery","useRouter","get","isEqual","prepareLoadListParams","getData","getError","getMeta","useDataList","params","multiSelectedItems","multiSelect","history","location","routerHook","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","id","select","set","toString","isMultiSelected","isNoneMultiSelected","length","getMultiSelected","multiSelectAll","isAllMultiSelected","prev","current"],"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 type { DocumentNode } from \"graphql\";\nimport type { 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,SAASA,QAAQ,EAAEC,SAAS,EAAEC,MAAM,EAAEC,WAAW,QAAQ,OAAO;AAChE,SAASC,QAAQ,QAAQ,qBAAqB;AAC9C,SAASC,SAAS,QAAQ,sBAAsB;AAChD,OAAOC,GAAG,MAAM,YAAY;AAC5B,OAAOC,OAAO,MAAM,gBAAgB;AACpC,SAASC,qBAAqB;AAC9B,SAASC,OAAO,EAAEC,QAAQ,EAAEC,OAAO;AAuCnC,MAAMC,WAAW,GAAIC,MAAyB,IAAK;EAC/C,MAAM,CAACC,kBAAkB,EAAEC,WAAW,CAAC,GAAGf,QAAQ,CAAW,EAAE,CAAC;EAEhE,IAAIgB,OAAO,GAAG,IAAI;EAClB;AACJ;AACA;EACI,IAAIC,QAAa,GAAG,IAAI;EACxB,MAAMC,UAAU,GAAGb,SAAS,CAAC,CAAC;EAE9B,IAAIQ,MAAM,CAACR,SAAS,KAAK,KAAK,EAAE;IAC5BW,OAAO,GAAGE,UAAU,CAACF,OAAO;IAC5BC,QAAQ,GAAGC,UAAU,CAACD,QAAQ;EAClC;EAEA,MAAME,eAAe,GAAGhB,WAAW,CAAC,MAAM;IACtC,IAAIiB,SAAS,GAAGP,MAAM,CAACO,SAAS;IAChC,IAAI,OAAOA,SAAS,KAAK,UAAU,EAAE;MACjCA,SAAS,GAAGA,SAAS,CAACP,MAAM,CAAC;IACjC;IAEA,OAAO;MACHQ,MAAM,EAAER,MAAM,CAACQ,MAAM;MACrBD,SAAS,EAAE;QACP,GAAGA,SAAS;QACZ,GAAGZ,qBAAqB,CAACS,QAAQ;MACrC;IACJ,CAAC;EACL,CAAC,EAAE,EAAE,CAAC;EAEN,M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,mBAAmBA,CAAA,EAAG;MAClB,OAAOvD,kBAAkB,CAACwD,MAAM,KAAK,CAAC;IAC1C,CAAC;IACDC,gBAAgBA,CAAA,EAAG;MACf,OAAOzD,kBAAkB;IAC7B,CAAC;IACD0D,cAAcA,CAACpB,KAAc,EAAQ;MACjC,MAAM;QAAE1B;MAAK,CAAC,GAAGD,aAAa;MAC9B,IAAI4B,KAAK,CAACC,OAAO,CAAC5B,IAAI,CAAC,EAAE;QACrBD,aAAa,CAACV,WAAW,CAACW,IAAI,EAAE0B,KAAK,CAAC;MAC1C,CAAC,MAAM;QACH3B,aAAa,CAACV,WAAW,CAAC,EAAE,EAAEqC,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,IAAIZ,kBAAkB,CAACwD,MAAM,KAAK5C,IAAI,CAAC4C,MAAM;IAC3E,CAAC;IAEDrC,YAAY,EAAEzB,qBAAqB,CAACS,QAAQ;EAChD,CAAC;EAEDhB,SAAS,CAAC,MAAM;IACZ,MAAMY,MAAM,GAAG;MACX6D,IAAI,EAAElD,iBAAiB,CAACmD,OAAO;MAC/BA,OAAO,EAAElD,aAAa,CAACQ;IAC3B,CAAC;IAED,IAAI,CAAC1B,OAAO,CAACM,MAAM,CAAC6D,IAAI,EAAE7D,MAAM,CAAC8D,OAAO,CAAC,EAAE;MACvClD,aAAa,CAACK,IAAI,CAAC,CAAC;IACxB;IAEAN,iBAAiB,CAACmD,OAAO,GAAG9D,MAAM,CAAC8D,OAAO;EAC9C,CAAC,CAAC;EAEF,OAAOlD,aAAa;AACxB,CAAC;AAED,SAASb,WAAW","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,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5C,CAAC;IACDY,mBAAmBA,CAAA,EAAG;MAClB,OAAOpD,kBAAkB,CAACqD,MAAM,KAAK,CAAC;IAC1C,CAAC;IACDC,gBAAgBA,CAAA,EAAG;MACf,OAAOtD,kBAAkB;IAC7B,CAAC;IACDuD,cAAcA,CAACpB,KAAc,EAAQ;MACjC,MAAM;QAAE1B;MAAK,CAAC,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,4 +1,3 @@
|
|
|
1
|
-
export { default as prepareLoadListParams } from "./prepareLoadListParams";
|
|
2
|
-
export { default as redirectToRouteWithQueryParams } from "./redirectToRouteWithQueryParams";
|
|
1
|
+
export { default as prepareLoadListParams } from "./prepareLoadListParams.js";
|
|
3
2
|
|
|
4
3
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["default","prepareLoadListParams"
|
|
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":[]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["keys","location","params","query","URLSearchParams","search","after","get","before","limit","parseInt","forEach","key","value","JSON","parse"
|
|
1
|
+
{"version":3,"names":["keys","location","params","query","URLSearchParams","search","after","get","before","limit","parseInt","forEach","key","value","JSON","parse"],"sources":["prepareLoadListParams.ts"],"sourcesContent":["interface Params {\n after?: string;\n before?: string;\n limit?: number;\n sort?: string;\n where?: Record<string, any>;\n search?: string;\n}\n\nconst keys: (keyof Params)[] = [\"sort\", \"where\", \"search\"];\n\nexport default (location?: Location): Params => {\n const params: Params = {};\n if (!location) {\n return params;\n }\n\n const query = new URLSearchParams(location.search);\n\n const after = query.get(\"after\");\n const before = query.get(\"before\");\n const limit = query.get(\"limit\");\n\n if (after) {\n params.after = after;\n }\n\n if (before) {\n params.before = before;\n }\n\n if (limit) {\n params.limit = parseInt(limit);\n }\n\n keys.forEach(key => {\n const value = query.get(key);\n if (typeof value !== \"string\") {\n return;\n }\n try {\n params[key] = JSON.parse(value);\n } catch {\n /**\n * If we can't parse the value, it means it's a string.\n */\n // @ts-expect-error\n params[key] = value;\n }\n });\n return params;\n};\n"],"mappings":"AASA,MAAMA,IAAsB,GAAG,CAAC,MAAM,EAAE,OAAO,EAAE,QAAQ,CAAC;AAE1D,eAAgBC,QAAmB,IAAa;EAC5C,MAAMC,MAAc,GAAG,CAAC,CAAC;EACzB,IAAI,CAACD,QAAQ,EAAE;IACX,OAAOC,MAAM;EACjB;EAEA,MAAMC,KAAK,GAAG,IAAIC,eAAe,CAACH,QAAQ,CAACI,MAAM,CAAC;EAElD,MAAMC,KAAK,GAAGH,KAAK,CAACI,GAAG,CAAC,OAAO,CAAC;EAChC,MAAMC,MAAM,GAAGL,KAAK,CAACI,GAAG,CAAC,QAAQ,CAAC;EAClC,MAAME,KAAK,GAAGN,KAAK,CAACI,GAAG,CAAC,OAAO,CAAC;EAEhC,IAAID,KAAK,EAAE;IACPJ,MAAM,CAACI,KAAK,GAAGA,KAAK;EACxB;EAEA,IAAIE,MAAM,EAAE;IACRN,MAAM,CAACM,MAAM,GAAGA,MAAM;EAC1B;EAEA,IAAIC,KAAK,EAAE;IACPP,MAAM,CAACO,KAAK,GAAGC,QAAQ,CAACD,KAAK,CAAC;EAClC;EAEAT,IAAI,CAACW,OAAO,CAACC,GAAG,IAAI;IAChB,MAAMC,KAAK,GAAGV,KAAK,CAACI,GAAG,CAACK,GAAG,CAAC;IAC5B,IAAI,OAAOC,KAAK,KAAK,QAAQ,EAAE;MAC3B;IACJ;IACA,IAAI;MACAX,MAAM,CAACU,GAAG,CAAC,GAAGE,IAAI,CAACC,KAAK,CAACF,KAAK,CAAC;IACnC,CAAC,CAAC,MAAM;MACJ;AACZ;AACA;MACY;MACAX,MAAM,CAACU,GAAG,CAAC,GAAGC,KAAK;IACvB;EACJ,CAAC,CAAC;EACF,OAAOX,MAAM;AACjB,CAAC","ignoreList":[]}
|
package/hooks/useHandlers.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["useRef","useEffect","useHandlers","props","factories","propsRef","handlersRef","names","Object","keys","reduce","handlers","name","args","handler","current"],"sources":["useHandlers.ts"],"sourcesContent":["import { useRef, useEffect } from \"react\";\n\ntype HandlerProps = { [key: string]: any };\ntype HandlerFactories = { [key: string]: (props: HandlerProps) => (...params: any[]) => any };\ntype Handlers = {\n [K in keyof HandlerFactories]: (...params: any[]) => any;\n};\n\nexport function useHandlers<H = Handlers>(props: HandlerProps, factories: HandlerFactories) {\n const propsRef = useRef(props);\n\n const handlersRef = useRef(\n (() => {\n const names = Object.keys(factories);\n return names.reduce((handlers, name) => {\n
|
|
1
|
+
{"version":3,"names":["useRef","useEffect","useHandlers","props","factories","propsRef","handlersRef","names","Object","keys","reduce","handlers","name","args","handler","current"],"sources":["useHandlers.ts"],"sourcesContent":["import { useRef, useEffect } from \"react\";\n\ntype HandlerProps = { [key: string]: any };\ntype HandlerFactories = { [key: string]: (props: HandlerProps) => (...params: any[]) => any };\ntype Handlers = {\n [K in keyof HandlerFactories]: (...params: any[]) => any;\n};\n\nexport function useHandlers<H = Handlers>(props: HandlerProps, factories: HandlerFactories) {\n const propsRef = useRef(props);\n\n const handlersRef = useRef(\n (() => {\n const names = Object.keys(factories);\n return names.reduce(\n (handlers, name) => {\n /**\n * TODO: figure out args types\n */\n handlers[name] = (...args: any) => {\n const handler = factories[name](propsRef.current);\n return handler(...args);\n };\n return handlers;\n },\n {} as Record<string, any>\n );\n })()\n );\n\n useEffect(() => {\n propsRef.current = props;\n });\n\n return handlersRef.current as H;\n}\n"],"mappings":"AAAA,SAASA,MAAM,EAAEC,SAAS,QAAQ,OAAO;AAQzC,OAAO,SAASC,WAAWA,CAAeC,KAAmB,EAAEC,SAA2B,EAAE;EACxF,MAAMC,QAAQ,GAAGL,MAAM,CAACG,KAAK,CAAC;EAE9B,MAAMG,WAAW,GAAGN,MAAM,CACtB,CAAC,MAAM;IACH,MAAMO,KAAK,GAAGC,MAAM,CAACC,IAAI,CAACL,SAAS,CAAC;IACpC,OAAOG,KAAK,CAACG,MAAM,CACf,CAACC,QAAQ,EAAEC,IAAI,KAAK;MAChB;AACpB;AACA;MACoBD,QAAQ,CAACC,IAAI,CAAC,GAAG,CAAC,GAAGC,IAAS,KAAK;QAC/B,MAAMC,OAAO,GAAGV,SAAS,CAACQ,IAAI,CAAC,CAACP,QAAQ,CAACU,OAAO,CAAC;QACjD,OAAOD,OAAO,CAAC,GAAGD,IAAI,CAAC;MAC3B,CAAC;MACD,OAAOF,QAAQ;IACnB,CAAC,EACD,CAAC,CACL,CAAC;EACL,CAAC,EAAE,CACP,CAAC;EAEDV,SAAS,CAAC,MAAM;IACZI,QAAQ,CAACU,OAAO,GAAGZ,KAAK;EAC5B,CAAC,CAAC;EAEF,OAAOG,WAAW,CAACS,OAAO;AAC9B","ignoreList":[]}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { type Plugin } from "@webiny/plugins/types";
|
|
1
|
+
import { type Plugin } from "@webiny/plugins/types.js";
|
|
2
2
|
export declare function useRegisterLegacyPlugin<TPlugin extends Plugin>(plugin: TPlugin): void;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["useRef","plugins","useRegisterLegacyPlugin","plugin","pluginRegistered","current","register"],"sources":["useRegisterLegacyPlugin.tsx"],"sourcesContent":["import { useRef } from \"react\";\nimport { plugins } from \"@webiny/plugins\";\nimport { type Plugin } from \"@webiny/plugins/types\";\n\nexport function useRegisterLegacyPlugin<TPlugin extends Plugin>(plugin: TPlugin) {\n const pluginRegistered = useRef<boolean>(false);\n if (!pluginRegistered.current) {\n pluginRegistered.current = true;\n plugins.register(plugin);\n }\n}\n"],"mappings":"AAAA,SAASA,MAAM,QAAQ,OAAO;AAC9B,SAASC,OAAO,QAAQ,iBAAiB;AAGzC,OAAO,SAASC,uBAAuBA,CAAyBC,MAAe,EAAE;EAC7E,MAAMC,gBAAgB,GAAGJ,MAAM,CAAU,KAAK,CAAC;EAC/C,IAAI,CAACI,gBAAgB,CAACC,OAAO,EAAE;IAC3BD,gBAAgB,CAACC,OAAO,GAAG,IAAI;IAC/BJ,OAAO,CAACK,QAAQ,CAACH,MAAM,CAAC;EAC5B;AACJ","ignoreList":[]}
|
|
1
|
+
{"version":3,"names":["useRef","plugins","useRegisterLegacyPlugin","plugin","pluginRegistered","current","register"],"sources":["useRegisterLegacyPlugin.tsx"],"sourcesContent":["import { useRef } from \"react\";\nimport { plugins } from \"@webiny/plugins\";\nimport { type Plugin } from \"@webiny/plugins/types.js\";\n\nexport function useRegisterLegacyPlugin<TPlugin extends Plugin>(plugin: TPlugin) {\n const pluginRegistered = useRef<boolean>(false);\n if (!pluginRegistered.current) {\n pluginRegistered.current = true;\n plugins.register(plugin);\n }\n}\n"],"mappings":"AAAA,SAASA,MAAM,QAAQ,OAAO;AAC9B,SAASC,OAAO,QAAQ,iBAAiB;AAGzC,OAAO,SAASC,uBAAuBA,CAAyBC,MAAe,EAAE;EAC7E,MAAMC,gBAAgB,GAAGJ,MAAM,CAAU,KAAK,CAAC;EAC/C,IAAI,CAACI,gBAAgB,CAACC,OAAO,EAAE;IAC3BD,gBAAgB,CAACC,OAAO,GAAG,IAAI;IAC/BJ,OAAO,CAACK,QAAQ,CAACH,MAAM,CAAC;EAC5B;AACJ","ignoreList":[]}
|
package/hooks/useUi.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import type { UiContextValue } from "../contexts/Ui";
|
|
1
|
+
import type { UiContextValue } from "../contexts/Ui/index.js";
|
|
2
2
|
export declare const useUi: () => UiContextValue;
|
package/hooks/useUi.js
CHANGED
package/hooks/useUi.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["useContext","UiContext","useUi"],"sources":["useUi.ts"],"sourcesContent":["import { useContext } from \"react\";\nimport type { UiContextValue } from \"~/contexts/Ui\";\nimport { UiContext } from \"~/contexts/Ui\";\n\nexport const useUi = () => {\n return useContext(UiContext) as UiContextValue;\n};\n"],"mappings":"AAAA,SAASA,UAAU,QAAQ,OAAO;AAElC,SAASC,SAAS;AAElB,OAAO,MAAMC,KAAK,GAAGA,CAAA,KAAM;EACvB,OAAOF,UAAU,CAACC,SAAS,CAAC;AAChC,CAAC","ignoreList":[]}
|
|
1
|
+
{"version":3,"names":["useContext","UiContext","useUi"],"sources":["useUi.ts"],"sourcesContent":["import { useContext } from \"react\";\nimport type { UiContextValue } from \"~/contexts/Ui/index.js\";\nimport { UiContext } from \"~/contexts/Ui/index.js\";\n\nexport const useUi = () => {\n return useContext(UiContext) as UiContextValue;\n};\n"],"mappings":"AAAA,SAASA,UAAU,QAAQ,OAAO;AAElC,SAASC,SAAS;AAElB,OAAO,MAAMC,KAAK,GAAGA,CAAA,KAAM;EACvB,OAAOF,UAAU,CAACC,SAAS,CAAC;AAChC,CAAC","ignoreList":[]}
|
package/i18n/index.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export { default as i18n } from "./i18n";
|
|
1
|
+
export { default as i18n } from "./i18n.js";
|
package/i18n/index.js
CHANGED
package/i18n/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["default","i18n"],"sources":["index.ts"],"sourcesContent":["export { default as i18n } from \"./i18n\";\n"],"mappings":"AAAA,SAASA,OAAO,IAAIC,IAAI","ignoreList":[]}
|
|
1
|
+
{"version":3,"names":["default","i18n"],"sources":["index.ts"],"sourcesContent":["export { default as i18n } from \"./i18n.js\";\n"],"mappings":"AAAA,SAASA,OAAO,IAAIC,IAAI","ignoreList":[]}
|
package/index.d.ts
CHANGED
|
@@ -1,17 +1,24 @@
|
|
|
1
|
-
export { AddQuerySelectionPlugin } from "./plugins/AddQuerySelectionPlugin";
|
|
2
|
-
export { ApolloLinkPlugin } from "./plugins/ApolloLinkPlugin";
|
|
3
|
-
export {
|
|
4
|
-
export { ApolloCacheObjectIdPlugin, type ApolloCacheObject } from "./plugins/ApolloCacheObjectIdPlugin";
|
|
1
|
+
export { AddQuerySelectionPlugin } from "./plugins/AddQuerySelectionPlugin.js";
|
|
2
|
+
export { ApolloLinkPlugin } from "./plugins/ApolloLinkPlugin.js";
|
|
3
|
+
export { ApolloCacheObjectIdPlugin, type ApolloCacheObject } from "./plugins/ApolloCacheObjectIdPlugin.js";
|
|
5
4
|
export * from "@webiny/react-composition";
|
|
6
5
|
export type { HigherOrderComponent, ComposeProps, ComposableFC } from "@webiny/react-composition";
|
|
7
|
-
export * from "./App";
|
|
8
|
-
export * from "./AppContainer";
|
|
9
|
-
export type { AppProps } from "./App";
|
|
10
|
-
export * from "./core/Plugins";
|
|
11
|
-
export * from "./core/Plugin";
|
|
12
|
-
export * from "./core/Provider";
|
|
13
|
-
export * from "./core/
|
|
14
|
-
export * from "./core/
|
|
15
|
-
export * from "./
|
|
16
|
-
export * from "./
|
|
17
|
-
export
|
|
6
|
+
export * from "./App.js";
|
|
7
|
+
export * from "./AppContainer.js";
|
|
8
|
+
export type { AppProps } from "./App.js";
|
|
9
|
+
export * from "./core/Plugins.js";
|
|
10
|
+
export * from "./core/Plugin.js";
|
|
11
|
+
export * from "./core/Provider.js";
|
|
12
|
+
export * from "./core/createProvider.js";
|
|
13
|
+
export * from "./core/createProviderPlugin.js";
|
|
14
|
+
export * from "./renderApp.js";
|
|
15
|
+
export * from "./utils/createGenericContext.js";
|
|
16
|
+
export { useContainer, DiContainerProvider } from "./shared/di/DiContainerProvider.js";
|
|
17
|
+
export { useFeature } from "./shared/di/useFeature.js";
|
|
18
|
+
export { createFeature } from "./shared/di/createFeature.js";
|
|
19
|
+
export { Route } from "./features/router/Route.js";
|
|
20
|
+
export { RouteLink, type RouteLinkProps } from "./presentation/router/components/RouteLink.js";
|
|
21
|
+
export { SimpleLink, type SimpleLinkProps } from "./presentation/router/components/SimpleLink.js";
|
|
22
|
+
export { useRouter, useRoute } from "./presentation/router/index.js";
|
|
23
|
+
export { useLocalStorage, useLocalStorageValue, useLocalStorageValues } from "./presentation/localStorage/index.js";
|
|
24
|
+
export * from "./helpers/InterfaceGenerator/index.js";
|
package/index.js
CHANGED
|
@@ -1,20 +1,27 @@
|
|
|
1
|
-
export { AddQuerySelectionPlugin } from "./plugins/AddQuerySelectionPlugin";
|
|
2
|
-
export { ApolloLinkPlugin } from "./plugins/ApolloLinkPlugin";
|
|
3
|
-
export {
|
|
4
|
-
export { ApolloCacheObjectIdPlugin } from "./plugins/ApolloCacheObjectIdPlugin";
|
|
1
|
+
export { AddQuerySelectionPlugin } from "./plugins/AddQuerySelectionPlugin.js";
|
|
2
|
+
export { ApolloLinkPlugin } from "./plugins/ApolloLinkPlugin.js";
|
|
3
|
+
export { ApolloCacheObjectIdPlugin } from "./plugins/ApolloCacheObjectIdPlugin.js";
|
|
5
4
|
|
|
6
5
|
// Composition - we re-export this for ease of use
|
|
7
6
|
export * from "@webiny/react-composition";
|
|
8
7
|
// App framework
|
|
9
|
-
export * from "./App";
|
|
10
|
-
export * from "./AppContainer";
|
|
11
|
-
export * from "./core/Plugins";
|
|
12
|
-
export * from "./core/Plugin";
|
|
13
|
-
export * from "./core/Provider";
|
|
14
|
-
export * from "./core/
|
|
15
|
-
export * from "./core/
|
|
16
|
-
export * from "./
|
|
17
|
-
export * from "./
|
|
18
|
-
export
|
|
8
|
+
export * from "./App.js";
|
|
9
|
+
export * from "./AppContainer.js";
|
|
10
|
+
export * from "./core/Plugins.js";
|
|
11
|
+
export * from "./core/Plugin.js";
|
|
12
|
+
export * from "./core/Provider.js";
|
|
13
|
+
export * from "./core/createProvider.js";
|
|
14
|
+
export * from "./core/createProviderPlugin.js";
|
|
15
|
+
export * from "./renderApp.js";
|
|
16
|
+
export * from "./utils/createGenericContext.js";
|
|
17
|
+
export { useContainer, DiContainerProvider } from "./shared/di/DiContainerProvider.js";
|
|
18
|
+
export { useFeature } from "./shared/di/useFeature.js";
|
|
19
|
+
export { createFeature } from "./shared/di/createFeature.js";
|
|
20
|
+
export { Route } from "./features/router/Route.js";
|
|
21
|
+
export { RouteLink } from "./presentation/router/components/RouteLink.js";
|
|
22
|
+
export { SimpleLink } from "./presentation/router/components/SimpleLink.js";
|
|
23
|
+
export { useRouter, useRoute } from "./presentation/router/index.js";
|
|
24
|
+
export { useLocalStorage, useLocalStorageValue, useLocalStorageValues } from "./presentation/localStorage/index.js";
|
|
25
|
+
export * from "./helpers/InterfaceGenerator/index.js";
|
|
19
26
|
|
|
20
27
|
//# sourceMappingURL=index.js.map
|
package/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["AddQuerySelectionPlugin","ApolloLinkPlugin","
|
|
1
|
+
{"version":3,"names":["AddQuerySelectionPlugin","ApolloLinkPlugin","ApolloCacheObjectIdPlugin","useContainer","DiContainerProvider","useFeature","createFeature","Route","RouteLink","SimpleLink","useRouter","useRoute","useLocalStorage","useLocalStorageValue","useLocalStorageValues"],"sources":["index.ts"],"sourcesContent":["export { AddQuerySelectionPlugin } from \"./plugins/AddQuerySelectionPlugin.js\";\nexport { ApolloLinkPlugin } from \"./plugins/ApolloLinkPlugin.js\";\nexport {\n ApolloCacheObjectIdPlugin,\n type ApolloCacheObject\n} from \"./plugins/ApolloCacheObjectIdPlugin.js\";\n\n// Composition - we re-export this for ease of use\nexport * from \"@webiny/react-composition\";\nexport type { HigherOrderComponent, ComposeProps, ComposableFC } from \"@webiny/react-composition\";\n\n// App framework\nexport * from \"./App.js\";\nexport * from \"./AppContainer.js\";\nexport type { AppProps } from \"./App.js\";\nexport * from \"./core/Plugins.js\";\nexport * from \"./core/Plugin.js\";\nexport * from \"./core/Provider.js\";\nexport * from \"./core/createProvider.js\";\nexport * from \"./core/createProviderPlugin.js\";\nexport * from \"./renderApp.js\";\nexport * from \"./utils/createGenericContext.js\";\nexport { useContainer, DiContainerProvider } from \"./shared/di/DiContainerProvider.js\";\nexport { useFeature } from \"./shared/di/useFeature.js\";\nexport { createFeature } from \"./shared/di/createFeature.js\";\n\nexport { Route } from \"./features/router/Route.js\";\nexport { RouteLink, type RouteLinkProps } from \"./presentation/router/components/RouteLink.js\";\nexport { SimpleLink, type SimpleLinkProps } from \"./presentation/router/components/SimpleLink.js\";\n\nexport { useRouter, useRoute } from \"./presentation/router/index.js\";\nexport {\n useLocalStorage,\n useLocalStorageValue,\n useLocalStorageValues\n} from \"./presentation/localStorage/index.js\";\n\nexport * from \"./helpers/InterfaceGenerator/index.js\";\n"],"mappings":"AAAA,SAASA,uBAAuB;AAChC,SAASC,gBAAgB;AACzB,SACIC,yBAAyB;;AAI7B;AACA,cAAc,2BAA2B;AAGzC;AACA;AACA;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,SAASC,YAAY,EAAEC,mBAAmB;AAC1C,SAASC,UAAU;AACnB,SAASC,aAAa;AAEtB,SAASC,KAAK;AACd,SAASC,SAAS;AAClB,SAASC,UAAU;AAEnB,SAASC,SAAS,EAAEC,QAAQ;AAC5B,SACIC,eAAe,EACfC,oBAAoB,EACpBC,qBAAqB;AAGzB","ignoreList":[]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@webiny/app",
|
|
3
|
-
"version": "0.0.0-unstable.
|
|
3
|
+
"version": "0.0.0-unstable.f6dc066313",
|
|
4
|
+
"type": "module",
|
|
4
5
|
"main": "index.js",
|
|
5
6
|
"repository": {
|
|
6
7
|
"type": "git",
|
|
@@ -17,13 +18,13 @@
|
|
|
17
18
|
"@apollo/react-hooks": "3.1.5",
|
|
18
19
|
"@emotion/styled": "11.10.6",
|
|
19
20
|
"@types/react": "18.2.79",
|
|
20
|
-
"@webiny/
|
|
21
|
-
"@webiny/
|
|
22
|
-
"@webiny/
|
|
23
|
-
"@webiny/react
|
|
24
|
-
"@webiny/
|
|
25
|
-
"@webiny/react-
|
|
26
|
-
"@webiny/
|
|
21
|
+
"@webiny/di": "0.2.3",
|
|
22
|
+
"@webiny/feature": "0.0.0-unstable.f6dc066313",
|
|
23
|
+
"@webiny/i18n": "0.0.0-unstable.f6dc066313",
|
|
24
|
+
"@webiny/i18n-react": "0.0.0-unstable.f6dc066313",
|
|
25
|
+
"@webiny/plugins": "0.0.0-unstable.f6dc066313",
|
|
26
|
+
"@webiny/react-composition": "0.0.0-unstable.f6dc066313",
|
|
27
|
+
"@webiny/react-properties": "0.0.0-unstable.f6dc066313",
|
|
27
28
|
"apollo-cache": "1.3.5",
|
|
28
29
|
"apollo-cache-inmemory": "1.6.6",
|
|
29
30
|
"apollo-client": "2.6.10",
|
|
@@ -34,31 +35,32 @@
|
|
|
34
35
|
"apollo-utilities": "1.3.4",
|
|
35
36
|
"boolean": "3.2.0",
|
|
36
37
|
"bytes": "3.1.2",
|
|
37
|
-
"graphql": "
|
|
38
|
+
"graphql": "16.13.0",
|
|
39
|
+
"history": "5.3.0",
|
|
38
40
|
"invariant": "2.2.4",
|
|
39
|
-
"lodash": "4.17.
|
|
40
|
-
"minimatch": "
|
|
41
|
-
"
|
|
41
|
+
"lodash": "4.17.23",
|
|
42
|
+
"minimatch": "10.2.4",
|
|
43
|
+
"mobx": "6.15.0",
|
|
44
|
+
"nanoid": "5.1.6",
|
|
42
45
|
"react": "18.2.0",
|
|
43
46
|
"react-dom": "18.2.0",
|
|
44
47
|
"ts-invariant": "0.10.3",
|
|
45
|
-
"warning": "4.0.3"
|
|
48
|
+
"warning": "4.0.3",
|
|
49
|
+
"zod": "3.25.76"
|
|
46
50
|
},
|
|
47
51
|
"devDependencies": {
|
|
48
|
-
"@types/lodash": "4.17.
|
|
49
|
-
"@types/warning": "3.0.
|
|
50
|
-
"@webiny/
|
|
51
|
-
"rimraf": "6.
|
|
52
|
-
"
|
|
52
|
+
"@types/lodash": "4.17.24",
|
|
53
|
+
"@types/warning": "3.0.3",
|
|
54
|
+
"@webiny/build-tools": "0.0.0-unstable.f6dc066313",
|
|
55
|
+
"rimraf": "6.1.3",
|
|
56
|
+
"type-fest": "5.4.4",
|
|
57
|
+
"typescript": "5.9.3",
|
|
58
|
+
"vitest": "4.0.18"
|
|
53
59
|
},
|
|
54
60
|
"publishConfig": {
|
|
55
61
|
"access": "public",
|
|
56
62
|
"directory": "dist"
|
|
57
63
|
},
|
|
58
|
-
"scripts": {
|
|
59
|
-
"build": "node ../cli/bin.js run build",
|
|
60
|
-
"watch": "node ../cli/bin.js run watch"
|
|
61
|
-
},
|
|
62
64
|
"adio": {
|
|
63
65
|
"ignore": {
|
|
64
66
|
"dependencies": [
|
|
@@ -66,5 +68,5 @@
|
|
|
66
68
|
]
|
|
67
69
|
}
|
|
68
70
|
},
|
|
69
|
-
"gitHead": "
|
|
71
|
+
"gitHead": "f6dc066313ddce5339d2aacec3aa84e61232689b"
|
|
70
72
|
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { ApolloLink } from "apollo-link";
|
|
2
2
|
import type { DocumentNode } from "graphql";
|
|
3
|
-
import { ApolloLinkPlugin } from "./ApolloLinkPlugin";
|
|
3
|
+
import { ApolloLinkPlugin } from "./ApolloLinkPlugin.js";
|
|
4
4
|
declare module "graphql" {
|
|
5
5
|
interface DocumentNode {
|
|
6
6
|
__webiny__: Set<string>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["ApolloLink","ApolloLinkPlugin","AddQuerySelectionPlugin","constructor","config","createLink","operation","forward","operationName","addSelectionToQuery","query","document","isProcessed","markProcessed","addSelection","selectionPath","firstQueryDefinition","definitions","selectionSet","tree","selections","fields","split","fieldLoop","field","selection","name","value","push","hasOwnProperty","__webiny__","Set","has","cacheKey","add"],"sources":["AddQuerySelectionPlugin.ts"],"sourcesContent":["import { ApolloLink } from \"apollo-link\";\nimport type { DocumentNode } from \"graphql\";\nimport { ApolloLinkPlugin } from \"./ApolloLinkPlugin\";\nimport type { ExecutableDefinitionNode, FieldNode } from \"graphql/language/ast\";\n\ndeclare module \"graphql\" {\n interface DocumentNode {\n __webiny__: Set<string>;\n }\n}\n\ninterface Config {\n operationName: string;\n selectionPath: string;\n addSelection: DocumentNode;\n}\n\nexport class AddQuerySelectionPlugin extends ApolloLinkPlugin {\n private readonly config: Config;\n\n constructor(config: Config) {\n super();\n this.config = config;\n }\n\n public override createLink(): ApolloLink {\n return new ApolloLink((operation, forward) => {\n if (operation.operationName !== this.config.operationName) {\n return forward(operation);\n }\n\n this.addSelectionToQuery(operation.operationName, operation.query);\n\n return forward(operation);\n });\n }\n\n public addSelectionToQuery(operationName: string, document: DocumentNode): void {\n if (operationName !== this.config.operationName) {\n return;\n }\n\n // If this plugin already processed the given document (documents are always passed by reference),\n // then we don't want to apply the selection again, to avoid adding duplicate selections.\n if (this.isProcessed(document)) {\n return;\n }\n\n this.markProcessed(document);\n\n const { addSelection, selectionPath } = this.config;\n\n const firstQueryDefinition = document.definitions[0] as ExecutableDefinitionNode;\n if (!firstQueryDefinition) {\n return;\n } else if (!firstQueryDefinition.selectionSet) {\n return;\n }\n\n let tree = firstQueryDefinition.selectionSet.selections as FieldNode[];\n const fields = selectionPath.split(\".\");\n\n fieldLoop: for (const field of fields) {\n for (const selection of tree) {\n if (!selection.selectionSet) {\n continue;\n }\n if (selection.name.value === field) {\n tree = selection.selectionSet.selections as FieldNode[];\n continue fieldLoop;\n }\n }\n // If we get here, it means we didn't find the necessary selection\n return;\n }\n /**\n * We must cast because there are a lot of types that are not intertwined and TS is complaining\n */\n tree.push(\n ...((addSelection.definitions[0] as ExecutableDefinitionNode).selectionSet\n .selections as FieldNode[])\n );\n }\n\n private isProcessed(document: DocumentNode) {\n if (!document.hasOwnProperty(\"__webiny__\")) {\n document.__webiny__ = new Set();\n }\n\n return document.__webiny__.has(this.cacheKey);\n }\n\n private markProcessed(document: DocumentNode) {\n if (!document.hasOwnProperty(\"__webiny__\")) {\n document.__webiny__ = new Set();\n }\n\n document.__webiny__.add(this.cacheKey);\n }\n}\n"],"mappings":"AAAA,SAASA,UAAU,QAAQ,aAAa;AAExC,SAASC,gBAAgB;AAezB,OAAO,MAAMC,uBAAuB,SAASD,gBAAgB,CAAC;EAG1DE,WAAWA,CAACC,MAAc,EAAE;IACxB,KAAK,CAAC,CAAC;IACP,IAAI,CAACA,MAAM,GAAGA,MAAM;EACxB;EAEgBC,UAAUA,CA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,SAASG,SAAS;QACtB;MACJ;MACA;MACA;IACJ;IACA;AACR;AACA;IACQJ,IAAI,CAACS,IAAI,CACL,GAAKd,YAAY,CAACG,WAAW,CAAC,CAAC,CAAC,CAA8BC,YAAY,CACrEE,UACT,CAAC;EACL;EAEQR,WAAWA,CAACD,QAAsB,EAAE;IACxC,IAAI,CAACA,QAAQ,CAACkB,cAAc,CAAC,YAAY,CAAC,EAAE;MACxClB,QAAQ,CAACmB,UAAU,GAAG,IAAIC,GAAG,CAAC,CAAC;IACnC;IAEA,OAAOpB,QAAQ,CAACmB,UAAU,CAACE,GAAG,CAAC,IAAI,CAACC,QAAQ,CAAC;EACjD;EAEQpB,aAAaA,CAACF,QAAsB,EAAE;IAC1C,IAAI,CAACA,QAAQ,CAACkB,cAAc,CAAC,YAAY,CAAC,EAAE;MACxClB,QAAQ,CAACmB,UAAU,GAAG,IAAIC,GAAG,CAAC,CAAC;IACnC;IAEApB,QAAQ,CAACmB,UAAU,CAACI,GAAG,CAAC,IAAI,CAACD,QAAQ,CAAC;EAC1C;AACJ","ignoreList":[]}
|
|
1
|
+
{"version":3,"names":["ApolloLink","ApolloLinkPlugin","AddQuerySelectionPlugin","constructor","config","createLink","operation","forward","operationName","addSelectionToQuery","query","document","isProcessed","markProcessed","addSelection","selectionPath","firstQueryDefinition","definitions","selectionSet","tree","selections","fields","split","fieldLoop","field","selection","name","value","push","hasOwnProperty","__webiny__","Set","has","cacheKey","add"],"sources":["AddQuerySelectionPlugin.ts"],"sourcesContent":["import { ApolloLink } from \"apollo-link\";\nimport type { DocumentNode } from \"graphql\";\nimport { ApolloLinkPlugin } from \"./ApolloLinkPlugin.js\";\nimport type { ExecutableDefinitionNode, FieldNode } from \"graphql/language/ast.js\";\n\ndeclare module \"graphql\" {\n interface DocumentNode {\n __webiny__: Set<string>;\n }\n}\n\ninterface Config {\n operationName: string;\n selectionPath: string;\n addSelection: DocumentNode;\n}\n\nexport class AddQuerySelectionPlugin extends ApolloLinkPlugin {\n private readonly config: Config;\n\n constructor(config: Config) {\n super();\n this.config = config;\n }\n\n public override createLink(): ApolloLink {\n return new ApolloLink((operation, forward) => {\n if (operation.operationName !== this.config.operationName) {\n return forward(operation);\n }\n\n this.addSelectionToQuery(operation.operationName, operation.query);\n\n return forward(operation);\n });\n }\n\n public addSelectionToQuery(operationName: string, document: DocumentNode): void {\n if (operationName !== this.config.operationName) {\n return;\n }\n\n // If this plugin already processed the given document (documents are always passed by reference),\n // then we don't want to apply the selection again, to avoid adding duplicate selections.\n if (this.isProcessed(document)) {\n return;\n }\n\n this.markProcessed(document);\n\n const { addSelection, selectionPath } = this.config;\n\n const firstQueryDefinition = document.definitions[0] as ExecutableDefinitionNode;\n if (!firstQueryDefinition) {\n return;\n } else if (!firstQueryDefinition.selectionSet) {\n return;\n }\n\n let tree = firstQueryDefinition.selectionSet.selections as FieldNode[];\n const fields = selectionPath.split(\".\");\n\n fieldLoop: for (const field of fields) {\n for (const selection of tree) {\n if (!selection.selectionSet) {\n continue;\n }\n if (selection.name.value === field) {\n tree = selection.selectionSet.selections as FieldNode[];\n continue fieldLoop;\n }\n }\n // If we get here, it means we didn't find the necessary selection\n return;\n }\n /**\n * We must cast because there are a lot of types that are not intertwined and TS is complaining\n */\n tree.push(\n ...((addSelection.definitions[0] as ExecutableDefinitionNode).selectionSet\n .selections as FieldNode[])\n );\n }\n\n private isProcessed(document: DocumentNode) {\n if (!document.hasOwnProperty(\"__webiny__\")) {\n document.__webiny__ = new Set();\n }\n\n return document.__webiny__.has(this.cacheKey);\n }\n\n private markProcessed(document: DocumentNode) {\n if (!document.hasOwnProperty(\"__webiny__\")) {\n document.__webiny__ = new Set();\n }\n\n document.__webiny__.add(this.cacheKey);\n }\n}\n"],"mappings":"AAAA,SAASA,UAAU,QAAQ,aAAa;AAExC,SAASC,gBAAgB;AAezB,OAAO,MAAMC,uBAAuB,SAASD,gBAAgB,CAAC;EAG1DE,WAAWA,CAACC,MAAc,EAAE;IACxB,KAAK,CAAC,CAA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EAAE;UAChCL,IAAI,GAAGM,SAAS,CAACP,YAAY,CAACE,UAAyB;UACvD,SAASG,SAAS;QACtB;MACJ;MACA;MACA;IACJ;IACA;AACR;AACA;IACQJ,IAAI,CAACS,IAAI,CACL,GAAKd,YAAY,CAACG,WAAW,CAAC,CAAC,CAAC,CAA8BC,YAAY,CACrEE,UACT,CAAC;EACL;EAEQR,WAAWA,CAACD,QAAsB,EAAE;IACxC,IAAI,CAACA,QAAQ,CAACkB,cAAc,CAAC,YAAY,CAAC,EAAE;MACxClB,QAAQ,CAACmB,UAAU,GAAG,IAAIC,GAAG,CAAC,CAAC;IACnC;IAEA,OAAOpB,QAAQ,CAACmB,UAAU,CAACE,GAAG,CAAC,IAAI,CAACC,QAAQ,CAAC;EACjD;EAEQpB,aAAaA,CAACF,QAAsB,EAAE;IAC1C,IAAI,CAACA,QAAQ,CAACkB,cAAc,CAAC,YAAY,CAAC,EAAE;MACxClB,QAAQ,CAACmB,UAAU,GAAG,IAAIC,GAAG,CAAC,CAAC;IACnC;IAEApB,QAAQ,CAACmB,UAAU,CAACI,GAAG,CAAC,IAAI,CAACD,QAAQ,CAAC;EAC1C;AACJ","ignoreList":[]}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { NextLink } from "apollo-link";
|
|
2
2
|
import { ApolloLink } from "apollo-link";
|
|
3
|
-
import type { Operation } from "apollo-link/lib/types";
|
|
3
|
+
import type { Operation } from "apollo-link/lib/types.js";
|
|
4
4
|
export declare class ApolloDynamicLink extends ApolloLink {
|
|
5
5
|
private cache;
|
|
6
6
|
request(operation: Operation, forward: NextLink): any;
|