@webiny/app 6.4.12-beta.5 → 6.5.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/config/RouterConfig.d.ts +1 -3
- package/core/Plugins.d.ts +2 -1
- package/features/graphqlClient/FetchGraphQLClient.d.ts +0 -3
- package/features/graphqlClient/FetchGraphQLClient.js +3 -21
- package/features/graphqlClient/FetchGraphQLClient.js.map +1 -1
- package/features/graphqlClient/__tests__/GraphQLClient.test.js +0 -4
- package/features/graphqlClient/__tests__/GraphQLClient.test.js.map +1 -1
- package/features/graphqlClient/abstractions.d.ts +0 -7
- package/features/graphqlClient/abstractions.js +1 -2
- package/features/graphqlClient/abstractions.js.map +1 -1
- package/features/graphqlClient/index.d.ts +0 -3
- package/features/graphqlClient/index.js +1 -2
- package/features/router/HistoryRouterGateway.d.ts +3 -0
- package/features/router/HistoryRouterGateway.js +12 -0
- package/features/router/HistoryRouterGateway.js.map +1 -1
- package/features/router/Route.d.ts +1 -1
- package/features/router/RouterPresenter.d.ts +2 -0
- package/features/router/RouterPresenter.js +10 -0
- package/features/router/RouterPresenter.js.map +1 -1
- package/features/router/RouterRepository.d.ts +2 -0
- package/features/router/RouterRepository.js +8 -2
- package/features/router/RouterRepository.js.map +1 -1
- package/features/router/abstractions.d.ts +9 -0
- package/features/router/abstractions.js.map +1 -1
- package/package.json +17 -18
- package/plugins/AddQuerySelectionPlugin.js +1 -1
- package/plugins/AddQuerySelectionPlugin.js.map +1 -1
- package/plugins/image.d.ts +1 -1
- package/presentation/router/components/RouteParamsSync.d.ts +22 -0
- package/presentation/router/components/RouteParamsSync.js +53 -0
- package/presentation/router/components/RouteParamsSync.js.map +1 -0
- package/presentation/router/hooks/useRoute.d.ts +1 -0
- package/presentation/router/hooks/useRoute.js +2 -1
- package/presentation/router/hooks/useRoute.js.map +1 -1
- package/presentation/router/hooks/useRouter.d.ts +1 -0
- package/presentation/router/hooks/useRouter.js +1 -0
- package/presentation/router/hooks/useRouter.js.map +1 -1
- package/presentation/router/index.d.ts +2 -0
- package/presentation/router/index.js +1 -0
- package/types.d.ts +0 -21
- package/features/graphqlClient/GraphQLExtensionsEvent.d.ts +0 -18
- package/features/graphqlClient/GraphQLExtensionsEvent.js +0 -13
- package/features/graphqlClient/GraphQLExtensionsEvent.js.map +0 -1
- package/hooks/useAutocomplete/index.d.ts +0 -1
- package/hooks/useAutocomplete/index.js +0 -1
- package/hooks/useAutocomplete/useAutocomplete.d.ts +0 -11
- package/hooks/useAutocomplete/useAutocomplete.js +0 -17
- package/hooks/useAutocomplete/useAutocomplete.js.map +0 -1
- package/hooks/useDataList/functions/getData.d.ts +0 -2
- package/hooks/useDataList/functions/getData.js +0 -5
- package/hooks/useDataList/functions/getData.js.map +0 -1
- package/hooks/useDataList/functions/getError.d.ts +0 -2
- package/hooks/useDataList/functions/getError.js +0 -5
- package/hooks/useDataList/functions/getError.js.map +0 -1
- package/hooks/useDataList/functions/getMeta.d.ts +0 -2
- package/hooks/useDataList/functions/getMeta.js +0 -5
- package/hooks/useDataList/functions/getMeta.js.map +0 -1
- package/hooks/useDataList/functions/index.d.ts +0 -3
- package/hooks/useDataList/functions/index.js +0 -3
- package/hooks/useDataList/functions/searchDataByKey.d.ts +0 -2
- package/hooks/useDataList/functions/searchDataByKey.js +0 -13
- package/hooks/useDataList/functions/searchDataByKey.js.map +0 -1
- package/hooks/useDataList/index.d.ts +0 -1
- package/hooks/useDataList/index.js +0 -1
- package/hooks/useDataList/useDataList.d.ts +0 -35
- package/hooks/useDataList/useDataList.js +0 -142
- package/hooks/useDataList/useDataList.js.map +0 -1
- package/hooks/useDataList/utils/index.d.ts +0 -1
- package/hooks/useDataList/utils/index.js +0 -1
- package/hooks/useDataList/utils/prepareLoadListParams.d.ts +0 -10
- package/hooks/useDataList/utils/prepareLoadListParams.js +0 -29
- package/hooks/useDataList/utils/prepareLoadListParams.js.map +0 -1
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@webiny/app",
|
|
3
|
-
"version": "6.
|
|
3
|
+
"version": "6.5.0-beta.0",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"exports": {
|
|
6
6
|
".": "./index.js",
|
|
@@ -18,17 +18,16 @@
|
|
|
18
18
|
],
|
|
19
19
|
"license": "MIT",
|
|
20
20
|
"dependencies": {
|
|
21
|
-
"@apollo/react-hooks": "3.1.5",
|
|
22
21
|
"@emotion/styled": "11.14.1",
|
|
23
22
|
"@types/react": "18.3.31",
|
|
24
|
-
"@webiny/di": "1.
|
|
25
|
-
"@webiny/feature": "6.
|
|
26
|
-
"@webiny/i18n": "6.
|
|
27
|
-
"@webiny/i18n-react": "6.
|
|
28
|
-
"@webiny/plugins": "6.
|
|
29
|
-
"@webiny/react-composition": "6.
|
|
30
|
-
"@webiny/react-properties": "6.
|
|
31
|
-
"@webiny/stdlib": "0.0.
|
|
23
|
+
"@webiny/di": "1.0.2",
|
|
24
|
+
"@webiny/feature": "6.5.0-beta.0",
|
|
25
|
+
"@webiny/i18n": "6.5.0-beta.0",
|
|
26
|
+
"@webiny/i18n-react": "6.5.0-beta.0",
|
|
27
|
+
"@webiny/plugins": "6.5.0-beta.0",
|
|
28
|
+
"@webiny/react-composition": "6.5.0-beta.0",
|
|
29
|
+
"@webiny/react-properties": "6.5.0-beta.0",
|
|
30
|
+
"@webiny/stdlib": "0.0.12",
|
|
32
31
|
"apollo-cache": "1.3.5",
|
|
33
32
|
"apollo-cache-inmemory": "1.6.6",
|
|
34
33
|
"apollo-client": "2.6.10",
|
|
@@ -41,22 +40,22 @@
|
|
|
41
40
|
"history": "5.3.0",
|
|
42
41
|
"invariant": "2.2.4",
|
|
43
42
|
"lodash": "4.18.1",
|
|
44
|
-
"mobx": "
|
|
45
|
-
"nanoid": "6.0.
|
|
43
|
+
"mobx": "6.16.1",
|
|
44
|
+
"nanoid": "6.0.0",
|
|
46
45
|
"react": "18.3.1",
|
|
47
46
|
"react-dom": "18.3.1",
|
|
48
47
|
"ts-invariant": "0.10.3",
|
|
49
48
|
"warning": "4.0.3",
|
|
50
|
-
"zod": "4.
|
|
49
|
+
"zod": "4.4.3"
|
|
51
50
|
},
|
|
52
51
|
"devDependencies": {
|
|
53
|
-
"@types/lodash": "4.17.
|
|
52
|
+
"@types/lodash": "4.17.24",
|
|
54
53
|
"@types/warning": "3.0.4",
|
|
55
|
-
"@webiny/build-tools": "6.
|
|
54
|
+
"@webiny/build-tools": "6.5.0-beta.0",
|
|
56
55
|
"rimraf": "6.1.3",
|
|
57
|
-
"type-fest": "5.
|
|
58
|
-
"typescript": "
|
|
59
|
-
"vitest": "
|
|
56
|
+
"type-fest": "5.8.0",
|
|
57
|
+
"typescript": "7.0.2",
|
|
58
|
+
"vitest": "4.1.10"
|
|
60
59
|
},
|
|
61
60
|
"publishConfig": {
|
|
62
61
|
"access": "public"
|
|
@@ -19,7 +19,7 @@ class AddQuerySelectionPlugin extends ApolloLinkPlugin {
|
|
|
19
19
|
const { addSelection, selectionPath } = this.config;
|
|
20
20
|
const firstQueryDefinition = document.definitions[0];
|
|
21
21
|
if (!firstQueryDefinition) return;
|
|
22
|
-
|
|
22
|
+
if (!firstQueryDefinition.selectionSet) return;
|
|
23
23
|
let tree = firstQueryDefinition.selectionSet.selections;
|
|
24
24
|
const fields = selectionPath.split(".");
|
|
25
25
|
fieldLoop: for (const field of fields){
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"plugins/AddQuerySelectionPlugin.js","sources":["../../src/plugins/AddQuerySelectionPlugin.ts"],"sourcesContent":["import { ApolloLink } from \"apollo-link\";\nimport type { DocumentNode } from \"graphql\";\nimport { ApolloLinkPlugin } from \"./ApolloLinkPlugin.js\";\nimport type { ExecutableDefinitionNode, FieldNode } from \"graphql/language/ast.js\";\n\ndeclare module \"graphql\" {\n interface DocumentNode {\n __webiny__: Set<string>;\n }\n}\n\ninterface Config {\n operationName: string;\n selectionPath: string;\n addSelection: DocumentNode;\n}\n\nexport class AddQuerySelectionPlugin extends ApolloLinkPlugin {\n private readonly config: Config;\n\n constructor(config: Config) {\n super();\n this.config = config;\n }\n\n public override createLink(): ApolloLink {\n return new ApolloLink((operation, forward) => {\n if (operation.operationName !== this.config.operationName) {\n return forward(operation);\n }\n\n this.addSelectionToQuery(operation.operationName, operation.query);\n\n return forward(operation);\n });\n }\n\n public addSelectionToQuery(operationName: string, document: DocumentNode): void {\n if (operationName !== this.config.operationName) {\n return;\n }\n\n // If this plugin already processed the given document (documents are always passed by reference),\n // then we don't want to apply the selection again, to avoid adding duplicate selections.\n if (this.isProcessed(document)) {\n return;\n }\n\n this.markProcessed(document);\n\n const { addSelection, selectionPath } = this.config;\n\n const firstQueryDefinition = document.definitions[0] as ExecutableDefinitionNode;\n if (!firstQueryDefinition) {\n return;\n } else if (!firstQueryDefinition.selectionSet) {\n return;\n }\n\n let tree = firstQueryDefinition.selectionSet.selections as FieldNode[];\n const fields = selectionPath.split(\".\");\n\n fieldLoop: for (const field of fields) {\n for (const selection of tree) {\n if (!selection.selectionSet) {\n continue;\n }\n if (selection.name.value === field) {\n tree = selection.selectionSet.selections as FieldNode[];\n continue fieldLoop;\n }\n }\n // If we get here, it means we didn't find the necessary selection\n return;\n }\n /**\n * We must cast because there are a lot of types that are not intertwined and TS is complaining\n */\n tree.push(\n ...((addSelection.definitions[0] as ExecutableDefinitionNode).selectionSet\n .selections as FieldNode[])\n );\n }\n\n private isProcessed(document: DocumentNode) {\n if (!document.hasOwnProperty(\"__webiny__\")) {\n document.__webiny__ = new Set();\n }\n\n return document.__webiny__.has(this.cacheKey);\n }\n\n private markProcessed(document: DocumentNode) {\n if (!document.hasOwnProperty(\"__webiny__\")) {\n document.__webiny__ = new Set();\n }\n\n document.__webiny__.add(this.cacheKey);\n }\n}\n"],"names":["AddQuerySelectionPlugin","ApolloLinkPlugin","config","ApolloLink","operation","forward","operationName","document","addSelection","selectionPath","firstQueryDefinition","tree","fields","fieldLoop","field","selection","Set"],"mappings":";;AAiBO,MAAMA,gCAAgCC;IAGzC,YAAYC,MAAc,CAAE;QACxB,KAAK;QACL,IAAI,CAAC,MAAM,GAAGA;IAClB;IAEgB,aAAyB;QACrC,OAAO,IAAIC,WAAW,CAACC,WAAWC;YAC9B,IAAID,UAAU,aAAa,KAAK,IAAI,CAAC,MAAM,CAAC,aAAa,EACrD,OAAOC,QAAQD;YAGnB,IAAI,CAAC,mBAAmB,CAACA,UAAU,aAAa,EAAEA,UAAU,KAAK;YAEjE,OAAOC,QAAQD;QACnB;IACJ;IAEO,oBAAoBE,aAAqB,EAAEC,QAAsB,EAAQ;QAC5E,IAAID,kBAAkB,IAAI,CAAC,MAAM,CAAC,aAAa,EAC3C;QAKJ,IAAI,IAAI,CAAC,WAAW,CAACC,WACjB;QAGJ,IAAI,CAAC,aAAa,CAACA;QAEnB,MAAM,EAAEC,YAAY,EAAEC,aAAa,EAAE,GAAG,IAAI,CAAC,MAAM;QAEnD,MAAMC,uBAAuBH,SAAS,WAAW,CAAC,EAAE;QACpD,IAAI,CAACG,sBACD;
|
|
1
|
+
{"version":3,"file":"plugins/AddQuerySelectionPlugin.js","sources":["../../src/plugins/AddQuerySelectionPlugin.ts"],"sourcesContent":["import { ApolloLink } from \"apollo-link\";\nimport type { DocumentNode } from \"graphql\";\nimport { ApolloLinkPlugin } from \"./ApolloLinkPlugin.js\";\nimport type { ExecutableDefinitionNode, FieldNode } from \"graphql/language/ast.js\";\n\ndeclare module \"graphql\" {\n interface DocumentNode {\n __webiny__: Set<string>;\n }\n}\n\ninterface Config {\n operationName: string;\n selectionPath: string;\n addSelection: DocumentNode;\n}\n\nexport class AddQuerySelectionPlugin extends ApolloLinkPlugin {\n private readonly config: Config;\n\n constructor(config: Config) {\n super();\n this.config = config;\n }\n\n public override createLink(): ApolloLink {\n return new ApolloLink((operation, forward) => {\n if (operation.operationName !== this.config.operationName) {\n return forward(operation);\n }\n\n this.addSelectionToQuery(operation.operationName, operation.query);\n\n return forward(operation);\n });\n }\n\n public addSelectionToQuery(operationName: string, document: DocumentNode): void {\n if (operationName !== this.config.operationName) {\n return;\n }\n\n // If this plugin already processed the given document (documents are always passed by reference),\n // then we don't want to apply the selection again, to avoid adding duplicate selections.\n if (this.isProcessed(document)) {\n return;\n }\n\n this.markProcessed(document);\n\n const { addSelection, selectionPath } = this.config;\n\n const firstQueryDefinition = document.definitions[0] as ExecutableDefinitionNode;\n if (!firstQueryDefinition) {\n return;\n } else if (!firstQueryDefinition.selectionSet) {\n return;\n }\n\n let tree = firstQueryDefinition.selectionSet.selections as FieldNode[];\n const fields = selectionPath.split(\".\");\n\n fieldLoop: for (const field of fields) {\n for (const selection of tree) {\n if (!selection.selectionSet) {\n continue;\n }\n if (selection.name.value === field) {\n tree = selection.selectionSet.selections as FieldNode[];\n continue fieldLoop;\n }\n }\n // If we get here, it means we didn't find the necessary selection\n return;\n }\n /**\n * We must cast because there are a lot of types that are not intertwined and TS is complaining\n */\n tree.push(\n ...((addSelection.definitions[0] as ExecutableDefinitionNode).selectionSet\n .selections as FieldNode[])\n );\n }\n\n private isProcessed(document: DocumentNode) {\n if (!document.hasOwnProperty(\"__webiny__\")) {\n document.__webiny__ = new Set();\n }\n\n return document.__webiny__.has(this.cacheKey);\n }\n\n private markProcessed(document: DocumentNode) {\n if (!document.hasOwnProperty(\"__webiny__\")) {\n document.__webiny__ = new Set();\n }\n\n document.__webiny__.add(this.cacheKey);\n }\n}\n"],"names":["AddQuerySelectionPlugin","ApolloLinkPlugin","config","ApolloLink","operation","forward","operationName","document","addSelection","selectionPath","firstQueryDefinition","tree","fields","fieldLoop","field","selection","Set"],"mappings":";;AAiBO,MAAMA,gCAAgCC;IAGzC,YAAYC,MAAc,CAAE;QACxB,KAAK;QACL,IAAI,CAAC,MAAM,GAAGA;IAClB;IAEgB,aAAyB;QACrC,OAAO,IAAIC,WAAW,CAACC,WAAWC;YAC9B,IAAID,UAAU,aAAa,KAAK,IAAI,CAAC,MAAM,CAAC,aAAa,EACrD,OAAOC,QAAQD;YAGnB,IAAI,CAAC,mBAAmB,CAACA,UAAU,aAAa,EAAEA,UAAU,KAAK;YAEjE,OAAOC,QAAQD;QACnB;IACJ;IAEO,oBAAoBE,aAAqB,EAAEC,QAAsB,EAAQ;QAC5E,IAAID,kBAAkB,IAAI,CAAC,MAAM,CAAC,aAAa,EAC3C;QAKJ,IAAI,IAAI,CAAC,WAAW,CAACC,WACjB;QAGJ,IAAI,CAAC,aAAa,CAACA;QAEnB,MAAM,EAAEC,YAAY,EAAEC,aAAa,EAAE,GAAG,IAAI,CAAC,MAAM;QAEnD,MAAMC,uBAAuBH,SAAS,WAAW,CAAC,EAAE;QACpD,IAAI,CAACG,sBACD;QACG,IAAI,CAACA,qBAAqB,YAAY,EACzC;QAGJ,IAAIC,OAAOD,qBAAqB,YAAY,CAAC,UAAU;QACvD,MAAME,SAASH,cAAc,KAAK,CAAC;QAEnCI,WAAW,KAAK,MAAMC,SAASF,OAAQ;YACnC,KAAK,MAAMG,aAAaJ,KACpB,IAAKI,UAAU,YAAY,EAG3B;gBAAA,IAAIA,UAAU,IAAI,CAAC,KAAK,KAAKD,OAAO;oBAChCH,OAAOI,UAAU,YAAY,CAAC,UAAU;oBACxC,SAASF;gBACb;YAAA;YAGJ;QACJ;QAIAF,KAAK,IAAI,IACAH,aAAa,WAAW,CAAC,EAAE,CAA8B,YAAY,CACrE,UAAU;IAEvB;IAEQ,YAAYD,QAAsB,EAAE;QACxC,IAAI,CAACA,SAAS,cAAc,CAAC,eACzBA,SAAS,UAAU,GAAG,IAAIS;QAG9B,OAAOT,SAAS,UAAU,CAAC,GAAG,CAAC,IAAI,CAAC,QAAQ;IAChD;IAEQ,cAAcA,QAAsB,EAAE;QAC1C,IAAI,CAACA,SAAS,cAAc,CAAC,eACzBA,SAAS,UAAU,GAAG,IAAIS;QAG9BT,SAAS,UAAU,CAAC,GAAG,CAAC,IAAI,CAAC,QAAQ;IACzC;AACJ"}
|
package/plugins/image.d.ts
CHANGED
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import type { Route, RouteParamsDefinition } from "../../../features/router/Route.js";
|
|
2
|
+
export interface RouteParamFieldConfig<T> {
|
|
3
|
+
param: string;
|
|
4
|
+
read: () => T | undefined;
|
|
5
|
+
write: (value: T | undefined) => void;
|
|
6
|
+
storageKey?: string;
|
|
7
|
+
}
|
|
8
|
+
export interface RouteParamField {
|
|
9
|
+
param: string;
|
|
10
|
+
read: () => unknown;
|
|
11
|
+
write: (value: unknown) => void;
|
|
12
|
+
storageKey?: string;
|
|
13
|
+
}
|
|
14
|
+
export interface RouteParamFieldBuilder {
|
|
15
|
+
create<T>(config: RouteParamFieldConfig<T>): RouteParamField;
|
|
16
|
+
}
|
|
17
|
+
interface RouteParamsSyncProps<TParams extends RouteParamsDefinition | undefined> {
|
|
18
|
+
route: Route<TParams>;
|
|
19
|
+
fields: (builder: RouteParamFieldBuilder) => RouteParamField[];
|
|
20
|
+
}
|
|
21
|
+
export declare function RouteParamsSync<TParams extends RouteParamsDefinition | undefined>({ route: routeDefinition, fields: buildFields }: RouteParamsSyncProps<TParams>): null;
|
|
22
|
+
export {};
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
import { useEffect, useRef } from "react";
|
|
2
|
+
import { reaction } from "mobx";
|
|
3
|
+
import { useRoute } from "../hooks/useRoute.js";
|
|
4
|
+
import { useLocalStorage } from "../../localStorage/useLocalStorage.js";
|
|
5
|
+
const fieldBuilder = {
|
|
6
|
+
create (config) {
|
|
7
|
+
return config;
|
|
8
|
+
}
|
|
9
|
+
};
|
|
10
|
+
function RouteParamsSync({ route: routeDefinition, fields: buildFields }) {
|
|
11
|
+
const localStorage = useLocalStorage();
|
|
12
|
+
const { route, setRouteParams, replaceRouteParams } = useRoute(routeDefinition);
|
|
13
|
+
const syncingFromUrl = useRef(false);
|
|
14
|
+
const fields = buildFields(fieldBuilder);
|
|
15
|
+
useEffect(()=>{
|
|
16
|
+
syncingFromUrl.current = true;
|
|
17
|
+
for (const field of fields){
|
|
18
|
+
const urlValue = route.params[field.param];
|
|
19
|
+
field.write(urlValue);
|
|
20
|
+
}
|
|
21
|
+
queueMicrotask(()=>{
|
|
22
|
+
syncingFromUrl.current = false;
|
|
23
|
+
});
|
|
24
|
+
}, fields.map((f)=>route.params[f.param]));
|
|
25
|
+
useEffect(()=>reaction(()=>{
|
|
26
|
+
const values = {};
|
|
27
|
+
for (const field of fields)values[field.param] = field.read();
|
|
28
|
+
return values;
|
|
29
|
+
}, (values)=>{
|
|
30
|
+
for (const field of fields)if (field.storageKey) {
|
|
31
|
+
const val = values[field.param];
|
|
32
|
+
if (null != val && "" !== val) localStorage.set(field.storageKey, val);
|
|
33
|
+
else localStorage.remove(field.storageKey);
|
|
34
|
+
}
|
|
35
|
+
const update = syncingFromUrl.current ? replaceRouteParams : setRouteParams;
|
|
36
|
+
update((params)=>{
|
|
37
|
+
const next = {
|
|
38
|
+
...params
|
|
39
|
+
};
|
|
40
|
+
for (const field of fields)next[field.param] = values[field.param];
|
|
41
|
+
return next;
|
|
42
|
+
});
|
|
43
|
+
}, {
|
|
44
|
+
equals: (a, b)=>{
|
|
45
|
+
for (const field of fields)if (a[field.param] !== b[field.param]) return false;
|
|
46
|
+
return true;
|
|
47
|
+
}
|
|
48
|
+
}), []);
|
|
49
|
+
return null;
|
|
50
|
+
}
|
|
51
|
+
export { RouteParamsSync };
|
|
52
|
+
|
|
53
|
+
//# sourceMappingURL=RouteParamsSync.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"presentation/router/components/RouteParamsSync.js","sources":["../../../../src/presentation/router/components/RouteParamsSync.tsx"],"sourcesContent":["import { useEffect, useRef } from \"react\";\nimport { reaction } from \"mobx\";\nimport type { Route, RouteParamsDefinition } from \"~/features/router/Route.js\";\nimport { useRoute } from \"~/presentation/router/hooks/useRoute.js\";\nimport { useLocalStorage } from \"~/presentation/localStorage/useLocalStorage.js\";\n\nexport interface RouteParamFieldConfig<T> {\n param: string;\n read: () => T | undefined;\n write: (value: T | undefined) => void;\n storageKey?: string;\n}\n\nexport interface RouteParamField {\n param: string;\n read: () => unknown;\n write: (value: unknown) => void;\n storageKey?: string;\n}\n\nexport interface RouteParamFieldBuilder {\n create<T>(config: RouteParamFieldConfig<T>): RouteParamField;\n}\n\nconst fieldBuilder: RouteParamFieldBuilder = {\n create<T>(config: RouteParamFieldConfig<T>): RouteParamField {\n return config as RouteParamField;\n }\n};\n\ninterface RouteParamsSyncProps<TParams extends RouteParamsDefinition | undefined> {\n route: Route<TParams>;\n fields: (builder: RouteParamFieldBuilder) => RouteParamField[];\n}\n\nexport function RouteParamsSync<TParams extends RouteParamsDefinition | undefined>({\n route: routeDefinition,\n fields: buildFields\n}: RouteParamsSyncProps<TParams>) {\n const localStorage = useLocalStorage();\n const { route, setRouteParams, replaceRouteParams } = useRoute(routeDefinition);\n const syncingFromUrl = useRef(false);\n const fields = buildFields(fieldBuilder);\n\n // URL → State: apply route params to presenter state on browser navigation.\n useEffect(\n () => {\n syncingFromUrl.current = true;\n\n for (const field of fields) {\n const urlValue = (route.params as Record<string, unknown>)[field.param];\n field.write(urlValue);\n }\n\n queueMicrotask(() => {\n syncingFromUrl.current = false;\n });\n },\n fields.map(f => (route.params as Record<string, unknown>)[f.param])\n );\n\n // State → URL: when MobX observable values change, update route params.\n useEffect(() => {\n return reaction(\n () => {\n const values: Record<string, unknown> = {};\n for (const field of fields) {\n values[field.param] = field.read();\n }\n return values;\n },\n values => {\n for (const field of fields) {\n if (field.storageKey) {\n const val = values[field.param];\n if (val !== undefined && val !== null && val !== \"\") {\n localStorage.set(field.storageKey, val);\n } else {\n localStorage.remove(field.storageKey);\n }\n }\n }\n\n const update = syncingFromUrl.current ? replaceRouteParams : setRouteParams;\n\n update((params: Record<string, unknown>) => {\n const next = { ...params };\n for (const field of fields) {\n next[field.param] = values[field.param];\n }\n return next;\n });\n },\n {\n equals: (a, b) => {\n for (const field of fields) {\n if (a[field.param] !== b[field.param]) {\n return false;\n }\n }\n return true;\n }\n }\n );\n }, []);\n\n return null;\n}\n"],"names":["fieldBuilder","config","RouteParamsSync","routeDefinition","buildFields","localStorage","useLocalStorage","route","setRouteParams","replaceRouteParams","useRoute","syncingFromUrl","useRef","fields","useEffect","field","urlValue","queueMicrotask","f","reaction","values","val","update","params","next","a","b"],"mappings":";;;;AAwBA,MAAMA,eAAuC;IACzC,QAAUC,MAAgC;QACtC,OAAOA;IACX;AACJ;AAOO,SAASC,gBAAmE,EAC/E,OAAOC,eAAe,EACtB,QAAQC,WAAW,EACS;IAC5B,MAAMC,eAAeC;IACrB,MAAM,EAAEC,KAAK,EAAEC,cAAc,EAAEC,kBAAkB,EAAE,GAAGC,SAASP;IAC/D,MAAMQ,iBAAiBC,OAAO;IAC9B,MAAMC,SAAST,YAAYJ;IAG3Bc,UACI;QACIH,eAAe,OAAO,GAAG;QAEzB,KAAK,MAAMI,SAASF,OAAQ;YACxB,MAAMG,WAAYT,MAAM,MAAkC,CAACQ,MAAM,KAAK,CAAC;YACvEA,MAAM,KAAK,CAACC;QAChB;QAEAC,eAAe;YACXN,eAAe,OAAO,GAAG;QAC7B;IACJ,GACAE,OAAO,GAAG,CAACK,CAAAA,IAAMX,MAAM,MAAkC,CAACW,EAAE,KAAK,CAAC;IAItEJ,UAAU,IACCK,SACH;YACI,MAAMC,SAAkC,CAAC;YACzC,KAAK,MAAML,SAASF,OAChBO,MAAM,CAACL,MAAM,KAAK,CAAC,GAAGA,MAAM,IAAI;YAEpC,OAAOK;QACX,GACAA,CAAAA;YACI,KAAK,MAAML,SAASF,OAChB,IAAIE,MAAM,UAAU,EAAE;gBAClB,MAAMM,MAAMD,MAAM,CAACL,MAAM,KAAK,CAAC;gBAC/B,IAAIM,QAAAA,OAAqCA,AAAQ,OAARA,KACrChB,aAAa,GAAG,CAACU,MAAM,UAAU,EAAEM;qBAEnChB,aAAa,MAAM,CAACU,MAAM,UAAU;YAE5C;YAGJ,MAAMO,SAASX,eAAe,OAAO,GAAGF,qBAAqBD;YAE7Dc,OAAO,CAACC;gBACJ,MAAMC,OAAO;oBAAE,GAAGD,MAAM;gBAAC;gBACzB,KAAK,MAAMR,SAASF,OAChBW,IAAI,CAACT,MAAM,KAAK,CAAC,GAAGK,MAAM,CAACL,MAAM,KAAK,CAAC;gBAE3C,OAAOS;YACX;QACJ,GACA;YACI,QAAQ,CAACC,GAAGC;gBACR,KAAK,MAAMX,SAASF,OAChB,IAAIY,CAAC,CAACV,MAAM,KAAK,CAAC,KAAKW,CAAC,CAACX,MAAM,KAAK,CAAC,EACjC,OAAO;gBAGf,OAAO;YACX;QACJ,IAEL,EAAE;IAEL,OAAO;AACX"}
|
|
@@ -3,4 +3,5 @@ import { MatchedRoute } from "../../../features/router/abstractions.js";
|
|
|
3
3
|
export declare function useRoute<TParams extends RouteParamsDefinition | undefined = undefined>(route?: Route<TParams>): {
|
|
4
4
|
route: MatchedRoute<TParams extends RouteParamsDefinition ? RouteParamsInfer<TParams> : undefined>;
|
|
5
5
|
setRouteParams: <T extends Record<string, any>>(cb: (params: T) => T) => void;
|
|
6
|
+
replaceRouteParams: <T extends Record<string, any>>(cb: (params: T) => T) => void;
|
|
6
7
|
};
|
|
@@ -14,7 +14,8 @@ function useRoute(route) {
|
|
|
14
14
|
}, []);
|
|
15
15
|
return {
|
|
16
16
|
route: currentRoute,
|
|
17
|
-
setRouteParams: presenter.setRouteParams.bind(presenter)
|
|
17
|
+
setRouteParams: presenter.setRouteParams.bind(presenter),
|
|
18
|
+
replaceRouteParams: presenter.replaceRouteParams.bind(presenter)
|
|
18
19
|
};
|
|
19
20
|
}
|
|
20
21
|
export { useRoute };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"presentation/router/hooks/useRoute.js","sources":["../../../../src/presentation/router/hooks/useRoute.ts"],"sourcesContent":["import { useEffect, useState } from \"react\";\nimport { autorun } from \"mobx\";\nimport type { Route, RouteParamsDefinition, RouteParamsInfer } from \"~/features/router/Route.js\";\nimport { MatchedRoute } from \"~/features/router/abstractions.js\";\nimport { RouterFeature } from \"~/features/router/feature.js\";\nimport { useFeature } from \"~/shared/di/useFeature.js\";\n\nexport function useRoute<TParams extends RouteParamsDefinition | undefined = undefined>(\n // oxlint-disable-next-line typescript/no-unused-vars\n route?: Route<TParams>\n) {\n const { presenter } = useFeature(RouterFeature);\n const [currentRoute, setCurrentRoute] = useState<MatchedRoute | undefined>(\n presenter.vm.currentRoute\n );\n\n useEffect(() => {\n autorun(() => {\n const route = presenter.vm.currentRoute;\n\n if (!route) {\n return;\n }\n\n setCurrentRoute(route);\n });\n }, []);\n\n // TODO: add validation (the requested route must match the current route)\n\n return {\n route: currentRoute as MatchedRoute<\n TParams extends RouteParamsDefinition ? RouteParamsInfer<TParams> : undefined\n >,\n setRouteParams: presenter.setRouteParams.bind(presenter)\n };\n}\n"],"names":["useRoute","route","presenter","useFeature","RouterFeature","currentRoute","setCurrentRoute","useState","useEffect","autorun"],"mappings":";;;;AAOO,SAASA,SAEZC,KAAsB;IAEtB,MAAM,EAAEC,SAAS,EAAE,GAAGC,WAAWC;IACjC,MAAM,CAACC,cAAcC,gBAAgB,GAAGC,SACpCL,UAAU,EAAE,CAAC,YAAY;IAG7BM,UAAU;QACNC,QAAQ;YACJ,MAAMR,QAAQC,UAAU,EAAE,CAAC,YAAY;YAEvC,IAAI,CAACD,OACD;YAGJK,gBAAgBL;QACpB;IACJ,GAAG,EAAE;IAIL,OAAO;QACH,OAAOI;QAGP,gBAAgBH,UAAU,cAAc,CAAC,IAAI,CAACA;
|
|
1
|
+
{"version":3,"file":"presentation/router/hooks/useRoute.js","sources":["../../../../src/presentation/router/hooks/useRoute.ts"],"sourcesContent":["import { useEffect, useState } from \"react\";\nimport { autorun } from \"mobx\";\nimport type { Route, RouteParamsDefinition, RouteParamsInfer } from \"~/features/router/Route.js\";\nimport { MatchedRoute } from \"~/features/router/abstractions.js\";\nimport { RouterFeature } from \"~/features/router/feature.js\";\nimport { useFeature } from \"~/shared/di/useFeature.js\";\n\nexport function useRoute<TParams extends RouteParamsDefinition | undefined = undefined>(\n // oxlint-disable-next-line typescript/no-unused-vars\n route?: Route<TParams>\n) {\n const { presenter } = useFeature(RouterFeature);\n const [currentRoute, setCurrentRoute] = useState<MatchedRoute | undefined>(\n presenter.vm.currentRoute\n );\n\n useEffect(() => {\n autorun(() => {\n const route = presenter.vm.currentRoute;\n\n if (!route) {\n return;\n }\n\n setCurrentRoute(route);\n });\n }, []);\n\n // TODO: add validation (the requested route must match the current route)\n\n return {\n route: currentRoute as MatchedRoute<\n TParams extends RouteParamsDefinition ? RouteParamsInfer<TParams> : undefined\n >,\n setRouteParams: presenter.setRouteParams.bind(presenter),\n replaceRouteParams: presenter.replaceRouteParams.bind(presenter)\n };\n}\n"],"names":["useRoute","route","presenter","useFeature","RouterFeature","currentRoute","setCurrentRoute","useState","useEffect","autorun"],"mappings":";;;;AAOO,SAASA,SAEZC,KAAsB;IAEtB,MAAM,EAAEC,SAAS,EAAE,GAAGC,WAAWC;IACjC,MAAM,CAACC,cAAcC,gBAAgB,GAAGC,SACpCL,UAAU,EAAE,CAAC,YAAY;IAG7BM,UAAU;QACNC,QAAQ;YACJ,MAAMR,QAAQC,UAAU,EAAE,CAAC,YAAY;YAEvC,IAAI,CAACD,OACD;YAGJK,gBAAgBL;QACpB;IACJ,GAAG,EAAE;IAIL,OAAO;QACH,OAAOI;QAGP,gBAAgBH,UAAU,cAAc,CAAC,IAAI,CAACA;QAC9C,oBAAoBA,UAAU,kBAAkB,CAAC,IAAI,CAACA;IAC1D;AACJ"}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { type ReactRoute } from "../../../presentation/router/index.js";
|
|
2
2
|
export declare const useRouter: () => {
|
|
3
3
|
goToRoute: <TParams extends import("../../../features/router/Route").RouteParamsDefinition | undefined>(route: import("../../..").Route<TParams>, ...args: import("../../../features/router/abstractions").RouteParamsArgs<TParams>) => void;
|
|
4
|
+
goBack: () => void;
|
|
4
5
|
getLink: <TParams extends import("../../../features/router/Route").RouteParamsDefinition | undefined>(route: import("../../..").Route<TParams>, ...args: import("../../../features/router/abstractions").RouteParamsArgs<TParams>) => string;
|
|
5
6
|
addTransitionGuard: (config: import("../../../features/router").RouteTransitionGuardConfig) => import("../../../features/router").GuardDisposer;
|
|
6
7
|
isTransitionBlocked: () => boolean;
|
|
@@ -8,6 +8,7 @@ const useRouter = ()=>{
|
|
|
8
8
|
const registry = container.resolve(RouteElementRegistry);
|
|
9
9
|
return {
|
|
10
10
|
goToRoute: presenter.goToRoute.bind(presenter),
|
|
11
|
+
goBack: presenter.goBack.bind(presenter),
|
|
11
12
|
getLink: presenter.getLink.bind(presenter),
|
|
12
13
|
addTransitionGuard: presenter.addTransitionGuard.bind(presenter),
|
|
13
14
|
isTransitionBlocked: presenter.isTransitionBlocked.bind(presenter),
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"presentation/router/hooks/useRouter.js","sources":["../../../../src/presentation/router/hooks/useRouter.ts"],"sourcesContent":["import { type ReactRoute, RouteElementRegistry } from \"~/presentation/router/index.js\";\nimport { RouterFeature } from \"~/features/router/feature.js\";\nimport { useFeature } from \"~/shared/di/useFeature.js\";\nimport { useContainer } from \"~/shared/di/DiContainerProvider.js\";\n\nexport const useRouter = () => {\n const { presenter } = useFeature(RouterFeature);\n const container = useContainer();\n const registry = container.resolve(RouteElementRegistry);\n\n return {\n goToRoute: presenter.goToRoute.bind(presenter),\n getLink: presenter.getLink.bind(presenter),\n addTransitionGuard: presenter.addTransitionGuard.bind(presenter),\n isTransitionBlocked: presenter.isTransitionBlocked.bind(presenter),\n unblockTransition: presenter.unblockTransition.bind(presenter),\n confirmTransition: presenter.confirmTransition.bind(presenter),\n cancelTransition: presenter.cancelTransition.bind(presenter),\n setRoutes: (routes: ReactRoute[]) => {\n const cleanRoutes = [];\n\n for (const route of routes) {\n cleanRoutes.push(route.route);\n registry.register(route.route.name, route.element);\n }\n\n presenter.bootstrap(cleanRoutes);\n }\n };\n};\n"],"names":["useRouter","presenter","useFeature","RouterFeature","container","useContainer","registry","RouteElementRegistry","routes","cleanRoutes","route"],"mappings":";;;;AAKO,MAAMA,YAAY;IACrB,MAAM,EAAEC,SAAS,EAAE,GAAGC,WAAWC;IACjC,MAAMC,YAAYC;IAClB,MAAMC,WAAWF,UAAU,OAAO,CAACG;IAEnC,OAAO;QACH,WAAWN,UAAU,SAAS,CAAC,IAAI,CAACA;QACpC,SAASA,UAAU,OAAO,CAAC,IAAI,CAACA;QAChC,oBAAoBA,UAAU,kBAAkB,CAAC,IAAI,CAACA;QACtD,qBAAqBA,UAAU,mBAAmB,CAAC,IAAI,CAACA;QACxD,mBAAmBA,UAAU,iBAAiB,CAAC,IAAI,CAACA;QACpD,mBAAmBA,UAAU,iBAAiB,CAAC,IAAI,CAACA;QACpD,kBAAkBA,UAAU,gBAAgB,CAAC,IAAI,CAACA;QAClD,WAAW,CAACO;YACR,MAAMC,cAAc,EAAE;YAEtB,KAAK,MAAMC,SAASF,OAAQ;gBACxBC,YAAY,IAAI,CAACC,MAAM,KAAK;gBAC5BJ,SAAS,QAAQ,CAACI,MAAM,KAAK,CAAC,IAAI,EAAEA,MAAM,OAAO;YACrD;YAEAT,UAAU,SAAS,CAACQ;QACxB;IACJ;AACJ"}
|
|
1
|
+
{"version":3,"file":"presentation/router/hooks/useRouter.js","sources":["../../../../src/presentation/router/hooks/useRouter.ts"],"sourcesContent":["import { type ReactRoute, RouteElementRegistry } from \"~/presentation/router/index.js\";\nimport { RouterFeature } from \"~/features/router/feature.js\";\nimport { useFeature } from \"~/shared/di/useFeature.js\";\nimport { useContainer } from \"~/shared/di/DiContainerProvider.js\";\n\nexport const useRouter = () => {\n const { presenter } = useFeature(RouterFeature);\n const container = useContainer();\n const registry = container.resolve(RouteElementRegistry);\n\n return {\n goToRoute: presenter.goToRoute.bind(presenter),\n goBack: presenter.goBack.bind(presenter),\n getLink: presenter.getLink.bind(presenter),\n addTransitionGuard: presenter.addTransitionGuard.bind(presenter),\n isTransitionBlocked: presenter.isTransitionBlocked.bind(presenter),\n unblockTransition: presenter.unblockTransition.bind(presenter),\n confirmTransition: presenter.confirmTransition.bind(presenter),\n cancelTransition: presenter.cancelTransition.bind(presenter),\n setRoutes: (routes: ReactRoute[]) => {\n const cleanRoutes = [];\n\n for (const route of routes) {\n cleanRoutes.push(route.route);\n registry.register(route.route.name, route.element);\n }\n\n presenter.bootstrap(cleanRoutes);\n }\n };\n};\n"],"names":["useRouter","presenter","useFeature","RouterFeature","container","useContainer","registry","RouteElementRegistry","routes","cleanRoutes","route"],"mappings":";;;;AAKO,MAAMA,YAAY;IACrB,MAAM,EAAEC,SAAS,EAAE,GAAGC,WAAWC;IACjC,MAAMC,YAAYC;IAClB,MAAMC,WAAWF,UAAU,OAAO,CAACG;IAEnC,OAAO;QACH,WAAWN,UAAU,SAAS,CAAC,IAAI,CAACA;QACpC,QAAQA,UAAU,MAAM,CAAC,IAAI,CAACA;QAC9B,SAASA,UAAU,OAAO,CAAC,IAAI,CAACA;QAChC,oBAAoBA,UAAU,kBAAkB,CAAC,IAAI,CAACA;QACtD,qBAAqBA,UAAU,mBAAmB,CAAC,IAAI,CAACA;QACxD,mBAAmBA,UAAU,iBAAiB,CAAC,IAAI,CAACA;QACpD,mBAAmBA,UAAU,iBAAiB,CAAC,IAAI,CAACA;QACpD,kBAAkBA,UAAU,gBAAgB,CAAC,IAAI,CAACA;QAClD,WAAW,CAACO;YACR,MAAMC,cAAc,EAAE;YAEtB,KAAK,MAAMC,SAASF,OAAQ;gBACxBC,YAAY,IAAI,CAACC,MAAM,KAAK;gBAC5BJ,SAAS,QAAQ,CAACI,MAAM,KAAK,CAAC,IAAI,EAAEA,MAAM,OAAO;YACrD;YAEAT,UAAU,SAAS,CAACQ;QACxB;IACJ;AACJ"}
|
|
@@ -1,4 +1,6 @@
|
|
|
1
1
|
export { useRouter } from "./hooks/useRouter.js";
|
|
2
2
|
export { useRoute } from "./hooks/useRoute.js";
|
|
3
|
+
export { RouteParamsSync } from "./components/RouteParamsSync.js";
|
|
4
|
+
export type { RouteParamField, RouteParamFieldBuilder, RouteParamFieldConfig } from "./components/RouteParamsSync.js";
|
|
3
5
|
export { RouteElementRegistry } from "./abstractions.js";
|
|
4
6
|
export type { ReactRoute } from "./types.js";
|
package/types.d.ts
CHANGED
|
@@ -1,34 +1,13 @@
|
|
|
1
1
|
import type * as React from "react";
|
|
2
2
|
import type { CSSProperties } from "react";
|
|
3
3
|
import { Plugin } from "@webiny/plugins/types.js";
|
|
4
|
-
import type { ApolloClient } from "apollo-client";
|
|
5
4
|
export type GenericRecordKey = string | number | symbol;
|
|
6
5
|
export type GenericRecord<K extends GenericRecordKey = GenericRecordKey, V = any> = Record<K, V>;
|
|
7
6
|
export type NonEmptyArray<T> = [T, ...T[]];
|
|
8
|
-
export type UploadOptions = {
|
|
9
|
-
apolloClient: ApolloClient<object>;
|
|
10
|
-
onProgress?: (params: {
|
|
11
|
-
sent: number;
|
|
12
|
-
total: number;
|
|
13
|
-
percentage: number;
|
|
14
|
-
}) => void;
|
|
15
|
-
};
|
|
16
7
|
export type UiStatePlugin = Plugin & {
|
|
17
8
|
type: "ui-state";
|
|
18
9
|
render(): React.ReactElement;
|
|
19
10
|
};
|
|
20
|
-
export interface UploadedFile {
|
|
21
|
-
id: string;
|
|
22
|
-
name: string;
|
|
23
|
-
type: string;
|
|
24
|
-
size: number;
|
|
25
|
-
key: string;
|
|
26
|
-
}
|
|
27
|
-
export type FileUploaderPlugin = Plugin & {
|
|
28
|
-
type: "file-uploader";
|
|
29
|
-
name: "file-uploader";
|
|
30
|
-
upload(file: File, options: UploadOptions): Promise<UploadedFile>;
|
|
31
|
-
};
|
|
32
11
|
export type { Plugin };
|
|
33
12
|
export interface ImageProps {
|
|
34
13
|
src: string;
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
import { BaseEvent } from "../../features/eventPublisher/index.js";
|
|
2
|
-
export interface GraphQLExtensionsPayload {
|
|
3
|
-
endpoint: string;
|
|
4
|
-
operationName?: string;
|
|
5
|
-
extensions: Record<string, any>;
|
|
6
|
-
}
|
|
7
|
-
/**
|
|
8
|
-
* Published when a GraphQL response carries `extensions`.
|
|
9
|
-
*
|
|
10
|
-
* `execute` returns only `data`, so extensions would otherwise be unreachable to anything outside
|
|
11
|
-
* this client - a decorator sees the return value, which is already past them. Publishing keeps that
|
|
12
|
-
* contract intact while letting an interested feature observe them, without this package needing to
|
|
13
|
-
* know who is listening.
|
|
14
|
-
*/
|
|
15
|
-
export declare class GraphQLExtensionsEvent extends BaseEvent<GraphQLExtensionsPayload> {
|
|
16
|
-
eventType: "graphql.extensions";
|
|
17
|
-
getHandlerAbstraction(): import("@webiny/di").Abstraction<import("~/features/eventPublisher/index.js").IEventHandler<GraphQLExtensionsEvent>>;
|
|
18
|
-
}
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
import { BaseEvent } from "../eventPublisher/index.js";
|
|
2
|
-
import { GraphQLExtensionsEventHandler } from "./abstractions.js";
|
|
3
|
-
class GraphQLExtensionsEvent extends BaseEvent {
|
|
4
|
-
getHandlerAbstraction() {
|
|
5
|
-
return GraphQLExtensionsEventHandler;
|
|
6
|
-
}
|
|
7
|
-
constructor(...args){
|
|
8
|
-
super(...args), this.eventType = "graphql.extensions";
|
|
9
|
-
}
|
|
10
|
-
}
|
|
11
|
-
export { GraphQLExtensionsEvent };
|
|
12
|
-
|
|
13
|
-
//# sourceMappingURL=GraphQLExtensionsEvent.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"features/graphqlClient/GraphQLExtensionsEvent.js","sources":["../../../src/features/graphqlClient/GraphQLExtensionsEvent.ts"],"sourcesContent":["import { BaseEvent } from \"~/features/eventPublisher/index.js\";\nimport { GraphQLExtensionsEventHandler } from \"./abstractions.js\";\n\nexport interface GraphQLExtensionsPayload {\n endpoint: string;\n operationName?: string;\n extensions: Record<string, any>;\n}\n\n/**\n * Published when a GraphQL response carries `extensions`.\n *\n * `execute` returns only `data`, so extensions would otherwise be unreachable to anything outside\n * this client - a decorator sees the return value, which is already past them. Publishing keeps that\n * contract intact while letting an interested feature observe them, without this package needing to\n * know who is listening.\n */\nexport class GraphQLExtensionsEvent extends BaseEvent<GraphQLExtensionsPayload> {\n eventType = \"graphql.extensions\" as const;\n\n getHandlerAbstraction() {\n return GraphQLExtensionsEventHandler;\n }\n}\n"],"names":["GraphQLExtensionsEvent","BaseEvent","GraphQLExtensionsEventHandler"],"mappings":";;AAiBO,MAAMA,+BAA+BC;IAGxC,wBAAwB;QACpB,OAAOC;IACX;;QALG,qBACH,SAAS,GAAG;;AAKhB"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export { useAutocomplete } from "./useAutocomplete.js";
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export { useAutocomplete } from "./useAutocomplete.js";
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
import type { DocumentNode } from "graphql";
|
|
2
|
-
interface UseAutocompleteHook {
|
|
3
|
-
options: any[];
|
|
4
|
-
onInput(value: string): void;
|
|
5
|
-
}
|
|
6
|
-
interface Props {
|
|
7
|
-
query: DocumentNode;
|
|
8
|
-
search?: string | ((value: string) => string);
|
|
9
|
-
}
|
|
10
|
-
export declare const useAutocomplete: (props: Props) => UseAutocompleteHook;
|
|
11
|
-
export {};
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
import { useDataList } from "../useDataList/index.js";
|
|
2
|
-
import debounce from "lodash/debounce.js";
|
|
3
|
-
const useAutocomplete = (props)=>{
|
|
4
|
-
const dataList = useDataList(props);
|
|
5
|
-
return {
|
|
6
|
-
options: dataList.data || [],
|
|
7
|
-
onInput: debounce((query)=>{
|
|
8
|
-
if (!query) return;
|
|
9
|
-
let search = props.search || query;
|
|
10
|
-
if ("function" == typeof search) search = search(query);
|
|
11
|
-
dataList.setSearch(search);
|
|
12
|
-
}, 250)
|
|
13
|
-
};
|
|
14
|
-
};
|
|
15
|
-
export { useAutocomplete };
|
|
16
|
-
|
|
17
|
-
//# sourceMappingURL=useAutocomplete.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"hooks/useAutocomplete/useAutocomplete.js","sources":["../../../src/hooks/useAutocomplete/useAutocomplete.ts"],"sourcesContent":["import { useDataList } from \"../useDataList/index.js\";\nimport debounce from \"lodash/debounce.js\";\nimport type { DocumentNode } from \"graphql\";\n\ninterface UseAutocompleteHook {\n options: any[];\n onInput(value: string): void;\n}\n\ninterface Props {\n query: DocumentNode;\n search?: string | ((value: string) => string);\n}\n\nexport const useAutocomplete = (props: Props): UseAutocompleteHook => {\n const dataList = useDataList(props);\n\n return {\n options: dataList.data || [],\n onInput: debounce(query => {\n if (!query) {\n return;\n }\n\n let search = props.search || query;\n if (typeof search === \"function\") {\n search = search(query);\n }\n\n dataList.setSearch(search);\n }, 250)\n };\n};\n"],"names":["useAutocomplete","props","dataList","useDataList","debounce","query","search"],"mappings":";;AAcO,MAAMA,kBAAkB,CAACC;IAC5B,MAAMC,WAAWC,YAAYF;IAE7B,OAAO;QACH,SAASC,SAAS,IAAI,IAAI,EAAE;QAC5B,SAASE,SAASC,CAAAA;YACd,IAAI,CAACA,OACD;YAGJ,IAAIC,SAASL,MAAM,MAAM,IAAII;YAC7B,IAAI,AAAkB,cAAlB,OAAOC,QACPA,SAASA,OAAOD;YAGpBH,SAAS,SAAS,CAACI;QACvB,GAAG;IACP;AACJ"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"hooks/useDataList/functions/getData.js","sources":["../../../../src/hooks/useDataList/functions/getData.ts"],"sourcesContent":["import searchDataByKey from \"./searchDataByKey.js\";\n\nexport default (response: Record<string, string>) => searchDataByKey(\"data\", response);\n"],"names":["response","searchDataByKey"],"mappings":";AAEA,gBAAgB,CAAAA,WAAqCC,gBAAgB,QAAQD"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"hooks/useDataList/functions/getError.js","sources":["../../../../src/hooks/useDataList/functions/getError.ts"],"sourcesContent":["import searchDataByKey from \"./searchDataByKey.js\";\n\nexport default (response: Record<string, string>) => searchDataByKey(\"error\", response);\n"],"names":["response","searchDataByKey"],"mappings":";AAEA,iBAAgB,CAAAA,WAAqCC,gBAAgB,SAASD"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"hooks/useDataList/functions/getMeta.js","sources":["../../../../src/hooks/useDataList/functions/getMeta.ts"],"sourcesContent":["import searchDataByKey from \"./searchDataByKey.js\";\n\nexport default (response: Record<string, string>) => searchDataByKey(\"meta\", response);\n"],"names":["response","searchDataByKey"],"mappings":";AAEA,gBAAgB,CAAAA,WAAqCC,gBAAgB,QAAQD"}
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
const searchDataByKey = (searchKey, object)=>{
|
|
2
|
-
if (!object || "object" != typeof object) return null;
|
|
3
|
-
if (object[searchKey]) return object[searchKey];
|
|
4
|
-
for(const key in object){
|
|
5
|
-
const value = searchDataByKey(searchKey, object[key]);
|
|
6
|
-
if (value) return value;
|
|
7
|
-
}
|
|
8
|
-
return null;
|
|
9
|
-
};
|
|
10
|
-
const functions_searchDataByKey = searchDataByKey;
|
|
11
|
-
export default functions_searchDataByKey;
|
|
12
|
-
|
|
13
|
-
//# sourceMappingURL=searchDataByKey.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"hooks/useDataList/functions/searchDataByKey.js","sources":["../../../../src/hooks/useDataList/functions/searchDataByKey.ts"],"sourcesContent":["const searchDataByKey = (searchKey: string, object: Record<string, any>): string | null => {\n if (!object || typeof object !== \"object\") {\n return null;\n }\n\n if (object[searchKey]) {\n return object[searchKey];\n }\n\n for (const key in object) {\n const value = searchDataByKey(searchKey, object[key]);\n if (value) {\n return value;\n }\n }\n\n return null;\n};\n\nexport default searchDataByKey;\n"],"names":["searchDataByKey","searchKey","object","key","value"],"mappings":"AAAA,MAAMA,kBAAkB,CAACC,WAAmBC;IACxC,IAAI,CAACA,UAAU,AAAkB,YAAlB,OAAOA,QAClB,OAAO;IAGX,IAAIA,MAAM,CAACD,UAAU,EACjB,OAAOC,MAAM,CAACD,UAAU;IAG5B,IAAK,MAAME,OAAOD,OAAQ;QACtB,MAAME,QAAQJ,gBAAgBC,WAAWC,MAAM,CAACC,IAAI;QACpD,IAAIC,OACA,OAAOA;IAEf;IAEA,OAAO;AACX;AAEA,kCAAeJ"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export { useDataList } from "./useDataList.js";
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export { useDataList } from "./useDataList.js";
|
|
@@ -1,35 +0,0 @@
|
|
|
1
|
-
import type { DocumentNode } from "graphql";
|
|
2
|
-
import type { ApolloClient } from "apollo-client";
|
|
3
|
-
export interface UseDataListParams {
|
|
4
|
-
variables?: ((params: UseDataListParams) => any) | object;
|
|
5
|
-
client?: ApolloClient<any>;
|
|
6
|
-
query: DocumentNode;
|
|
7
|
-
getData?: (data: any) => any;
|
|
8
|
-
getMeta?: (data: any) => any;
|
|
9
|
-
getError?: (data: any) => any;
|
|
10
|
-
}
|
|
11
|
-
export interface DataListProps {
|
|
12
|
-
__loadParams: any;
|
|
13
|
-
refresh: (params?: any) => void;
|
|
14
|
-
data: any[];
|
|
15
|
-
meta: any;
|
|
16
|
-
error: any;
|
|
17
|
-
loading: boolean;
|
|
18
|
-
isSelected: (item: any) => boolean;
|
|
19
|
-
select: (item: any) => void;
|
|
20
|
-
isMultiSelected: (item: any) => boolean;
|
|
21
|
-
isNoneMultiSelected: () => boolean;
|
|
22
|
-
isAllMultiSelected: () => boolean;
|
|
23
|
-
multiSelectAll: (value: boolean) => void;
|
|
24
|
-
getMultiSelected: () => any[];
|
|
25
|
-
setSearch: (search: any) => void;
|
|
26
|
-
setWhere: (where: any) => void;
|
|
27
|
-
setSorters: (sort: any) => void;
|
|
28
|
-
setPerPage: (perPage: number) => void;
|
|
29
|
-
setPreviousPage: (cursor: string) => void;
|
|
30
|
-
setNextPage: (cursor: string) => void;
|
|
31
|
-
multiSelect: (items: string | string[], value?: boolean) => void;
|
|
32
|
-
init: () => void;
|
|
33
|
-
}
|
|
34
|
-
declare const useDataList: (params: UseDataListParams) => DataListProps;
|
|
35
|
-
export { useDataList };
|