@webiny/app 6.3.0-beta.4 → 6.4.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.js +70 -77
- package/App.js.map +1 -1
- package/AppContainer.js +3 -6
- package/AppContainer.js.map +1 -1
- package/apollo-client/InMemoryCache.js +11 -13
- package/apollo-client/InMemoryCache.js.map +1 -1
- package/apollo-client/IntrospectionFragmentMatcher.js +26 -38
- package/apollo-client/IntrospectionFragmentMatcher.js.map +1 -1
- package/components/Image.js +11 -17
- package/components/Image.js.map +1 -1
- package/components/index.js +0 -2
- package/config/RouterConfig/Route.js +23 -28
- package/config/RouterConfig/Route.js.map +1 -1
- package/config/RouterConfig.js +11 -10
- package/config/RouterConfig.js.map +1 -1
- package/config.js +19 -20
- package/config.js.map +1 -1
- package/contexts/Ui/index.js +26 -28
- package/contexts/Ui/index.js.map +1 -1
- package/core/Plugin.js +7 -9
- package/core/Plugin.js.map +1 -1
- package/core/Plugins.js +15 -34
- package/core/Plugins.js.map +1 -1
- package/core/Provider.js +5 -13
- package/core/Provider.js.map +1 -1
- package/core/createProvider.js +3 -6
- package/core/createProvider.js.map +1 -1
- package/core/createProviderPlugin.js +8 -13
- package/core/createProviderPlugin.js.map +1 -1
- package/errors/AuthenticationErrorEvent.js +8 -5
- package/errors/AuthenticationErrorEvent.js.map +1 -1
- package/errors/NetworkErrorEvent.js +8 -5
- package/errors/NetworkErrorEvent.js.map +1 -1
- package/errors/abstractions.js +3 -2
- package/errors/abstractions.js.map +1 -1
- package/errors/index.js +1 -4
- package/exports/admin/env-config.js +0 -2
- package/exports/admin/graphql-client.js +0 -2
- package/exports/admin/local-storage.js +0 -2
- package/exports/admin/router.js +0 -2
- package/exports/admin/security.js +0 -2
- package/exports/admin.js +0 -2
- package/features/envConfig/EnvConfig.js +12 -13
- package/features/envConfig/EnvConfig.js.map +1 -1
- package/features/envConfig/abstractions.js +2 -1
- package/features/envConfig/abstractions.js.map +1 -1
- package/features/envConfig/feature.js +9 -8
- package/features/envConfig/feature.js.map +1 -1
- package/features/envConfig/index.js +0 -2
- package/features/eventPublisher/EventPublisher.js +13 -21
- package/features/eventPublisher/EventPublisher.js.map +1 -1
- package/features/eventPublisher/abstractions.js +7 -9
- package/features/eventPublisher/abstractions.js.map +1 -1
- package/features/eventPublisher/feature.js +13 -12
- package/features/eventPublisher/feature.js.map +1 -1
- package/features/eventPublisher/index.js +1 -3
- package/features/graphqlClient/AuthenticationErrorPublishing.js +26 -26
- package/features/graphqlClient/AuthenticationErrorPublishing.js.map +1 -1
- package/features/graphqlClient/BatchingGraphQLClient.js +104 -149
- package/features/graphqlClient/BatchingGraphQLClient.js.map +1 -1
- package/features/graphqlClient/FetchGraphQLClient.js +41 -48
- package/features/graphqlClient/FetchGraphQLClient.js.map +1 -1
- package/features/graphqlClient/NetworkErrorPublishing.js +35 -42
- package/features/graphqlClient/NetworkErrorPublishing.js.map +1 -1
- package/features/graphqlClient/RequestValue.js +42 -41
- package/features/graphqlClient/RequestValue.js.map +1 -1
- package/features/graphqlClient/RetryGraphQLClient.js +36 -45
- package/features/graphqlClient/RetryGraphQLClient.js.map +1 -1
- package/features/graphqlClient/__tests__/GraphQLClient.test.js +383 -356
- package/features/graphqlClient/__tests__/GraphQLClient.test.js.map +1 -1
- package/features/graphqlClient/abstractions.js +2 -1
- package/features/graphqlClient/abstractions.js.map +1 -1
- package/features/graphqlClient/feature.js +14 -20
- package/features/graphqlClient/feature.js.map +1 -1
- package/features/graphqlClient/index.js +0 -2
- package/features/graphqlClient/types.js +0 -3
- package/features/localStorage/BrowserLocalStorageGateway.js +56 -63
- package/features/localStorage/BrowserLocalStorageGateway.js.map +1 -1
- package/features/localStorage/LocalStorage.js +27 -24
- package/features/localStorage/LocalStorage.js.map +1 -1
- package/features/localStorage/LocalStorageRepository.js +75 -88
- package/features/localStorage/LocalStorageRepository.js.map +1 -1
- package/features/localStorage/abstractions.js +5 -16
- package/features/localStorage/abstractions.js.map +1 -1
- package/features/localStorage/feature.js +17 -28
- package/features/localStorage/feature.js.map +1 -1
- package/features/localStorage/index.js +1 -3
- package/features/mainGraphQLClient/MainGraphQLClient.js +18 -14
- package/features/mainGraphQLClient/MainGraphQLClient.js.map +1 -1
- package/features/mainGraphQLClient/abstractions.js +2 -1
- package/features/mainGraphQLClient/abstractions.js.map +1 -1
- package/features/mainGraphQLClient/feature.js +11 -10
- package/features/mainGraphQLClient/feature.js.map +1 -1
- package/features/mainGraphQLClient/index.js +0 -2
- package/features/router/HistoryRouterGateway.js +75 -105
- package/features/router/HistoryRouterGateway.js.map +1 -1
- package/features/router/HistoryRouterGateway.test.js +184 -193
- package/features/router/HistoryRouterGateway.test.js.map +1 -1
- package/features/router/Route.js +38 -54
- package/features/router/Route.js.map +1 -1
- package/features/router/RouteUrl.js +84 -217
- package/features/router/RouteUrl.js.map +1 -1
- package/features/router/Router.js +67 -124
- package/features/router/Router.js.map +1 -1
- package/features/router/RouterPresenter.js +44 -49
- package/features/router/RouterPresenter.js.map +1 -1
- package/features/router/RouterRepository.js +103 -111
- package/features/router/RouterRepository.js.map +1 -1
- package/features/router/RouterRepository.test.js +119 -150
- package/features/router/RouterRepository.test.js.map +1 -1
- package/features/router/abstractions.js +4 -14
- package/features/router/abstractions.js.map +1 -1
- package/features/router/feature.js +13 -12
- package/features/router/feature.js.map +1 -1
- package/features/router/index.js +1 -3
- package/helpers/InterfaceGenerator/date.js +0 -3
- package/helpers/InterfaceGenerator/id.js +0 -3
- package/helpers/InterfaceGenerator/identity.js +0 -3
- package/helpers/InterfaceGenerator/index.js +0 -3
- package/helpers/InterfaceGenerator/numeric.js +0 -3
- package/helpers/InterfaceGenerator/truthful.js +0 -3
- package/hooks/useAutocomplete/index.js +0 -2
- package/hooks/useAutocomplete/useAutocomplete.js +12 -15
- package/hooks/useAutocomplete/useAutocomplete.js.map +1 -1
- package/hooks/useDataList/functions/getData.js +2 -1
- package/hooks/useDataList/functions/getData.js.map +1 -1
- package/hooks/useDataList/functions/getError.js +2 -1
- package/hooks/useDataList/functions/getError.js.map +1 -1
- package/hooks/useDataList/functions/getMeta.js +2 -1
- package/hooks/useDataList/functions/getMeta.js.map +1 -1
- package/hooks/useDataList/functions/index.js +0 -2
- package/hooks/useDataList/functions/searchDataByKey.js +9 -14
- package/hooks/useDataList/functions/searchDataByKey.js.map +1 -1
- package/hooks/useDataList/index.js +0 -2
- package/hooks/useDataList/useDataList.js +131 -152
- package/hooks/useDataList/useDataList.js.map +1 -1
- package/hooks/useDataList/utils/index.js +0 -2
- package/hooks/useDataList/utils/prepareLoadListParams.js +25 -34
- package/hooks/useDataList/utils/prepareLoadListParams.js.map +1 -1
- package/hooks/useHandler.js +12 -16
- package/hooks/useHandler.js.map +1 -1
- package/hooks/useHandlers.js +18 -20
- package/hooks/useHandlers.js.map +1 -1
- package/hooks/useRegisterLegacyPlugin.js +7 -6
- package/hooks/useRegisterLegacyPlugin.js.map +1 -1
- package/hooks/useUi.js +2 -3
- package/hooks/useUi.js.map +1 -1
- package/i18n/i18n.js +8 -4
- package/i18n/i18n.js.map +1 -1
- package/i18n/index.js +0 -2
- package/index.js +6 -11
- package/package.json +13 -13
- package/plugins/AddQuerySelectionPlugin.js +36 -61
- package/plugins/AddQuerySelectionPlugin.js.map +1 -1
- package/plugins/ApolloCacheObjectIdPlugin.js +12 -11
- package/plugins/ApolloCacheObjectIdPlugin.js.map +1 -1
- package/plugins/ApolloDynamicLink.js +20 -22
- package/plugins/ApolloDynamicLink.js.map +1 -1
- package/plugins/ApolloLinkPlugin.js +16 -15
- package/plugins/ApolloLinkPlugin.js.map +1 -1
- package/plugins/ConsoleLinkPlugin.js +19 -21
- package/plugins/ConsoleLinkPlugin.js.map +1 -1
- package/plugins/NetworkErrorLinkPlugin/ErrorOverlay.js +39 -45
- package/plugins/NetworkErrorLinkPlugin/ErrorOverlay.js.map +1 -1
- package/plugins/NetworkErrorLinkPlugin/GqlErrorOverlay.js +18 -22
- package/plugins/NetworkErrorLinkPlugin/GqlErrorOverlay.js.map +1 -1
- package/plugins/NetworkErrorLinkPlugin/LocalAwsLambdaTimeoutMessage.js +21 -29
- package/plugins/NetworkErrorLinkPlugin/LocalAwsLambdaTimeoutMessage.js.map +1 -1
- package/plugins/NetworkErrorLinkPlugin/StyledComponents.js +6 -15
- package/plugins/NetworkErrorLinkPlugin/StyledComponents.js.map +1 -1
- package/plugins/NetworkErrorLinkPlugin/Typography.js +9 -14
- package/plugins/NetworkErrorLinkPlugin/Typography.js.map +1 -1
- package/plugins/NetworkErrorLinkPlugin/assets/close_24px.js +19 -0
- package/plugins/NetworkErrorLinkPlugin/assets/close_24px.js.map +1 -0
- package/plugins/NetworkErrorLinkPlugin/createErrorOverlay.js +11 -18
- package/plugins/NetworkErrorLinkPlugin/createErrorOverlay.js.map +1 -1
- package/plugins/NetworkErrorLinkPlugin.js +41 -58
- package/plugins/NetworkErrorLinkPlugin.js.map +1 -1
- package/plugins/OmitTypenameLinkPlugin.js +9 -14
- package/plugins/OmitTypenameLinkPlugin.js.map +1 -1
- package/plugins/TenantHeaderLinkPlugin.js +23 -32
- package/plugins/TenantHeaderLinkPlugin.js.map +1 -1
- package/plugins/components/Image.js +8 -15
- package/plugins/components/Image.js.map +1 -1
- package/plugins/image.js +94 -133
- package/plugins/image.js.map +1 -1
- package/plugins/index.js +35 -59
- package/plugins/index.js.map +1 -1
- package/presentation/envConfig/useEnvConfig.js +4 -8
- package/presentation/envConfig/useEnvConfig.js.map +1 -1
- package/presentation/localStorage/index.js +0 -2
- package/presentation/localStorage/useLocalStorage.js +10 -16
- package/presentation/localStorage/useLocalStorage.js.map +1 -1
- package/presentation/localStorage/useLocalStorageValue.js +15 -13
- package/presentation/localStorage/useLocalStorageValue.js.map +1 -1
- package/presentation/localStorage/useLocalStorageValues.js +23 -30
- package/presentation/localStorage/useLocalStorageValues.js.map +1 -1
- package/presentation/router/RouteElementRegistry.js +22 -25
- package/presentation/router/RouteElementRegistry.js.map +1 -1
- package/presentation/router/abstractions.js +2 -1
- package/presentation/router/abstractions.js.map +1 -1
- package/presentation/router/components/Redirect.js +8 -10
- package/presentation/router/components/Redirect.js.map +1 -1
- package/presentation/router/components/RouteContent.js +14 -17
- package/presentation/router/components/RouteContent.js.map +1 -1
- package/presentation/router/components/RouteLink.js +11 -16
- package/presentation/router/components/RouteLink.js.map +1 -1
- package/presentation/router/components/SimpleLink.js +18 -24
- package/presentation/router/components/SimpleLink.js.map +1 -1
- package/presentation/router/hooks/useRoute.js +15 -23
- package/presentation/router/hooks/useRoute.js.map +1 -1
- package/presentation/router/hooks/useRouter.js +22 -23
- package/presentation/router/hooks/useRouter.js.map +1 -1
- package/presentation/router/index.js +0 -2
- package/presentation/router/types.js +0 -3
- package/react-butterfiles/Files.js +148 -217
- package/react-butterfiles/Files.js.map +1 -1
- package/react-butterfiles/index.js +2 -1
- package/react-butterfiles/index.js.map +1 -1
- package/react-butterfiles/utils/generateId.js +2 -3
- package/react-butterfiles/utils/generateId.js.map +1 -1
- package/react-butterfiles/utils/readFileContent.js +9 -13
- package/react-butterfiles/utils/readFileContent.js.map +1 -1
- package/renderApp.js +7 -6
- package/renderApp.js.map +1 -1
- package/router.js +0 -3
- package/rslib-runtime.js +14 -0
- package/rslib-runtime.js.map +1 -0
- package/shared/di/DiContainerProvider.js +8 -12
- package/shared/di/DiContainerProvider.js.map +1 -1
- package/shared/di/createFeature.js +7 -8
- package/shared/di/createFeature.js.map +1 -1
- package/shared/di/useFeature.js +7 -3
- package/shared/di/useFeature.js.map +1 -1
- package/static/svg/close_24px.33adaadc.svg +1 -0
- package/types.js +0 -3
- package/utils/createGenericContext.js +17 -21
- package/utils/createGenericContext.js.map +1 -1
- package/utils/createHashing.js +13 -16
- package/utils/createHashing.js.map +1 -1
- package/utils/index.js +0 -2
- package/utils/legacyPluginToReactComponent.js +11 -10
- package/utils/legacyPluginToReactComponent.js.map +1 -1
- package/components/index.js.map +0 -1
- package/errors/index.js.map +0 -1
- package/exports/admin/env-config.js.map +0 -1
- package/exports/admin/graphql-client.js.map +0 -1
- package/exports/admin/local-storage.js.map +0 -1
- package/exports/admin/router.js.map +0 -1
- package/exports/admin/security.js.map +0 -1
- package/exports/admin.js.map +0 -1
- package/features/envConfig/index.js.map +0 -1
- package/features/eventPublisher/index.js.map +0 -1
- package/features/graphqlClient/index.js.map +0 -1
- package/features/graphqlClient/types.js.map +0 -1
- package/features/localStorage/index.js.map +0 -1
- package/features/mainGraphQLClient/index.js.map +0 -1
- package/features/router/index.js.map +0 -1
- package/helpers/InterfaceGenerator/date.js.map +0 -1
- package/helpers/InterfaceGenerator/id.js.map +0 -1
- package/helpers/InterfaceGenerator/identity.js.map +0 -1
- package/helpers/InterfaceGenerator/index.js.map +0 -1
- package/helpers/InterfaceGenerator/numeric.js.map +0 -1
- package/helpers/InterfaceGenerator/truthful.js.map +0 -1
- package/hooks/useAutocomplete/index.js.map +0 -1
- package/hooks/useDataList/functions/index.js.map +0 -1
- package/hooks/useDataList/index.js.map +0 -1
- package/hooks/useDataList/utils/index.js.map +0 -1
- package/i18n/index.js.map +0 -1
- package/index.js.map +0 -1
- package/presentation/localStorage/index.js.map +0 -1
- package/presentation/router/index.js.map +0 -1
- package/presentation/router/types.js.map +0 -1
- package/router.js.map +0 -1
- package/types.js.map +0 -1
- package/utils/index.js.map +0 -1
|
@@ -4,159 +4,138 @@ import get from "lodash/get.js";
|
|
|
4
4
|
import isEqual from "lodash/isEqual.js";
|
|
5
5
|
import { prepareLoadListParams } from "./utils/index.js";
|
|
6
6
|
import { getData, getError, getMeta } from "./functions/index.js";
|
|
7
|
-
const useDataList = params
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
7
|
+
const useDataList = (params)=>{
|
|
8
|
+
const [multiSelectedItems, multiSelect] = useState([]);
|
|
9
|
+
const getQueryOptions = useCallback(()=>{
|
|
10
|
+
let variables = params.variables;
|
|
11
|
+
if ("function" == typeof variables) variables = variables(params);
|
|
12
|
+
return {
|
|
13
|
+
client: params.client,
|
|
14
|
+
variables: {
|
|
15
|
+
...variables,
|
|
16
|
+
...prepareLoadListParams()
|
|
17
|
+
}
|
|
18
|
+
};
|
|
19
|
+
}, []);
|
|
20
|
+
const queryData = useQuery(params.query, getQueryOptions());
|
|
21
|
+
const prevLoadParamsRef = useRef({});
|
|
22
|
+
const dataListProps = {
|
|
23
|
+
data: get(params, "getData", getData)(queryData.data),
|
|
24
|
+
meta: get(params, "getMeta", getMeta)(queryData.data),
|
|
25
|
+
error: get(params, "getError", getError)(queryData.data),
|
|
26
|
+
loading: queryData.loading,
|
|
27
|
+
init () {
|
|
28
|
+
this.refresh();
|
|
29
|
+
},
|
|
30
|
+
refresh (params = null) {
|
|
31
|
+
multiSelect([]);
|
|
32
|
+
if (!params) return void queryData.refetch(dataListProps.__loadParams);
|
|
33
|
+
queryData.refetch(params);
|
|
34
|
+
},
|
|
35
|
+
setPerPage (perPage) {
|
|
36
|
+
const preparedParams = {
|
|
37
|
+
...dataListProps.__loadParams,
|
|
38
|
+
limit: parseInt("" + perPage),
|
|
39
|
+
after: void 0,
|
|
40
|
+
before: void 0
|
|
41
|
+
};
|
|
42
|
+
this.refresh(preparedParams);
|
|
43
|
+
},
|
|
44
|
+
setNextPage (cursor) {
|
|
45
|
+
const preparedParams = {
|
|
46
|
+
...dataListProps.__loadParams,
|
|
47
|
+
after: cursor,
|
|
48
|
+
before: void 0
|
|
49
|
+
};
|
|
50
|
+
this.refresh(preparedParams);
|
|
51
|
+
},
|
|
52
|
+
setPreviousPage (cursor) {
|
|
53
|
+
const preparedParams = {
|
|
54
|
+
...dataListProps.__loadParams,
|
|
55
|
+
after: void 0,
|
|
56
|
+
before: cursor
|
|
57
|
+
};
|
|
58
|
+
this.refresh(preparedParams);
|
|
59
|
+
},
|
|
60
|
+
setSearch (search) {
|
|
61
|
+
const preparedParams = {
|
|
62
|
+
...dataListProps.__loadParams,
|
|
63
|
+
search,
|
|
64
|
+
after: void 0,
|
|
65
|
+
before: void 0
|
|
66
|
+
};
|
|
67
|
+
this.refresh(preparedParams);
|
|
68
|
+
},
|
|
69
|
+
setWhere (where) {
|
|
70
|
+
const preparedParams = {
|
|
71
|
+
...dataListProps.__loadParams,
|
|
72
|
+
where,
|
|
73
|
+
after: void 0,
|
|
74
|
+
before: void 0
|
|
75
|
+
};
|
|
76
|
+
this.refresh(preparedParams);
|
|
77
|
+
},
|
|
78
|
+
setSorters (sort) {
|
|
79
|
+
const preparedParams = {
|
|
80
|
+
...dataListProps.__loadParams,
|
|
81
|
+
sort,
|
|
82
|
+
after: void 0,
|
|
83
|
+
before: void 0
|
|
84
|
+
};
|
|
85
|
+
this.refresh(preparedParams);
|
|
86
|
+
},
|
|
87
|
+
multiSelect (items, value) {
|
|
88
|
+
if (!Array.isArray(items)) items = [
|
|
89
|
+
items
|
|
90
|
+
];
|
|
91
|
+
const returnItems = [
|
|
92
|
+
...multiSelectedItems
|
|
93
|
+
];
|
|
94
|
+
items.forEach((item)=>{
|
|
95
|
+
if (void 0 === value) returnItems.includes(item) ? returnItems.splice(returnItems.indexOf(item), 1) : returnItems.push(item);
|
|
96
|
+
else if (true === value) returnItems.includes(item) || returnItems.push(item);
|
|
97
|
+
else returnItems.includes(item) && returnItems.splice(returnItems.indexOf(item), 1);
|
|
98
|
+
});
|
|
99
|
+
multiSelect(returnItems);
|
|
100
|
+
},
|
|
101
|
+
isSelected (item) {
|
|
102
|
+
const query = new URLSearchParams(location.search);
|
|
103
|
+
return query.get("id") === item.id;
|
|
104
|
+
},
|
|
105
|
+
select (item) {
|
|
106
|
+
const query = new URLSearchParams(location.search);
|
|
107
|
+
query.set("id", item.id);
|
|
108
|
+
},
|
|
109
|
+
isMultiSelected (item) {
|
|
110
|
+
if (!Array.isArray(multiSelectedItems)) return false;
|
|
111
|
+
return multiSelectedItems.includes(item);
|
|
112
|
+
},
|
|
113
|
+
isNoneMultiSelected () {
|
|
114
|
+
return 0 === multiSelectedItems.length;
|
|
115
|
+
},
|
|
116
|
+
getMultiSelected () {
|
|
117
|
+
return multiSelectedItems;
|
|
118
|
+
},
|
|
119
|
+
multiSelectAll (value) {
|
|
120
|
+
const { data } = dataListProps;
|
|
121
|
+
if (Array.isArray(data)) dataListProps.multiSelect(data, value);
|
|
122
|
+
else dataListProps.multiSelect([], value);
|
|
123
|
+
},
|
|
124
|
+
isAllMultiSelected () {
|
|
125
|
+
const { data } = dataListProps;
|
|
126
|
+
return Array.isArray(data) && multiSelectedItems.length === data.length;
|
|
127
|
+
},
|
|
128
|
+
__loadParams: prepareLoadListParams(location)
|
|
20
129
|
};
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
this.refresh();
|
|
31
|
-
},
|
|
32
|
-
refresh(params = null) {
|
|
33
|
-
// Refresh multi select first.
|
|
34
|
-
multiSelect([]);
|
|
35
|
-
if (!params) {
|
|
36
|
-
queryData.refetch(dataListProps.__loadParams);
|
|
37
|
-
return;
|
|
38
|
-
}
|
|
39
|
-
queryData.refetch(params);
|
|
40
|
-
},
|
|
41
|
-
setPerPage(perPage) {
|
|
42
|
-
const preparedParams = {
|
|
43
|
-
...dataListProps.__loadParams,
|
|
44
|
-
limit: parseInt("" + perPage),
|
|
45
|
-
after: undefined,
|
|
46
|
-
before: undefined
|
|
47
|
-
};
|
|
48
|
-
this.refresh(preparedParams);
|
|
49
|
-
},
|
|
50
|
-
setNextPage(cursor) {
|
|
51
|
-
const preparedParams = {
|
|
52
|
-
...dataListProps.__loadParams,
|
|
53
|
-
after: cursor,
|
|
54
|
-
before: undefined
|
|
55
|
-
};
|
|
56
|
-
this.refresh(preparedParams);
|
|
57
|
-
},
|
|
58
|
-
setPreviousPage(cursor) {
|
|
59
|
-
const preparedParams = {
|
|
60
|
-
...dataListProps.__loadParams,
|
|
61
|
-
after: undefined,
|
|
62
|
-
before: cursor
|
|
63
|
-
};
|
|
64
|
-
this.refresh(preparedParams);
|
|
65
|
-
},
|
|
66
|
-
setSearch(search) {
|
|
67
|
-
const preparedParams = {
|
|
68
|
-
...dataListProps.__loadParams,
|
|
69
|
-
search,
|
|
70
|
-
after: undefined,
|
|
71
|
-
before: undefined
|
|
72
|
-
};
|
|
73
|
-
this.refresh(preparedParams);
|
|
74
|
-
},
|
|
75
|
-
setWhere(where) {
|
|
76
|
-
const preparedParams = {
|
|
77
|
-
...dataListProps.__loadParams,
|
|
78
|
-
where,
|
|
79
|
-
after: undefined,
|
|
80
|
-
before: undefined
|
|
81
|
-
};
|
|
82
|
-
this.refresh(preparedParams);
|
|
83
|
-
},
|
|
84
|
-
setSorters(sort) {
|
|
85
|
-
const preparedParams = {
|
|
86
|
-
...dataListProps.__loadParams,
|
|
87
|
-
sort,
|
|
88
|
-
after: undefined,
|
|
89
|
-
before: undefined
|
|
90
|
-
};
|
|
91
|
-
this.refresh(preparedParams);
|
|
92
|
-
},
|
|
93
|
-
multiSelect(items, value) {
|
|
94
|
-
if (!Array.isArray(items)) {
|
|
95
|
-
items = [items];
|
|
96
|
-
}
|
|
97
|
-
const returnItems = [...multiSelectedItems];
|
|
98
|
-
items.forEach(item => {
|
|
99
|
-
if (value === undefined) {
|
|
100
|
-
returnItems.includes(item) ? returnItems.splice(returnItems.indexOf(item), 1) : returnItems.push(item);
|
|
101
|
-
} else {
|
|
102
|
-
if (value === true) {
|
|
103
|
-
!returnItems.includes(item) && returnItems.push(item);
|
|
104
|
-
} else {
|
|
105
|
-
returnItems.includes(item) && returnItems.splice(returnItems.indexOf(item), 1);
|
|
106
|
-
}
|
|
107
|
-
}
|
|
108
|
-
});
|
|
109
|
-
multiSelect(returnItems);
|
|
110
|
-
},
|
|
111
|
-
isSelected(item) {
|
|
112
|
-
const query = new URLSearchParams(location.search);
|
|
113
|
-
return query.get("id") === item.id;
|
|
114
|
-
},
|
|
115
|
-
select(item) {
|
|
116
|
-
const query = new URLSearchParams(location.search);
|
|
117
|
-
query.set("id", item.id);
|
|
118
|
-
},
|
|
119
|
-
isMultiSelected(item) {
|
|
120
|
-
if (!Array.isArray(multiSelectedItems)) {
|
|
121
|
-
return false;
|
|
122
|
-
}
|
|
123
|
-
return multiSelectedItems.includes(item);
|
|
124
|
-
},
|
|
125
|
-
isNoneMultiSelected() {
|
|
126
|
-
return multiSelectedItems.length === 0;
|
|
127
|
-
},
|
|
128
|
-
getMultiSelected() {
|
|
129
|
-
return multiSelectedItems;
|
|
130
|
-
},
|
|
131
|
-
multiSelectAll(value) {
|
|
132
|
-
const {
|
|
133
|
-
data
|
|
134
|
-
} = dataListProps;
|
|
135
|
-
if (Array.isArray(data)) {
|
|
136
|
-
dataListProps.multiSelect(data, value);
|
|
137
|
-
} else {
|
|
138
|
-
dataListProps.multiSelect([], value);
|
|
139
|
-
}
|
|
140
|
-
},
|
|
141
|
-
isAllMultiSelected() {
|
|
142
|
-
const {
|
|
143
|
-
data
|
|
144
|
-
} = dataListProps;
|
|
145
|
-
return Array.isArray(data) && multiSelectedItems.length === data.length;
|
|
146
|
-
},
|
|
147
|
-
__loadParams: prepareLoadListParams(location)
|
|
148
|
-
};
|
|
149
|
-
useEffect(() => {
|
|
150
|
-
const params = {
|
|
151
|
-
prev: prevLoadParamsRef.current,
|
|
152
|
-
current: dataListProps.__loadParams
|
|
153
|
-
};
|
|
154
|
-
if (!isEqual(params.prev, params.current)) {
|
|
155
|
-
dataListProps.init();
|
|
156
|
-
}
|
|
157
|
-
prevLoadParamsRef.current = params.current;
|
|
158
|
-
});
|
|
159
|
-
return dataListProps;
|
|
130
|
+
useEffect(()=>{
|
|
131
|
+
const params = {
|
|
132
|
+
prev: prevLoadParamsRef.current,
|
|
133
|
+
current: dataListProps.__loadParams
|
|
134
|
+
};
|
|
135
|
+
if (!isEqual(params.prev, params.current)) dataListProps.init();
|
|
136
|
+
prevLoadParamsRef.current = params.current;
|
|
137
|
+
});
|
|
138
|
+
return dataListProps;
|
|
160
139
|
};
|
|
161
140
|
export { useDataList };
|
|
162
141
|
|
|
@@ -1 +1 @@
|
|
|
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,GAAG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EAN,iBAAiB,CAACmD,OAAO,GAAG3D,MAAM,CAAC2D,OAAO;EAC9C,CAAC,CAAC;EAEF,OAAOlD,aAAa;AACxB,CAAC;AAED,SAASV,WAAW","ignoreList":[]}
|
|
1
|
+
{"version":3,"file":"hooks/useDataList/useDataList.js","sources":["../../../src/hooks/useDataList/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"],"names":["useDataList","params","multiSelectedItems","multiSelect","useState","getQueryOptions","useCallback","variables","prepareLoadListParams","queryData","useQuery","prevLoadParamsRef","useRef","dataListProps","get","getData","getMeta","getError","perPage","preparedParams","parseInt","undefined","cursor","search","where","sort","items","value","Array","returnItems","item","query","URLSearchParams","location","data","useEffect","isEqual"],"mappings":";;;;;;AA2CA,MAAMA,cAAc,CAACC;IACjB,MAAM,CAACC,oBAAoBC,YAAY,GAAGC,SAAmB,EAAE;IAE/D,MAAMC,kBAAkBC,YAAY;QAChC,IAAIC,YAAYN,OAAO,SAAS;QAChC,IAAI,AAAqB,cAArB,OAAOM,WACPA,YAAYA,UAAUN;QAG1B,OAAO;YACH,QAAQA,OAAO,MAAM;YACrB,WAAW;gBACP,GAAGM,SAAS;gBACZ,GAAGC,uBAAuB;YAC9B;QACJ;IACJ,GAAG,EAAE;IAEL,MAAMC,YAAYC,SAAST,OAAO,KAAK,EAAEI;IACzC,MAAMM,oBAAoBC,OAAO,CAAC;IAElC,MAAMC,gBAA+B;QACjC,MAAMC,IAAIb,QAAQ,WAAWc,SAAS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SAAS;YACX,MAAMU,kBAAkB,OAAO;YAC/B,SAASE,cAAc,YAAY;QACvC;QAEA,IAAI,CAACuB,QAAQnC,OAAO,IAAI,EAAEA,OAAO,OAAO,GACpCY,cAAc,IAAI;QAGtBF,kBAAkB,OAAO,GAAGV,OAAO,OAAO;IAC9C;IAEA,OAAOY;AACX"}
|
|
@@ -1,38 +1,29 @@
|
|
|
1
|
-
const keys = [
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
1
|
+
const keys = [
|
|
2
|
+
"sort",
|
|
3
|
+
"where",
|
|
4
|
+
"search"
|
|
5
|
+
];
|
|
6
|
+
const prepareLoadListParams = (location)=>{
|
|
7
|
+
const params = {};
|
|
8
|
+
if (!location) return params;
|
|
9
|
+
const query = new URLSearchParams(location.search);
|
|
10
|
+
const after = query.get("after");
|
|
11
|
+
const before = query.get("before");
|
|
12
|
+
const limit = query.get("limit");
|
|
13
|
+
if (after) params.after = after;
|
|
14
|
+
if (before) params.before = before;
|
|
15
|
+
if (limit) params.limit = parseInt(limit);
|
|
16
|
+
keys.forEach((key)=>{
|
|
17
|
+
const value = query.get(key);
|
|
18
|
+
if ("string" != typeof value) return;
|
|
19
|
+
try {
|
|
20
|
+
params[key] = JSON.parse(value);
|
|
21
|
+
} catch {
|
|
22
|
+
params[key] = value;
|
|
23
|
+
}
|
|
24
|
+
});
|
|
5
25
|
return params;
|
|
6
|
-
}
|
|
7
|
-
const query = new URLSearchParams(location.search);
|
|
8
|
-
const after = query.get("after");
|
|
9
|
-
const before = query.get("before");
|
|
10
|
-
const limit = query.get("limit");
|
|
11
|
-
if (after) {
|
|
12
|
-
params.after = after;
|
|
13
|
-
}
|
|
14
|
-
if (before) {
|
|
15
|
-
params.before = before;
|
|
16
|
-
}
|
|
17
|
-
if (limit) {
|
|
18
|
-
params.limit = parseInt(limit);
|
|
19
|
-
}
|
|
20
|
-
keys.forEach(key => {
|
|
21
|
-
const value = query.get(key);
|
|
22
|
-
if (typeof value !== "string") {
|
|
23
|
-
return;
|
|
24
|
-
}
|
|
25
|
-
try {
|
|
26
|
-
params[key] = JSON.parse(value);
|
|
27
|
-
} catch {
|
|
28
|
-
/**
|
|
29
|
-
* If we can't parse the value, it means it's a string.
|
|
30
|
-
*/
|
|
31
|
-
// @ts-expect-error
|
|
32
|
-
params[key] = value;
|
|
33
|
-
}
|
|
34
|
-
});
|
|
35
|
-
return params;
|
|
36
26
|
};
|
|
27
|
+
export default prepareLoadListParams;
|
|
37
28
|
|
|
38
29
|
//# sourceMappingURL=prepareLoadListParams.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"
|
|
1
|
+
{"version":3,"file":"hooks/useDataList/utils/prepareLoadListParams.js","sources":["../../../../src/hooks/useDataList/utils/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"],"names":["keys","location","params","query","URLSearchParams","after","before","limit","parseInt","key","value","JSON"],"mappings":"AASA,MAAMA,OAAyB;IAAC;IAAQ;IAAS;CAAS;AAE1D,8BAAgB,CAAAC;IACZ,MAAMC,SAAiB,CAAC;IACxB,IAAI,CAACD,UACD,OAAOC;IAGX,MAAMC,QAAQ,IAAIC,gBAAgBH,SAAS,MAAM;IAEjD,MAAMI,QAAQF,MAAM,GAAG,CAAC;IACxB,MAAMG,SAASH,MAAM,GAAG,CAAC;IACzB,MAAMI,QAAQJ,MAAM,GAAG,CAAC;IAExB,IAAIE,OACAH,OAAO,KAAK,GAAGG;IAGnB,IAAIC,QACAJ,OAAO,MAAM,GAAGI;IAGpB,IAAIC,OACAL,OAAO,KAAK,GAAGM,SAASD;IAG5BP,KAAK,OAAO,CAACS,CAAAA;QACT,MAAMC,QAAQP,MAAM,GAAG,CAACM;QACxB,IAAI,AAAiB,YAAjB,OAAOC,OACP;QAEJ,IAAI;YACAR,MAAM,CAACO,IAAI,GAAGE,KAAK,KAAK,CAACD;QAC7B,EAAE,OAAM;YAKJR,MAAM,CAACO,IAAI,GAAGC;QAClB;IACJ;IACA,OAAOR;AACX"}
|
package/hooks/useHandler.js
CHANGED
|
@@ -1,19 +1,15 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
return
|
|
12
|
-
});
|
|
13
|
-
useEffect(() => {
|
|
14
|
-
propsRef.current = props;
|
|
15
|
-
});
|
|
16
|
-
return handlerRef.current;
|
|
1
|
+
import { useEffect, useRef } from "react";
|
|
2
|
+
function useHandler(props, factory) {
|
|
3
|
+
const propsRef = useRef(props);
|
|
4
|
+
const handlerRef = useRef((...args)=>{
|
|
5
|
+
const handler = factory(propsRef.current);
|
|
6
|
+
return handler(...args);
|
|
7
|
+
});
|
|
8
|
+
useEffect(()=>{
|
|
9
|
+
propsRef.current = props;
|
|
10
|
+
});
|
|
11
|
+
return handlerRef.current;
|
|
17
12
|
}
|
|
13
|
+
export { useHandler };
|
|
18
14
|
|
|
19
15
|
//# sourceMappingURL=useHandler.js.map
|
package/hooks/useHandler.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"
|
|
1
|
+
{"version":3,"file":"hooks/useHandler.js","sources":["../../src/hooks/useHandler.ts"],"sourcesContent":["import { useRef, useEffect } from \"react\";\n\n/**\n * TODO: figure out any types.\n */\ninterface Props {\n [key: string]: any;\n}\ninterface Factory {\n (...args: any): any;\n}\nexport function useHandler(props: Props, factory: Factory) {\n const propsRef = useRef(props);\n\n const handlerRef = useRef((...args: any) => {\n const handler = factory(propsRef.current);\n return handler(...args);\n });\n\n useEffect(() => {\n propsRef.current = props;\n });\n\n return handlerRef.current;\n}\n"],"names":["useHandler","props","factory","propsRef","useRef","handlerRef","args","handler","useEffect"],"mappings":";AAWO,SAASA,WAAWC,KAAY,EAAEC,OAAgB;IACrD,MAAMC,WAAWC,OAAOH;IAExB,MAAMI,aAAaD,OAAO,CAAC,GAAGE;QAC1B,MAAMC,UAAUL,QAAQC,SAAS,OAAO;QACxC,OAAOI,WAAWD;IACtB;IAEAE,UAAU;QACNL,SAAS,OAAO,GAAGF;IACvB;IAEA,OAAOI,WAAW,OAAO;AAC7B"}
|
package/hooks/useHandlers.js
CHANGED
|
@@ -1,23 +1,21 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
propsRef.current = props;
|
|
19
|
-
});
|
|
20
|
-
return handlersRef.current;
|
|
1
|
+
import { useEffect, useRef } from "react";
|
|
2
|
+
function useHandlers(props, factories) {
|
|
3
|
+
const propsRef = useRef(props);
|
|
4
|
+
const handlersRef = useRef((()=>{
|
|
5
|
+
const names = Object.keys(factories);
|
|
6
|
+
return names.reduce((handlers, name)=>{
|
|
7
|
+
handlers[name] = (...args)=>{
|
|
8
|
+
const handler = factories[name](propsRef.current);
|
|
9
|
+
return handler(...args);
|
|
10
|
+
};
|
|
11
|
+
return handlers;
|
|
12
|
+
}, {});
|
|
13
|
+
})());
|
|
14
|
+
useEffect(()=>{
|
|
15
|
+
propsRef.current = props;
|
|
16
|
+
});
|
|
17
|
+
return handlersRef.current;
|
|
21
18
|
}
|
|
19
|
+
export { useHandlers };
|
|
22
20
|
|
|
23
21
|
//# sourceMappingURL=useHandlers.js.map
|
package/hooks/useHandlers.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"
|
|
1
|
+
{"version":3,"file":"hooks/useHandlers.js","sources":["../../src/hooks/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"],"names":["useHandlers","props","factories","propsRef","useRef","handlersRef","names","Object","handlers","name","args","handler","useEffect"],"mappings":";AAQO,SAASA,YAA0BC,KAAmB,EAAEC,SAA2B;IACtF,MAAMC,WAAWC,OAAOH;IAExB,MAAMI,cAAcD,OACf,AAAC;QACE,MAAME,QAAQC,OAAO,IAAI,CAACL;QAC1B,OAAOI,MAAM,MAAM,CACf,CAACE,UAAUC;YAIPD,QAAQ,CAACC,KAAK,GAAG,CAAC,GAAGC;gBACjB,MAAMC,UAAUT,SAAS,CAACO,KAAK,CAACN,SAAS,OAAO;gBAChD,OAAOQ,WAAWD;YACtB;YACA,OAAOF;QACX,GACA,CAAC;IAET;IAGJI,UAAU;QACNT,SAAS,OAAO,GAAGF;IACvB;IAEA,OAAOI,YAAY,OAAO;AAC9B"}
|
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
import { useRef } from "react";
|
|
2
2
|
import { plugins } from "@webiny/plugins";
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
3
|
+
function useRegisterLegacyPlugin(plugin) {
|
|
4
|
+
const pluginRegistered = useRef(false);
|
|
5
|
+
if (!pluginRegistered.current) {
|
|
6
|
+
pluginRegistered.current = true;
|
|
7
|
+
plugins.register(plugin);
|
|
8
|
+
}
|
|
9
9
|
}
|
|
10
|
+
export { useRegisterLegacyPlugin };
|
|
10
11
|
|
|
11
12
|
//# sourceMappingURL=useRegisterLegacyPlugin.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"
|
|
1
|
+
{"version":3,"file":"hooks/useRegisterLegacyPlugin.js","sources":["../../src/hooks/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"],"names":["useRegisterLegacyPlugin","plugin","pluginRegistered","useRef","plugins"],"mappings":";;AAIO,SAASA,wBAAgDC,MAAe;IAC3E,MAAMC,mBAAmBC,OAAgB;IACzC,IAAI,CAACD,iBAAiB,OAAO,EAAE;QAC3BA,iBAAiB,OAAO,GAAG;QAC3BE,QAAQ,QAAQ,CAACH;IACrB;AACJ"}
|
package/hooks/useUi.js
CHANGED
package/hooks/useUi.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"
|
|
1
|
+
{"version":3,"file":"hooks/useUi.js","sources":["../../src/hooks/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"],"names":["useUi","useContext","UiContext"],"mappings":";;AAIO,MAAMA,QAAQ,IACVC,WAAWC"}
|
package/i18n/i18n.js
CHANGED
|
@@ -1,7 +1,11 @@
|
|
|
1
|
-
import i18n, {
|
|
2
|
-
import
|
|
3
|
-
i18n.registerProcessors([
|
|
1
|
+
import i18n, { defaultModifiers, defaultProcessor } from "@webiny/i18n";
|
|
2
|
+
import i18n_react from "@webiny/i18n-react";
|
|
3
|
+
i18n.registerProcessors([
|
|
4
|
+
defaultProcessor,
|
|
5
|
+
i18n_react
|
|
6
|
+
]);
|
|
4
7
|
i18n.registerModifiers(defaultModifiers);
|
|
5
|
-
|
|
8
|
+
const i18n_i18n = i18n;
|
|
9
|
+
export default i18n_i18n;
|
|
6
10
|
|
|
7
11
|
//# sourceMappingURL=i18n.js.map
|
package/i18n/i18n.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"
|
|
1
|
+
{"version":3,"file":"i18n/i18n.js","sources":["../../src/i18n/i18n.ts"],"sourcesContent":["import i18n, { defaultProcessor, defaultModifiers } from \"@webiny/i18n\";\nimport reactProcessor from \"@webiny/i18n-react\";\n\ni18n.registerProcessors([defaultProcessor, reactProcessor]);\ni18n.registerModifiers(defaultModifiers);\n\nexport default i18n;\n"],"names":["i18n","defaultProcessor","reactProcessor","defaultModifiers"],"mappings":";;AAGAA,KAAK,kBAAkB,CAAC;IAACC;IAAkBC;CAAe;AAC1DF,KAAK,iBAAiB,CAACG;AAEvB,kBAAeH"}
|
package/i18n/index.js
CHANGED
package/index.js
CHANGED
|
@@ -1,10 +1,4 @@
|
|
|
1
|
-
export { AddQuerySelectionPlugin } from "./plugins/AddQuerySelectionPlugin.js";
|
|
2
|
-
export { ApolloLinkPlugin } from "./plugins/ApolloLinkPlugin.js";
|
|
3
|
-
export { ApolloCacheObjectIdPlugin } from "./plugins/ApolloCacheObjectIdPlugin.js";
|
|
4
|
-
|
|
5
|
-
// Composition - we re-export this for ease of use
|
|
6
1
|
export * from "@webiny/react-composition";
|
|
7
|
-
// App framework
|
|
8
2
|
export * from "./App.js";
|
|
9
3
|
export * from "./AppContainer.js";
|
|
10
4
|
export * from "./core/Plugins.js";
|
|
@@ -14,15 +8,16 @@ export * from "./core/createProvider.js";
|
|
|
14
8
|
export * from "./core/createProviderPlugin.js";
|
|
15
9
|
export * from "./renderApp.js";
|
|
16
10
|
export * from "./utils/createGenericContext.js";
|
|
17
|
-
export
|
|
11
|
+
export * from "./helpers/InterfaceGenerator/index.js";
|
|
12
|
+
export { AddQuerySelectionPlugin } from "./plugins/AddQuerySelectionPlugin.js";
|
|
13
|
+
export { ApolloLinkPlugin } from "./plugins/ApolloLinkPlugin.js";
|
|
14
|
+
export { ApolloCacheObjectIdPlugin } from "./plugins/ApolloCacheObjectIdPlugin.js";
|
|
15
|
+
export { DiContainerProvider, useContainer } from "./shared/di/DiContainerProvider.js";
|
|
18
16
|
export { useFeature } from "./shared/di/useFeature.js";
|
|
19
17
|
export { createFeature } from "./shared/di/createFeature.js";
|
|
20
18
|
export { Route } from "./features/router/Route.js";
|
|
21
19
|
export { RouteLink } from "./presentation/router/components/RouteLink.js";
|
|
22
20
|
export { SimpleLink } from "./presentation/router/components/SimpleLink.js";
|
|
23
21
|
export { useEnvConfig } from "./presentation/envConfig/useEnvConfig.js";
|
|
24
|
-
export {
|
|
22
|
+
export { useRoute, useRouter } from "./presentation/router/index.js";
|
|
25
23
|
export { useLocalStorage, useLocalStorageValue, useLocalStorageValues } from "./presentation/localStorage/index.js";
|
|
26
|
-
export * from "./helpers/InterfaceGenerator/index.js";
|
|
27
|
-
|
|
28
|
-
//# sourceMappingURL=index.js.map
|