@vuu-ui/vuu-data-react 0.13.15 → 0.13.17
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.
|
@@ -10,29 +10,45 @@ const getTypeaheadParams = (table, column, text = "", selectedValues = []) => {
|
|
|
10
10
|
return [table, column];
|
|
11
11
|
};
|
|
12
12
|
const useTypeaheadSuggestions = () => {
|
|
13
|
-
const
|
|
13
|
+
const dataSource = vuuUtils.useDataSource(false);
|
|
14
14
|
return react.useCallback(
|
|
15
|
-
async (
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
15
|
+
async ([{ module, table }, column, starts]) => {
|
|
16
|
+
if (dataSource === void 0) {
|
|
17
|
+
console.warn(
|
|
18
|
+
`[useTypeaheadSuggestions] no dataSource provided (use DataSourceProvider)`
|
|
19
|
+
);
|
|
20
|
+
return false;
|
|
21
|
+
}
|
|
22
|
+
const rpcMessage = starts === void 0 ? {
|
|
23
|
+
params: {
|
|
24
|
+
column,
|
|
25
|
+
module,
|
|
26
|
+
table
|
|
27
|
+
},
|
|
28
|
+
rpcName: "getUniqueFieldValues",
|
|
29
|
+
type: "RPC_REQUEST"
|
|
21
30
|
} : {
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
31
|
+
params: {
|
|
32
|
+
column,
|
|
33
|
+
module,
|
|
34
|
+
starts,
|
|
35
|
+
table
|
|
36
|
+
},
|
|
37
|
+
rpcName: "getUniqueFieldValuesStartingWith",
|
|
38
|
+
type: "RPC_REQUEST"
|
|
26
39
|
};
|
|
27
40
|
try {
|
|
28
|
-
const
|
|
29
|
-
|
|
30
|
-
|
|
41
|
+
const response = await dataSource.rpcCall?.(rpcMessage);
|
|
42
|
+
if (response?.type === "SUCCESS_RESULT") {
|
|
43
|
+
return response.data;
|
|
44
|
+
} else {
|
|
45
|
+
return false;
|
|
46
|
+
}
|
|
31
47
|
} catch (err) {
|
|
32
48
|
return false;
|
|
33
49
|
}
|
|
34
50
|
},
|
|
35
|
-
[
|
|
51
|
+
[dataSource]
|
|
36
52
|
);
|
|
37
53
|
};
|
|
38
54
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useTypeaheadSuggestions.js","sources":["../../../../packages/vuu-data-react/src/hooks/useTypeaheadSuggestions.ts"],"sourcesContent":["import { SuggestionFetcher, TableSchemaTable } from \"@vuu-ui/vuu-data-types\";\nimport {\n
|
|
1
|
+
{"version":3,"file":"useTypeaheadSuggestions.js","sources":["../../../../packages/vuu-data-react/src/hooks/useTypeaheadSuggestions.ts"],"sourcesContent":["import { SuggestionFetcher, TableSchemaTable } from \"@vuu-ui/vuu-data-types\";\nimport {\n RpcResultError,\n RpcResultSuccess,\n TypeaheadParams,\n VuuRpcServiceRequest,\n} from \"@vuu-ui/vuu-protocol-types\";\nimport { useDataSource } from \"@vuu-ui/vuu-utils\";\nimport { useCallback } from \"react\";\n\nexport const getTypeaheadParams = (\n table: TableSchemaTable,\n column: string,\n text = \"\",\n selectedValues: string[] = [],\n): TypeaheadParams => {\n if (text !== \"\" && !selectedValues.includes(text.toLowerCase())) {\n return [table, column, text];\n }\n return [table, column];\n};\n\nexport const useTypeaheadSuggestions = () => {\n const dataSource = useDataSource(false);\n return useCallback<SuggestionFetcher>(\n async ([{ module, table }, column, starts]: TypeaheadParams) => {\n if (dataSource === undefined) {\n console.warn(\n `[useTypeaheadSuggestions] no dataSource provided (use DataSourceProvider)`,\n );\n return false;\n }\n const rpcMessage: Omit<VuuRpcServiceRequest, \"context\"> =\n starts === undefined\n ? {\n params: {\n column,\n module,\n table,\n },\n rpcName: \"getUniqueFieldValues\",\n type: \"RPC_REQUEST\",\n }\n : {\n params: {\n column,\n module,\n starts,\n table,\n },\n rpcName: \"getUniqueFieldValuesStartingWith\",\n type: \"RPC_REQUEST\",\n };\n\n try {\n // We don't just return rpcCall . In the case of an\n // error we will be returning the rejected promise, bypassing\n // the catch block below.\n const response = await dataSource.rpcCall?.<\n RpcResultSuccess | RpcResultError\n >(rpcMessage);\n if (response?.type === \"SUCCESS_RESULT\") {\n return response.data as string[];\n } else {\n return false;\n }\n } catch (err) {\n return false;\n }\n },\n [dataSource],\n );\n};\n"],"names":["useDataSource","useCallback"],"mappings":";;;;;AAUa,MAAA,kBAAA,GAAqB,CAChC,KACA,EAAA,MAAA,EACA,OAAO,EACP,EAAA,cAAA,GAA2B,EACP,KAAA;AACpB,EAAI,IAAA,IAAA,KAAS,MAAM,CAAC,cAAA,CAAe,SAAS,IAAK,CAAA,WAAA,EAAa,CAAG,EAAA;AAC/D,IAAO,OAAA,CAAC,KAAO,EAAA,MAAA,EAAQ,IAAI,CAAA;AAAA;AAE7B,EAAO,OAAA,CAAC,OAAO,MAAM,CAAA;AACvB;AAEO,MAAM,0BAA0B,MAAM;AAC3C,EAAM,MAAA,UAAA,GAAaA,uBAAc,KAAK,CAAA;AACtC,EAAO,OAAAC,iBAAA;AAAA,IACL,OAAO,CAAC,EAAE,MAAA,EAAQ,OAAS,EAAA,MAAA,EAAQ,MAAM,CAAuB,KAAA;AAC9D,MAAA,IAAI,eAAe,KAAW,CAAA,EAAA;AAC5B,QAAQ,OAAA,CAAA,IAAA;AAAA,UACN,CAAA,yEAAA;AAAA,SACF;AACA,QAAO,OAAA,KAAA;AAAA;AAET,MAAM,MAAA,UAAA,GACJ,WAAW,KACP,CAAA,GAAA;AAAA,QACE,MAAQ,EAAA;AAAA,UACN,MAAA;AAAA,UACA,MAAA;AAAA,UACA;AAAA,SACF;AAAA,QACA,OAAS,EAAA,sBAAA;AAAA,QACT,IAAM,EAAA;AAAA,OAER,GAAA;AAAA,QACE,MAAQ,EAAA;AAAA,UACN,MAAA;AAAA,UACA,MAAA;AAAA,UACA,MAAA;AAAA,UACA;AAAA,SACF;AAAA,QACA,OAAS,EAAA,kCAAA;AAAA,QACT,IAAM,EAAA;AAAA,OACR;AAEN,MAAI,IAAA;AAIF,QAAA,MAAM,QAAW,GAAA,MAAM,UAAW,CAAA,OAAA,GAEhC,UAAU,CAAA;AACZ,QAAI,IAAA,QAAA,EAAU,SAAS,gBAAkB,EAAA;AACvC,UAAA,OAAO,QAAS,CAAA,IAAA;AAAA,SACX,MAAA;AACL,UAAO,OAAA,KAAA;AAAA;AACT,eACO,GAAK,EAAA;AACZ,QAAO,OAAA,KAAA;AAAA;AACT,KACF;AAAA,IACA,CAAC,UAAU;AAAA,GACb;AACF;;;;;"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { useDataSource } from '@vuu-ui/vuu-utils';
|
|
2
2
|
import { useCallback } from 'react';
|
|
3
3
|
|
|
4
4
|
const getTypeaheadParams = (table, column, text = "", selectedValues = []) => {
|
|
@@ -8,29 +8,45 @@ const getTypeaheadParams = (table, column, text = "", selectedValues = []) => {
|
|
|
8
8
|
return [table, column];
|
|
9
9
|
};
|
|
10
10
|
const useTypeaheadSuggestions = () => {
|
|
11
|
-
const
|
|
11
|
+
const dataSource = useDataSource(false);
|
|
12
12
|
return useCallback(
|
|
13
|
-
async (
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
13
|
+
async ([{ module, table }, column, starts]) => {
|
|
14
|
+
if (dataSource === void 0) {
|
|
15
|
+
console.warn(
|
|
16
|
+
`[useTypeaheadSuggestions] no dataSource provided (use DataSourceProvider)`
|
|
17
|
+
);
|
|
18
|
+
return false;
|
|
19
|
+
}
|
|
20
|
+
const rpcMessage = starts === void 0 ? {
|
|
21
|
+
params: {
|
|
22
|
+
column,
|
|
23
|
+
module,
|
|
24
|
+
table
|
|
25
|
+
},
|
|
26
|
+
rpcName: "getUniqueFieldValues",
|
|
27
|
+
type: "RPC_REQUEST"
|
|
19
28
|
} : {
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
29
|
+
params: {
|
|
30
|
+
column,
|
|
31
|
+
module,
|
|
32
|
+
starts,
|
|
33
|
+
table
|
|
34
|
+
},
|
|
35
|
+
rpcName: "getUniqueFieldValuesStartingWith",
|
|
36
|
+
type: "RPC_REQUEST"
|
|
24
37
|
};
|
|
25
38
|
try {
|
|
26
|
-
const
|
|
27
|
-
|
|
28
|
-
|
|
39
|
+
const response = await dataSource.rpcCall?.(rpcMessage);
|
|
40
|
+
if (response?.type === "SUCCESS_RESULT") {
|
|
41
|
+
return response.data;
|
|
42
|
+
} else {
|
|
43
|
+
return false;
|
|
44
|
+
}
|
|
29
45
|
} catch (err) {
|
|
30
46
|
return false;
|
|
31
47
|
}
|
|
32
48
|
},
|
|
33
|
-
[
|
|
49
|
+
[dataSource]
|
|
34
50
|
);
|
|
35
51
|
};
|
|
36
52
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useTypeaheadSuggestions.js","sources":["../../../../packages/vuu-data-react/src/hooks/useTypeaheadSuggestions.ts"],"sourcesContent":["import { SuggestionFetcher, TableSchemaTable } from \"@vuu-ui/vuu-data-types\";\nimport {\n
|
|
1
|
+
{"version":3,"file":"useTypeaheadSuggestions.js","sources":["../../../../packages/vuu-data-react/src/hooks/useTypeaheadSuggestions.ts"],"sourcesContent":["import { SuggestionFetcher, TableSchemaTable } from \"@vuu-ui/vuu-data-types\";\nimport {\n RpcResultError,\n RpcResultSuccess,\n TypeaheadParams,\n VuuRpcServiceRequest,\n} from \"@vuu-ui/vuu-protocol-types\";\nimport { useDataSource } from \"@vuu-ui/vuu-utils\";\nimport { useCallback } from \"react\";\n\nexport const getTypeaheadParams = (\n table: TableSchemaTable,\n column: string,\n text = \"\",\n selectedValues: string[] = [],\n): TypeaheadParams => {\n if (text !== \"\" && !selectedValues.includes(text.toLowerCase())) {\n return [table, column, text];\n }\n return [table, column];\n};\n\nexport const useTypeaheadSuggestions = () => {\n const dataSource = useDataSource(false);\n return useCallback<SuggestionFetcher>(\n async ([{ module, table }, column, starts]: TypeaheadParams) => {\n if (dataSource === undefined) {\n console.warn(\n `[useTypeaheadSuggestions] no dataSource provided (use DataSourceProvider)`,\n );\n return false;\n }\n const rpcMessage: Omit<VuuRpcServiceRequest, \"context\"> =\n starts === undefined\n ? {\n params: {\n column,\n module,\n table,\n },\n rpcName: \"getUniqueFieldValues\",\n type: \"RPC_REQUEST\",\n }\n : {\n params: {\n column,\n module,\n starts,\n table,\n },\n rpcName: \"getUniqueFieldValuesStartingWith\",\n type: \"RPC_REQUEST\",\n };\n\n try {\n // We don't just return rpcCall . In the case of an\n // error we will be returning the rejected promise, bypassing\n // the catch block below.\n const response = await dataSource.rpcCall?.<\n RpcResultSuccess | RpcResultError\n >(rpcMessage);\n if (response?.type === \"SUCCESS_RESULT\") {\n return response.data as string[];\n } else {\n return false;\n }\n } catch (err) {\n return false;\n }\n },\n [dataSource],\n );\n};\n"],"names":[],"mappings":";;;AAUa,MAAA,kBAAA,GAAqB,CAChC,KACA,EAAA,MAAA,EACA,OAAO,EACP,EAAA,cAAA,GAA2B,EACP,KAAA;AACpB,EAAI,IAAA,IAAA,KAAS,MAAM,CAAC,cAAA,CAAe,SAAS,IAAK,CAAA,WAAA,EAAa,CAAG,EAAA;AAC/D,IAAO,OAAA,CAAC,KAAO,EAAA,MAAA,EAAQ,IAAI,CAAA;AAAA;AAE7B,EAAO,OAAA,CAAC,OAAO,MAAM,CAAA;AACvB;AAEO,MAAM,0BAA0B,MAAM;AAC3C,EAAM,MAAA,UAAA,GAAa,cAAc,KAAK,CAAA;AACtC,EAAO,OAAA,WAAA;AAAA,IACL,OAAO,CAAC,EAAE,MAAA,EAAQ,OAAS,EAAA,MAAA,EAAQ,MAAM,CAAuB,KAAA;AAC9D,MAAA,IAAI,eAAe,KAAW,CAAA,EAAA;AAC5B,QAAQ,OAAA,CAAA,IAAA;AAAA,UACN,CAAA,yEAAA;AAAA,SACF;AACA,QAAO,OAAA,KAAA;AAAA;AAET,MAAM,MAAA,UAAA,GACJ,WAAW,KACP,CAAA,GAAA;AAAA,QACE,MAAQ,EAAA;AAAA,UACN,MAAA;AAAA,UACA,MAAA;AAAA,UACA;AAAA,SACF;AAAA,QACA,OAAS,EAAA,sBAAA;AAAA,QACT,IAAM,EAAA;AAAA,OAER,GAAA;AAAA,QACE,MAAQ,EAAA;AAAA,UACN,MAAA;AAAA,UACA,MAAA;AAAA,UACA,MAAA;AAAA,UACA;AAAA,SACF;AAAA,QACA,OAAS,EAAA,kCAAA;AAAA,QACT,IAAM,EAAA;AAAA,OACR;AAEN,MAAI,IAAA;AAIF,QAAA,MAAM,QAAW,GAAA,MAAM,UAAW,CAAA,OAAA,GAEhC,UAAU,CAAA;AACZ,QAAI,IAAA,QAAA,EAAU,SAAS,gBAAkB,EAAA;AACvC,UAAA,OAAO,QAAS,CAAA,IAAA;AAAA,SACX,MAAA;AACL,UAAO,OAAA,KAAA;AAAA;AACT,eACO,GAAK,EAAA;AACZ,QAAO,OAAA,KAAA;AAAA;AACT,KACF;AAAA,IACA,CAAC,UAAU;AAAA,GACb;AACF;;;;"}
|
package/package.json
CHANGED
|
@@ -1,23 +1,23 @@
|
|
|
1
1
|
{
|
|
2
|
-
"version": "0.13.
|
|
2
|
+
"version": "0.13.17",
|
|
3
3
|
"author": "heswell",
|
|
4
4
|
"license": "Apache-2.0",
|
|
5
5
|
"devDependencies": {
|
|
6
|
-
"@vuu-ui/vuu-data-types": "0.13.
|
|
7
|
-
"@vuu-ui/vuu-filter-types": "0.13.
|
|
8
|
-
"@vuu-ui/vuu-popups": "0.13.
|
|
9
|
-
"@vuu-ui/vuu-protocol-types": "0.13.
|
|
10
|
-
"@vuu-ui/vuu-table-types": "0.13.
|
|
6
|
+
"@vuu-ui/vuu-data-types": "0.13.17",
|
|
7
|
+
"@vuu-ui/vuu-filter-types": "0.13.17",
|
|
8
|
+
"@vuu-ui/vuu-popups": "0.13.17",
|
|
9
|
+
"@vuu-ui/vuu-protocol-types": "0.13.17",
|
|
10
|
+
"@vuu-ui/vuu-table-types": "0.13.17"
|
|
11
11
|
},
|
|
12
12
|
"dependencies": {
|
|
13
|
-
"@vuu-ui/vuu-context-menu": "0.13.
|
|
14
|
-
"@vuu-ui/vuu-data-remote": "0.13.
|
|
15
|
-
"@vuu-ui/vuu-filter-parser": "0.13.
|
|
16
|
-
"@vuu-ui/vuu-layout": "0.13.
|
|
17
|
-
"@vuu-ui/vuu-popups": "0.13.
|
|
18
|
-
"@vuu-ui/vuu-ui-controls": "0.13.
|
|
19
|
-
"@vuu-ui/vuu-utils": "0.13.
|
|
20
|
-
"@vuu-ui/vuu-table": "0.13.
|
|
13
|
+
"@vuu-ui/vuu-context-menu": "0.13.17",
|
|
14
|
+
"@vuu-ui/vuu-data-remote": "0.13.17",
|
|
15
|
+
"@vuu-ui/vuu-filter-parser": "0.13.17",
|
|
16
|
+
"@vuu-ui/vuu-layout": "0.13.17",
|
|
17
|
+
"@vuu-ui/vuu-popups": "0.13.17",
|
|
18
|
+
"@vuu-ui/vuu-ui-controls": "0.13.17",
|
|
19
|
+
"@vuu-ui/vuu-utils": "0.13.17",
|
|
20
|
+
"@vuu-ui/vuu-table": "0.13.17",
|
|
21
21
|
"@salt-ds/core": "1.43.0",
|
|
22
22
|
"@salt-ds/styles": "0.2.1",
|
|
23
23
|
"@salt-ds/window": "0.1.1"
|