@pipe0/react-sdk 0.0.72 → 0.0.73
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 +3 -1
- package/dist/hooks/usePipeCatalogTable.d.ts.map +1 -1
- package/dist/hooks/usePipeCatalogTable.js +25 -19
- package/dist/hooks/useSearchCatalogTable.d.ts +2 -0
- package/dist/hooks/useSearchCatalogTable.d.ts.map +1 -1
- package/dist/hooks/useSearchCatalogTable.js +19 -10
- package/dist/index.d.ts +2 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/utils/helpers.d.ts +2 -0
- package/dist/utils/helpers.d.ts.map +1 -1
- package/dist/utils/helpers.js +10 -0
- package/package.json +3 -2
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { type
|
|
1
|
+
import { type PipeCategory, type PipeEntryWithLatestVersion, type PipeId } from "@pipe0/ops";
|
|
2
2
|
import { type ColumnFilter } from "@tanstack/react-table";
|
|
3
3
|
export type InputFieldEntries = Record<string, PipeId[]>;
|
|
4
4
|
export type OutputFieldEntries = Record<string, PipeId[]>;
|
|
@@ -31,5 +31,7 @@ export declare function usePipeCatalogTable(config?: {
|
|
|
31
31
|
category: PipeCategory | null;
|
|
32
32
|
setCategory: (category: PipeCategory | null) => void;
|
|
33
33
|
showFeaturedPipes: boolean;
|
|
34
|
+
getColumnFilterValue: (id: "inputFields" | "outputFields" | "tags" | "providers") => string;
|
|
34
35
|
};
|
|
36
|
+
export type UsePipeCatalogTableReturn = ReturnType<typeof usePipeCatalogTable>;
|
|
35
37
|
//# sourceMappingURL=usePipeCatalogTable.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"usePipeCatalogTable.d.ts","sourceRoot":"","sources":["../../src/hooks/usePipeCatalogTable.ts"],"names":[],"mappings":"AAAA,OAAO,EAKL,KAAK,0BAA0B,EAC/B,KAAK,
|
|
1
|
+
{"version":3,"file":"usePipeCatalogTable.d.ts","sourceRoot":"","sources":["../../src/hooks/usePipeCatalogTable.ts"],"names":[],"mappings":"AAAA,OAAO,EAKL,KAAK,YAAY,EACjB,KAAK,0BAA0B,EAC/B,KAAK,MAAM,EACZ,MAAM,YAAY,CAAC;AACpB,OAAO,EACL,KAAK,YAAY,EAMlB,MAAM,uBAAuB,CAAC;AA4C/B,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;AA0C1D,wBAAgB,mBAAmB,CACjC,MAAM,GAAE;IACN,oBAAoB,CAAC,EAAE,YAAY,EAAE,CAAC;CAClC;;;;;;;;;;;;;iCAwGC,aAAa,GAAG,cAAc,GAAG,MAAM,GAAG,WAAW;8BAxBpD,aAAa,GAAG,cAAc,GAAG,MAAM,GAAG,WAAW,SAClD,MAAM;;;;;wBAgDV,aAAa,GAAG,cAAc,aAAa,MAAM;;;0BAjBhD,aAAa,GAAG,cAAc,GAAG,MAAM,GAAG,WAAW,SAClD,MAAM;;;4BAvBJ,YAAY,GAAG,IAAI;;+BA+BzB,aAAa,GAAG,cAAc,GAAG,MAAM,GAAG,WAAW,KAE1C,MAAM;EAkDzB;AAED,MAAM,MAAM,yBAAyB,GAAG,UAAU,CAAC,OAAO,mBAAmB,CAAC,CAAC"}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { getDefaultOutputFields, getDefaultPipeProviders, getInitialTableData, getTableDataAggregates, } from "@pipe0/ops";
|
|
2
|
-
import { createColumnHelper, getCoreRowModel, getFilteredRowModel,
|
|
2
|
+
import { createColumnHelper, getCoreRowModel, getFilteredRowModel, useReactTable, } from "@tanstack/react-table";
|
|
3
3
|
import { useCallback, useEffect, useMemo, useRef, useState } from "react";
|
|
4
|
+
import { fuzzyFilter } from "../utils/helpers.js";
|
|
4
5
|
const globalFilterFn = (row, columnId, filterValue) => {
|
|
5
6
|
const value = row.getValue(columnId);
|
|
6
7
|
if (Array.isArray(value)) {
|
|
@@ -31,6 +32,14 @@ const columns = [
|
|
|
31
32
|
filterFn: "includesString",
|
|
32
33
|
enableGlobalFilter: true,
|
|
33
34
|
}),
|
|
35
|
+
columnHelper.accessor("label", {
|
|
36
|
+
filterFn: "fuzzy",
|
|
37
|
+
enableGlobalFilter: true,
|
|
38
|
+
}),
|
|
39
|
+
columnHelper.accessor("description", {
|
|
40
|
+
filterFn: "fuzzy",
|
|
41
|
+
enableGlobalFilter: true,
|
|
42
|
+
}),
|
|
34
43
|
columnHelper.accessor((row) => row.defaultInputGroups.flatMap((g) => Object.keys(g.fields)) || [], {
|
|
35
44
|
id: "inputFields",
|
|
36
45
|
filterFn: "arrIncludes",
|
|
@@ -51,11 +60,6 @@ const columns = [
|
|
|
51
60
|
filterFn: "arrIncludes",
|
|
52
61
|
enableGlobalFilter: true,
|
|
53
62
|
}),
|
|
54
|
-
// columnHelper.accessor((row) => row.categories || [], {
|
|
55
|
-
// id: "categories",
|
|
56
|
-
// filterFn: "arrIncludes",
|
|
57
|
-
// enableGlobalFilter: true,
|
|
58
|
-
// }),
|
|
59
63
|
];
|
|
60
64
|
export function usePipeCatalogTable(config = {}) {
|
|
61
65
|
const [category, setCategory] = useState(null);
|
|
@@ -65,9 +69,11 @@ export function usePipeCatalogTable(config = {}) {
|
|
|
65
69
|
columns,
|
|
66
70
|
data: initialTableData,
|
|
67
71
|
getCoreRowModel: getCoreRowModel(),
|
|
68
|
-
getPaginationRowModel: getPaginationRowModel(),
|
|
69
72
|
getFilteredRowModel: getFilteredRowModel(),
|
|
70
|
-
globalFilterFn:
|
|
73
|
+
globalFilterFn: fuzzyFilter,
|
|
74
|
+
filterFns: {
|
|
75
|
+
fuzzy: fuzzyFilter,
|
|
76
|
+
},
|
|
71
77
|
getColumnCanGlobalFilter: (column) => column.columnDef.enableGlobalFilter !== false,
|
|
72
78
|
initialState: {
|
|
73
79
|
columnFilters: initialColumnFilters,
|
|
@@ -109,11 +115,8 @@ export function usePipeCatalogTable(config = {}) {
|
|
|
109
115
|
});
|
|
110
116
|
const addColumnFilter = useCallback((id, value) => {
|
|
111
117
|
setGlobalFilterImmediately("");
|
|
112
|
-
table.setColumnFilters([
|
|
113
|
-
|
|
114
|
-
{ id, value },
|
|
115
|
-
]);
|
|
116
|
-
}, [category, setGlobalFilterImmediately, table]);
|
|
118
|
+
table.setColumnFilters([{ id, value }]);
|
|
119
|
+
}, [setGlobalFilterImmediately, table]);
|
|
117
120
|
const handleCategoryChange = useCallback((category) => {
|
|
118
121
|
setCategory(category);
|
|
119
122
|
table.setColumnFilters([]);
|
|
@@ -121,21 +124,23 @@ export function usePipeCatalogTable(config = {}) {
|
|
|
121
124
|
}, [table, setGlobalFilterImmediately]);
|
|
122
125
|
const resetColumnFilters = useCallback(() => {
|
|
123
126
|
setGlobalFilterImmediately("");
|
|
124
|
-
|
|
125
|
-
}, [setGlobalFilterImmediately
|
|
127
|
+
setCategory(null);
|
|
128
|
+
}, [setGlobalFilterImmediately]);
|
|
126
129
|
const removeColumnFilter = useCallback((id) => {
|
|
127
130
|
table.getColumn(id)?.setFilterValue(null);
|
|
128
131
|
}, [table]);
|
|
129
132
|
const isFilterChecked = useCallback((id, value) => {
|
|
130
133
|
return columnFilters.some((f) => f.id === id && f.value === value);
|
|
131
134
|
}, [columnFilters]);
|
|
135
|
+
const getColumnFilterValue = useCallback((id) => {
|
|
136
|
+
const res = columnFilters.find((f) => f.id === id)?.value;
|
|
137
|
+
return res;
|
|
138
|
+
}, [columnFilters]);
|
|
132
139
|
const filterByField = useCallback((id, fieldName) => {
|
|
133
140
|
setExpandedSidebarSections([id]);
|
|
134
141
|
setGlobalFilterImmediately("");
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
{ id, value: fieldName },
|
|
138
|
-
]);
|
|
142
|
+
setCategory(null);
|
|
143
|
+
table.setColumnFilters([{ id, value: fieldName }]);
|
|
139
144
|
}, [table, setExpandedSidebarSections, setGlobalFilterImmediately]);
|
|
140
145
|
const tableState = table.getState();
|
|
141
146
|
const showFeaturedPipes = !globalFilterInput &&
|
|
@@ -167,5 +172,6 @@ export function usePipeCatalogTable(config = {}) {
|
|
|
167
172
|
category,
|
|
168
173
|
setCategory: handleCategoryChange,
|
|
169
174
|
showFeaturedPipes,
|
|
175
|
+
getColumnFilterValue,
|
|
170
176
|
};
|
|
171
177
|
}
|
|
@@ -26,5 +26,7 @@ export declare function useSearchCatalogTable(config?: {
|
|
|
26
26
|
category: SearchCategory | null;
|
|
27
27
|
setCategory: (category: SearchCategory | null) => void;
|
|
28
28
|
showFeaturedSearches: boolean;
|
|
29
|
+
getColumnFilterValue: (id: "outputFields" | "tags" | "providers") => string;
|
|
29
30
|
};
|
|
31
|
+
export type UseSearchCatalogTableReturn = ReturnType<typeof useSearchCatalogTable>;
|
|
30
32
|
//# sourceMappingURL=useSearchCatalogTable.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useSearchCatalogTable.d.ts","sourceRoot":"","sources":["../../src/hooks/useSearchCatalogTable.ts"],"names":[],"mappings":"AAAA,OAAO,EAIL,KAAK,sBAAsB,EAC3B,KAAK,cAAc,EACnB,KAAK,QAAQ,EACd,MAAM,YAAY,CAAC;AACpB,OAAO,EACL,KAAK,YAAY,
|
|
1
|
+
{"version":3,"file":"useSearchCatalogTable.d.ts","sourceRoot":"","sources":["../../src/hooks/useSearchCatalogTable.ts"],"names":[],"mappings":"AAAA,OAAO,EAIL,KAAK,sBAAsB,EAC3B,KAAK,cAAc,EACnB,KAAK,QAAQ,EACd,MAAM,YAAY,CAAC;AACpB,OAAO,EACL,KAAK,YAAY,EAKlB,MAAM,uBAAuB,CAAC;AA8B/B,MAAM,MAAM,wBAAwB,GAAG,MAAM,CAAC,MAAM,EAAE,QAAQ,EAAE,CAAC,CAAC;AAoClE,wBAAgB,qBAAqB,CACnC,MAAM,GAAE;IACN,oBAAoB,CAAC,EAAE,YAAY,EAAE,CAAC;CAClC;;;;;;;;;;;iCA2EA,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;;;4BA0BF,cAAc,GAAG,IAAI;;+BAS3B,cAAc,GAAG,MAAM,GAAG,WAAW,KAE1B,MAAM;EA8BzB;AAED,MAAM,MAAM,2BAA2B,GAAG,UAAU,CAClD,OAAO,qBAAqB,CAC7B,CAAC"}
|
|
@@ -1,13 +1,7 @@
|
|
|
1
1
|
import { getDefaultSearchOutputFields, getInitialSearchTableData, getSearchTableDataAggregates, } from "@pipe0/ops";
|
|
2
|
-
import { createColumnHelper, getCoreRowModel, getFilteredRowModel,
|
|
2
|
+
import { createColumnHelper, getCoreRowModel, getFilteredRowModel, useReactTable, } from "@tanstack/react-table";
|
|
3
3
|
import { useCallback, useEffect, useMemo, useRef, useState } from "react";
|
|
4
|
-
|
|
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
|
-
};
|
|
4
|
+
import { fuzzyFilter } from "../utils/helpers.js";
|
|
11
5
|
function useDebounce(cb, config = {}) {
|
|
12
6
|
const { initialValue = "", timeout = 400 } = config;
|
|
13
7
|
const [value, setValue] = useState(initialValue);
|
|
@@ -31,6 +25,14 @@ const columns = [
|
|
|
31
25
|
filterFn: "includesString",
|
|
32
26
|
enableGlobalFilter: true,
|
|
33
27
|
}),
|
|
28
|
+
columnHelper.accessor("description", {
|
|
29
|
+
filterFn: "fuzzy",
|
|
30
|
+
enableGlobalFilter: true,
|
|
31
|
+
}),
|
|
32
|
+
columnHelper.accessor("label", {
|
|
33
|
+
filterFn: "includesString",
|
|
34
|
+
enableGlobalFilter: true,
|
|
35
|
+
}),
|
|
34
36
|
columnHelper.accessor((row) => getDefaultSearchOutputFields(row.searchId) || [], {
|
|
35
37
|
id: "outputFields",
|
|
36
38
|
filterFn: "arrIncludes",
|
|
@@ -54,9 +56,11 @@ export function useSearchCatalogTable(config = {}) {
|
|
|
54
56
|
columns,
|
|
55
57
|
data: initialSearchTableData,
|
|
56
58
|
getCoreRowModel: getCoreRowModel(),
|
|
57
|
-
getPaginationRowModel: getPaginationRowModel(),
|
|
58
59
|
getFilteredRowModel: getFilteredRowModel(),
|
|
59
|
-
globalFilterFn:
|
|
60
|
+
globalFilterFn: fuzzyFilter,
|
|
61
|
+
filterFns: {
|
|
62
|
+
fuzzy: fuzzyFilter,
|
|
63
|
+
},
|
|
60
64
|
getColumnCanGlobalFilter: (column) => column.columnDef.enableGlobalFilter !== false,
|
|
61
65
|
initialState: {
|
|
62
66
|
columnFilters: initialColumnFilters,
|
|
@@ -114,6 +118,10 @@ export function useSearchCatalogTable(config = {}) {
|
|
|
114
118
|
table.setColumnFilters([]);
|
|
115
119
|
setGlobalFilterImmediately("");
|
|
116
120
|
}, [table, setGlobalFilterImmediately]);
|
|
121
|
+
const getColumnFilterValue = useCallback((id) => {
|
|
122
|
+
const res = columnFilters.find((f) => f.id === id)?.value;
|
|
123
|
+
return res;
|
|
124
|
+
}, [columnFilters]);
|
|
117
125
|
return {
|
|
118
126
|
table,
|
|
119
127
|
sidebar: {
|
|
@@ -137,5 +145,6 @@ export function useSearchCatalogTable(config = {}) {
|
|
|
137
145
|
category,
|
|
138
146
|
setCategory: handleCategoryChange,
|
|
139
147
|
showFeaturedSearches,
|
|
148
|
+
getColumnFilterValue,
|
|
140
149
|
};
|
|
141
150
|
}
|
package/dist/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export { usePipeCatalogTable, type InputFieldEntries, type OutputFieldEntries, } from "./hooks/usePipeCatalogTable.js";
|
|
2
|
-
export { useSearchCatalogTable, type SearchOutputFieldEntries, } from "./hooks/useSearchCatalogTable.js";
|
|
1
|
+
export { usePipeCatalogTable, type InputFieldEntries, type OutputFieldEntries, type UsePipeCatalogTableReturn, } from "./hooks/usePipeCatalogTable.js";
|
|
2
|
+
export { useSearchCatalogTable, type SearchOutputFieldEntries, type UseSearchCatalogTableReturn, } from "./hooks/useSearchCatalogTable.js";
|
|
3
3
|
export * from "./utils/helpers.js";
|
|
4
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,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,mBAAmB,EACnB,KAAK,iBAAiB,EACtB,KAAK,kBAAkB,EACvB,KAAK,yBAAyB,GAC/B,MAAM,gCAAgC,CAAC;AACxC,OAAO,EACL,qBAAqB,EACrB,KAAK,wBAAwB,EAC7B,KAAK,2BAA2B,GACjC,MAAM,kCAAkC,CAAC;AAC1C,cAAc,oBAAoB,CAAC"}
|
package/dist/utils/helpers.d.ts
CHANGED
|
@@ -1,4 +1,6 @@
|
|
|
1
1
|
import type { RecordFieldType, RecordFieldStatus } from "@pipe0/ops";
|
|
2
|
+
import { type FilterFn } from "@tanstack/react-table";
|
|
2
3
|
export declare function getFieldTypeIcon(fieldType: RecordFieldType): import("react").ForwardRefExoticComponent<Omit<import("lucide-react").LucideProps, "ref"> & import("react").RefAttributes<SVGSVGElement>>;
|
|
3
4
|
export declare function getFieldStatusIcon(fieldStatus: RecordFieldStatus): import("react").ForwardRefExoticComponent<Omit<import("lucide-react").LucideProps, "ref"> & import("react").RefAttributes<SVGSVGElement>>;
|
|
5
|
+
export declare const fuzzyFilter: FilterFn<any>;
|
|
4
6
|
//# sourceMappingURL=helpers.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"helpers.d.ts","sourceRoot":"","sources":["../../src/utils/helpers.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,iBAAiB,EAAE,MAAM,YAAY,CAAC;
|
|
1
|
+
{"version":3,"file":"helpers.d.ts","sourceRoot":"","sources":["../../src/utils/helpers.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,iBAAiB,EAAE,MAAM,YAAY,CAAC;AAiBrE,OAAO,EAAE,KAAK,QAAQ,EAAE,MAAM,uBAAuB,CAAC;AAoBtD,wBAAgB,gBAAgB,CAAC,SAAS,EAAE,eAAe,6IAE1D;AAED,wBAAgB,kBAAkB,CAAC,WAAW,EAAE,iBAAiB,6IAEhE;AAED,eAAO,MAAM,WAAW,EAAE,QAAQ,CAAC,GAAG,CASrC,CAAC"}
|
package/dist/utils/helpers.js
CHANGED
|
@@ -1,4 +1,6 @@
|
|
|
1
1
|
import { BookDashed, Bookmark, Braces, CheckCheck, Hash, HelpCircle, Loader, Pause, ToggleRight, TriangleDashed, Type, X, } from "lucide-react";
|
|
2
|
+
import { rankItem } from "@tanstack/match-sorter-utils";
|
|
3
|
+
import {} from "@tanstack/react-table";
|
|
2
4
|
const fieldStatusIconMap = {
|
|
3
5
|
completed: CheckCheck,
|
|
4
6
|
failed: X,
|
|
@@ -21,3 +23,11 @@ export function getFieldTypeIcon(fieldType) {
|
|
|
21
23
|
export function getFieldStatusIcon(fieldStatus) {
|
|
22
24
|
return fieldStatusIconMap[fieldStatus];
|
|
23
25
|
}
|
|
26
|
+
export const fuzzyFilter = (row, columnId, value, addMeta) => {
|
|
27
|
+
// Rank the item
|
|
28
|
+
const itemRank = rankItem(row.getValue(columnId), value);
|
|
29
|
+
// Store the itemRank info
|
|
30
|
+
addMeta({ itemRank });
|
|
31
|
+
// Return if the item should be filtered in/out
|
|
32
|
+
return itemRank.passed;
|
|
33
|
+
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@pipe0/react-sdk",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.73",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "React utils to work with pipe0",
|
|
6
6
|
"keywords": [
|
|
@@ -30,11 +30,12 @@
|
|
|
30
30
|
"author": "",
|
|
31
31
|
"license": "MIT",
|
|
32
32
|
"dependencies": {
|
|
33
|
+
"@tanstack/match-sorter-utils": "^8.19.4",
|
|
33
34
|
"@tanstack/react-table": "^8.21.3",
|
|
34
35
|
"lucide-react": "^0.475.0",
|
|
35
36
|
"react": "^19.0.0",
|
|
36
37
|
"react-dom": "^19.0.0",
|
|
37
|
-
"@pipe0/ops": "0.0.
|
|
38
|
+
"@pipe0/ops": "0.0.4"
|
|
38
39
|
},
|
|
39
40
|
"devDependencies": {
|
|
40
41
|
"@types/node": "^22.18.10",
|