@webiny/app-aco 6.4.5 → 6.6.0-alpha.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/components/Actions/DeleteFolder/DeleteFolder.js +1 -1
- package/components/Actions/DeleteFolder/DeleteFolder.js.map +1 -1
- package/components/AdvancedSearch/domain/Filter.d.ts +1 -1
- package/components/AdvancedSearch/domain/FilterRepositoryFactory.d.ts +2 -2
- package/components/AdvancedSearch/domain/FilterRepositoryFactory.js.map +1 -1
- package/components/AdvancedSearch/gateways/FiltersGraphQLGateway.d.ts +2 -2
- package/components/AdvancedSearch/gateways/FiltersGraphQLGateway.js +9 -10
- package/components/AdvancedSearch/gateways/FiltersGraphQLGateway.js.map +1 -1
- package/components/AdvancedSearch/gateways/filters.gql.d.ts +5 -5
- package/components/AdvancedSearch/gateways/filters.gql.js +5 -6
- package/components/AdvancedSearch/gateways/filters.gql.js.map +1 -1
- package/components/AdvancedSearch/useFilterRepository.js +7 -2
- package/components/AdvancedSearch/useFilterRepository.js.map +1 -1
- package/components/Table/cells/CellAuthor.d.ts +2 -0
- package/components/Table/cells/CellAuthor.js +10 -0
- package/components/Table/cells/CellAuthor.js.map +1 -0
- package/components/Table/cells/CellCreated.d.ts +2 -0
- package/components/Table/cells/CellCreated.js +13 -0
- package/components/Table/cells/CellCreated.js.map +1 -0
- package/components/Table/cells/CellModified.d.ts +2 -0
- package/components/Table/cells/CellModified.js +13 -0
- package/components/Table/cells/CellModified.js.map +1 -0
- package/components/Table/cells/index.d.ts +3 -0
- package/components/Table/cells/index.js +3 -0
- package/components/Table/createTableData.d.ts +7 -5
- package/components/Table/createTableData.js +22 -7
- package/components/Table/createTableData.js.map +1 -1
- package/components/Table/index.d.ts +2 -2
- package/components/Table/index.js +2 -2
- package/components/index.d.ts +0 -1
- package/components/index.js +0 -1
- package/config/AcoConfig.d.ts +8 -12
- package/config/advanced-search/FieldRenderer.d.ts +3 -1
- package/config/folder/Action.d.ts +1 -1
- package/config/folder/index.d.ts +3 -2
- package/config/index.d.ts +0 -1
- package/config/index.js +0 -1
- package/config/record/Action.d.ts +1 -1
- package/config/record/index.d.ts +1 -1
- package/config/table/Column.d.ts +8 -39
- package/config/table/Column.js +4 -67
- package/config/table/Column.js.map +1 -1
- package/config/table/Sorting.d.ts +2 -11
- package/config/table/Sorting.js +1 -28
- package/config/table/index.d.ts +5 -9
- package/contexts/index.d.ts +0 -3
- package/contexts/index.js +0 -3
- package/dialogs/DialogSetPermissions/graphql.d.ts +1 -1
- package/dialogs/DialogSetPermissions/graphql.js +1 -2
- package/dialogs/DialogSetPermissions/graphql.js.map +1 -1
- package/dialogs/useCreateDialog.js +2 -2
- package/dialogs/useCreateDialog.js.map +1 -1
- package/dialogs/useEditDialog.js +2 -2
- package/dialogs/useEditDialog.js.map +1 -1
- package/dialogs/useSetPermissionsDialog.js +16 -4
- package/dialogs/useSetPermissionsDialog.js.map +1 -1
- package/domain/folder/Folder.d.ts +2 -1
- package/domain/folder/Folder.js.map +1 -1
- package/features/folders/createFolder/CreateFolderGqlGateway.d.ts +3 -3
- package/features/folders/createFolder/CreateFolderGqlGateway.js +15 -16
- package/features/folders/createFolder/CreateFolderGqlGateway.js.map +1 -1
- package/features/folders/deleteFolder/DeleteFolderGqlGateway.d.ts +3 -3
- package/features/folders/deleteFolder/DeleteFolderGqlGateway.js +5 -6
- package/features/folders/deleteFolder/DeleteFolderGqlGateway.js.map +1 -1
- package/features/folders/folderModelProvider/FolderModelProvider.js +29 -31
- package/features/folders/folderModelProvider/FolderModelProvider.js.map +1 -1
- package/features/folders/folderModelProvider/GetFolderModelGqlGateway.d.ts +3 -3
- package/features/folders/folderModelProvider/GetFolderModelGqlGateway.js +5 -7
- package/features/folders/folderModelProvider/GetFolderModelGqlGateway.js.map +1 -1
- package/features/folders/getFolder/GetFolderGqlGateway.d.ts +3 -3
- package/features/folders/getFolder/GetFolderGqlGateway.js +5 -7
- package/features/folders/getFolder/GetFolderGqlGateway.js.map +1 -1
- package/features/folders/getFolderExtensionsFields/GetFolderExtensionsFieldsUseCase.d.ts +3 -3
- package/features/folders/getFolderExtensionsFields/useFolderExtensionsFields.d.ts +3 -3
- package/features/folders/listFolders/ListFoldersGqlGateway.d.ts +1 -1
- package/features/folders/listFolders/ListFoldersGqlGateway.js +1 -2
- package/features/folders/listFolders/ListFoldersGqlGateway.js.map +1 -1
- package/features/folders/listFolders/useListFolders.d.ts +1 -1
- package/features/folders/listFoldersByParentIds/ListFoldersByParentIdsGqlGateway.d.ts +3 -3
- package/features/folders/listFoldersByParentIds/ListFoldersByParentIdsGqlGateway.js +5 -7
- package/features/folders/listFoldersByParentIds/ListFoldersByParentIdsGqlGateway.js.map +1 -1
- package/features/folders/listFoldersByParentIds/useListFoldersByParentIds.d.ts +2 -2
- package/features/folders/loadFolderHierarchy/useLoadFolderHierarchy.d.ts +2 -2
- package/features/folders/updateFolder/UpdateFolderGqlGateway.d.ts +3 -3
- package/features/folders/updateFolder/UpdateFolderGqlGateway.js +5 -6
- package/features/folders/updateFolder/UpdateFolderGqlGateway.js.map +1 -1
- package/hooks/index.d.ts +0 -6
- package/hooks/index.js +0 -6
- package/index.d.ts +3 -2
- package/index.js +2 -2
- package/package.json +16 -23
- package/presentation/folderTree/FolderTreePresenter.js +8 -8
- package/presentation/folderTree/FolderTreePresenter.js.map +1 -1
- package/presentation/folderTree/FolderTreePresenter.test.js +4 -2
- package/presentation/folderTree/FolderTreePresenter.test.js.map +1 -1
- package/table.types.d.ts +2 -9
- package/types.d.ts +5 -26
- package/types.js.map +1 -1
- package/components/Extensions/Extensions.d.ts +0 -2
- package/components/Extensions/Extensions.js +0 -30
- package/components/Extensions/Extensions.js.map +0 -1
- package/components/Extensions/index.d.ts +0 -1
- package/components/Extensions/index.js +0 -1
- package/config/folder/createFolderFieldDecoratorFactory.d.ts +0 -13
- package/config/folder/createFolderFieldDecoratorFactory.js +0 -17
- package/config/folder/createFolderFieldDecoratorFactory.js.map +0 -1
- package/config/table/Sorting.js.map +0 -1
- package/contexts/acoList.d.ts +0 -49
- package/contexts/acoList.js +0 -303
- package/contexts/acoList.js.map +0 -1
- package/contexts/app.d.ts +0 -33
- package/contexts/app.js +0 -47
- package/contexts/app.js.map +0 -1
- package/contexts/folders.d.ts +0 -12
- package/contexts/folders.js +0 -32
- package/contexts/folders.js.map +0 -1
- package/contexts/navigateFolder.d.ts +0 -17
- package/contexts/navigateFolder.js +0 -54
- package/contexts/navigateFolder.js.map +0 -1
- package/contexts/records.d.ts +0 -31
- package/contexts/records.js +0 -316
- package/contexts/records.js.map +0 -1
- package/exports/admin/aco.d.ts +0 -2
- package/exports/admin/aco.js +0 -2
- package/graphql/app.gql.d.ts +0 -17
- package/graphql/app.gql.js +0 -22
- package/graphql/app.gql.js.map +0 -1
- package/graphql/records/common.d.ts +0 -4
- package/graphql/records/common.js +0 -57
- package/graphql/records/common.js.map +0 -1
- package/graphql/records/getRecord.d.ts +0 -2
- package/graphql/records/getRecord.js +0 -5
- package/graphql/records/getRecord.js.map +0 -1
- package/graphql/records/listRecords.d.ts +0 -2
- package/graphql/records/listRecords.js +0 -26
- package/graphql/records/listRecords.js.map +0 -1
- package/graphql/records/moveRecord.d.ts +0 -2
- package/graphql/records/moveRecord.js +0 -16
- package/graphql/records/moveRecord.js.map +0 -1
- package/graphql/records/types.d.ts +0 -108
- package/graphql/records/types.js +0 -0
- package/graphql/records.gql.d.ts +0 -3
- package/graphql/records.gql.js +0 -3
- package/handlers.d.ts +0 -23
- package/handlers.js +0 -22
- package/handlers.js.map +0 -1
- package/hooks/useAcoApp.d.ts +0 -2
- package/hooks/useAcoApp.js +0 -16
- package/hooks/useAcoApp.js.map +0 -1
- package/hooks/useAcoList.d.ts +0 -3
- package/hooks/useAcoList.js +0 -10
- package/hooks/useAcoList.js.map +0 -1
- package/hooks/useFolderModel.d.ts +0 -2
- package/hooks/useFolderModel.js +0 -16
- package/hooks/useFolderModel.js.map +0 -1
- package/hooks/useFoldersType.d.ts +0 -1
- package/hooks/useFoldersType.js +0 -12
- package/hooks/useFoldersType.js.map +0 -1
- package/hooks/useNavigateFolder.d.ts +0 -2
- package/hooks/useNavigateFolder.js +0 -10
- package/hooks/useNavigateFolder.js.map +0 -1
- package/hooks/useRecords.d.ts +0 -62
- package/hooks/useRecords.js +0 -64
- package/hooks/useRecords.js.map +0 -1
- package/hooks/useTags.d.ts +0 -14
- package/hooks/useTags.js +0 -27
- package/hooks/useTags.js.map +0 -1
- package/sorting.d.ts +0 -9
- package/sorting.js +0 -31
- package/sorting.js.map +0 -1
|
@@ -1,108 +0,0 @@
|
|
|
1
|
-
import type { AcoError, ListMeta, ListSearchRecordsSort, SearchRecordItem, TagItem } from "../../types.js";
|
|
2
|
-
export interface UpdateSearchRecordResponse {
|
|
3
|
-
search: {
|
|
4
|
-
updateRecord: {
|
|
5
|
-
data: SearchRecordItem | null;
|
|
6
|
-
error: AcoError | null;
|
|
7
|
-
};
|
|
8
|
-
};
|
|
9
|
-
}
|
|
10
|
-
export interface UpdateSearchRecordVariables {
|
|
11
|
-
id: string;
|
|
12
|
-
data: Pick<SearchRecordItem, "location" | "title" | "content" | "data">;
|
|
13
|
-
}
|
|
14
|
-
export interface MoveSearchRecordResponse {
|
|
15
|
-
search: {
|
|
16
|
-
moveRecord: {
|
|
17
|
-
data: boolean | null;
|
|
18
|
-
error: AcoError | null;
|
|
19
|
-
};
|
|
20
|
-
};
|
|
21
|
-
}
|
|
22
|
-
export interface MoveSearchRecordVariables {
|
|
23
|
-
id: string;
|
|
24
|
-
folderId: string;
|
|
25
|
-
}
|
|
26
|
-
export interface ListTagsWhereQueryVariables {
|
|
27
|
-
tags_in?: string[];
|
|
28
|
-
tags_startsWith?: string;
|
|
29
|
-
tags_not_startsWith?: string;
|
|
30
|
-
AND?: ListTagsWhereQueryVariables[];
|
|
31
|
-
OR?: ListTagsWhereQueryVariables[];
|
|
32
|
-
}
|
|
33
|
-
export interface ListTagsQueryVariables {
|
|
34
|
-
where?: ListTagsWhereQueryVariables;
|
|
35
|
-
}
|
|
36
|
-
export interface ListTagsResponse {
|
|
37
|
-
search: {
|
|
38
|
-
content: {
|
|
39
|
-
data: TagItem[] | null;
|
|
40
|
-
error: AcoError | null;
|
|
41
|
-
};
|
|
42
|
-
};
|
|
43
|
-
}
|
|
44
|
-
export interface ListSearchRecordsResponse {
|
|
45
|
-
search: {
|
|
46
|
-
content: {
|
|
47
|
-
data: SearchRecordItem[] | null;
|
|
48
|
-
meta: ListMeta | null;
|
|
49
|
-
error: AcoError | null;
|
|
50
|
-
};
|
|
51
|
-
};
|
|
52
|
-
}
|
|
53
|
-
interface ListSearchRecordsWhereLocationQueryVariables {
|
|
54
|
-
folderId?: string;
|
|
55
|
-
folderId_in?: string[];
|
|
56
|
-
folderId_not_in?: string[];
|
|
57
|
-
}
|
|
58
|
-
export interface ListSearchRecordsWhereQueryVariables {
|
|
59
|
-
location?: ListSearchRecordsWhereLocationQueryVariables;
|
|
60
|
-
wbyAco_location?: ListSearchRecordsWhereLocationQueryVariables;
|
|
61
|
-
createdBy?: string;
|
|
62
|
-
tags_in?: string[];
|
|
63
|
-
tags_startsWith?: string;
|
|
64
|
-
tags_not_startsWith?: string;
|
|
65
|
-
AND?: ListSearchRecordsWhereQueryVariables[];
|
|
66
|
-
OR?: ListSearchRecordsWhereQueryVariables[];
|
|
67
|
-
}
|
|
68
|
-
export interface ListSearchRecordsQueryVariables {
|
|
69
|
-
where?: ListSearchRecordsWhereQueryVariables;
|
|
70
|
-
search?: string;
|
|
71
|
-
limit?: number;
|
|
72
|
-
after?: string | null;
|
|
73
|
-
sort?: ListSearchRecordsSort;
|
|
74
|
-
}
|
|
75
|
-
export interface GetSearchRecordResponse {
|
|
76
|
-
search: {
|
|
77
|
-
content: {
|
|
78
|
-
data: SearchRecordItem | null;
|
|
79
|
-
error: AcoError | null;
|
|
80
|
-
};
|
|
81
|
-
};
|
|
82
|
-
}
|
|
83
|
-
export interface GetSearchRecordQueryVariables {
|
|
84
|
-
entryId: string;
|
|
85
|
-
}
|
|
86
|
-
export interface DeleteSearchRecordVariables {
|
|
87
|
-
id: string;
|
|
88
|
-
}
|
|
89
|
-
export interface DeleteSearchRecordResponse {
|
|
90
|
-
search: {
|
|
91
|
-
content: {
|
|
92
|
-
data: boolean;
|
|
93
|
-
error: AcoError | null;
|
|
94
|
-
};
|
|
95
|
-
};
|
|
96
|
-
}
|
|
97
|
-
export interface CreateSearchRecordResponse {
|
|
98
|
-
search: {
|
|
99
|
-
content: {
|
|
100
|
-
data: SearchRecordItem | null;
|
|
101
|
-
error: AcoError | null;
|
|
102
|
-
};
|
|
103
|
-
};
|
|
104
|
-
}
|
|
105
|
-
export interface CreateSearchRecordVariables {
|
|
106
|
-
data: Omit<SearchRecordItem, "id" | "createdOn" | "savedOn" | "modifiedOn" | "createdBy" | "savedBy" | "modifiedBy">;
|
|
107
|
-
}
|
|
108
|
-
export {};
|
package/graphql/records/types.js
DELETED
|
File without changes
|
package/graphql/records.gql.d.ts
DELETED
package/graphql/records.gql.js
DELETED
package/handlers.d.ts
DELETED
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
import type { Dispatch, SetStateAction } from "react";
|
|
2
|
-
import type { ApolloQueryResult } from "apollo-client/core/types.js";
|
|
3
|
-
import type { FetchResult } from "apollo-link";
|
|
4
|
-
import type { Loading, LoadingActions } from "./types.js";
|
|
5
|
-
/**
|
|
6
|
-
* A simple wrapper for Apollo fetching operations that handles the `loading` state as side effect.
|
|
7
|
-
*
|
|
8
|
-
* @param loadingHandler: function that handle the loading state.
|
|
9
|
-
* @param apolloQuery: Apollo Query or Mutation
|
|
10
|
-
*/
|
|
11
|
-
export declare const apolloFetchingHandler: <ListSearchRecordsResponse = any>(loadingHandler: (flag: boolean) => void, apolloQuery: () => Promise<ApolloQueryResult<ListSearchRecordsResponse> | FetchResult<ListSearchRecordsResponse>>) => Promise<ApolloQueryResult<ListSearchRecordsResponse> | FetchResult<ListSearchRecordsResponse>>;
|
|
12
|
-
/**
|
|
13
|
-
* A simple function to handle `loading` state.
|
|
14
|
-
*
|
|
15
|
-
* @param action: the `action` that has been performed.
|
|
16
|
-
* @param setState: the logic to update the loading state.
|
|
17
|
-
*/
|
|
18
|
-
export declare const loadingHandler: (action: LoadingActions, setState?: Dispatch<SetStateAction<Loading<LoadingActions>>>) => (flag: boolean) => void;
|
|
19
|
-
/**
|
|
20
|
-
* A data loader wrapper that manages the loading state via a callback.
|
|
21
|
-
* `loader` can be any function that returns a Promise.
|
|
22
|
-
*/
|
|
23
|
-
export declare function dataLoader<T>(loadingHandler: (flag: boolean) => void, loader: () => Promise<T>): Promise<T>;
|
package/handlers.js
DELETED
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
const apolloFetchingHandler = async (loadingHandler, apolloQuery)=>{
|
|
2
|
-
loadingHandler(true);
|
|
3
|
-
const response = await apolloQuery();
|
|
4
|
-
loadingHandler(false);
|
|
5
|
-
return response;
|
|
6
|
-
};
|
|
7
|
-
const handlers_loadingHandler = (action, setState)=>(flag)=>{
|
|
8
|
-
if (!setState) return;
|
|
9
|
-
setState((state)=>({
|
|
10
|
-
...state,
|
|
11
|
-
[action]: flag
|
|
12
|
-
}));
|
|
13
|
-
};
|
|
14
|
-
async function dataLoader(loadingHandler, loader) {
|
|
15
|
-
loadingHandler(true);
|
|
16
|
-
return loader().finally(()=>{
|
|
17
|
-
loadingHandler(false);
|
|
18
|
-
});
|
|
19
|
-
}
|
|
20
|
-
export { apolloFetchingHandler, dataLoader, handlers_loadingHandler as loadingHandler };
|
|
21
|
-
|
|
22
|
-
//# sourceMappingURL=handlers.js.map
|
package/handlers.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"handlers.js","sources":["../src/handlers.tsx"],"sourcesContent":["import type { Dispatch, SetStateAction } from \"react\";\nimport type { ApolloQueryResult } from \"apollo-client/core/types.js\";\nimport type { FetchResult } from \"apollo-link\";\nimport type { Loading, LoadingActions } from \"~/types.js\";\n\n/**\n * A simple wrapper for Apollo fetching operations that handles the `loading` state as side effect.\n *\n * @param loadingHandler: function that handle the loading state.\n * @param apolloQuery: Apollo Query or Mutation\n */\nexport const apolloFetchingHandler = async <ListSearchRecordsResponse = any,>(\n loadingHandler: (flag: boolean) => void,\n apolloQuery: () => Promise<\n ApolloQueryResult<ListSearchRecordsResponse> | FetchResult<ListSearchRecordsResponse>\n >\n) => {\n loadingHandler(true);\n\n const response = await apolloQuery();\n loadingHandler(false);\n\n return response;\n};\n\n/**\n * A simple function to handle `loading` state.\n *\n * @param action: the `action` that has been performed.\n * @param setState: the logic to update the loading state.\n */\nexport const loadingHandler = (\n action: LoadingActions,\n setState?: Dispatch<SetStateAction<Loading<LoadingActions>>>\n) => {\n return (flag: boolean) => {\n if (!setState) {\n return;\n }\n setState(state => {\n return {\n ...state,\n [action]: flag\n };\n });\n };\n};\n\n/**\n * A data loader wrapper that manages the loading state via a callback.\n * `loader` can be any function that returns a Promise.\n */\nexport async function dataLoader<T>(\n loadingHandler: (flag: boolean) => void,\n loader: () => Promise<T>\n) {\n loadingHandler(true);\n\n return loader().finally(() => {\n loadingHandler(false);\n });\n}\n"],"names":["apolloFetchingHandler","loadingHandler","apolloQuery","response","action","setState","flag","state","dataLoader","loader"],"mappings":"AAWO,MAAMA,wBAAwB,OACjCC,gBACAC;IAIAD,eAAe;IAEf,MAAME,WAAW,MAAMD;IACvBD,eAAe;IAEf,OAAOE;AACX;AAQO,MAAMF,0BAAiB,CAC1BG,QACAC,WAEO,CAACC;QACJ,IAAI,CAACD,UACD;QAEJA,SAASE,CAAAA,QACE;gBACH,GAAGA,KAAK;gBACR,CAACH,OAAO,EAAEE;YACd;IAER;AAOG,eAAeE,WAClBP,cAAuC,EACvCQ,MAAwB;IAExBR,eAAe;IAEf,OAAOQ,SAAS,OAAO,CAAC;QACpBR,eAAe;IACnB;AACJ"}
|
package/hooks/useAcoApp.d.ts
DELETED
package/hooks/useAcoApp.js
DELETED
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
import { useContext } from "react";
|
|
2
|
-
import { AcoAppContext } from "../contexts/app.js";
|
|
3
|
-
const useAcoApp = ()=>{
|
|
4
|
-
const context = useContext(AcoAppContext);
|
|
5
|
-
if (!context) throw new Error("useAcoApp must be used within a AcoAppContext");
|
|
6
|
-
return {
|
|
7
|
-
app: context.app,
|
|
8
|
-
folderIdPath: context.folderIdPath,
|
|
9
|
-
folderIdInPath: context.folderIdInPath,
|
|
10
|
-
model: context.model,
|
|
11
|
-
client: context.client
|
|
12
|
-
};
|
|
13
|
-
};
|
|
14
|
-
export { useAcoApp };
|
|
15
|
-
|
|
16
|
-
//# sourceMappingURL=useAcoApp.js.map
|
package/hooks/useAcoApp.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"hooks/useAcoApp.js","sources":["../../src/hooks/useAcoApp.ts"],"sourcesContent":["import { useContext } from \"react\";\nimport type { AcoAppProviderContext } from \"~/contexts/app.js\";\nimport { AcoAppContext } from \"~/contexts/app.js\";\n\nexport const useAcoApp = (): AcoAppProviderContext => {\n const context = useContext(AcoAppContext);\n\n if (!context) {\n throw new Error(\"useAcoApp must be used within a AcoAppContext\");\n }\n\n return {\n app: context.app,\n folderIdPath: context.folderIdPath,\n folderIdInPath: context.folderIdInPath,\n model: context.model,\n client: context.client\n };\n};\n"],"names":["useAcoApp","context","useContext","AcoAppContext","Error"],"mappings":";;AAIO,MAAMA,YAAY;IACrB,MAAMC,UAAUC,WAAWC;IAE3B,IAAI,CAACF,SACD,MAAM,IAAIG,MAAM;IAGpB,OAAO;QACH,KAAKH,QAAQ,GAAG;QAChB,cAAcA,QAAQ,YAAY;QAClC,gBAAgBA,QAAQ,cAAc;QACtC,OAAOA,QAAQ,KAAK;QACpB,QAAQA,QAAQ,MAAM;IAC1B;AACJ"}
|
package/hooks/useAcoList.d.ts
DELETED
package/hooks/useAcoList.js
DELETED
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
import { useContext } from "react";
|
|
2
|
-
import { AcoListContext } from "../contexts/acoList.js";
|
|
3
|
-
const useAcoList = ()=>{
|
|
4
|
-
const context = useContext(AcoListContext);
|
|
5
|
-
if (!context) throw new Error("useAcoList must be used within a AcoListContext");
|
|
6
|
-
return context;
|
|
7
|
-
};
|
|
8
|
-
export { useAcoList };
|
|
9
|
-
|
|
10
|
-
//# sourceMappingURL=useAcoList.js.map
|
package/hooks/useAcoList.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"hooks/useAcoList.js","sources":["../../src/hooks/useAcoList.ts"],"sourcesContent":["import type { Context } from \"react\";\nimport { useContext } from \"react\";\nimport type { AcoListContextData } from \"~/contexts/acoList.js\";\nimport { AcoListContext } from \"~/contexts/acoList.js\";\nimport type { GenericSearchData } from \"~/types.js\";\n\nexport const useAcoList = <T extends GenericSearchData>() => {\n const context = useContext<AcoListContextData<T>>(\n AcoListContext as unknown as Context<AcoListContextData<T>>\n );\n if (!context) {\n throw new Error(\"useAcoList must be used within a AcoListContext\");\n }\n\n return context;\n};\n"],"names":["useAcoList","context","useContext","AcoListContext","Error"],"mappings":";;AAMO,MAAMA,aAAa;IACtB,MAAMC,UAAUC,WACZC;IAEJ,IAAI,CAACF,SACD,MAAM,IAAIG,MAAM;IAGpB,OAAOH;AACX"}
|
package/hooks/useFolderModel.js
DELETED
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
import { useEffect, useState } from "react";
|
|
2
|
-
import { useFeature } from "@webiny/app-admin";
|
|
3
|
-
import { FolderModelProviderFeature } from "../features/folders/folderModelProvider/feature.js";
|
|
4
|
-
function useFolderModel() {
|
|
5
|
-
const { provider } = useFeature(FolderModelProviderFeature);
|
|
6
|
-
const [model, setModel] = useState(null);
|
|
7
|
-
useEffect(()=>{
|
|
8
|
-
provider.getModel().then((model)=>{
|
|
9
|
-
setModel(model);
|
|
10
|
-
});
|
|
11
|
-
}, []);
|
|
12
|
-
return model;
|
|
13
|
-
}
|
|
14
|
-
export { useFolderModel };
|
|
15
|
-
|
|
16
|
-
//# sourceMappingURL=useFolderModel.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"hooks/useFolderModel.js","sources":["../../src/hooks/useFolderModel.ts"],"sourcesContent":["import { useEffect } from \"react\";\nimport { useState } from \"react\";\nimport { useFeature } from \"@webiny/app-admin\";\nimport { CmsModel } from \"@webiny/app-headless-cms-common/types\";\nimport { FolderModelProviderFeature } from \"~/features/folders/folderModelProvider/feature.js\";\n\nexport function useFolderModel() {\n const { provider } = useFeature(FolderModelProviderFeature);\n const [model, setModel] = useState<CmsModel | null>(null);\n\n useEffect(() => {\n provider.getModel().then(model => {\n setModel(model);\n });\n }, []);\n\n return model;\n}\n"],"names":["useFolderModel","provider","useFeature","FolderModelProviderFeature","model","setModel","useState","useEffect"],"mappings":";;;AAMO,SAASA;IACZ,MAAM,EAAEC,QAAQ,EAAE,GAAGC,WAAWC;IAChC,MAAM,CAACC,OAAOC,SAAS,GAAGC,SAA0B;IAEpDC,UAAU;QACNN,SAAS,QAAQ,GAAG,IAAI,CAACG,CAAAA;YACrBC,SAASD;QACb;IACJ,GAAG,EAAE;IAEL,OAAOA;AACX"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export declare const useFoldersType: () => string;
|
package/hooks/useFoldersType.js
DELETED
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
import { useContext } from "react";
|
|
2
|
-
import { FoldersContext } from "../contexts/folders.js";
|
|
3
|
-
const useFoldersType = ()=>{
|
|
4
|
-
const foldersContext = useContext(FoldersContext);
|
|
5
|
-
if (!foldersContext) throw new Error("useFoldersType must be used within a FoldersProvider!");
|
|
6
|
-
const { type } = foldersContext;
|
|
7
|
-
if (!type) throw Error('FoldersProvider requires a "type" prop or an AcoAppContext to be available!');
|
|
8
|
-
return type;
|
|
9
|
-
};
|
|
10
|
-
export { useFoldersType };
|
|
11
|
-
|
|
12
|
-
//# sourceMappingURL=useFoldersType.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"hooks/useFoldersType.js","sources":["../../src/hooks/useFoldersType.ts"],"sourcesContent":["import { useContext } from \"react\";\n\nimport { FoldersContext } from \"~/contexts/folders.js\";\n\nexport const useFoldersType = () => {\n const foldersContext = useContext(FoldersContext);\n\n if (!foldersContext) {\n throw new Error(\"useFoldersType must be used within a FoldersProvider!\");\n }\n\n const { type } = foldersContext;\n\n if (!type) {\n throw Error(`FoldersProvider requires a \"type\" prop or an AcoAppContext to be available!`);\n }\n\n return type;\n};\n"],"names":["useFoldersType","foldersContext","useContext","FoldersContext","Error","type"],"mappings":";;AAIO,MAAMA,iBAAiB;IAC1B,MAAMC,iBAAiBC,WAAWC;IAElC,IAAI,CAACF,gBACD,MAAM,IAAIG,MAAM;IAGpB,MAAM,EAAEC,IAAI,EAAE,GAAGJ;IAEjB,IAAI,CAACI,MACD,MAAMD,MAAM;IAGhB,OAAOC;AACX"}
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
import { useContext } from "react";
|
|
2
|
-
import { NavigateFolderContext } from "../contexts/navigateFolder.js";
|
|
3
|
-
const useNavigateFolder = ()=>{
|
|
4
|
-
const context = useContext(NavigateFolderContext);
|
|
5
|
-
if (!context) throw new Error("useNavigateFolder must be used within a NavigateFolderContext");
|
|
6
|
-
return context;
|
|
7
|
-
};
|
|
8
|
-
export { useNavigateFolder };
|
|
9
|
-
|
|
10
|
-
//# sourceMappingURL=useNavigateFolder.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"hooks/useNavigateFolder.js","sources":["../../src/hooks/useNavigateFolder.ts"],"sourcesContent":["import { useContext } from \"react\";\nimport { NavigateFolderContext } from \"~/contexts/navigateFolder.js\";\n\nexport const useNavigateFolder = () => {\n const context = useContext(NavigateFolderContext);\n if (!context) {\n throw new Error(\"useNavigateFolder must be used within a NavigateFolderContext\");\n }\n\n return context;\n};\n"],"names":["useNavigateFolder","context","useContext","NavigateFolderContext","Error"],"mappings":";;AAGO,MAAMA,oBAAoB;IAC7B,MAAMC,UAAUC,WAAWC;IAC3B,IAAI,CAACF,SACD,MAAM,IAAIG,MAAM;IAGpB,OAAOH;AACX"}
|
package/hooks/useRecords.d.ts
DELETED
|
@@ -1,62 +0,0 @@
|
|
|
1
|
-
import type { ListRecordsParams } from "../contexts/records.js";
|
|
2
|
-
import type { DeletableSearchRecordItem, MovableSearchRecordItem, SearchRecordItem } from "../types.js";
|
|
3
|
-
export declare const useRecords: import("@webiny/app-admin").GenericHook<string, {
|
|
4
|
-
/**
|
|
5
|
-
* NOTE: you do NOT need to call `listRecords` from this hook on component mount, because you already have folders in the `listRecords` property.
|
|
6
|
-
* As soon as you call `useRecords()`, you'll initiate fetching of `records`, which is managed by the `SearchRecordContext`.
|
|
7
|
-
* Since this method lists records with pagination, you might need to call it multiple times passing the `after` param.
|
|
8
|
-
*/
|
|
9
|
-
loading: import("~/types.js").Loading<import("~/types.js").LoadingActions>;
|
|
10
|
-
meta: import("~/types.js").ListMeta;
|
|
11
|
-
records: SearchRecordItem<import("~/types.js").GenericSearchData>[];
|
|
12
|
-
listRecords(params: ListRecordsParams): Promise<SearchRecordItem<import("~/types.js").GenericSearchData>[]>;
|
|
13
|
-
getRecord(id: string): Promise<SearchRecordItem<import("~/types.js").GenericSearchData> | null>;
|
|
14
|
-
createRecord(record: Omit<SearchRecordItem, "id">): Promise<SearchRecordItem<import("~/types.js").GenericSearchData>>;
|
|
15
|
-
updateRecord(record: SearchRecordItem): Promise<SearchRecordItem<import("~/types.js").GenericSearchData>>;
|
|
16
|
-
moveRecord(params: MovableSearchRecordItem): Promise<void>;
|
|
17
|
-
deleteRecord(record: DeletableSearchRecordItem): Promise<true>;
|
|
18
|
-
addRecordToCache: (record: any) => void;
|
|
19
|
-
removeRecordFromCache: (id: string) => void;
|
|
20
|
-
updateRecordInCache: (record: any) => void;
|
|
21
|
-
}> & {
|
|
22
|
-
original: import("@webiny/app-admin").GenericHook<string, {
|
|
23
|
-
/**
|
|
24
|
-
* NOTE: you do NOT need to call `listRecords` from this hook on component mount, because you already have folders in the `listRecords` property.
|
|
25
|
-
* As soon as you call `useRecords()`, you'll initiate fetching of `records`, which is managed by the `SearchRecordContext`.
|
|
26
|
-
* Since this method lists records with pagination, you might need to call it multiple times passing the `after` param.
|
|
27
|
-
*/
|
|
28
|
-
loading: import("~/types.js").Loading<import("~/types.js").LoadingActions>;
|
|
29
|
-
meta: import("~/types.js").ListMeta;
|
|
30
|
-
records: SearchRecordItem<import("~/types.js").GenericSearchData>[];
|
|
31
|
-
listRecords(params: ListRecordsParams): Promise<SearchRecordItem<import("~/types.js").GenericSearchData>[]>;
|
|
32
|
-
getRecord(id: string): Promise<SearchRecordItem<import("~/types.js").GenericSearchData> | null>;
|
|
33
|
-
createRecord(record: Omit<SearchRecordItem, "id">): Promise<SearchRecordItem<import("~/types.js").GenericSearchData>>;
|
|
34
|
-
updateRecord(record: SearchRecordItem): Promise<SearchRecordItem<import("~/types.js").GenericSearchData>>;
|
|
35
|
-
moveRecord(params: MovableSearchRecordItem): Promise<void>;
|
|
36
|
-
deleteRecord(record: DeletableSearchRecordItem): Promise<true>;
|
|
37
|
-
addRecordToCache: (record: any) => void;
|
|
38
|
-
removeRecordFromCache: (id: string) => void;
|
|
39
|
-
updateRecordInCache: (record: any) => void;
|
|
40
|
-
}>;
|
|
41
|
-
originalName: string;
|
|
42
|
-
} & {
|
|
43
|
-
createDecorator: (decorator: import("@webiny/app-admin").Decorator<(folderId?: string) => {
|
|
44
|
-
/**
|
|
45
|
-
* NOTE: you do NOT need to call `listRecords` from this hook on component mount, because you already have folders in the `listRecords` property.
|
|
46
|
-
* As soon as you call `useRecords()`, you'll initiate fetching of `records`, which is managed by the `SearchRecordContext`.
|
|
47
|
-
* Since this method lists records with pagination, you might need to call it multiple times passing the `after` param.
|
|
48
|
-
*/
|
|
49
|
-
loading: import("~/types.js").Loading<import("~/types.js").LoadingActions>;
|
|
50
|
-
meta: import("~/types.js").ListMeta;
|
|
51
|
-
records: SearchRecordItem<import("~/types.js").GenericSearchData>[];
|
|
52
|
-
listRecords(params: ListRecordsParams): Promise<SearchRecordItem<import("~/types.js").GenericSearchData>[]>;
|
|
53
|
-
getRecord(id: string): Promise<SearchRecordItem<import("~/types.js").GenericSearchData> | null>;
|
|
54
|
-
createRecord(record: Omit<SearchRecordItem, "id">): Promise<SearchRecordItem<import("~/types.js").GenericSearchData>>;
|
|
55
|
-
updateRecord(record: SearchRecordItem): Promise<SearchRecordItem<import("~/types.js").GenericSearchData>>;
|
|
56
|
-
moveRecord(params: MovableSearchRecordItem): Promise<void>;
|
|
57
|
-
deleteRecord(record: DeletableSearchRecordItem): Promise<true>;
|
|
58
|
-
addRecordToCache: (record: any) => void;
|
|
59
|
-
removeRecordFromCache: (id: string) => void;
|
|
60
|
-
updateRecordInCache: (record: any) => void;
|
|
61
|
-
}>) => () => React.JSX.Element;
|
|
62
|
-
};
|
package/hooks/useRecords.js
DELETED
|
@@ -1,64 +0,0 @@
|
|
|
1
|
-
import dot_prop_immutable from "dot-prop-immutable";
|
|
2
|
-
import { useContext, useEffect, useMemo } from "react";
|
|
3
|
-
import { makeDecoratable } from "@webiny/app-admin";
|
|
4
|
-
import { SearchRecordsContext } from "../contexts/records.js";
|
|
5
|
-
import { useAcoApp } from "./useAcoApp.js";
|
|
6
|
-
import { useNavigateFolder } from "./useNavigateFolder.js";
|
|
7
|
-
const useRecords = makeDecoratable((folderId)=>{
|
|
8
|
-
const context = useContext(SearchRecordsContext);
|
|
9
|
-
if (!context) throw new Error("useSearchRecords must be used within a SearchRecordsContext");
|
|
10
|
-
const { folderIdPath } = useAcoApp();
|
|
11
|
-
const { currentFolderId } = useNavigateFolder();
|
|
12
|
-
const { records, loading, meta, listRecords, getRecord, createRecord, updateRecord, moveRecord, deleteRecord, addRecordToCache, updateRecordInCache, removeRecordFromCache } = context;
|
|
13
|
-
useEffect(()=>{
|
|
14
|
-
if (!folderId) return;
|
|
15
|
-
const where = dot_prop_immutable.set({}, folderIdPath, folderId);
|
|
16
|
-
listRecords({
|
|
17
|
-
where
|
|
18
|
-
});
|
|
19
|
-
}, [
|
|
20
|
-
folderId
|
|
21
|
-
]);
|
|
22
|
-
return useMemo(()=>({
|
|
23
|
-
loading,
|
|
24
|
-
meta,
|
|
25
|
-
records: records.filter((record)=>{
|
|
26
|
-
const recordFolderId = dot_prop_immutable.get(record, folderIdPath);
|
|
27
|
-
return recordFolderId === folderId || recordFolderId === currentFolderId;
|
|
28
|
-
}),
|
|
29
|
-
listRecords (params) {
|
|
30
|
-
const where = dot_prop_immutable.set(params.where || {}, folderIdPath, folderId);
|
|
31
|
-
return listRecords({
|
|
32
|
-
...params,
|
|
33
|
-
where
|
|
34
|
-
});
|
|
35
|
-
},
|
|
36
|
-
getRecord (id) {
|
|
37
|
-
return getRecord(id);
|
|
38
|
-
},
|
|
39
|
-
createRecord (record) {
|
|
40
|
-
return createRecord(record);
|
|
41
|
-
},
|
|
42
|
-
updateRecord (record) {
|
|
43
|
-
return updateRecord(record, folderId);
|
|
44
|
-
},
|
|
45
|
-
moveRecord (params) {
|
|
46
|
-
return moveRecord(params);
|
|
47
|
-
},
|
|
48
|
-
deleteRecord (record) {
|
|
49
|
-
return deleteRecord(record);
|
|
50
|
-
},
|
|
51
|
-
addRecordToCache,
|
|
52
|
-
removeRecordFromCache,
|
|
53
|
-
updateRecordInCache
|
|
54
|
-
}), [
|
|
55
|
-
records,
|
|
56
|
-
loading,
|
|
57
|
-
meta,
|
|
58
|
-
currentFolderId,
|
|
59
|
-
folderId
|
|
60
|
-
]);
|
|
61
|
-
});
|
|
62
|
-
export { useRecords };
|
|
63
|
-
|
|
64
|
-
//# sourceMappingURL=useRecords.js.map
|
package/hooks/useRecords.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"hooks/useRecords.js","sources":["../../src/hooks/useRecords.ts"],"sourcesContent":["import dotPropImmutable from \"dot-prop-immutable\";\nimport { useContext, useEffect, useMemo } from \"react\";\nimport { makeDecoratable } from \"@webiny/app-admin\";\nimport type { ListRecordsParams } from \"~/contexts/records.js\";\nimport { SearchRecordsContext } from \"~/contexts/records.js\";\nimport type {\n DeletableSearchRecordItem,\n MovableSearchRecordItem,\n SearchRecordItem\n} from \"~/types.js\";\nimport { useAcoApp } from \"~/hooks/useAcoApp.js\";\nimport { useNavigateFolder } from \"~/hooks/useNavigateFolder.js\";\n\nexport const useRecords = makeDecoratable((folderId?: string) => {\n const context = useContext(SearchRecordsContext);\n\n if (!context) {\n throw new Error(\"useSearchRecords must be used within a SearchRecordsContext\");\n }\n\n const { folderIdPath } = useAcoApp();\n\n const { currentFolderId } = useNavigateFolder();\n\n const {\n records,\n loading,\n meta,\n listRecords,\n getRecord,\n createRecord,\n updateRecord,\n moveRecord,\n deleteRecord,\n addRecordToCache,\n updateRecordInCache,\n removeRecordFromCache\n } = context;\n\n useEffect(() => {\n /**\n * On first mount, call `listRecords`, which will either issue a network request, or load links from cache.\n * We don't need to store the result of it to any local state; that is managed by the context provider.\n */\n if (!folderId) {\n return;\n }\n const where = dotPropImmutable.set({}, folderIdPath, folderId);\n listRecords({\n where\n });\n }, [folderId]);\n\n return useMemo(\n () => ({\n /**\n * NOTE: you do NOT need to call `listRecords` from this hook on component mount, because you already have folders in the `listRecords` property.\n * As soon as you call `useRecords()`, you'll initiate fetching of `records`, which is managed by the `SearchRecordContext`.\n * Since this method lists records with pagination, you might need to call it multiple times passing the `after` param.\n */\n loading,\n meta,\n records: records.filter(record => {\n const recordFolderId = dotPropImmutable.get(record, folderIdPath);\n return recordFolderId === folderId || recordFolderId === currentFolderId;\n }),\n listRecords(params: ListRecordsParams) {\n const where = dotPropImmutable.set(params.where || {}, folderIdPath, folderId);\n return listRecords({\n ...params,\n where\n });\n },\n getRecord(id: string) {\n return getRecord(id);\n },\n createRecord(record: Omit<SearchRecordItem, \"id\">) {\n return createRecord(record);\n },\n updateRecord(record: SearchRecordItem) {\n return updateRecord(record, folderId);\n },\n moveRecord(params: MovableSearchRecordItem) {\n return moveRecord(params);\n },\n deleteRecord(record: DeletableSearchRecordItem) {\n return deleteRecord(record);\n },\n addRecordToCache,\n removeRecordFromCache,\n updateRecordInCache\n }),\n [records, loading, meta, currentFolderId, folderId]\n );\n});\n"],"names":["useRecords","makeDecoratable","folderId","context","useContext","SearchRecordsContext","Error","folderIdPath","useAcoApp","currentFolderId","useNavigateFolder","records","loading","meta","listRecords","getRecord","createRecord","updateRecord","moveRecord","deleteRecord","addRecordToCache","updateRecordInCache","removeRecordFromCache","useEffect","where","dotPropImmutable","useMemo","record","recordFolderId","params","id"],"mappings":";;;;;;AAaO,MAAMA,aAAaC,gBAAgB,CAACC;IACvC,MAAMC,UAAUC,WAAWC;IAE3B,IAAI,CAACF,SACD,MAAM,IAAIG,MAAM;IAGpB,MAAM,EAAEC,YAAY,EAAE,GAAGC;IAEzB,MAAM,EAAEC,eAAe,EAAE,GAAGC;IAE5B,MAAM,EACFC,OAAO,EACPC,OAAO,EACPC,IAAI,EACJC,WAAW,EACXC,SAAS,EACTC,YAAY,EACZC,YAAY,EACZC,UAAU,EACVC,YAAY,EACZC,gBAAgB,EAChBC,mBAAmB,EACnBC,qBAAqB,EACxB,GAAGnB;IAEJoB,UAAU;QAKN,IAAI,CAACrB,UACD;QAEJ,MAAMsB,QAAQC,mBAAAA,GAAoB,CAAC,CAAC,GAAGlB,cAAcL;QACrDY,YAAY;YACRU;QACJ;IACJ,GAAG;QAACtB;KAAS;IAEb,OAAOwB,QACH,IAAO;YAMHd;YACAC;YACA,SAASF,QAAQ,MAAM,CAACgB,CAAAA;gBACpB,MAAMC,iBAAiBH,mBAAAA,GAAoB,CAACE,QAAQpB;gBACpD,OAAOqB,mBAAmB1B,YAAY0B,mBAAmBnB;YAC7D;YACA,aAAYoB,MAAyB;gBACjC,MAAML,QAAQC,mBAAAA,GAAoB,CAACI,OAAO,KAAK,IAAI,CAAC,GAAGtB,cAAcL;gBACrE,OAAOY,YAAY;oBACf,GAAGe,MAAM;oBACTL;gBACJ;YACJ;YACA,WAAUM,EAAU;gBAChB,OAAOf,UAAUe;YACrB;YACA,cAAaH,MAAoC;gBAC7C,OAAOX,aAAaW;YACxB;YACA,cAAaA,MAAwB;gBACjC,OAAOV,aAAaU,QAAQzB;YAChC;YACA,YAAW2B,MAA+B;gBACtC,OAAOX,WAAWW;YACtB;YACA,cAAaF,MAAiC;gBAC1C,OAAOR,aAAaQ;YACxB;YACAP;YACAE;YACAD;QACJ,IACA;QAACV;QAASC;QAASC;QAAMJ;QAAiBP;KAAS;AAE3D"}
|
package/hooks/useTags.d.ts
DELETED
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
import type { ListTagsWhereQueryVariables, TagItem } from "../types.js";
|
|
2
|
-
interface UseTagsParams {
|
|
3
|
-
tagsModifier?: (tags: TagItem[]) => TagItem[];
|
|
4
|
-
where?: ListTagsWhereQueryVariables;
|
|
5
|
-
}
|
|
6
|
-
export declare const useTags: (params: UseTagsParams) => {
|
|
7
|
-
/**
|
|
8
|
-
* NOTE: you do NOT need to call `listTags` from this hook on component mount, because you already have tags in the `listTags` property.
|
|
9
|
-
* As soon as you call `useTags()`, you'll initiate fetching of `tags`, which is managed by the `SearchRecordContext`.
|
|
10
|
-
*/
|
|
11
|
-
loading: import("~/types.js").Loading<import("~/types.js").LoadingActions>;
|
|
12
|
-
tags: TagItem[];
|
|
13
|
-
};
|
|
14
|
-
export {};
|
package/hooks/useTags.js
DELETED
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
import { useContext, useEffect, useMemo } from "react";
|
|
2
|
-
import { SearchRecordsContext } from "../contexts/records.js";
|
|
3
|
-
import { useAcoApp } from "./useAcoApp.js";
|
|
4
|
-
const useTags = (params)=>{
|
|
5
|
-
const { tagsModifier, where } = params;
|
|
6
|
-
const context = useContext(SearchRecordsContext);
|
|
7
|
-
const { app } = useAcoApp();
|
|
8
|
-
if (!context) throw new Error("useTags must be used within a SearchRecordsContext");
|
|
9
|
-
const { tags, loading, listTags } = context;
|
|
10
|
-
useEffect(()=>{
|
|
11
|
-
listTags({
|
|
12
|
-
where
|
|
13
|
-
});
|
|
14
|
-
}, [
|
|
15
|
-
app.id
|
|
16
|
-
]);
|
|
17
|
-
return useMemo(()=>({
|
|
18
|
-
loading,
|
|
19
|
-
tags: tagsModifier && "function" == typeof tagsModifier ? tagsModifier(tags) : tags
|
|
20
|
-
}), [
|
|
21
|
-
tags,
|
|
22
|
-
loading
|
|
23
|
-
]);
|
|
24
|
-
};
|
|
25
|
-
export { useTags };
|
|
26
|
-
|
|
27
|
-
//# sourceMappingURL=useTags.js.map
|
package/hooks/useTags.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"hooks/useTags.js","sources":["../../src/hooks/useTags.ts"],"sourcesContent":["import { useContext, useEffect, useMemo } from \"react\";\nimport { SearchRecordsContext } from \"~/contexts/records.js\";\nimport type { ListTagsWhereQueryVariables, TagItem } from \"~/types.js\";\nimport { useAcoApp } from \"~/hooks/useAcoApp.js\";\n\ninterface UseTagsParams {\n tagsModifier?: (tags: TagItem[]) => TagItem[];\n where?: ListTagsWhereQueryVariables;\n}\n\nexport const useTags = (params: UseTagsParams) => {\n const { tagsModifier, where } = params;\n\n const context = useContext(SearchRecordsContext);\n const { app } = useAcoApp();\n\n if (!context) {\n throw new Error(\"useTags must be used within a SearchRecordsContext\");\n }\n\n const { tags, loading, listTags } = context;\n\n useEffect(() => {\n listTags({ where });\n }, [app.id]);\n\n return useMemo(\n () => ({\n /**\n * NOTE: you do NOT need to call `listTags` from this hook on component mount, because you already have tags in the `listTags` property.\n * As soon as you call `useTags()`, you'll initiate fetching of `tags`, which is managed by the `SearchRecordContext`.\n */\n loading,\n tags: tagsModifier && typeof tagsModifier === \"function\" ? tagsModifier(tags) : tags\n }),\n [tags, loading]\n );\n};\n"],"names":["useTags","params","tagsModifier","where","context","useContext","SearchRecordsContext","app","useAcoApp","Error","tags","loading","listTags","useEffect","useMemo"],"mappings":";;;AAUO,MAAMA,UAAU,CAACC;IACpB,MAAM,EAAEC,YAAY,EAAEC,KAAK,EAAE,GAAGF;IAEhC,MAAMG,UAAUC,WAAWC;IAC3B,MAAM,EAAEC,GAAG,EAAE,GAAGC;IAEhB,IAAI,CAACJ,SACD,MAAM,IAAIK,MAAM;IAGpB,MAAM,EAAEC,IAAI,EAAEC,OAAO,EAAEC,QAAQ,EAAE,GAAGR;IAEpCS,UAAU;QACND,SAAS;YAAET;QAAM;IACrB,GAAG;QAACI,IAAI,EAAE;KAAC;IAEX,OAAOO,QACH,IAAO;YAKHH;YACA,MAAMT,gBAAgB,AAAwB,cAAxB,OAAOA,eAA8BA,aAAaQ,QAAQA;QACpF,IACA;QAACA;QAAMC;KAAQ;AAEvB"}
|
package/sorting.d.ts
DELETED
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
import type { DataTableSorting } from "@webiny/admin-ui";
|
|
2
|
-
import type { ListSearchRecordsSort } from "./types.js";
|
|
3
|
-
export declare const validateOrGetDefaultDbSort: (initial?: ListSearchRecordsSort) => ListSearchRecordsSort;
|
|
4
|
-
interface IRecord {
|
|
5
|
-
id: string;
|
|
6
|
-
}
|
|
7
|
-
export declare const sortTableItems: (records: IRecord[], sort?: ListSearchRecordsSort, mapKeys?: Record<string, string>) => any[];
|
|
8
|
-
export declare const createSort: (sorting?: DataTableSorting) => ListSearchRecordsSort | undefined;
|
|
9
|
-
export {};
|
package/sorting.js
DELETED
|
@@ -1,31 +0,0 @@
|
|
|
1
|
-
import orderBy from "lodash/orderBy.js";
|
|
2
|
-
const validateOrGetDefaultDbSort = (initial)=>{
|
|
3
|
-
if (!Array.isArray(initial) || 0 === initial.length) return [
|
|
4
|
-
"savedOn_DESC"
|
|
5
|
-
];
|
|
6
|
-
return initial;
|
|
7
|
-
};
|
|
8
|
-
const sortTableItems = (records, sort, mapKeys = {})=>{
|
|
9
|
-
const dbSorting = validateOrGetDefaultDbSort(sort);
|
|
10
|
-
const fields = [];
|
|
11
|
-
const orders = [];
|
|
12
|
-
for (const sort of dbSorting){
|
|
13
|
-
const [field, order] = sort.split("_");
|
|
14
|
-
const mappedKey = mapKeys[field] ?? field;
|
|
15
|
-
fields.push(mappedKey);
|
|
16
|
-
orders.push(order.toLowerCase());
|
|
17
|
-
}
|
|
18
|
-
return orderBy(records, fields, orders);
|
|
19
|
-
};
|
|
20
|
-
const createSort = (sorting)=>{
|
|
21
|
-
if (!sorting?.length) return;
|
|
22
|
-
return sorting.reduce((items, item)=>{
|
|
23
|
-
const sort = `${item.id}_${item.desc ? "DESC" : "ASC"}`;
|
|
24
|
-
if (items.includes(sort)) return items;
|
|
25
|
-
items.push(sort);
|
|
26
|
-
return items;
|
|
27
|
-
}, []);
|
|
28
|
-
};
|
|
29
|
-
export { createSort, sortTableItems, validateOrGetDefaultDbSort };
|
|
30
|
-
|
|
31
|
-
//# sourceMappingURL=sorting.js.map
|
package/sorting.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"sorting.js","sources":["../src/sorting.tsx"],"sourcesContent":["import orderBy from \"lodash/orderBy.js\";\nimport type { DataTableSorting } from \"@webiny/admin-ui\";\nimport type { ListSearchRecordsSort, ListSearchRecordsSortItem } from \"~/types.js\";\n\nexport const validateOrGetDefaultDbSort = (\n initial?: ListSearchRecordsSort\n): ListSearchRecordsSort => {\n if (!Array.isArray(initial) || initial.length === 0) {\n return [\"savedOn_DESC\"];\n }\n\n return initial;\n};\n\ninterface IRecord {\n id: string;\n}\n\nexport const sortTableItems = (\n records: IRecord[],\n sort?: ListSearchRecordsSort,\n mapKeys: Record<string, string> = {}\n): any[] => {\n const dbSorting = validateOrGetDefaultDbSort(sort);\n const fields: string[] = [];\n const orders: (boolean | \"asc\" | \"desc\")[] = [];\n\n for (const sort of dbSorting) {\n const [field, order] = sort.split(\"_\");\n const mappedKey = mapKeys[field] ?? field;\n fields.push(mappedKey);\n orders.push(order.toLowerCase() as \"asc\" | \"desc\");\n }\n\n return orderBy(records, fields, orders);\n};\n\nexport const createSort = (sorting?: DataTableSorting): ListSearchRecordsSort | undefined => {\n if (!sorting?.length) {\n return undefined;\n }\n return sorting.reduce<ListSearchRecordsSort>((items, item) => {\n const sort = `${item.id}_${item.desc ? \"DESC\" : \"ASC\"}` as ListSearchRecordsSortItem;\n if (items.includes(sort)) {\n return items;\n }\n items.push(sort);\n return items;\n }, []);\n};\n"],"names":["validateOrGetDefaultDbSort","initial","Array","sortTableItems","records","sort","mapKeys","dbSorting","fields","orders","field","order","mappedKey","orderBy","createSort","sorting","items","item"],"mappings":";AAIO,MAAMA,6BAA6B,CACtCC;IAEA,IAAI,CAACC,MAAM,OAAO,CAACD,YAAYA,AAAmB,MAAnBA,QAAQ,MAAM,EACzC,OAAO;QAAC;KAAe;IAG3B,OAAOA;AACX;AAMO,MAAME,iBAAiB,CAC1BC,SACAC,MACAC,UAAkC,CAAC,CAAC;IAEpC,MAAMC,YAAYP,2BAA2BK;IAC7C,MAAMG,SAAmB,EAAE;IAC3B,MAAMC,SAAuC,EAAE;IAE/C,KAAK,MAAMJ,QAAQE,UAAW;QAC1B,MAAM,CAACG,OAAOC,MAAM,GAAGN,KAAK,KAAK,CAAC;QAClC,MAAMO,YAAYN,OAAO,CAACI,MAAM,IAAIA;QACpCF,OAAO,IAAI,CAACI;QACZH,OAAO,IAAI,CAACE,MAAM,WAAW;IACjC;IAEA,OAAOE,QAAQT,SAASI,QAAQC;AACpC;AAEO,MAAMK,aAAa,CAACC;IACvB,IAAI,CAACA,SAAS,QACV;IAEJ,OAAOA,QAAQ,MAAM,CAAwB,CAACC,OAAOC;QACjD,MAAMZ,OAAO,GAAGY,KAAK,EAAE,CAAC,CAAC,EAAEA,KAAK,IAAI,GAAG,SAAS,OAAO;QACvD,IAAID,MAAM,QAAQ,CAACX,OACf,OAAOW;QAEXA,MAAM,IAAI,CAACX;QACX,OAAOW;IACX,GAAG,EAAE;AACT"}
|