@vuu-ui/vuu-utils 5.0.0-alpha.2 → 5.0.0-alpha.4

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/package.json CHANGED
@@ -1,5 +1,5 @@
1
1
  {
2
- "version": "5.0.0-alpha.2",
2
+ "version": "5.0.0-alpha.4",
3
3
  "author": "heswell",
4
4
  "main": "./src/index.js",
5
5
  "license": "Apache-2.0",
@@ -15,14 +15,14 @@
15
15
  },
16
16
  "devDependencies": {
17
17
  "@dnd-kit/react": "^0.5.0",
18
- "@vuu-ui/vuu-data-types": "5.0.0-alpha.2",
19
- "@vuu-ui/vuu-table-types": "5.0.0-alpha.2",
20
- "@vuu-ui/vuu-filter-types": "5.0.0-alpha.2",
21
- "@vuu-ui/vuu-protocol-types": "5.0.0-alpha.2"
18
+ "@vuu-ui/vuu-data-types": "5.0.0-alpha.4",
19
+ "@vuu-ui/vuu-table-types": "5.0.0-alpha.4",
20
+ "@vuu-ui/vuu-filter-types": "5.0.0-alpha.4",
21
+ "@vuu-ui/vuu-protocol-types": "5.0.0-alpha.4"
22
22
  },
23
23
  "peerDependencies": {
24
24
  "@internationalized/date": "^3.0.0",
25
- "@vuu-ui/vuu-filter-parser": "5.0.0-alpha.2",
25
+ "@vuu-ui/vuu-filter-parser": "5.0.0-alpha.4",
26
26
  "clsx": "^2.0.0",
27
27
  "react": "^19.2.3",
28
28
  "react-dom": "^19.2.3"
package/src/index.js CHANGED
@@ -72,4 +72,5 @@ export { WidthHeight, WidthOnly, useResizeObserver } from "./useResizeObserver.j
72
72
  export { DataContext } from "./context-definitions/DataContext.js";
73
73
  export { DataSourceProvider, useDataSource } from "./context-definitions/DataSourceProvider.js";
74
74
  export { PageVisibilityObserver } from "./PageVisibilityObserver.js";
75
+ export { getTypeaheadParams, useTypeaheadSuggestions } from "./useTypeaheadSuggestions.js";
75
76
  export { ThemeLoadChecker } from "./theme-utils.js";
@@ -0,0 +1,50 @@
1
+ import { useDataSource } from "./context-definitions/DataSourceProvider.js";
2
+ import { useCallback } from "react";
3
+ const getTypeaheadParams = (table, column, text = "", selectedValues = [])=>{
4
+ if ("" !== text && !selectedValues.includes(text.toLowerCase())) return [
5
+ table,
6
+ column,
7
+ text
8
+ ];
9
+ return [
10
+ table,
11
+ column
12
+ ];
13
+ };
14
+ const useTypeaheadSuggestions = ()=>{
15
+ const dataSource = useDataSource(false);
16
+ return useCallback(async ([{ module, table }, column, starts])=>{
17
+ if (void 0 === dataSource) {
18
+ console.warn("[useTypeaheadSuggestions] no dataSource provided (use DataSourceProvider)");
19
+ return false;
20
+ }
21
+ const rpcMessage = void 0 === starts ? {
22
+ params: {
23
+ column,
24
+ module,
25
+ table
26
+ },
27
+ rpcName: "getUniqueFieldValues",
28
+ type: "RPC_REQUEST"
29
+ } : {
30
+ params: {
31
+ column,
32
+ module,
33
+ starts,
34
+ table
35
+ },
36
+ rpcName: "getUniqueFieldValuesStartingWith",
37
+ type: "RPC_REQUEST"
38
+ };
39
+ try {
40
+ const response = await dataSource.rpcRequest?.(rpcMessage);
41
+ if (response?.type === "SUCCESS_RESULT") return response.data;
42
+ return false;
43
+ } catch (err) {
44
+ return false;
45
+ }
46
+ }, [
47
+ dataSource
48
+ ]);
49
+ };
50
+ export { getTypeaheadParams, useTypeaheadSuggestions };
@@ -66,6 +66,7 @@ export declare const stripFilterFromColumns: (columns: RuntimeColumnDescriptor[]
66
66
  valueFormatter: import("@vuu-ui/vuu-table-types").ValueFormatter;
67
67
  width: number;
68
68
  editable?: import("@vuu-ui/vuu-data-types").DataEditable;
69
+ editor?: import("@vuu-ui/vuu-data-types").DataValueEditor;
69
70
  editableBulk?: import("@vuu-ui/vuu-data-types").BulkEdit;
70
71
  name: string;
71
72
  required?: boolean;
package/types/index.d.ts CHANGED
@@ -73,5 +73,6 @@ export * from "./context-definitions/DataProvider";
73
73
  export { DataSourceProvider, useDataSource, } from "./context-definitions/DataSourceProvider";
74
74
  export * from "./context-definitions/WorkspaceContext";
75
75
  export { PageVisibilityObserver } from "./PageVisibilityObserver";
76
+ export { getTypeaheadParams, useTypeaheadSuggestions, } from "./useTypeaheadSuggestions";
76
77
  export * from "./ShellContext";
77
78
  export { ThemeLoadChecker } from "./theme-utils";
@@ -0,0 +1,4 @@
1
+ import { SuggestionFetcher, TableSchemaTable } from "@vuu-ui/vuu-data-types";
2
+ import { TypeaheadParams } from "@vuu-ui/vuu-protocol-types";
3
+ export declare const getTypeaheadParams: (table: TableSchemaTable, column: string, text?: string, selectedValues?: string[]) => TypeaheadParams;
4
+ export declare const useTypeaheadSuggestions: () => SuggestionFetcher;