@pipe0/react-sdk 0.0.10 → 0.0.11
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 +1 -1
- package/dist/hooks/usePipeCatalogTable.js +2 -2
- package/dist/hooks/useSearchCatalogTable.d.ts +30 -0
- package/dist/hooks/useSearchCatalogTable.d.ts.map +1 -0
- package/dist/hooks/useSearchCatalogTable.js +151 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +2 -0
- package/dist/utils/helpers.d.ts +3 -0
- package/dist/utils/helpers.d.ts.map +1 -0
- package/dist/utils/helpers.js +13 -0
- package/package.json +4 -3
|
@@ -20,7 +20,7 @@ export declare function usePipeCatalogTable(config?: {
|
|
|
20
20
|
removeColumnFilter: (id: "inputFields" | "outputFields" | "tags" | "providers") => void;
|
|
21
21
|
addColumnFilter: (id: "inputFields" | "outputFields" | "tags" | "providers", value: string) => void;
|
|
22
22
|
};
|
|
23
|
-
pipeEntriesByBasePipe: Record<string, (import("@pipe0/client-sdk").
|
|
23
|
+
pipeEntriesByBasePipe: Record<string, (import("@pipe0/client-sdk").PipeCatalogEntry<"people:workemail:waterfall@1" | "people:split:name@1" | "people:validate:email:zerobounce@1" | "people:is:workemail@1" | "company:websiteurl:email@1" | "company:newssummary:website@1" | "company:profile:builtwith@1" | "company:identity@1" | "company:overview@1" | "website:technologystack:builtwith@1" | "run:prompt@1" | "people:mobilenumber:professionalprofile:waterfall@1" | "people:mobilenumber:workemail:waterfall@1" | "people:join:name@1" | "people:professionalprofile:waterfall@1" | "people:professionalprofileurl:name@1" | "people:professionalprofileurl:email:waterfall@1" | "people:personalemail:professionalprofile:waterfall@1"> & {
|
|
24
24
|
pipeId: PipeId;
|
|
25
25
|
})[]>;
|
|
26
26
|
filterByField: (id: "inputFields" | "outputFields", fieldName: string) => void;
|
|
@@ -31,12 +31,12 @@ const columns = [
|
|
|
31
31
|
filterFn: "includesString",
|
|
32
32
|
enableGlobalFilter: true,
|
|
33
33
|
}),
|
|
34
|
-
columnHelper.accessor((row) => row.
|
|
34
|
+
columnHelper.accessor((row) => row.defaultInputGroups.flatMap((g) => Object.keys(g.fields)) || [], {
|
|
35
35
|
id: "inputFields",
|
|
36
36
|
filterFn: "arrIncludes",
|
|
37
37
|
enableGlobalFilter: true,
|
|
38
38
|
}),
|
|
39
|
-
columnHelper.accessor((row) => row.
|
|
39
|
+
columnHelper.accessor((row) => row.defaultOutputFields || [], {
|
|
40
40
|
id: "outputFields",
|
|
41
41
|
filterFn: "arrIncludes",
|
|
42
42
|
enableGlobalFilter: true,
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { type SearchCatalogTableData, type SearchCategory, type SearchId } from "@pipe0/client-sdk";
|
|
2
|
+
import { type ColumnFilter } from "@tanstack/react-table";
|
|
3
|
+
export type SearchOutputFieldEntries = Record<string, SearchId[]>;
|
|
4
|
+
export declare function useSearchCatalogTable(config?: {
|
|
5
|
+
initialColumnFilters?: ColumnFilter[];
|
|
6
|
+
}): {
|
|
7
|
+
table: import("@tanstack/react-table").Table<SearchCatalogTableData>;
|
|
8
|
+
sidebar: {
|
|
9
|
+
sortedOutputFieldEntries: [string, ("people:profiles:icypeas@1" | "companies:profiles:icypeas@1")[]][];
|
|
10
|
+
sortedTagEntries: [string, ("people:profiles:icypeas@1" | "companies:profiles:icypeas@1")[]][];
|
|
11
|
+
sortedProviderEntries: [string, ("people:profiles:icypeas@1" | "companies:profiles:icypeas@1")[]][];
|
|
12
|
+
searchIdsByOutputField: Record<string, ("people:profiles:icypeas@1" | "companies:profiles:icypeas@1")[]>;
|
|
13
|
+
searchIdsByProvider: Record<string, ("people:profiles:icypeas@1" | "companies:profiles:icypeas@1")[]>;
|
|
14
|
+
searchIdsByTag: Record<string, ("people:profiles:icypeas@1" | "companies:profiles:icypeas@1")[]>;
|
|
15
|
+
expandedSidebarSections: string[];
|
|
16
|
+
setExpandedSidebarSections: import("react").Dispatch<import("react").SetStateAction<string[]>>;
|
|
17
|
+
removeColumnFilter: (id: "inputFields" | "outputFields" | "tags" | "providers") => void;
|
|
18
|
+
addColumnFilter: (id: "inputFields" | "outputFields" | "tags" | "providers", value: string) => void;
|
|
19
|
+
};
|
|
20
|
+
searchEntriesByBaseSearch: Record<string, import("@pipe0/client-sdk").SearchMetaEntryWithId[]>;
|
|
21
|
+
filterByField: (id: "inputFields" | "outputFields", fieldName: string) => void;
|
|
22
|
+
globalFilterInput: string;
|
|
23
|
+
setGlobalFilterInput: import("react").Dispatch<import("react").SetStateAction<string>>;
|
|
24
|
+
isFilterChecked: (id: "inputFields" | "outputFields" | "tags" | "providers", value: string) => boolean;
|
|
25
|
+
resetColumnFilters: () => void;
|
|
26
|
+
category: SearchCategory;
|
|
27
|
+
setCategory: (category: SearchCategory | null) => void;
|
|
28
|
+
showFeaturedPipes: boolean;
|
|
29
|
+
};
|
|
30
|
+
//# sourceMappingURL=useSearchCatalogTable.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useSearchCatalogTable.d.ts","sourceRoot":"","sources":["../../src/hooks/useSearchCatalogTable.ts"],"names":[],"mappings":"AAAA,OAAO,EAKL,KAAK,sBAAsB,EAC3B,KAAK,cAAc,EACnB,KAAK,QAAQ,EACd,MAAM,mBAAmB,CAAC;AAC3B,OAAO,EACL,KAAK,YAAY,EAOlB,MAAM,uBAAuB,CAAC;AA2C/B,MAAM,MAAM,wBAAwB,GAAG,MAAM,CAAC,MAAM,EAAE,QAAQ,EAAE,CAAC,CAAC;AA+BlE,wBAAgB,qBAAqB,CACnC,MAAM,GAAE;IACN,oBAAoB,CAAC,EAAE,YAAY,EAAE,CAAC;CAClC;;;;;;;;;;;iCAmFA,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,cAAc,GAAG,IAAI;;EA2FrD"}
|
|
@@ -0,0 +1,151 @@
|
|
|
1
|
+
import { getInitialSearchTableData, getSearchTableDataAggregates, } 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
|
+
const globalFilterFn = (row, columnId, filterValue) => {
|
|
5
|
+
const value = row.getValue(columnId);
|
|
6
|
+
if (Array.isArray(value)) {
|
|
7
|
+
return value.some((item) => String(item).toLowerCase().includes(filterValue.toLowerCase()));
|
|
8
|
+
}
|
|
9
|
+
return String(value).toLowerCase().includes(filterValue.toLowerCase());
|
|
10
|
+
};
|
|
11
|
+
function useDebounce(cb, config = {}) {
|
|
12
|
+
const { initialValue = "", timeout = 400 } = config;
|
|
13
|
+
const [value, setValue] = useState(initialValue);
|
|
14
|
+
const cbRef = useRef(cb);
|
|
15
|
+
cbRef.current = cb;
|
|
16
|
+
const setImmediately = useCallback((v) => {
|
|
17
|
+
setValue(v);
|
|
18
|
+
cbRef.current(v);
|
|
19
|
+
}, []);
|
|
20
|
+
useEffect(() => {
|
|
21
|
+
const handle = setTimeout(() => {
|
|
22
|
+
cbRef.current(value);
|
|
23
|
+
}, timeout);
|
|
24
|
+
return () => clearTimeout(handle);
|
|
25
|
+
}, [value, timeout]);
|
|
26
|
+
return [value, setValue, setImmediately];
|
|
27
|
+
}
|
|
28
|
+
const columnHelper = createColumnHelper();
|
|
29
|
+
const columns = [
|
|
30
|
+
columnHelper.accessor("searchId", {
|
|
31
|
+
filterFn: "includesString",
|
|
32
|
+
enableGlobalFilter: true,
|
|
33
|
+
}),
|
|
34
|
+
columnHelper.accessor((row) => row.outputFields || [], {
|
|
35
|
+
id: "outputFields",
|
|
36
|
+
filterFn: "arrIncludes",
|
|
37
|
+
enableGlobalFilter: true,
|
|
38
|
+
}),
|
|
39
|
+
columnHelper.accessor((row) => row.tags || [], {
|
|
40
|
+
id: "tags",
|
|
41
|
+
filterFn: "arrIncludes",
|
|
42
|
+
enableGlobalFilter: true,
|
|
43
|
+
}),
|
|
44
|
+
columnHelper.accessor((row) => row.providers || [], {
|
|
45
|
+
id: "providers",
|
|
46
|
+
filterFn: "arrIncludes",
|
|
47
|
+
enableGlobalFilter: true,
|
|
48
|
+
}),
|
|
49
|
+
columnHelper.accessor((row) => row.categories || [], {
|
|
50
|
+
id: "categories",
|
|
51
|
+
filterFn: "arrIncludes",
|
|
52
|
+
enableGlobalFilter: true,
|
|
53
|
+
}),
|
|
54
|
+
];
|
|
55
|
+
export function useSearchCatalogTable(config = {}) {
|
|
56
|
+
const { initialColumnFilters: initialColumnFilters = [] } = config;
|
|
57
|
+
const initialSearchTableData = useMemo(() => getInitialSearchTableData(), []);
|
|
58
|
+
const table = useReactTable({
|
|
59
|
+
columns,
|
|
60
|
+
data: initialSearchTableData,
|
|
61
|
+
getCoreRowModel: getCoreRowModel(),
|
|
62
|
+
getPaginationRowModel: getPaginationRowModel(),
|
|
63
|
+
getFilteredRowModel: getFilteredRowModel(),
|
|
64
|
+
globalFilterFn: globalFilterFn,
|
|
65
|
+
getColumnCanGlobalFilter: (column) => column.columnDef.enableGlobalFilter !== false,
|
|
66
|
+
initialState: {
|
|
67
|
+
columnFilters: initialColumnFilters,
|
|
68
|
+
pagination: {
|
|
69
|
+
pageSize: 10,
|
|
70
|
+
},
|
|
71
|
+
},
|
|
72
|
+
});
|
|
73
|
+
const columnFilters = table.getState().columnFilters;
|
|
74
|
+
const category = useMemo(() => columnFilters.find((e) => e.id === "categories" && e.value)
|
|
75
|
+
?.value || null, [columnFilters]);
|
|
76
|
+
const { searchIdsByOutputField, searchIdsByTag, searchIdsByProvider, sortedTagEntries, sortedOutputFieldEntries, sortedProviderEntries, searchEntriesByBaseSearch, } = useMemo(() => {
|
|
77
|
+
return getSearchTableDataAggregates(initialSearchTableData, category);
|
|
78
|
+
}, [category, initialSearchTableData]);
|
|
79
|
+
const [expandedSidebarSections, setExpandedSidebarSections] = useState(["tags"]);
|
|
80
|
+
const setCategory = (category) => {
|
|
81
|
+
table.setGlobalFilter(null);
|
|
82
|
+
if (category) {
|
|
83
|
+
table.setColumnFilters([{ id: "categories", value: category }]);
|
|
84
|
+
}
|
|
85
|
+
else {
|
|
86
|
+
table.setColumnFilters([]);
|
|
87
|
+
}
|
|
88
|
+
};
|
|
89
|
+
const [globalFilterInput, setGlobalFilterInput, setGlobalFilterImmediately] = useDebounce((v) => {
|
|
90
|
+
if (v === table.getState().globalFilter)
|
|
91
|
+
return;
|
|
92
|
+
table.setGlobalFilter(v);
|
|
93
|
+
if (v) {
|
|
94
|
+
table.setColumnFilters([]);
|
|
95
|
+
}
|
|
96
|
+
});
|
|
97
|
+
const addColumnFilter = (id, value) => {
|
|
98
|
+
setGlobalFilterImmediately("");
|
|
99
|
+
table.setColumnFilters([
|
|
100
|
+
{ id: "categories", value: category },
|
|
101
|
+
{ id, value },
|
|
102
|
+
]);
|
|
103
|
+
};
|
|
104
|
+
const resetColumnFilters = () => {
|
|
105
|
+
setGlobalFilterImmediately("");
|
|
106
|
+
table.setColumnFilters([{ id: "categories", value: null }]);
|
|
107
|
+
};
|
|
108
|
+
const removeColumnFilter = (id) => {
|
|
109
|
+
table.getColumn(id)?.setFilterValue(null);
|
|
110
|
+
};
|
|
111
|
+
const isFilterChecked = (id, value) => {
|
|
112
|
+
return columnFilters.some((f) => f.id === id && f.value === value);
|
|
113
|
+
};
|
|
114
|
+
const filterByField = (id, fieldName) => {
|
|
115
|
+
setExpandedSidebarSections([id]);
|
|
116
|
+
setGlobalFilterImmediately("");
|
|
117
|
+
table.setColumnFilters([
|
|
118
|
+
{ id: "categories", value: null },
|
|
119
|
+
{ id, value: fieldName },
|
|
120
|
+
]);
|
|
121
|
+
};
|
|
122
|
+
const tableState = table.getState();
|
|
123
|
+
const showFeaturedSearches = !globalFilterInput &&
|
|
124
|
+
category === null &&
|
|
125
|
+
tableState.columnFilters.every((e) => e.id === "categories") &&
|
|
126
|
+
tableState.pagination.pageIndex === 0;
|
|
127
|
+
return {
|
|
128
|
+
table,
|
|
129
|
+
sidebar: {
|
|
130
|
+
sortedOutputFieldEntries,
|
|
131
|
+
sortedTagEntries,
|
|
132
|
+
sortedProviderEntries,
|
|
133
|
+
searchIdsByOutputField,
|
|
134
|
+
searchIdsByProvider,
|
|
135
|
+
searchIdsByTag,
|
|
136
|
+
expandedSidebarSections,
|
|
137
|
+
setExpandedSidebarSections,
|
|
138
|
+
removeColumnFilter,
|
|
139
|
+
addColumnFilter,
|
|
140
|
+
},
|
|
141
|
+
searchEntriesByBaseSearch,
|
|
142
|
+
filterByField,
|
|
143
|
+
globalFilterInput,
|
|
144
|
+
setGlobalFilterInput,
|
|
145
|
+
isFilterChecked,
|
|
146
|
+
resetColumnFilters,
|
|
147
|
+
category,
|
|
148
|
+
setCategory,
|
|
149
|
+
showFeaturedPipes: showFeaturedSearches,
|
|
150
|
+
};
|
|
151
|
+
}
|
package/dist/index.d.ts
CHANGED
|
@@ -1,2 +1,4 @@
|
|
|
1
1
|
export { usePipeCatalogTable, type InputFieldEntries, type OutputFieldEntries, } from "./hooks/usePipeCatalogTable.js";
|
|
2
|
+
export { useSearchCatalogTable, type SearchOutputFieldEntries, } from "./hooks/useSearchCatalogTable.js";
|
|
3
|
+
export * from "./utils/helpers.js";
|
|
2
4
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,mBAAmB,EACnB,KAAK,iBAAiB,EACtB,KAAK,kBAAkB,GACxB,MAAM,gCAAgC,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,mBAAmB,EACnB,KAAK,iBAAiB,EACtB,KAAK,kBAAkB,GACxB,MAAM,gCAAgC,CAAC;AACxC,OAAO,EACL,qBAAqB,EACrB,KAAK,wBAAwB,GAC9B,MAAM,kCAAkC,CAAC;AAC1C,cAAc,oBAAoB,CAAC"}
|
package/dist/index.js
CHANGED
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import type { RecordFieldStatus } from "@pipe0/client-sdk";
|
|
2
|
+
export declare function getFieldStatusIcon(fieldStatus: RecordFieldStatus): import("react").ForwardRefExoticComponent<Omit<import("lucide-react").LucideProps, "ref"> & import("react").RefAttributes<SVGSVGElement>>;
|
|
3
|
+
//# sourceMappingURL=helpers.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"helpers.d.ts","sourceRoot":"","sources":["../../src/utils/helpers.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,mBAAmB,CAAC;AAsB3D,wBAAgB,kBAAkB,CAAC,WAAW,EAAE,iBAAiB,6IAEhE"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { BookDashed, Bookmark, CheckCheck, Loader, Pause, TriangleDashed, X, } from "lucide-react";
|
|
2
|
+
const fieldStatusIconMap = {
|
|
3
|
+
completed: CheckCheck,
|
|
4
|
+
failed: X,
|
|
5
|
+
no_result: BookDashed,
|
|
6
|
+
pending: Bookmark,
|
|
7
|
+
processing: Loader,
|
|
8
|
+
queued: Pause,
|
|
9
|
+
skipped: TriangleDashed,
|
|
10
|
+
};
|
|
11
|
+
export function getFieldStatusIcon(fieldStatus) {
|
|
12
|
+
return fieldStatusIconMap[fieldStatus];
|
|
13
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@pipe0/react-sdk",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.11",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "React utils to work with pipe0",
|
|
6
6
|
"keywords": [
|
|
@@ -25,10 +25,11 @@
|
|
|
25
25
|
"author": "",
|
|
26
26
|
"license": "MIT",
|
|
27
27
|
"dependencies": {
|
|
28
|
-
"@tanstack/react-table": "^8.21.
|
|
28
|
+
"@tanstack/react-table": "^8.21.3",
|
|
29
|
+
"lucide-react": "^0.475.0",
|
|
29
30
|
"react": "^19.0.0",
|
|
30
31
|
"react-dom": "^19.0.0",
|
|
31
|
-
"@pipe0/client-sdk": "0.0.
|
|
32
|
+
"@pipe0/client-sdk": "0.0.53"
|
|
32
33
|
},
|
|
33
34
|
"devDependencies": {
|
|
34
35
|
"@types/node": "^22.13.2",
|