@pipe0/react-sdk 0.0.3 → 0.0.5
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/dist/hooks/usePipeCatalogTable.d.ts +39 -0
- package/dist/hooks/usePipeCatalogTable.d.ts.map +1 -0
- package/dist/hooks/usePipeCatalogTable.js +134 -0
- package/dist/index.d.ts +3 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +2 -0
- package/package.json +21 -15
- package/CHANGELOG.md +0 -17
- package/eslint.config.mjs +0 -4
- package/src/hooks/usePipeCatalogTable.ts +0 -208
- package/src/index.ts +0 -2
- package/tsconfig.json +0 -29
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import { type PipeCatalogTableData, type PipeCategory, type PipeId } from "@pipe0/client-sdk";
|
|
2
|
+
import { type ColumnFilter } from "@tanstack/react-table";
|
|
3
|
+
export declare function useDebounce(cb: (v: string) => unknown, config?: {
|
|
4
|
+
initialValue?: string;
|
|
5
|
+
timeout?: number;
|
|
6
|
+
}): readonly [string, import("react").Dispatch<import("react").SetStateAction<string>>, (v: string) => void];
|
|
7
|
+
export type InputFieldEntries = Record<string, PipeId[]>;
|
|
8
|
+
export type OutputFieldEntries = Record<string, PipeId[]>;
|
|
9
|
+
export declare function usePipeCatalogTable(config?: {
|
|
10
|
+
initialColumnFilters?: ColumnFilter[];
|
|
11
|
+
}): {
|
|
12
|
+
table: import("@tanstack/react-table").Table<PipeCatalogTableData>;
|
|
13
|
+
sidebar: {
|
|
14
|
+
sortedInputFieldEntries: [string, ("run:prompt@1" | "company:newssummary:website@1" | "website:technologystack:builtwith@1" | "company:websiteurl:email@1" | "people:workemail:waterfall@1" | "people:is:workemail@1" | "people:split:name@1" | "people:join:name@1" | "people:professionalprofile:waterfall@1" | "people:professionalprofileurl:name@1" | "people:professionalprofileurl:email:waterfall@1" | "people:personalemail:professionalprofile:waterfall@1" | "people:validate:email:zerobounce@1" | "people:mobilenumber:professionalprofile:waterfall@1" | "people:mobilenumber:workemail:waterfall@1" | "company:profile:builtwith@1" | "company:identity@1" | "company:overview@1")[]][];
|
|
15
|
+
sortedOutputFieldEntries: [string, ("run:prompt@1" | "company:newssummary:website@1" | "website:technologystack:builtwith@1" | "company:websiteurl:email@1" | "people:workemail:waterfall@1" | "people:is:workemail@1" | "people:split:name@1" | "people:join:name@1" | "people:professionalprofile:waterfall@1" | "people:professionalprofileurl:name@1" | "people:professionalprofileurl:email:waterfall@1" | "people:personalemail:professionalprofile:waterfall@1" | "people:validate:email:zerobounce@1" | "people:mobilenumber:professionalprofile:waterfall@1" | "people:mobilenumber:workemail:waterfall@1" | "company:profile:builtwith@1" | "company:identity@1" | "company:overview@1")[]][];
|
|
16
|
+
sortedTagEntries: [string, ("run:prompt@1" | "company:newssummary:website@1" | "website:technologystack:builtwith@1" | "company:websiteurl:email@1" | "people:workemail:waterfall@1" | "people:is:workemail@1" | "people:split:name@1" | "people:join:name@1" | "people:professionalprofile:waterfall@1" | "people:professionalprofileurl:name@1" | "people:professionalprofileurl:email:waterfall@1" | "people:personalemail:professionalprofile:waterfall@1" | "people:validate:email:zerobounce@1" | "people:mobilenumber:professionalprofile:waterfall@1" | "people:mobilenumber:workemail:waterfall@1" | "company:profile:builtwith@1" | "company:identity@1" | "company:overview@1")[]][];
|
|
17
|
+
sortedProviderEntries: [string, ("run:prompt@1" | "company:newssummary:website@1" | "website:technologystack:builtwith@1" | "company:websiteurl:email@1" | "people:workemail:waterfall@1" | "people:is:workemail@1" | "people:split:name@1" | "people:join:name@1" | "people:professionalprofile:waterfall@1" | "people:professionalprofileurl:name@1" | "people:professionalprofileurl:email:waterfall@1" | "people:personalemail:professionalprofile:waterfall@1" | "people:validate:email:zerobounce@1" | "people:mobilenumber:professionalprofile:waterfall@1" | "people:mobilenumber:workemail:waterfall@1" | "company:profile:builtwith@1" | "company:identity@1" | "company:overview@1")[]][];
|
|
18
|
+
pipeIdsByInputField: Record<string, ("run:prompt@1" | "company:newssummary:website@1" | "website:technologystack:builtwith@1" | "company:websiteurl:email@1" | "people:workemail:waterfall@1" | "people:is:workemail@1" | "people:split:name@1" | "people:join:name@1" | "people:professionalprofile:waterfall@1" | "people:professionalprofileurl:name@1" | "people:professionalprofileurl:email:waterfall@1" | "people:personalemail:professionalprofile:waterfall@1" | "people:validate:email:zerobounce@1" | "people:mobilenumber:professionalprofile:waterfall@1" | "people:mobilenumber:workemail:waterfall@1" | "company:profile:builtwith@1" | "company:identity@1" | "company:overview@1")[]>;
|
|
19
|
+
pipeIdsByOutputField: Record<string, ("run:prompt@1" | "company:newssummary:website@1" | "website:technologystack:builtwith@1" | "company:websiteurl:email@1" | "people:workemail:waterfall@1" | "people:is:workemail@1" | "people:split:name@1" | "people:join:name@1" | "people:professionalprofile:waterfall@1" | "people:professionalprofileurl:name@1" | "people:professionalprofileurl:email:waterfall@1" | "people:personalemail:professionalprofile:waterfall@1" | "people:validate:email:zerobounce@1" | "people:mobilenumber:professionalprofile:waterfall@1" | "people:mobilenumber:workemail:waterfall@1" | "company:profile:builtwith@1" | "company:identity@1" | "company:overview@1")[]>;
|
|
20
|
+
pipeIdsByProvider: Record<string, ("run:prompt@1" | "company:newssummary:website@1" | "website:technologystack:builtwith@1" | "company:websiteurl:email@1" | "people:workemail:waterfall@1" | "people:is:workemail@1" | "people:split:name@1" | "people:join:name@1" | "people:professionalprofile:waterfall@1" | "people:professionalprofileurl:name@1" | "people:professionalprofileurl:email:waterfall@1" | "people:personalemail:professionalprofile:waterfall@1" | "people:validate:email:zerobounce@1" | "people:mobilenumber:professionalprofile:waterfall@1" | "people:mobilenumber:workemail:waterfall@1" | "company:profile:builtwith@1" | "company:identity@1" | "company:overview@1")[]>;
|
|
21
|
+
pipeIdsByTag: Record<string, ("run:prompt@1" | "company:newssummary:website@1" | "website:technologystack:builtwith@1" | "company:websiteurl:email@1" | "people:workemail:waterfall@1" | "people:is:workemail@1" | "people:split:name@1" | "people:join:name@1" | "people:professionalprofile:waterfall@1" | "people:professionalprofileurl:name@1" | "people:professionalprofileurl:email:waterfall@1" | "people:personalemail:professionalprofile:waterfall@1" | "people:validate:email:zerobounce@1" | "people:mobilenumber:professionalprofile:waterfall@1" | "people:mobilenumber:workemail:waterfall@1" | "company:profile:builtwith@1" | "company:identity@1" | "company:overview@1")[]>;
|
|
22
|
+
expandedSidebarSections: string[];
|
|
23
|
+
setExpandedSidebarSections: import("react").Dispatch<import("react").SetStateAction<string[]>>;
|
|
24
|
+
removeColumnFilter: (id: "inputFields" | "outputFields" | "tags" | "providers") => void;
|
|
25
|
+
addColumnFilter: (id: "inputFields" | "outputFields" | "tags" | "providers", value: string) => void;
|
|
26
|
+
};
|
|
27
|
+
pipeEntriesByBasePipe: Record<string, (import("@pipe0/client-sdk").PipeMetaCatalogEntry<"run:prompt@1" | "company:newssummary:website@1" | "website:technologystack:builtwith@1" | "company:websiteurl:email@1" | "people:workemail:waterfall@1" | "people:is:workemail@1" | "people:split:name@1" | "people:join:name@1" | "people:professionalprofile:waterfall@1" | "people:professionalprofileurl:name@1" | "people:professionalprofileurl:email:waterfall@1" | "people:personalemail:professionalprofile:waterfall@1" | "people:validate:email:zerobounce@1" | "people:mobilenumber:professionalprofile:waterfall@1" | "people:mobilenumber:workemail:waterfall@1" | "company:profile:builtwith@1" | "company:identity@1" | "company:overview@1"> & {
|
|
28
|
+
pipeId: PipeId;
|
|
29
|
+
})[]>;
|
|
30
|
+
filterByField: (id: "inputFields" | "outputFields", fieldName: string) => void;
|
|
31
|
+
globalFilterInput: string;
|
|
32
|
+
setGlobalFilterInput: import("react").Dispatch<import("react").SetStateAction<string>>;
|
|
33
|
+
isFilterChecked: (id: "inputFields" | "outputFields" | "tags" | "providers", value: string) => boolean;
|
|
34
|
+
resetColumnFilters: () => void;
|
|
35
|
+
category: PipeCategory;
|
|
36
|
+
setCategory: (category: PipeCategory | null) => void;
|
|
37
|
+
showFeaturedPipes: boolean;
|
|
38
|
+
};
|
|
39
|
+
//# sourceMappingURL=usePipeCatalogTable.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"usePipeCatalogTable.d.ts","sourceRoot":"","sources":["../../src/hooks/usePipeCatalogTable.ts"],"names":[],"mappings":"AAAA,OAAO,EAGL,KAAK,oBAAoB,EACzB,KAAK,YAAY,EACjB,KAAK,MAAM,EACZ,MAAM,mBAAmB,CAAC;AAC3B,OAAO,EACL,KAAK,YAAY,EAMlB,MAAM,uBAAuB,CAAC;AAG/B,wBAAgB,WAAW,CACzB,EAAE,EAAE,CAAC,CAAC,EAAE,MAAM,KAAK,OAAO,EAC1B,MAAM,GAAE;IAAE,YAAY,CAAC,EAAE,MAAM,CAAC;IAAC,OAAO,CAAC,EAAE,MAAM,CAAA;CAAO,2FAQjB,MAAM,WAc9C;AAED,MAAM,MAAM,iBAAiB,GAAG,MAAM,CAAC,MAAM,EAAE,MAAM,EAAE,CAAC,CAAC;AACzD,MAAM,MAAM,kBAAkB,GAAG,MAAM,CAAC,MAAM,EAAE,MAAM,EAAE,CAAC,CAAC;AA0B1D,wBAAgB,mBAAmB,CACjC,MAAM,GAAE;IACN,oBAAoB,CAAC,EAAE,YAAY,EAAE,CAAC;CAClC;;;;;;;;;;;;;iCAkFA,aAAa,GAAG,cAAc,GAAG,MAAM,GAAG,WAAW;8BAhBrD,aAAa,GAAG,cAAc,GAAG,MAAM,GAAG,WAAW,SAClD,MAAM;;;;;wBA4BT,aAAa,GAAG,cAAc,aACvB,MAAM;;;0BARb,aAAa,GAAG,cAAc,GAAG,MAAM,GAAG,WAAW,SAClD,MAAM;;;4BA1CgB,YAAY,GAAG,IAAI;;EA0FnD"}
|
|
@@ -0,0 +1,134 @@
|
|
|
1
|
+
import { getInitialTableData, getTableDataAggregates, } from "@pipe0/client-sdk";
|
|
2
|
+
import { createColumnHelper, getCoreRowModel, getFilteredRowModel, getPaginationRowModel, useReactTable, } from "@tanstack/react-table";
|
|
3
|
+
import { useCallback, useEffect, useMemo, useRef, useState } from "react";
|
|
4
|
+
export function useDebounce(cb, config = {}) {
|
|
5
|
+
const { initialValue = "", timeout = 400 } = config;
|
|
6
|
+
const [value, setValue] = useState(initialValue);
|
|
7
|
+
const cbRef = useRef(cb);
|
|
8
|
+
cbRef.current = cb;
|
|
9
|
+
const setImmediately = useCallback((v) => {
|
|
10
|
+
setValue(v);
|
|
11
|
+
cbRef.current(v);
|
|
12
|
+
}, []);
|
|
13
|
+
useEffect(() => {
|
|
14
|
+
const handle = setTimeout(() => {
|
|
15
|
+
cbRef.current(value);
|
|
16
|
+
}, timeout);
|
|
17
|
+
return () => clearTimeout(handle);
|
|
18
|
+
}, [value, timeout]);
|
|
19
|
+
return [value, setValue, setImmediately];
|
|
20
|
+
}
|
|
21
|
+
const columnHelper = createColumnHelper();
|
|
22
|
+
const columns = [
|
|
23
|
+
columnHelper.accessor("pipeId", {}),
|
|
24
|
+
columnHelper.accessor((row) => row.inputGroups.flatMap((g) => Object.keys(g.fields)).join(", "), {
|
|
25
|
+
id: "inputFields",
|
|
26
|
+
}),
|
|
27
|
+
columnHelper.accessor((row) => row.outputFields.join(", "), {
|
|
28
|
+
id: "outputFields",
|
|
29
|
+
}),
|
|
30
|
+
columnHelper.accessor((row) => row.tags.join(", "), {
|
|
31
|
+
id: "tags",
|
|
32
|
+
}),
|
|
33
|
+
columnHelper.accessor((row) => row.providers.join(", "), {
|
|
34
|
+
id: "providers",
|
|
35
|
+
}),
|
|
36
|
+
columnHelper.accessor((row) => row.categories.join(", "), {
|
|
37
|
+
id: "categories",
|
|
38
|
+
}),
|
|
39
|
+
];
|
|
40
|
+
export function usePipeCatalogTable(config = {}) {
|
|
41
|
+
const { initialColumnFilters: initialColumnFilters = [] } = config;
|
|
42
|
+
const initialTableData = useMemo(() => getInitialTableData(), []);
|
|
43
|
+
const table = useReactTable({
|
|
44
|
+
columns,
|
|
45
|
+
data: initialTableData,
|
|
46
|
+
getCoreRowModel: getCoreRowModel(),
|
|
47
|
+
getPaginationRowModel: getPaginationRowModel(),
|
|
48
|
+
getFilteredRowModel: getFilteredRowModel(),
|
|
49
|
+
initialState: {
|
|
50
|
+
columnFilters: initialColumnFilters,
|
|
51
|
+
pagination: {
|
|
52
|
+
pageSize: 10,
|
|
53
|
+
},
|
|
54
|
+
},
|
|
55
|
+
});
|
|
56
|
+
const columnFilters = table.getState().columnFilters;
|
|
57
|
+
const category = useMemo(() => columnFilters.find((e) => e.id === "categories" && e.value)
|
|
58
|
+
?.value || null, [columnFilters]);
|
|
59
|
+
const { pipeIdsByInputField, pipeIdsByOutputField, pipeIdsByTag, pipeIdsByProvider, sortedTagEntries, sortedInputFieldEntries, sortedOutputFieldEntries, sortedProviderEntries, pipeEntriesByBasePipe, } = useMemo(() => {
|
|
60
|
+
return getTableDataAggregates(initialTableData, category);
|
|
61
|
+
}, [category, initialTableData]);
|
|
62
|
+
const [expandedSidebarSections, setExpandedSidebarSections] = useState(["tags"]);
|
|
63
|
+
const setCategory = (category) => {
|
|
64
|
+
table.setGlobalFilter(null);
|
|
65
|
+
if (category) {
|
|
66
|
+
table.setColumnFilters([{ id: "categories", value: category }]);
|
|
67
|
+
}
|
|
68
|
+
else {
|
|
69
|
+
table.setColumnFilters([]);
|
|
70
|
+
}
|
|
71
|
+
};
|
|
72
|
+
const [globalFilterInput, setGlobalFilterInput, setGlobalFilterImmediately] = useDebounce((v) => {
|
|
73
|
+
if (v === table.getState().globalFilter)
|
|
74
|
+
return;
|
|
75
|
+
table.setGlobalFilter(v);
|
|
76
|
+
if (v) {
|
|
77
|
+
table.setColumnFilters([]);
|
|
78
|
+
}
|
|
79
|
+
});
|
|
80
|
+
const addColumnFilter = (id, value) => {
|
|
81
|
+
setGlobalFilterImmediately("");
|
|
82
|
+
table.setColumnFilters([
|
|
83
|
+
{ id: "categories", value: category },
|
|
84
|
+
{ id, value },
|
|
85
|
+
]);
|
|
86
|
+
};
|
|
87
|
+
const resetColumnFilters = () => {
|
|
88
|
+
setGlobalFilterImmediately("");
|
|
89
|
+
table.setColumnFilters([{ id: "categories", value: null }]);
|
|
90
|
+
};
|
|
91
|
+
const removeColumnFilter = (id) => {
|
|
92
|
+
table.getColumn(id)?.setFilterValue(null);
|
|
93
|
+
};
|
|
94
|
+
const isFilterChecked = (id, value) => {
|
|
95
|
+
return columnFilters.some((f) => f.id === id && f.value === value);
|
|
96
|
+
};
|
|
97
|
+
const filterByField = (id, fieldName) => {
|
|
98
|
+
setExpandedSidebarSections([id]);
|
|
99
|
+
setGlobalFilterImmediately("");
|
|
100
|
+
table.setColumnFilters([
|
|
101
|
+
{ id: "categories", value: null },
|
|
102
|
+
{ id, value: fieldName },
|
|
103
|
+
]);
|
|
104
|
+
};
|
|
105
|
+
const showFeaturedPipes = !globalFilterInput &&
|
|
106
|
+
category === null &&
|
|
107
|
+
table.getState().columnFilters.every((e) => e.id === "categories");
|
|
108
|
+
return {
|
|
109
|
+
table,
|
|
110
|
+
sidebar: {
|
|
111
|
+
sortedInputFieldEntries,
|
|
112
|
+
sortedOutputFieldEntries,
|
|
113
|
+
sortedTagEntries,
|
|
114
|
+
sortedProviderEntries,
|
|
115
|
+
pipeIdsByInputField,
|
|
116
|
+
pipeIdsByOutputField,
|
|
117
|
+
pipeIdsByProvider,
|
|
118
|
+
pipeIdsByTag,
|
|
119
|
+
expandedSidebarSections,
|
|
120
|
+
setExpandedSidebarSections,
|
|
121
|
+
removeColumnFilter,
|
|
122
|
+
addColumnFilter,
|
|
123
|
+
},
|
|
124
|
+
pipeEntriesByBasePipe,
|
|
125
|
+
filterByField,
|
|
126
|
+
globalFilterInput,
|
|
127
|
+
setGlobalFilterInput,
|
|
128
|
+
isFilterChecked,
|
|
129
|
+
resetColumnFilters,
|
|
130
|
+
category,
|
|
131
|
+
setCategory,
|
|
132
|
+
showFeaturedPipes,
|
|
133
|
+
};
|
|
134
|
+
}
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,gCAAgC,CAAC;AAC/C,cAAc,mBAAmB,CAAC"}
|
package/dist/index.js
ADDED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@pipe0/react-sdk",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.5",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "React utils to work with pipe0",
|
|
6
6
|
"keywords": [
|
|
@@ -15,27 +15,33 @@
|
|
|
15
15
|
"provenance": false,
|
|
16
16
|
"access": "public"
|
|
17
17
|
},
|
|
18
|
+
"files": [
|
|
19
|
+
"dist"
|
|
20
|
+
],
|
|
18
21
|
"exports": {
|
|
19
|
-
".": "./
|
|
22
|
+
".": "./dist/index.js"
|
|
20
23
|
},
|
|
21
24
|
"private": false,
|
|
25
|
+
"scripts": {
|
|
26
|
+
"lint": "eslint . --max-warnings 0",
|
|
27
|
+
"check-types": "tsc --noEmit",
|
|
28
|
+
"dev": " tsc --watch",
|
|
29
|
+
"build": "rm -rf ./dist && tsc",
|
|
30
|
+
"prepublishOnly": "pnpm run build"
|
|
31
|
+
},
|
|
22
32
|
"author": "",
|
|
23
33
|
"license": "MIT",
|
|
24
34
|
"dependencies": {
|
|
25
|
-
"
|
|
26
|
-
"react
|
|
27
|
-
"
|
|
28
|
-
"@
|
|
35
|
+
"@pipe0/client-sdk": "workspace:*",
|
|
36
|
+
"react": "catalog:",
|
|
37
|
+
"react-dom": "catalog:",
|
|
38
|
+
"@tanstack/react-table": "catalog:"
|
|
29
39
|
},
|
|
30
40
|
"devDependencies": {
|
|
31
|
-
"@
|
|
41
|
+
"@pipe0/eslint-config": "workspace:*",
|
|
42
|
+
"@types/react": "catalog:",
|
|
32
43
|
"@types/node": "^22.13.2",
|
|
33
|
-
"eslint": "
|
|
34
|
-
"@types/react-dom": "
|
|
35
|
-
"@pipe0/eslint-config": "0.0.0"
|
|
36
|
-
},
|
|
37
|
-
"scripts": {
|
|
38
|
-
"lint": "eslint . --max-warnings 0",
|
|
39
|
-
"check-types": "tsc --noEmit"
|
|
44
|
+
"eslint": "catalog:",
|
|
45
|
+
"@types/react-dom": "catalog:"
|
|
40
46
|
}
|
|
41
|
-
}
|
|
47
|
+
}
|
package/CHANGELOG.md
DELETED
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
# @pipe0/react-sdk
|
|
2
|
-
|
|
3
|
-
## 0.0.3
|
|
4
|
-
|
|
5
|
-
### Patch Changes
|
|
6
|
-
|
|
7
|
-
- Add exports to react-sdk
|
|
8
|
-
- Updated dependencies
|
|
9
|
-
- @pipe0/client-sdk@0.0.48
|
|
10
|
-
|
|
11
|
-
## 0.0.2
|
|
12
|
-
|
|
13
|
-
### Patch Changes
|
|
14
|
-
|
|
15
|
-
- Updates
|
|
16
|
-
- Updated dependencies
|
|
17
|
-
- @pipe0/client-sdk@0.0.47
|
package/eslint.config.mjs
DELETED
|
@@ -1,208 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
getInitialTableData,
|
|
3
|
-
getTableDataAggregates,
|
|
4
|
-
type PipeCatalogTableData,
|
|
5
|
-
type PipeCategory,
|
|
6
|
-
type PipeId,
|
|
7
|
-
} from "@pipe0/client-sdk";
|
|
8
|
-
import {
|
|
9
|
-
type ColumnFilter,
|
|
10
|
-
createColumnHelper,
|
|
11
|
-
getCoreRowModel,
|
|
12
|
-
getFilteredRowModel,
|
|
13
|
-
getPaginationRowModel,
|
|
14
|
-
useReactTable,
|
|
15
|
-
} from "@tanstack/react-table";
|
|
16
|
-
import { useCallback, useEffect, useMemo, useRef, useState } from "react";
|
|
17
|
-
|
|
18
|
-
export function useDebounce(
|
|
19
|
-
cb: (v: string) => unknown,
|
|
20
|
-
config: { initialValue?: string; timeout?: number } = {}
|
|
21
|
-
) {
|
|
22
|
-
const { initialValue = "", timeout = 400 } = config;
|
|
23
|
-
const [value, setValue] = useState(initialValue);
|
|
24
|
-
|
|
25
|
-
const cbRef = useRef(cb);
|
|
26
|
-
cbRef.current = cb;
|
|
27
|
-
|
|
28
|
-
const setImmediately = useCallback((v: string) => {
|
|
29
|
-
setValue(v);
|
|
30
|
-
cbRef.current(v);
|
|
31
|
-
}, []);
|
|
32
|
-
|
|
33
|
-
useEffect(() => {
|
|
34
|
-
const handle = setTimeout(() => {
|
|
35
|
-
cbRef.current(value);
|
|
36
|
-
}, timeout);
|
|
37
|
-
|
|
38
|
-
return () => clearTimeout(handle);
|
|
39
|
-
}, [value, timeout]);
|
|
40
|
-
|
|
41
|
-
return [value, setValue, setImmediately] as const;
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
export type InputFieldEntries = Record<string, PipeId[]>;
|
|
45
|
-
export type OutputFieldEntries = Record<string, PipeId[]>;
|
|
46
|
-
|
|
47
|
-
const columnHelper = createColumnHelper<PipeCatalogTableData>();
|
|
48
|
-
|
|
49
|
-
const columns = [
|
|
50
|
-
columnHelper.accessor("pipeId", {}),
|
|
51
|
-
columnHelper.accessor(
|
|
52
|
-
(row) => row.inputGroups.flatMap((g) => Object.keys(g.fields)).join(", "),
|
|
53
|
-
{
|
|
54
|
-
id: "inputFields",
|
|
55
|
-
}
|
|
56
|
-
),
|
|
57
|
-
columnHelper.accessor((row) => row.outputFields.join(", "), {
|
|
58
|
-
id: "outputFields",
|
|
59
|
-
}),
|
|
60
|
-
columnHelper.accessor((row) => row.tags.join(", "), {
|
|
61
|
-
id: "tags",
|
|
62
|
-
}),
|
|
63
|
-
columnHelper.accessor((row) => row.providers.join(", "), {
|
|
64
|
-
id: "providers",
|
|
65
|
-
}),
|
|
66
|
-
columnHelper.accessor((row) => row.categories.join(", "), {
|
|
67
|
-
id: "categories",
|
|
68
|
-
}),
|
|
69
|
-
];
|
|
70
|
-
|
|
71
|
-
export function usePipeCatalogTable(
|
|
72
|
-
config: {
|
|
73
|
-
initialColumnFilters?: ColumnFilter[];
|
|
74
|
-
} = {}
|
|
75
|
-
) {
|
|
76
|
-
const {
|
|
77
|
-
initialColumnFilters: initialColumnFilters = [
|
|
78
|
-
{ id: "category", value: "enrichment" },
|
|
79
|
-
] as ColumnFilter[],
|
|
80
|
-
} = config;
|
|
81
|
-
|
|
82
|
-
const initialTableData = useMemo(() => getInitialTableData(), []);
|
|
83
|
-
|
|
84
|
-
const table = useReactTable({
|
|
85
|
-
columns,
|
|
86
|
-
data: initialTableData,
|
|
87
|
-
getCoreRowModel: getCoreRowModel(),
|
|
88
|
-
getPaginationRowModel: getPaginationRowModel(),
|
|
89
|
-
getFilteredRowModel: getFilteredRowModel(),
|
|
90
|
-
initialState: {
|
|
91
|
-
columnFilters: initialColumnFilters,
|
|
92
|
-
pagination: {
|
|
93
|
-
pageSize: 10,
|
|
94
|
-
},
|
|
95
|
-
},
|
|
96
|
-
});
|
|
97
|
-
|
|
98
|
-
const columnFilters = table.getState().columnFilters;
|
|
99
|
-
const category: PipeCategory | null = useMemo(
|
|
100
|
-
() =>
|
|
101
|
-
(columnFilters.find((e) => e.id === "categories" && e.value)
|
|
102
|
-
?.value as PipeCategory) || null,
|
|
103
|
-
[columnFilters]
|
|
104
|
-
);
|
|
105
|
-
|
|
106
|
-
const {
|
|
107
|
-
pipeIdsByInputField,
|
|
108
|
-
pipeIdsByOutputField,
|
|
109
|
-
pipeIdsByTag,
|
|
110
|
-
pipeIdsByProvider,
|
|
111
|
-
sortedTagEntries,
|
|
112
|
-
sortedInputFieldEntries,
|
|
113
|
-
sortedOutputFieldEntries,
|
|
114
|
-
sortedProviderEntries,
|
|
115
|
-
pipeEntriesByBasePipe,
|
|
116
|
-
} = useMemo(() => {
|
|
117
|
-
return getTableDataAggregates(initialTableData, category);
|
|
118
|
-
}, [category, initialTableData]);
|
|
119
|
-
|
|
120
|
-
const [expandedSidebarSections, setExpandedSidebarSections] = useState<
|
|
121
|
-
string[]
|
|
122
|
-
>(["tags"]);
|
|
123
|
-
|
|
124
|
-
const setCategory = (category: PipeCategory | null) => {
|
|
125
|
-
table.setGlobalFilter(null);
|
|
126
|
-
if (category) {
|
|
127
|
-
table.setColumnFilters([{ id: "categories", value: category }]);
|
|
128
|
-
} else {
|
|
129
|
-
table.setColumnFilters([]);
|
|
130
|
-
}
|
|
131
|
-
};
|
|
132
|
-
|
|
133
|
-
const [globalFilterInput, setGlobalFilterInput, setGlobalFilterImmediately] =
|
|
134
|
-
useDebounce((v) => {
|
|
135
|
-
if (v === table.getState().globalFilter) return;
|
|
136
|
-
table.setGlobalFilter(v);
|
|
137
|
-
if (v) {
|
|
138
|
-
table.setColumnFilters([]);
|
|
139
|
-
}
|
|
140
|
-
});
|
|
141
|
-
|
|
142
|
-
const addColumnFilter = (
|
|
143
|
-
id: "inputFields" | "outputFields" | "tags" | "providers",
|
|
144
|
-
value: string
|
|
145
|
-
) => {
|
|
146
|
-
setGlobalFilterImmediately("");
|
|
147
|
-
table.setColumnFilters([
|
|
148
|
-
{ id: "categories", value: category },
|
|
149
|
-
{ id, value },
|
|
150
|
-
]);
|
|
151
|
-
};
|
|
152
|
-
|
|
153
|
-
const resetColumnFilters = () => {
|
|
154
|
-
setGlobalFilterImmediately("");
|
|
155
|
-
table.setColumnFilters([{ id: "categories", value: null }]);
|
|
156
|
-
};
|
|
157
|
-
|
|
158
|
-
const removeColumnFilter = (
|
|
159
|
-
id: "inputFields" | "outputFields" | "tags" | "providers"
|
|
160
|
-
) => {
|
|
161
|
-
table.getColumn(id)?.setFilterValue(null);
|
|
162
|
-
};
|
|
163
|
-
|
|
164
|
-
const isFilterChecked = (
|
|
165
|
-
id: "inputFields" | "outputFields" | "tags" | "providers",
|
|
166
|
-
value: string
|
|
167
|
-
) => {
|
|
168
|
-
return columnFilters.some((f) => f.id === id && f.value === value);
|
|
169
|
-
};
|
|
170
|
-
|
|
171
|
-
const filterByField = (
|
|
172
|
-
id: "inputFields" | "outputFields",
|
|
173
|
-
fieldName: string
|
|
174
|
-
) => {
|
|
175
|
-
setExpandedSidebarSections([id]);
|
|
176
|
-
setGlobalFilterImmediately("");
|
|
177
|
-
table.setColumnFilters([
|
|
178
|
-
{ id: "categories", value: null },
|
|
179
|
-
{ id, value: fieldName },
|
|
180
|
-
]);
|
|
181
|
-
};
|
|
182
|
-
|
|
183
|
-
return {
|
|
184
|
-
table,
|
|
185
|
-
sidebar: {
|
|
186
|
-
sortedInputFieldEntries,
|
|
187
|
-
sortedOutputFieldEntries,
|
|
188
|
-
sortedTagEntries,
|
|
189
|
-
sortedProviderEntries,
|
|
190
|
-
pipeIdsByInputField,
|
|
191
|
-
pipeIdsByOutputField,
|
|
192
|
-
pipeIdsByProvider,
|
|
193
|
-
pipeIdsByTag,
|
|
194
|
-
expandedSidebarSections,
|
|
195
|
-
setExpandedSidebarSections,
|
|
196
|
-
removeColumnFilter,
|
|
197
|
-
addColumnFilter,
|
|
198
|
-
},
|
|
199
|
-
pipeEntriesByBasePipe,
|
|
200
|
-
filterByField,
|
|
201
|
-
globalFilterInput,
|
|
202
|
-
setGlobalFilterInput,
|
|
203
|
-
isFilterChecked,
|
|
204
|
-
resetColumnFilters,
|
|
205
|
-
category,
|
|
206
|
-
setCategory,
|
|
207
|
-
};
|
|
208
|
-
}
|
package/src/index.ts
DELETED
package/tsconfig.json
DELETED
|
@@ -1,29 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"compilerOptions": {
|
|
3
|
-
"target": "es2023",
|
|
4
|
-
"lib": ["ES2020", "DOM", "DOM.Iterable"],
|
|
5
|
-
"rootDir": "src",
|
|
6
|
-
"moduleDetection": "force",
|
|
7
|
-
"useDefineForClassFields": true,
|
|
8
|
-
"module": "esnext",
|
|
9
|
-
"moduleResolution": "bundler",
|
|
10
|
-
"noUncheckedIndexedAccess": true,
|
|
11
|
-
"resolveJsonModule": true,
|
|
12
|
-
"types": ["node"],
|
|
13
|
-
"noFallthroughCasesInSwitch": true,
|
|
14
|
-
"noUnusedLocals": false,
|
|
15
|
-
"noUnusedParameters": true,
|
|
16
|
-
"verbatimModuleSyntax": true,
|
|
17
|
-
"isolatedModules": true,
|
|
18
|
-
"skipLibCheck": true,
|
|
19
|
-
"noUncheckedSideEffectImports": true,
|
|
20
|
-
"outDir": "./dist",
|
|
21
|
-
"noEmit": false,
|
|
22
|
-
"declaration": true,
|
|
23
|
-
"declarationMap": true,
|
|
24
|
-
"esModuleInterop": true,
|
|
25
|
-
"strict": true,
|
|
26
|
-
"jsx": "react-jsx"
|
|
27
|
-
},
|
|
28
|
-
"include": ["./src"]
|
|
29
|
-
}
|