@pipe0/react 1.0.29 → 1.0.31
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/CHANGELOG.md +16 -0
- package/dist/components/compound/pipe-catalog/active-filters.mjs +1 -1
- package/dist/components/compound/pipe-catalog/active-filters.mjs.map +1 -1
- package/dist/components/compound/search-catalog/active-filters.mjs +1 -1
- package/dist/components/compound/search-catalog/active-filters.mjs.map +1 -1
- package/dist/components/compound/searches-catalog/active-filters.mjs +1 -1
- package/dist/components/compound/searches-catalog/active-filters.mjs.map +1 -1
- package/dist/components/ui/button.d.mts +1 -1
- package/dist/hooks/catalog-table.d.mts +83 -0
- package/dist/hooks/catalog-table.d.mts.map +1 -0
- package/dist/hooks/catalog-table.mjs +42 -0
- package/dist/hooks/catalog-table.mjs.map +1 -0
- package/dist/hooks/use-effect-catalog-table.d.mts +17 -1
- package/dist/hooks/use-effect-catalog-table.d.mts.map +1 -1
- package/dist/hooks/use-effect-catalog-table.mjs +11 -20
- package/dist/hooks/use-effect-catalog-table.mjs.map +1 -1
- package/dist/hooks/use-pipe-catalog-table.d.mts +17 -1
- package/dist/hooks/use-pipe-catalog-table.d.mts.map +1 -1
- package/dist/hooks/use-pipe-catalog-table.mjs +20 -29
- package/dist/hooks/use-pipe-catalog-table.mjs.map +1 -1
- package/dist/hooks/use-search-catalog-table.d.mts +17 -1
- package/dist/hooks/use-search-catalog-table.d.mts.map +1 -1
- package/dist/hooks/use-search-catalog-table.mjs +20 -29
- package/dist/hooks/use-search-catalog-table.mjs.map +1 -1
- package/dist/hooks/use-searches-catalog-table.d.mts +17 -1
- package/dist/hooks/use-searches-catalog-table.d.mts.map +1 -1
- package/dist/hooks/use-searches-catalog-table.mjs +20 -29
- package/dist/hooks/use-searches-catalog-table.mjs.map +1 -1
- package/dist/index.d.mts +3 -2
- package/dist/index.mjs +3 -2
- package/dist/utils/catalog-helpers.d.mts +21 -4
- package/dist/utils/catalog-helpers.d.mts.map +1 -1
- package/dist/utils/catalog-helpers.mjs +33 -4
- package/dist/utils/catalog-helpers.mjs.map +1 -1
- package/package.json +3 -3
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { scoreCatalogSearch } from "@pipe0/base";
|
|
2
|
-
import { BookDashed, Bookmark, Braces, CheckCheck, Hash, HelpCircle, Loader, Pause, ToggleRight, TriangleDashed, Type, X } from "lucide-react";
|
|
2
|
+
import { AtSign, BookDashed, Bookmark, Braces, Calendar, CalendarClock, CheckCheck, Coins, Contact, Globe, Hash, HelpCircle, Loader, MapPin, Pause, Percent, Phone, TextAlignStart, ToggleRight, TriangleDashed, Type, X } from "lucide-react";
|
|
3
3
|
import { rankItem } from "@tanstack/match-sorter-utils";
|
|
4
4
|
|
|
5
5
|
//#region src/utils/catalog-helpers.tsx
|
|
@@ -22,17 +22,46 @@ const FieldTypeIconMap = {
|
|
|
22
22
|
function getFieldTypeIcon(fieldType) {
|
|
23
23
|
return FieldTypeIconMap[fieldType];
|
|
24
24
|
}
|
|
25
|
+
const FieldFormatIconMap = {
|
|
26
|
+
email: AtSign,
|
|
27
|
+
url: Globe,
|
|
28
|
+
website_url: Globe,
|
|
29
|
+
domain: Globe,
|
|
30
|
+
profile_url: Contact,
|
|
31
|
+
phone: Phone,
|
|
32
|
+
date: Calendar,
|
|
33
|
+
datetime: CalendarClock,
|
|
34
|
+
address_line_1: MapPin,
|
|
35
|
+
zip_code: Hash,
|
|
36
|
+
currency: Coins,
|
|
37
|
+
percent: Percent,
|
|
38
|
+
markdown: TextAlignStart,
|
|
39
|
+
long_text: TextAlignStart,
|
|
40
|
+
text: Type,
|
|
41
|
+
int: Hash,
|
|
42
|
+
decimal: Hash,
|
|
43
|
+
json_object: Braces,
|
|
44
|
+
json_list: Braces,
|
|
45
|
+
json_list_string: Braces
|
|
46
|
+
};
|
|
47
|
+
/**
|
|
48
|
+
* Column icon: the format is the expressive signal (an email column looks
|
|
49
|
+
* different from a date column), the type is the fallback for untyped fields.
|
|
50
|
+
*/
|
|
51
|
+
function getFieldFormatIcon(format, fieldType) {
|
|
52
|
+
return (format ? FieldFormatIconMap[format] : void 0) ?? getFieldTypeIcon(fieldType);
|
|
53
|
+
}
|
|
25
54
|
function getFieldStatusIcon(fieldStatus) {
|
|
26
55
|
return fieldStatusIconMap[fieldStatus];
|
|
27
56
|
}
|
|
28
57
|
const fuzzyFilter = (row, columnId, value, addMeta) => {
|
|
29
58
|
const itemRank = rankItem(row.getValue(columnId), value);
|
|
30
|
-
addMeta({ itemRank });
|
|
59
|
+
addMeta?.({ itemRank });
|
|
31
60
|
return itemRank.passed;
|
|
32
61
|
};
|
|
33
62
|
const catalogSearchFilter = (row, columnId, value, addMeta) => {
|
|
34
63
|
const score = scoreCatalogSearch(row.getValue(columnId), String(value ?? ""));
|
|
35
|
-
addMeta({ searchScore: score });
|
|
64
|
+
addMeta?.({ searchScore: score });
|
|
36
65
|
return score > 0;
|
|
37
66
|
};
|
|
38
67
|
const catalogSearchSort = (rowA, rowB, columnId) => {
|
|
@@ -40,5 +69,5 @@ const catalogSearchSort = (rowA, rowB, columnId) => {
|
|
|
40
69
|
};
|
|
41
70
|
|
|
42
71
|
//#endregion
|
|
43
|
-
export { catalogSearchFilter, catalogSearchSort, fuzzyFilter, getFieldStatusIcon, getFieldTypeIcon };
|
|
72
|
+
export { catalogSearchFilter, catalogSearchSort, fuzzyFilter, getFieldFormatIcon, getFieldStatusIcon, getFieldTypeIcon };
|
|
44
73
|
//# sourceMappingURL=catalog-helpers.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"catalog-helpers.mjs","names":[],"sources":["../../src/utils/catalog-helpers.tsx"],"sourcesContent":["import { type RecordFieldStatus
|
|
1
|
+
{"version":3,"file":"catalog-helpers.mjs","names":[],"sources":["../../src/utils/catalog-helpers.tsx"],"sourcesContent":["import {\n type CatalogSearchTarget,\n type RecordFieldFormat,\n type RecordFieldStatus,\n type RecordFieldType,\n scoreCatalogSearch,\n} from \"@pipe0/base\";\nimport { type RankingInfo, rankItem } from \"@tanstack/match-sorter-utils\";\nimport type { FilterFn, RowData, SortFn, TableFeatures } from \"@tanstack/react-table\";\nimport {\n AtSign,\n BookDashed,\n Bookmark,\n Braces,\n Calendar,\n CalendarClock,\n CheckCheck,\n Coins,\n Contact,\n Globe,\n Hash,\n HelpCircle,\n Loader,\n MapPin,\n Pause,\n Percent,\n Phone,\n TextAlignStart,\n ToggleRight,\n TriangleDashed,\n Type,\n X,\n} from \"lucide-react\";\nimport type { ComponentType } from \"react\";\n\nconst fieldStatusIconMap = {\n completed: CheckCheck,\n failed: X,\n no_result: BookDashed,\n pending: Bookmark,\n processing: Loader,\n queued: Pause,\n skipped: TriangleDashed,\n} satisfies Record<RecordFieldStatus, ComponentType>;\n\nconst FieldTypeIconMap = {\n boolean: ToggleRight,\n json: Braces,\n number: Hash,\n string: Type,\n unknown: HelpCircle,\n} satisfies Record<RecordFieldType, ComponentType>;\n\nexport function getFieldTypeIcon(fieldType: RecordFieldType) {\n return FieldTypeIconMap[fieldType];\n}\n\nconst FieldFormatIconMap: Partial<Record<NonNullable<RecordFieldFormat>, ComponentType>> = {\n email: AtSign,\n url: Globe,\n website_url: Globe,\n domain: Globe,\n profile_url: Contact,\n phone: Phone,\n date: Calendar,\n datetime: CalendarClock,\n address_line_1: MapPin,\n zip_code: Hash,\n currency: Coins,\n percent: Percent,\n markdown: TextAlignStart,\n long_text: TextAlignStart,\n text: Type,\n int: Hash,\n decimal: Hash,\n json_object: Braces,\n json_list: Braces,\n json_list_string: Braces,\n};\n\n/**\n * Column icon: the format is the expressive signal (an email column looks\n * different from a date column), the type is the fallback for untyped fields.\n */\nexport function getFieldFormatIcon(format: RecordFieldFormat, fieldType: RecordFieldType) {\n return (format ? FieldFormatIconMap[format] : undefined) ?? getFieldTypeIcon(fieldType);\n}\n\nexport function getFieldStatusIcon(fieldStatus: RecordFieldStatus) {\n return fieldStatusIconMap[fieldStatus];\n}\n\n/** Filter meta the catalog filter fns attach to rows, read back by the sort fns. */\nexport interface CatalogFilterMeta {\n itemRank?: RankingInfo;\n searchScore?: number;\n}\n\n// Docs idiom (fuzzy-filtering guide): a features type that only carries the\n// meta shape, so these fns are not coupled to one exact features object.\nexport type CatalogSearchFeatures = TableFeatures & { filterMeta: CatalogFilterMeta };\n\nexport const fuzzyFilter: FilterFn<CatalogSearchFeatures, RowData> = (\n row,\n columnId,\n value,\n addMeta,\n) => {\n const itemRank = rankItem(row.getValue(columnId), value);\n addMeta?.({ itemRank });\n return itemRank.passed;\n};\n\n// Global-filter fn for the catalog tables' hidden \"search\" column (its value\n// is a precomputed CatalogSearchTarget). Stashes the score so\n// catalogSearchSort can order rows by relevance while a query is active.\nexport const catalogSearchFilter: FilterFn<CatalogSearchFeatures, RowData> = (\n row,\n columnId,\n value,\n addMeta,\n) => {\n const score = scoreCatalogSearch(\n row.getValue<CatalogSearchTarget>(columnId),\n String(value ?? \"\"),\n );\n addMeta?.({ searchScore: score });\n return score > 0;\n};\n\nexport const catalogSearchSort: SortFn<CatalogSearchFeatures, RowData> = (rowA, rowB, columnId) => {\n const a = rowA.columnFiltersMeta[columnId]?.searchScore ?? 0;\n const b = rowB.columnFiltersMeta[columnId]?.searchScore ?? 0;\n return a - b; // paired with `desc: true` → highest score first\n};\n"],"mappings":";;;;;AAmCA,MAAM,qBAAqB;CACzB,WAAW;CACX,QAAQ;CACR,WAAW;CACX,SAAS;CACT,YAAY;CACZ,QAAQ;CACR,SAAS;CACV;AAED,MAAM,mBAAmB;CACvB,SAAS;CACT,MAAM;CACN,QAAQ;CACR,QAAQ;CACR,SAAS;CACV;AAED,SAAgB,iBAAiB,WAA4B;AAC3D,QAAO,iBAAiB;;AAG1B,MAAM,qBAAqF;CACzF,OAAO;CACP,KAAK;CACL,aAAa;CACb,QAAQ;CACR,aAAa;CACb,OAAO;CACP,MAAM;CACN,UAAU;CACV,gBAAgB;CAChB,UAAU;CACV,UAAU;CACV,SAAS;CACT,UAAU;CACV,WAAW;CACX,MAAM;CACN,KAAK;CACL,SAAS;CACT,aAAa;CACb,WAAW;CACX,kBAAkB;CACnB;;;;;AAMD,SAAgB,mBAAmB,QAA2B,WAA4B;AACxF,SAAQ,SAAS,mBAAmB,UAAU,WAAc,iBAAiB,UAAU;;AAGzF,SAAgB,mBAAmB,aAAgC;AACjE,QAAO,mBAAmB;;AAa5B,MAAa,eACX,KACA,UACA,OACA,YACG;CACH,MAAM,WAAW,SAAS,IAAI,SAAS,SAAS,EAAE,MAAM;AACxD,WAAU,EAAE,UAAU,CAAC;AACvB,QAAO,SAAS;;AAMlB,MAAa,uBACX,KACA,UACA,OACA,YACG;CACH,MAAM,QAAQ,mBACZ,IAAI,SAA8B,SAAS,EAC3C,OAAO,SAAS,GAAG,CACpB;AACD,WAAU,EAAE,aAAa,OAAO,CAAC;AACjC,QAAO,QAAQ;;AAGjB,MAAa,qBAA6D,MAAM,MAAM,aAAa;AAGjG,SAFU,KAAK,kBAAkB,WAAW,eAAe,MACjD,KAAK,kBAAkB,WAAW,eAAe"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@pipe0/react",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.31",
|
|
4
4
|
"description": "React component library for building forms and catalogs powered by pipe0 pipes and searches.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"author": "pipe0",
|
|
@@ -71,7 +71,7 @@
|
|
|
71
71
|
"@hookform/resolvers": "^5.2.1",
|
|
72
72
|
"@radix-ui/react-slot": "^1.2.2",
|
|
73
73
|
"@tanstack/match-sorter-utils": "^8.19.4",
|
|
74
|
-
"@tanstack/react-table": "^
|
|
74
|
+
"@tanstack/react-table": "^9.2.4",
|
|
75
75
|
"@tiptap/core": "^3.7.2",
|
|
76
76
|
"@tiptap/pm": "^3.7.2",
|
|
77
77
|
"@tiptap/react": "^3.7.2",
|
|
@@ -85,7 +85,7 @@
|
|
|
85
85
|
"react-hook-form": "^7.62.0",
|
|
86
86
|
"swr": "^2.4.1",
|
|
87
87
|
"tailwind-merge": "^3.3.1",
|
|
88
|
-
"@pipe0/base": "1.0.
|
|
88
|
+
"@pipe0/base": "1.0.31"
|
|
89
89
|
},
|
|
90
90
|
"devDependencies": {
|
|
91
91
|
"@base-ui/react": "^1.6.0",
|