@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 +1 @@
|
|
|
1
|
-
{"version":3,"file":"use-pipe-catalog-table.mjs","names":[],"sources":["../../src/hooks/use-pipe-catalog-table.ts"],"sourcesContent":["import {\n type CatalogFilter,\n collectRequirementFields,\n filterPipeEntries,\n getDefaultOutputFields,\n getDefaultPipeProviders,\n getInitialTableData,\n getLowestPipeCreditAmount,\n getPipeAccessLevel,\n getPipeSearchTarget,\n getStartingCostPerPipesProvider,\n getTableDataAggregates,\n isEntryAccessible,\n isTokenBilledOperations,\n type OrgAccessLevel,\n type PipeCatalogEntry,\n type PipeCategory,\n type PipeEntryWithLatestVersion,\n type PipeId,\n} from \"@pipe0/base\";\nimport {\n type ColumnFilter,\n createColumnHelper,\n getCoreRowModel,\n getFilteredRowModel,\n getSortedRowModel,\n useReactTable,\n} from \"@tanstack/react-table\";\nimport { useCallback, useMemo, useState } from \"react\";\nimport type { PipeCardData } from \"../types/catalog-adapters.js\";\nimport { catalogSearchFilter, catalogSearchSort } from \"../utils/catalog-helpers.js\";\nimport { useDebounce } from \"./use-debounce.js\";\n\nexport type InputFieldEntries = Record<string, PipeId[]>;\nexport type OutputFieldEntries = Record<string, PipeId[]>;\n\n/**\n * Access-ladder trim for table data: partner-gated entries are hidden below\n * partner. Verified-gated entries stay in the table — the cards mark them\n * `locked` so they render grayed with a \"requires verification\" note. No\n * `accessLevel` (undefined) = no gating, so existing consumers are unchanged.\n */\nfunction hidePartnerGated<T extends { pipeId: PipeId }>(\n rows: T[],\n accessLevel: OrgAccessLevel | undefined,\n): T[] {\n if (accessLevel === undefined || accessLevel === \"partner\") return rows;\n return rows.filter((row) => getPipeAccessLevel(row.pipeId) !== \"partner\");\n}\n\nconst columnHelper = createColumnHelper<PipeEntryWithLatestVersion>();\n\nconst columns = [\n columnHelper.accessor(\"pipeId\", {\n filterFn: \"includesString\",\n enableGlobalFilter: false,\n }),\n columnHelper.accessor(\"label\", {\n enableGlobalFilter: false,\n }),\n columnHelper.accessor(\"description\", {\n enableGlobalFilter: false,\n }),\n columnHelper.accessor(\n (row) =>\n row.defaultInputRequirement\n ? collectRequirementFields(row.defaultInputRequirement).map(({ field }) => field.name)\n : [],\n {\n id: \"inputFields\",\n filterFn: \"arrIncludes\",\n enableGlobalFilter: false,\n },\n ),\n columnHelper.accessor((row) => getDefaultOutputFields(row) || [], {\n id: \"outputFields\",\n filterFn: \"arrIncludes\",\n enableGlobalFilter: false,\n }),\n columnHelper.accessor((row) => row.tags || [], {\n id: \"tags\",\n filterFn: \"arrIncludes\",\n enableGlobalFilter: false,\n }),\n columnHelper.accessor((row) => getDefaultPipeProviders(row.pipeId) || [], {\n id: \"providers\",\n filterFn: \"arrIncludes\",\n enableGlobalFilter: false,\n }),\n // Hidden relevance column — the ONLY globally-filterable one, so the global\n // filter scores each row exactly once and catalogSearchSort can read the\n // score back from this column's filter meta.\n columnHelper.accessor((row) => getPipeSearchTarget(row), {\n id: \"search\",\n enableGlobalFilter: true,\n enableSorting: true,\n sortingFn: catalogSearchSort,\n }),\n];\n\nexport function usePipeCatalogTable(\n config: {\n initialColumnFilters?: ColumnFilter[];\n /**\n * Optional whitelist/blacklist of pipes and providers. Memoize to avoid\n * recomputing the table data on every render.\n */\n filter?: CatalogFilter;\n /**\n * The viewing org's access level. Hides partner-gated pipes below partner\n * and marks verified-gated cards `locked` below verified. Omit for no\n * gating (docs/playground).\n */\n accessLevel?: OrgAccessLevel;\n } = {},\n) {\n const [category, setCategory] = useState<PipeCategory | null>(null);\n const { initialColumnFilters = [] as ColumnFilter[], filter, accessLevel } = config;\n\n const initialTableData = useMemo(\n () => hidePartnerGated(filterPipeEntries(getInitialTableData(category), filter), accessLevel),\n [category, filter, accessLevel],\n );\n\n // Baseline (config.filter applied, but no category / column / global filter).\n // Drives the stable category-button counts so the row doesn't jump when the\n // user changes a filter.\n const baselineTableData = useMemo(\n () => hidePartnerGated(filterPipeEntries(getInitialTableData(null), filter), accessLevel),\n [filter, accessLevel],\n );\n\n const table = useReactTable({\n columns,\n data: initialTableData,\n getCoreRowModel: getCoreRowModel(),\n getFilteredRowModel: getFilteredRowModel(),\n getSortedRowModel: getSortedRowModel(),\n globalFilterFn: catalogSearchFilter,\n getColumnCanGlobalFilter: (column) => column.columnDef.enableGlobalFilter !== false,\n initialState: {\n columnFilters: initialColumnFilters,\n pagination: {\n pageSize: 10,\n },\n },\n });\n\n const columnFilters = table.getState().columnFilters;\n\n const aggregates = useMemo(\n () => getTableDataAggregates(initialTableData, category),\n [category, initialTableData],\n );\n\n const [globalFilterInput, setGlobalFilterInput, setGlobalFilterImmediately] = useDebounce((v) => {\n if (v === table.getState().globalFilter) return;\n table.setGlobalFilter(v);\n // Relevance order only while a query is active; empty query restores\n // catalog order.\n table.setSorting(v ? [{ id: \"search\", desc: true }] : []);\n if (v) {\n setCategory(null);\n table.setColumnFilters([]);\n }\n });\n\n const addColumnFilter = useCallback(\n (id: \"inputFields\" | \"outputFields\" | \"tags\" | \"providers\", value: string) => {\n setGlobalFilterImmediately(\"\");\n table.setColumnFilters([{ id, value }]);\n },\n [setGlobalFilterImmediately, table],\n );\n\n const handleCategoryChange = useCallback(\n (category: PipeCategory | null) => {\n setCategory(category);\n table.setColumnFilters([]);\n setGlobalFilterImmediately(\"\");\n },\n [table, setGlobalFilterImmediately],\n );\n\n const resetFilters = useCallback(() => {\n setGlobalFilterImmediately(\"\");\n setCategory(null);\n }, [setGlobalFilterImmediately]);\n\n const removeColumnFilter = useCallback(\n (id: \"inputFields\" | \"outputFields\" | \"tags\" | \"providers\") => {\n table.getColumn(id)?.setFilterValue(null);\n },\n [table],\n );\n\n const getColumnFilterValue = useCallback(\n (id: \"inputFields\" | \"outputFields\" | \"tags\" | \"providers\") => {\n const res = columnFilters.find((f) => f.id === id)?.value;\n return res as string;\n },\n [columnFilters],\n );\n\n // Pre-compute card display data so consumers don't have to. Memoized on\n // the filtered rows + aggregate map (both stable references from tanstack).\n const rows = table.getRowModel().rows;\n const cards = useMemo<PipeCardData[]>(\n () =>\n rows.map((row) => {\n const entry = row.original;\n const latestEntry = (aggregates.pipeEntriesByBasePipe[entry.basePipe]?.[0] ??\n entry) as PipeCatalogEntry & { pipeId: PipeId };\n const providers = getDefaultPipeProviders(latestEntry.pipeId);\n const gate = getPipeAccessLevel(latestEntry.pipeId);\n const locked =\n accessLevel !== undefined && gate !== undefined && !isEntryAccessible(gate, accessLevel);\n return {\n ...(locked ? { locked, requiredAccessLevel: gate } : {}),\n pipeId: latestEntry.pipeId,\n basePipe: entry.basePipe,\n label: entry.label,\n description: entry.description,\n providers,\n startingCostPerProvider: getStartingCostPerPipesProvider(latestEntry.pipeId),\n startingCreditAmount: getLowestPipeCreditAmount(latestEntry),\n costMode: isTokenBilledOperations(latestEntry.billableOperations)\n ? \"usage\"\n : \"per_result\",\n defaultInputFields: latestEntry.defaultInputRequirement\n ? collectRequirementFields(latestEntry.defaultInputRequirement).map(({ field }) => ({\n name: field.name,\n }))\n : [],\n defaultOutputFields: getDefaultOutputFields(latestEntry) ?? [],\n docPath: latestEntry.docPath,\n entry,\n latestEntry,\n };\n }),\n [rows, aggregates.pipeEntriesByBasePipe, accessLevel],\n );\n\n // Group cards by category. Pipes can belong to multiple categories — they\n // appear once per matching category. Order: insertion (first-seen).\n const cardsByCategory = useMemo<{ category: PipeCategory; cards: PipeCardData[] }[]>(() => {\n const groups = new Map<PipeCategory, PipeCardData[]>();\n for (const card of cards) {\n const cats = (card.entry.categories ?? []) as PipeCategory[];\n for (const cat of cats) {\n const arr = groups.get(cat);\n if (arr) arr.push(card);\n else groups.set(cat, [card]);\n }\n }\n return Array.from(groups, ([category, group]) => ({\n category,\n cards: group,\n }));\n }, [cards]);\n\n // Count of cards per category (a pipe in N categories counts N times).\n const categoryCounts = useMemo<Partial<Record<PipeCategory, number>>>(() => {\n const counts: Partial<Record<PipeCategory, number>> = {};\n for (const card of cards) {\n const cats = (card.entry.categories ?? []) as PipeCategory[];\n for (const cat of cats) {\n counts[cat] = (counts[cat] ?? 0) + 1;\n }\n }\n return counts;\n }, [cards]);\n\n // Stable counts based on the baseline (no category / column / global filter\n // applied). Use these to render category-selector counts that don't jump as\n // the user clicks around.\n const baselineCardCount = baselineTableData.length;\n const baselineCategoryCounts = useMemo<Partial<Record<PipeCategory, number>>>(() => {\n const counts: Partial<Record<PipeCategory, number>> = {};\n for (const entry of baselineTableData) {\n const cats = (entry.categories ?? []) as PipeCategory[];\n for (const cat of cats) {\n counts[cat] = (counts[cat] ?? 0) + 1;\n }\n }\n return counts;\n }, [baselineTableData]);\n\n return {\n table,\n cards,\n cardsByCategory,\n categoryCounts,\n baselineCardCount,\n baselineCategoryCounts,\n\n // category + global filter\n category,\n setCategory: handleCategoryChange,\n globalFilterInput,\n setGlobalFilterInput,\n\n // mutators\n addColumnFilter,\n removeColumnFilter,\n resetFilters,\n getColumnFilterValue,\n\n // aggregates for filter UI\n sortedInputFieldEntries: aggregates.sortedInputFieldEntries,\n sortedOutputFieldEntries: aggregates.sortedOutputFieldEntries,\n sortedTagEntries: aggregates.sortedTagEntries,\n sortedProviderEntries: aggregates.sortedProviderEntries,\n\n // reverse indexes (power-user / inverted-filter UX)\n pipeIdsByInputField: aggregates.pipeIdsByInputField,\n pipeIdsByOutputField: aggregates.pipeIdsByOutputField,\n pipeIdsByProvider: aggregates.pipeIdsByProvider,\n pipeIdsByTag: aggregates.pipeIdsByTag,\n };\n}\n\nexport type UsePipeCatalogTableReturn = ReturnType<typeof usePipeCatalogTable>;\n"],"mappings":";;;;;;;;;;;;;AA0CA,SAAS,iBACP,MACA,aACK;AACL,KAAI,gBAAgB,UAAa,gBAAgB,UAAW,QAAO;AACnE,QAAO,KAAK,QAAQ,QAAQ,mBAAmB,IAAI,OAAO,KAAK,UAAU;;AAG3E,MAAM,eAAe,oBAAgD;AAErE,MAAM,UAAU;CACd,aAAa,SAAS,UAAU;EAC9B,UAAU;EACV,oBAAoB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vC,UAAO;KACN,CAAC,MAAM,CAAC;EAsBT,mBAjBwB,kBAAkB;EAkB1C,wBAjB6B,cAAqD;GAClF,MAAM,SAAgD,EAAE;AACxD,QAAK,MAAM,SAAS,mBAAmB;IACrC,MAAM,OAAQ,MAAM,cAAc,EAAE;AACpC,SAAK,MAAM,OAAO,KAChB,QAAO,QAAQ,OAAO,QAAQ,KAAK;;AAGvC,UAAO;KACN,CAAC,kBAAkB,CAAC;EAWrB;EACA,aAAa;EACb;EACA;EAGA;EACA;EACA;EACA;EAGA,yBAAyB,WAAW;EACpC,0BAA0B,WAAW;EACrC,kBAAkB,WAAW;EAC7B,uBAAuB,WAAW;EAGlC,qBAAqB,WAAW;EAChC,sBAAsB,WAAW;EACjC,mBAAmB,WAAW;EAC9B,cAAc,WAAW;EAC1B"}
|
|
1
|
+
{"version":3,"file":"use-pipe-catalog-table.mjs","names":[],"sources":["../../src/hooks/use-pipe-catalog-table.ts"],"sourcesContent":["import {\n type CatalogFilter,\n collectRequirementFields,\n filterPipeEntries,\n getDefaultOutputFields,\n getDefaultPipeProviders,\n getInitialTableData,\n getLowestPipeCreditAmount,\n getPipeAccessLevel,\n getPipeSearchTarget,\n getStartingCostPerPipesProvider,\n getTableDataAggregates,\n isEntryAccessible,\n isTokenBilledOperations,\n type OrgAccessLevel,\n type PipeCatalogEntry,\n type PipeCategory,\n type PipeEntryWithLatestVersion,\n type PipeId,\n} from \"@pipe0/base\";\nimport type { ColumnFilter } from \"@tanstack/react-table\";\nimport { useMemo, useState } from \"react\";\nimport type { PipeCardData } from \"../types/catalog-adapters.js\";\nimport { createCatalogColumnHelper, useCatalogTable } from \"./catalog-table.js\";\nimport { useDebounce } from \"./use-debounce.js\";\n\nexport type InputFieldEntries = Record<string, PipeId[]>;\nexport type OutputFieldEntries = Record<string, PipeId[]>;\n\n/**\n * Access-ladder trim for table data: partner-gated entries are hidden below\n * partner. Verified-gated entries stay in the table — the cards mark them\n * `locked` so they render grayed with a \"requires verification\" note. No\n * `accessLevel` (undefined) = no gating, so existing consumers are unchanged.\n */\nfunction hidePartnerGated<T extends { pipeId: PipeId }>(\n rows: T[],\n accessLevel: OrgAccessLevel | undefined,\n): T[] {\n if (accessLevel === undefined || accessLevel === \"partner\") return rows;\n return rows.filter((row) => getPipeAccessLevel(row.pipeId) !== \"partner\");\n}\n\nconst columnHelper = createCatalogColumnHelper<PipeEntryWithLatestVersion>();\n\nconst columns = columnHelper.columns([\n columnHelper.accessor(\"pipeId\", {\n filterFn: \"includesString\",\n enableGlobalFilter: false,\n }),\n columnHelper.accessor(\"label\", {\n enableGlobalFilter: false,\n }),\n columnHelper.accessor(\"description\", {\n enableGlobalFilter: false,\n }),\n columnHelper.accessor(\n (row) =>\n row.defaultInputRequirement\n ? collectRequirementFields(row.defaultInputRequirement).map(({ field }) => field.name)\n : [],\n {\n id: \"inputFields\",\n filterFn: \"arrIncludes\",\n enableGlobalFilter: false,\n },\n ),\n columnHelper.accessor((row) => getDefaultOutputFields(row) || [], {\n id: \"outputFields\",\n filterFn: \"arrIncludes\",\n enableGlobalFilter: false,\n }),\n columnHelper.accessor((row) => row.tags || [], {\n id: \"tags\",\n filterFn: \"arrIncludes\",\n enableGlobalFilter: false,\n }),\n columnHelper.accessor((row) => getDefaultPipeProviders(row.pipeId) || [], {\n id: \"providers\",\n filterFn: \"arrIncludes\",\n enableGlobalFilter: false,\n }),\n // Hidden relevance column — the ONLY globally-filterable one, so the global\n // filter scores each row exactly once and catalogSearchSort can read the\n // score back from this column's filter meta.\n columnHelper.accessor((row) => getPipeSearchTarget(row), {\n id: \"search\",\n enableGlobalFilter: true,\n enableSorting: true,\n sortFn: \"catalogSearch\",\n }),\n]);\n\nexport function usePipeCatalogTable(\n config: {\n initialColumnFilters?: ColumnFilter[];\n /**\n * Optional whitelist/blacklist of pipes and providers. Memoize to avoid\n * recomputing the table data on every render.\n */\n filter?: CatalogFilter;\n /**\n * The viewing org's access level. Hides partner-gated pipes below partner\n * and marks verified-gated cards `locked` below verified. Omit for no\n * gating (docs/playground).\n */\n accessLevel?: OrgAccessLevel;\n } = {},\n) {\n const [category, setCategory] = useState<PipeCategory | null>(null);\n const { initialColumnFilters = [] as ColumnFilter[], filter, accessLevel } = config;\n\n const initialTableData = useMemo(\n () => hidePartnerGated(filterPipeEntries(getInitialTableData(category), filter), accessLevel),\n [category, filter, accessLevel],\n );\n\n // Baseline (config.filter applied, but no category / column / global filter).\n // Drives the stable category-button counts so the row doesn't jump when the\n // user changes a filter.\n const baselineTableData = useMemo(\n () => hidePartnerGated(filterPipeEntries(getInitialTableData(null), filter), accessLevel),\n [filter, accessLevel],\n );\n\n const table = useCatalogTable({\n columns,\n data: initialTableData,\n initialState: { columnFilters: initialColumnFilters },\n });\n\n const columnFilters = table.state.columnFilters;\n\n const aggregates = useMemo(\n () => getTableDataAggregates(initialTableData, category),\n [category, initialTableData],\n );\n\n const [globalFilterInput, setGlobalFilterInput, setGlobalFilterImmediately] = useDebounce((v) => {\n if (v === table.atoms.globalFilter.get()) return;\n table.setGlobalFilter(v);\n // Relevance order only while a query is active; empty query restores\n // catalog order.\n table.setSorting(v ? [{ id: \"search\", desc: true }] : []);\n if (v) {\n setCategory(null);\n table.setColumnFilters([]);\n }\n });\n\n const addColumnFilter = (\n id: \"inputFields\" | \"outputFields\" | \"tags\" | \"providers\",\n value: string,\n ) => {\n setGlobalFilterImmediately(\"\");\n table.setColumnFilters([{ id, value }]);\n };\n\n const handleCategoryChange = (category: PipeCategory | null) => {\n setCategory(category);\n table.setColumnFilters([]);\n setGlobalFilterImmediately(\"\");\n };\n\n const resetFilters = () => {\n setGlobalFilterImmediately(\"\");\n setCategory(null);\n };\n\n const removeColumnFilter = (id: \"inputFields\" | \"outputFields\" | \"tags\" | \"providers\") => {\n table.getColumn(id)?.setFilterValue(null);\n };\n\n const getColumnFilterValue = (id: \"inputFields\" | \"outputFields\" | \"tags\" | \"providers\") => {\n const res = columnFilters.find((f) => f.id === id)?.value;\n return res as string;\n };\n\n // Pre-compute card display data so consumers don't have to. Memoized on\n // the filtered rows + aggregate map (both stable references from tanstack).\n const rows = table.getRowModel().rows;\n const cards = useMemo<PipeCardData[]>(\n () =>\n rows.map((row) => {\n const entry = row.original;\n const latestEntry = (aggregates.pipeEntriesByBasePipe[entry.basePipe]?.[0] ??\n entry) as PipeCatalogEntry & { pipeId: PipeId };\n const providers = getDefaultPipeProviders(latestEntry.pipeId);\n const gate = getPipeAccessLevel(latestEntry.pipeId);\n const locked =\n accessLevel !== undefined && gate !== undefined && !isEntryAccessible(gate, accessLevel);\n return {\n ...(locked ? { locked, requiredAccessLevel: gate } : {}),\n pipeId: latestEntry.pipeId,\n basePipe: entry.basePipe,\n label: entry.label,\n description: entry.description,\n providers,\n startingCostPerProvider: getStartingCostPerPipesProvider(latestEntry.pipeId),\n startingCreditAmount: getLowestPipeCreditAmount(latestEntry),\n costMode: isTokenBilledOperations(latestEntry.billableOperations)\n ? \"usage\"\n : \"per_result\",\n defaultInputFields: latestEntry.defaultInputRequirement\n ? collectRequirementFields(latestEntry.defaultInputRequirement).map(({ field }) => ({\n name: field.name,\n }))\n : [],\n defaultOutputFields: getDefaultOutputFields(latestEntry) ?? [],\n docPath: latestEntry.docPath,\n entry,\n latestEntry,\n };\n }),\n [rows, aggregates.pipeEntriesByBasePipe, accessLevel],\n );\n\n // Group cards by category. Pipes can belong to multiple categories — they\n // appear once per matching category. Order: insertion (first-seen).\n const cardsByCategory = useMemo<{ category: PipeCategory; cards: PipeCardData[] }[]>(() => {\n const groups = new Map<PipeCategory, PipeCardData[]>();\n for (const card of cards) {\n const cats = (card.entry.categories ?? []) as PipeCategory[];\n for (const cat of cats) {\n const arr = groups.get(cat);\n if (arr) arr.push(card);\n else groups.set(cat, [card]);\n }\n }\n return Array.from(groups, ([category, group]) => ({\n category,\n cards: group,\n }));\n }, [cards]);\n\n // Count of cards per category (a pipe in N categories counts N times).\n const categoryCounts = useMemo<Partial<Record<PipeCategory, number>>>(() => {\n const counts: Partial<Record<PipeCategory, number>> = {};\n for (const card of cards) {\n const cats = (card.entry.categories ?? []) as PipeCategory[];\n for (const cat of cats) {\n counts[cat] = (counts[cat] ?? 0) + 1;\n }\n }\n return counts;\n }, [cards]);\n\n // Stable counts based on the baseline (no category / column / global filter\n // applied). Use these to render category-selector counts that don't jump as\n // the user clicks around.\n const baselineCardCount = baselineTableData.length;\n const baselineCategoryCounts = useMemo<Partial<Record<PipeCategory, number>>>(() => {\n const counts: Partial<Record<PipeCategory, number>> = {};\n for (const entry of baselineTableData) {\n const cats = (entry.categories ?? []) as PipeCategory[];\n for (const cat of cats) {\n counts[cat] = (counts[cat] ?? 0) + 1;\n }\n }\n return counts;\n }, [baselineTableData]);\n\n return {\n table,\n cards,\n cardsByCategory,\n categoryCounts,\n baselineCardCount,\n baselineCategoryCounts,\n\n // category + global filter\n category,\n setCategory: handleCategoryChange,\n globalFilterInput,\n setGlobalFilterInput,\n\n // mutators\n addColumnFilter,\n removeColumnFilter,\n resetFilters,\n getColumnFilterValue,\n\n // aggregates for filter UI\n sortedInputFieldEntries: aggregates.sortedInputFieldEntries,\n sortedOutputFieldEntries: aggregates.sortedOutputFieldEntries,\n sortedTagEntries: aggregates.sortedTagEntries,\n sortedProviderEntries: aggregates.sortedProviderEntries,\n\n // reverse indexes (power-user / inverted-filter UX)\n pipeIdsByInputField: aggregates.pipeIdsByInputField,\n pipeIdsByOutputField: aggregates.pipeIdsByOutputField,\n pipeIdsByProvider: aggregates.pipeIdsByProvider,\n pipeIdsByTag: aggregates.pipeIdsByTag,\n };\n}\n\nexport type UsePipeCatalogTableReturn = ReturnType<typeof usePipeCatalogTable>;\n"],"mappings":";;;;;;;;;;;;AAmCA,SAAS,iBACP,MACA,aACK;AACL,KAAI,gBAAgB,UAAa,gBAAgB,UAAW,QAAO;AACnE,QAAO,KAAK,QAAQ,QAAQ,mBAAmB,IAAI,OAAO,KAAK,UAAU;;AAG3E,MAAM,eAAe,2BAAuD;AAE5E,MAAM,UAAU,aAAa,QAAQ;C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,CAAC,kBAAkB,CAAC;EAWrB;EACA,aAAa;EACb;EACA;EAGA;EACA;EACA;EACA;EAGA,yBAAyB,WAAW;EACpC,0BAA0B,WAAW;EACrC,kBAAkB,WAAW;EAC7B,uBAAuB,WAAW;EAGlC,qBAAqB,WAAW;EAChC,sBAAsB,WAAW;EACjC,mBAAmB,WAAW;EAC9B,cAAc,WAAW;EAC1B"}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { SearchCardData } from "../types/catalog-adapters.mjs";
|
|
2
|
+
import { CatalogFilterMeta, CatalogSearchFeatures } from "../utils/catalog-helpers.mjs";
|
|
2
3
|
import * as _$react from "react";
|
|
3
4
|
import { CatalogFilter, OrgAccessLevel, SearchCatalogTableData, SearchCategory, SearchId } from "@pipe0/base";
|
|
4
5
|
import * as _$_tanstack_react_table0 from "@tanstack/react-table";
|
|
@@ -16,7 +17,22 @@ declare function useSearchCatalogTable(config?: {
|
|
|
16
17
|
*/
|
|
17
18
|
accessLevel?: OrgAccessLevel;
|
|
18
19
|
}): {
|
|
19
|
-
table: _$_tanstack_react_table0.
|
|
20
|
+
table: _$_tanstack_react_table0.AppReactTable<{
|
|
21
|
+
columnFilteringFeature: _$_tanstack_react_table0.TableFeature;
|
|
22
|
+
globalFilteringFeature: _$_tanstack_react_table0.TableFeature;
|
|
23
|
+
rowSortingFeature: _$_tanstack_react_table0.TableFeature;
|
|
24
|
+
filteredRowModel: (table: _$_tanstack_react_table0.Table<any, any>) => () => _$_tanstack_react_table0.RowModel<any, any>;
|
|
25
|
+
sortedRowModel: (table: _$_tanstack_react_table0.Table<any, any>) => () => _$_tanstack_react_table0.RowModel<any, any>;
|
|
26
|
+
filterFns: {
|
|
27
|
+
includesString: _$_tanstack_react_table0.CreatedFilterFn<any, any>;
|
|
28
|
+
arrIncludes: _$_tanstack_react_table0.CreatedFilterFn<any, any>;
|
|
29
|
+
catalogSearch: _$_tanstack_react_table0.FilterFn<CatalogSearchFeatures, _$_tanstack_react_table0.RowData>;
|
|
30
|
+
};
|
|
31
|
+
sortFns: {
|
|
32
|
+
catalogSearch: _$_tanstack_react_table0.SortFn<CatalogSearchFeatures, _$_tanstack_react_table0.RowData>;
|
|
33
|
+
};
|
|
34
|
+
filterMeta: CatalogFilterMeta;
|
|
35
|
+
}, SearchCatalogTableData, _$_tanstack_react_table0.TableState_ColumnFiltering & _$_tanstack_react_table0.TableState_GlobalFiltering & _$_tanstack_react_table0.TableState_RowSorting, {}, {}, {}>;
|
|
20
36
|
cards: SearchCardData[];
|
|
21
37
|
cardsByCategory: {
|
|
22
38
|
category: SearchCategory;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"use-search-catalog-table.d.mts","names":[],"sources":["../../src/hooks/use-search-catalog-table.ts"],"mappings":"
|
|
1
|
+
{"version":3,"file":"use-search-catalog-table.d.mts","names":[],"sources":["../../src/hooks/use-search-catalog-table.ts"],"mappings":";;;;;;;;KAwBY,wBAAA,GAA2B,MAAA,SAAe,QAAA;AAAA,iBAkDtC,qBAAA,CACd,MAAA;EACE,oBAAA,GAAuB,YAAA;EAEvB,MAAA,GAAS,aAAA;;AAtDb;;;;EA4DI,WAAA,GAAc,cAAA;AAAA;;4BAAc,wBAAA,CAAA,YAAA;;;;;;;;;;;;;;;;;cA+Gc,cAAA;WAAuB,cAAA;EAAA;;;;;0BA9C3B,cAAA;;yCAAc,OAAA,CAAA,cAAA;+EAhBK,KAAA;;;;;;;;;;;KAmIjD,2BAAA,GAA8B,UAAA,QAAkB,qBAAA"}
|
|
@@ -1,8 +1,7 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { createCatalogColumnHelper, useCatalogTable } from "./catalog-table.mjs";
|
|
2
2
|
import { useDebounce } from "./use-debounce.mjs";
|
|
3
|
-
import {
|
|
3
|
+
import { useMemo, useState } from "react";
|
|
4
4
|
import { filterSearchEntries, getDefaultSearchOutputFields, getInitialSearchTableData, getLoweestSearchCreditAmount, getSearchAccessLevel, getSearchSearchTarget, getSearchTableDataAggregates, getStartingCostPerSearchProvider, isEntryAccessible, isTokenBilledOperations } from "@pipe0/base";
|
|
5
|
-
import { createColumnHelper, getCoreRowModel, getFilteredRowModel, getSortedRowModel, useReactTable } from "@tanstack/react-table";
|
|
6
5
|
|
|
7
6
|
//#region src/hooks/use-search-catalog-table.ts
|
|
8
7
|
/** Mirrors the pipe hook: partner-gated searches are hidden below partner. */
|
|
@@ -10,8 +9,8 @@ function hidePartnerGated(rows, accessLevel) {
|
|
|
10
9
|
if (accessLevel === void 0 || accessLevel === "partner") return rows;
|
|
11
10
|
return rows.filter((row) => getSearchAccessLevel(row.searchId) !== "partner");
|
|
12
11
|
}
|
|
13
|
-
const columnHelper =
|
|
14
|
-
const columns = [
|
|
12
|
+
const columnHelper = createCatalogColumnHelper();
|
|
13
|
+
const columns = columnHelper.columns([
|
|
15
14
|
columnHelper.accessor("searchId", {
|
|
16
15
|
filterFn: "includesString",
|
|
17
16
|
enableGlobalFilter: false
|
|
@@ -39,9 +38,9 @@ const columns = [
|
|
|
39
38
|
id: "search",
|
|
40
39
|
enableGlobalFilter: true,
|
|
41
40
|
enableSorting: true,
|
|
42
|
-
|
|
41
|
+
sortFn: "catalogSearch"
|
|
43
42
|
})
|
|
44
|
-
];
|
|
43
|
+
]);
|
|
45
44
|
function useSearchCatalogTable(config = {}) {
|
|
46
45
|
const [category, setCategory] = useState(null);
|
|
47
46
|
const { initialColumnFilters = [], filter, accessLevel } = config;
|
|
@@ -51,23 +50,15 @@ function useSearchCatalogTable(config = {}) {
|
|
|
51
50
|
accessLevel
|
|
52
51
|
]);
|
|
53
52
|
const baselineTableData = useMemo(() => hidePartnerGated(filterSearchEntries(getInitialSearchTableData(null), filter), accessLevel), [filter, accessLevel]);
|
|
54
|
-
const table =
|
|
53
|
+
const table = useCatalogTable({
|
|
55
54
|
columns,
|
|
56
55
|
data: initialSearchTableData,
|
|
57
|
-
|
|
58
|
-
getFilteredRowModel: getFilteredRowModel(),
|
|
59
|
-
getSortedRowModel: getSortedRowModel(),
|
|
60
|
-
globalFilterFn: catalogSearchFilter,
|
|
61
|
-
getColumnCanGlobalFilter: (column) => column.columnDef.enableGlobalFilter !== false,
|
|
62
|
-
initialState: {
|
|
63
|
-
columnFilters: initialColumnFilters,
|
|
64
|
-
pagination: { pageSize: 10 }
|
|
65
|
-
}
|
|
56
|
+
initialState: { columnFilters: initialColumnFilters }
|
|
66
57
|
});
|
|
67
|
-
const columnFilters = table.
|
|
58
|
+
const columnFilters = table.state.columnFilters;
|
|
68
59
|
const aggregates = useMemo(() => getSearchTableDataAggregates(initialSearchTableData, category), [category, initialSearchTableData]);
|
|
69
60
|
const [globalFilterInput, setGlobalFilterInput, setGlobalFilterImmediately] = useDebounce((v) => {
|
|
70
|
-
if (v === table.
|
|
61
|
+
if (v === table.atoms.globalFilter.get()) return;
|
|
71
62
|
table.setGlobalFilter(v);
|
|
72
63
|
table.setSorting(v ? [{
|
|
73
64
|
id: "search",
|
|
@@ -78,28 +69,28 @@ function useSearchCatalogTable(config = {}) {
|
|
|
78
69
|
table.setColumnFilters([]);
|
|
79
70
|
}
|
|
80
71
|
});
|
|
81
|
-
const addColumnFilter =
|
|
72
|
+
const addColumnFilter = (id, value) => {
|
|
82
73
|
setGlobalFilterImmediately("");
|
|
83
74
|
table.setColumnFilters([{
|
|
84
75
|
id,
|
|
85
76
|
value
|
|
86
77
|
}]);
|
|
87
|
-
}
|
|
88
|
-
const resetFilters =
|
|
78
|
+
};
|
|
79
|
+
const resetFilters = () => {
|
|
89
80
|
setGlobalFilterImmediately("");
|
|
90
81
|
setCategory(null);
|
|
91
|
-
}
|
|
92
|
-
const removeColumnFilter =
|
|
82
|
+
};
|
|
83
|
+
const removeColumnFilter = (id) => {
|
|
93
84
|
table.getColumn(id)?.setFilterValue(null);
|
|
94
|
-
}
|
|
95
|
-
const handleCategoryChange =
|
|
85
|
+
};
|
|
86
|
+
const handleCategoryChange = (category) => {
|
|
96
87
|
setCategory(category);
|
|
97
88
|
table.setColumnFilters([]);
|
|
98
89
|
setGlobalFilterImmediately("");
|
|
99
|
-
}
|
|
100
|
-
const getColumnFilterValue =
|
|
90
|
+
};
|
|
91
|
+
const getColumnFilterValue = (id) => {
|
|
101
92
|
return columnFilters.find((f) => f.id === id)?.value;
|
|
102
|
-
}
|
|
93
|
+
};
|
|
103
94
|
const rows = table.getRowModel().rows;
|
|
104
95
|
const cards = useMemo(() => rows.map((row) => {
|
|
105
96
|
const entry = row.original;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"use-search-catalog-table.mjs","names":[],"sources":["../../src/hooks/use-search-catalog-table.ts"],"sourcesContent":["import {\n type CatalogFilter,\n filterSearchEntries,\n getDefaultSearchOutputFields,\n getInitialSearchTableData,\n getLoweestSearchCreditAmount,\n getSearchAccessLevel,\n getSearchSearchTarget,\n getSearchTableDataAggregates,\n getStartingCostPerSearchProvider,\n isEntryAccessible,\n isTokenBilledOperations,\n type OrgAccessLevel,\n type SearchCatalogEntry,\n type SearchCatalogTableData,\n type SearchCategory,\n type SearchId,\n} from \"@pipe0/base\";\nimport {\n type ColumnFilter,\n createColumnHelper,\n getCoreRowModel,\n getFilteredRowModel,\n getSortedRowModel,\n useReactTable,\n} from \"@tanstack/react-table\";\nimport { useCallback, useMemo, useState } from \"react\";\nimport type { CostMode, SearchCardData } from \"../types/catalog-adapters.js\";\nimport { catalogSearchFilter, catalogSearchSort } from \"../utils/catalog-helpers.js\";\nimport { useDebounce } from \"./use-debounce.js\";\n\nexport type SearchOutputFieldEntries = Record<string, SearchId[]>;\n\n/** Mirrors the pipe hook: partner-gated searches are hidden below partner. */\nfunction hidePartnerGated<T extends { searchId: SearchId }>(\n rows: T[],\n accessLevel: OrgAccessLevel | undefined,\n): T[] {\n if (accessLevel === undefined || accessLevel === \"partner\") return rows;\n return rows.filter((row) => getSearchAccessLevel(row.searchId) !== \"partner\");\n}\n\nconst columnHelper = createColumnHelper<SearchCatalogTableData>();\n\nconst columns = [\n columnHelper.accessor(\"searchId\", {\n filterFn: \"includesString\",\n enableGlobalFilter: false,\n }),\n columnHelper.accessor(\"description\", {\n enableGlobalFilter: false,\n }),\n columnHelper.accessor(\"label\", {\n filterFn: \"includesString\",\n enableGlobalFilter: false,\n }),\n columnHelper.accessor((row) => getDefaultSearchOutputFields(row.searchId) || [], {\n id: \"outputFields\",\n filterFn: \"arrIncludes\",\n enableGlobalFilter: false,\n }),\n columnHelper.accessor((row) => row.tags || [], {\n id: \"tags\",\n filterFn: \"arrIncludes\",\n enableGlobalFilter: false,\n }),\n columnHelper.accessor((row) => row.provider, {\n id: \"providers\",\n enableGlobalFilter: false,\n }),\n // Hidden relevance column — the ONLY globally-filterable one, so the global\n // filter scores each row exactly once and catalogSearchSort can read the\n // score back from this column's filter meta.\n columnHelper.accessor((row) => getSearchSearchTarget(row), {\n id: \"search\",\n enableGlobalFilter: true,\n enableSorting: true,\n sortingFn: catalogSearchSort,\n }),\n];\n\nexport function useSearchCatalogTable(\n config: {\n initialColumnFilters?: ColumnFilter[];\n /** Optional whitelist/blacklist of searches and providers. Memoize. */\n filter?: CatalogFilter;\n /**\n * The viewing org's access level. Hides partner-gated searches below\n * partner and marks verified-gated cards `locked` below verified. Omit\n * for no gating (docs/playground).\n */\n accessLevel?: OrgAccessLevel;\n } = {},\n) {\n const [category, setCategory] = useState<SearchCategory | null>(null);\n const { initialColumnFilters = [] as ColumnFilter[], filter, accessLevel } = config;\n\n const initialSearchTableData = useMemo(\n () =>\n hidePartnerGated(\n filterSearchEntries(getInitialSearchTableData(category), filter),\n accessLevel,\n ),\n [category, filter, accessLevel],\n );\n\n // Baseline (config.filter applied, but no category / column / global filter).\n // Drives the stable category-button counts so the row doesn't jump.\n const baselineTableData = useMemo(\n () =>\n hidePartnerGated(filterSearchEntries(getInitialSearchTableData(null), filter), accessLevel),\n [filter, accessLevel],\n );\n\n const table = useReactTable({\n columns,\n data: initialSearchTableData,\n getCoreRowModel: getCoreRowModel(),\n getFilteredRowModel: getFilteredRowModel(),\n getSortedRowModel: getSortedRowModel(),\n globalFilterFn: catalogSearchFilter,\n getColumnCanGlobalFilter: (column) => column.columnDef.enableGlobalFilter !== false,\n initialState: {\n columnFilters: initialColumnFilters,\n pagination: {\n pageSize: 10,\n },\n },\n });\n\n const columnFilters = table.getState().columnFilters;\n\n const aggregates = useMemo(\n () => getSearchTableDataAggregates(initialSearchTableData, category),\n [category, initialSearchTableData],\n );\n\n const [globalFilterInput, setGlobalFilterInput, setGlobalFilterImmediately] = useDebounce((v) => {\n if (v === table.getState().globalFilter) return;\n table.setGlobalFilter(v);\n // Relevance order only while a query is active; empty query restores\n // catalog order.\n table.setSorting(v ? [{ id: \"search\", desc: true }] : []);\n if (v) {\n setCategory(null);\n table.setColumnFilters([]);\n }\n });\n\n const addColumnFilter = useCallback(\n (id: \"inputFields\" | \"outputFields\" | \"tags\" | \"providers\", value: string) => {\n setGlobalFilterImmediately(\"\");\n table.setColumnFilters([{ id, value }]);\n },\n [setGlobalFilterImmediately, table],\n );\n\n const resetFilters = useCallback(() => {\n setGlobalFilterImmediately(\"\");\n setCategory(null);\n }, [setGlobalFilterImmediately]);\n\n const removeColumnFilter = useCallback(\n (id: \"inputFields\" | \"outputFields\" | \"tags\" | \"providers\") => {\n table.getColumn(id)?.setFilterValue(null);\n },\n [table],\n );\n\n const handleCategoryChange = useCallback(\n (category: SearchCategory | null) => {\n setCategory(category);\n table.setColumnFilters([]);\n setGlobalFilterImmediately(\"\");\n },\n [table, setGlobalFilterImmediately],\n );\n\n const getColumnFilterValue = useCallback(\n (id: \"inputFields\" | \"outputFields\" | \"tags\" | \"providers\") => {\n const res = columnFilters.find((f) => f.id === id)?.value;\n return res as string;\n },\n [columnFilters],\n );\n\n const rows = table.getRowModel().rows;\n const cards = useMemo<SearchCardData[]>(\n () =>\n rows.map((row) => {\n const entry = row.original;\n const latestEntry = (aggregates.searchEntriesByBaseSearch[entry.baseSearch]?.[0] ??\n entry) as SearchCatalogEntry & { searchId: SearchId };\n const gate = getSearchAccessLevel(latestEntry.searchId);\n const locked =\n accessLevel !== undefined && gate !== undefined && !isEntryAccessible(gate, accessLevel);\n return {\n ...(locked ? { locked, requiredAccessLevel: gate } : {}),\n searchId: latestEntry.searchId,\n baseSearch: entry.baseSearch,\n label: entry.label,\n description: entry.description,\n provider: entry.provider,\n providers: [entry.provider],\n startingCostPerProvider: getStartingCostPerSearchProvider(latestEntry.searchId),\n startingCreditAmount: getLoweestSearchCreditAmount(latestEntry),\n // A usage-metered search bills per operation and carries cost.credits 0,\n // so the flat mode would render it as free. Same branch the pipe and\n // effect hooks already use.\n costMode: isTokenBilledOperations(latestEntry.billableOperations ?? {})\n ? (\"usage\" as CostMode)\n : ((latestEntry.cost.mode ?? \"per_page\") as CostMode),\n defaultOutputFields: getDefaultSearchOutputFields(latestEntry.searchId),\n docPath: latestEntry.docPath,\n entry: entry as SearchCatalogTableData,\n latestEntry,\n };\n }),\n [rows, aggregates.searchEntriesByBaseSearch, accessLevel],\n );\n\n const cardsByCategory = useMemo<{ category: SearchCategory; cards: SearchCardData[] }[]>(() => {\n const groups = new Map<SearchCategory, SearchCardData[]>();\n for (const card of cards) {\n const cats = (card.entry.categories ?? []) as SearchCategory[];\n for (const cat of cats) {\n const arr = groups.get(cat);\n if (arr) arr.push(card);\n else groups.set(cat, [card]);\n }\n }\n return Array.from(groups, ([category, group]) => ({\n category,\n cards: group,\n }));\n }, [cards]);\n\n const categoryCounts = useMemo<Partial<Record<SearchCategory, number>>>(() => {\n const counts: Partial<Record<SearchCategory, number>> = {};\n for (const card of cards) {\n const cats = (card.entry.categories ?? []) as SearchCategory[];\n for (const cat of cats) {\n counts[cat] = (counts[cat] ?? 0) + 1;\n }\n }\n return counts;\n }, [cards]);\n\n // Stable counts based on the baseline (no category / column / global filter\n // applied).\n const baselineCardCount = baselineTableData.length;\n const baselineCategoryCounts = useMemo<Partial<Record<SearchCategory, number>>>(() => {\n const counts: Partial<Record<SearchCategory, number>> = {};\n for (const entry of baselineTableData) {\n const cats = (entry.categories ?? []) as SearchCategory[];\n for (const cat of cats) {\n counts[cat] = (counts[cat] ?? 0) + 1;\n }\n }\n return counts;\n }, [baselineTableData]);\n\n return {\n table,\n cards,\n cardsByCategory,\n categoryCounts,\n baselineCardCount,\n baselineCategoryCounts,\n\n category,\n setCategory: handleCategoryChange,\n globalFilterInput,\n setGlobalFilterInput,\n\n addColumnFilter,\n removeColumnFilter,\n resetFilters,\n getColumnFilterValue,\n\n sortedOutputFieldEntries: aggregates.sortedOutputFieldEntries,\n sortedTagEntries: aggregates.sortedTagEntries,\n sortedProviderEntries: aggregates.sortedProviderEntries,\n\n searchIdsByOutputField: aggregates.searchIdsByOutputField,\n searchIdsByProvider: aggregates.searchIdsByProvider,\n searchIdsByTag: aggregates.searchIdsByTag,\n };\n}\n\nexport type UseSearchCatalogTableReturn = ReturnType<typeof useSearchCatalogTable>;\n"],"mappings":";;;;;;;;AAkCA,SAAS,iBACP,MACA,aACK;AACL,KAAI,gBAAgB,UAAa,gBAAgB,UAAW,QAAO;AACnE,QAAO,KAAK,QAAQ,QAAQ,qBAAqB,IAAI,SAAS,KAAK,UAAU;;AAG/E,MAAM,eAAe,oBAA4C;AAEjE,MAAM,UAAU;CACd,aAAa,SAAS,YAAY;EAChC,UAAU;EACV,oBAAoB;EACrB,CAAC;CACF,aAAa,SAAS,eAAe,EACnC,oBAAoB,OACrB,CAAC;CACF,aAAa,SAAS,SAAS;EAC7B,UAAU;EACV,oBAAoB;EACrB,CAAC;CACF,aAAa,UAAU,QAAQ,6BAA6B,IAAI,SAAS,IAAI,EAAE,EAAE;EAC/E,IAAI;EACJ,UAAU;EACV,oBAAoB;EACrB,CAAC;CACF,aAAa,UAAU,QAAQ,IAAI,QAAQ,EAAE,EAAE;EAC7C,IAAI;EACJ,UAAU;EACV,oBAAoB;EACrB,CAAC;CACF,aAAa,UAAU,QAAQ,IAAI,UAAU;EAC3C,IAAI;EACJ,oBAAoB;EACrB,CAAC;CAIF,aAAa,UAAU,QAAQ,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AS,IAAI,KAAuC;AAC1D,QAAK,MAAM,QAAQ,OAAO;IACxB,MAAM,OAAQ,KAAK,MAAM,cAAc,EAAE;AACzC,SAAK,MAAM,OAAO,MAAM;KACtB,MAAM,MAAM,OAAO,IAAI,IAAI;AAC3B,SAAI,IAAK,KAAI,KAAK,KAAK;SAClB,QAAO,IAAI,KAAK,CAAC,KAAK,CAAC;;;AAGhC,UAAO,MAAM,KAAK,SAAS,CAAC,UAAU,YAAY;IAChD;IACA,OAAO;IACR,EAAE;KACF,CAAC,MAAM,CAAC;EA+BT,gBA7BqB,cAAuD;GAC5E,MAAM,SAAkD,EAAE;AAC1D,QAAK,MAAM,QAAQ,OAAO;IACxB,MAAM,OAAQ,KAAK,MAAM,cAAc,EAAE;AACzC,SAAK,MAAM,OAAO,KAChB,QAAO,QAAQ,OAAO,QAAQ,KAAK;;AAGvC,UAAO;KACN,CAAC,MAAM,CAAC;EAqBT,mBAjBwB,kBAAkB;EAkB1C,wBAjB6B,cAAuD;GACpF,MAAM,SAAkD,EAAE;AAC1D,QAAK,MAAM,SAAS,mBAAmB;IACrC,MAAM,OAAQ,MAAM,cAAc,EAAE;AACpC,SAAK,MAAM,OAAO,KAChB,QAAO,QAAQ,OAAO,QAAQ,KAAK;;AAGvC,UAAO;KACN,CAAC,kBAAkB,CAAC;EAUrB;EACA,aAAa;EACb;EACA;EAEA;EACA;EACA;EACA;EAEA,0BAA0B,WAAW;EACrC,kBAAkB,WAAW;EAC7B,uBAAuB,WAAW;EAElC,wBAAwB,WAAW;EACnC,qBAAqB,WAAW;EAChC,gBAAgB,WAAW;EAC5B"}
|
|
1
|
+
{"version":3,"file":"use-search-catalog-table.mjs","names":[],"sources":["../../src/hooks/use-search-catalog-table.ts"],"sourcesContent":["import {\n type CatalogFilter,\n filterSearchEntries,\n getDefaultSearchOutputFields,\n getInitialSearchTableData,\n getLoweestSearchCreditAmount,\n getSearchAccessLevel,\n getSearchSearchTarget,\n getSearchTableDataAggregates,\n getStartingCostPerSearchProvider,\n isEntryAccessible,\n isTokenBilledOperations,\n type OrgAccessLevel,\n type SearchCatalogEntry,\n type SearchCatalogTableData,\n type SearchCategory,\n type SearchId,\n} from \"@pipe0/base\";\nimport type { ColumnFilter } from \"@tanstack/react-table\";\nimport { useMemo, useState } from \"react\";\nimport type { CostMode, SearchCardData } from \"../types/catalog-adapters.js\";\nimport { createCatalogColumnHelper, useCatalogTable } from \"./catalog-table.js\";\nimport { useDebounce } from \"./use-debounce.js\";\n\nexport type SearchOutputFieldEntries = Record<string, SearchId[]>;\n\n/** Mirrors the pipe hook: partner-gated searches are hidden below partner. */\nfunction hidePartnerGated<T extends { searchId: SearchId }>(\n rows: T[],\n accessLevel: OrgAccessLevel | undefined,\n): T[] {\n if (accessLevel === undefined || accessLevel === \"partner\") return rows;\n return rows.filter((row) => getSearchAccessLevel(row.searchId) !== \"partner\");\n}\n\nconst columnHelper = createCatalogColumnHelper<SearchCatalogTableData>();\n\nconst columns = columnHelper.columns([\n columnHelper.accessor(\"searchId\", {\n filterFn: \"includesString\",\n enableGlobalFilter: false,\n }),\n columnHelper.accessor(\"description\", {\n enableGlobalFilter: false,\n }),\n columnHelper.accessor(\"label\", {\n filterFn: \"includesString\",\n enableGlobalFilter: false,\n }),\n columnHelper.accessor((row) => getDefaultSearchOutputFields(row.searchId) || [], {\n id: \"outputFields\",\n filterFn: \"arrIncludes\",\n enableGlobalFilter: false,\n }),\n columnHelper.accessor((row) => row.tags || [], {\n id: \"tags\",\n filterFn: \"arrIncludes\",\n enableGlobalFilter: false,\n }),\n columnHelper.accessor((row) => row.provider, {\n id: \"providers\",\n enableGlobalFilter: false,\n }),\n // Hidden relevance column — the ONLY globally-filterable one, so the global\n // filter scores each row exactly once and catalogSearchSort can read the\n // score back from this column's filter meta.\n columnHelper.accessor((row) => getSearchSearchTarget(row), {\n id: \"search\",\n enableGlobalFilter: true,\n enableSorting: true,\n sortFn: \"catalogSearch\",\n }),\n]);\n\nexport function useSearchCatalogTable(\n config: {\n initialColumnFilters?: ColumnFilter[];\n /** Optional whitelist/blacklist of searches and providers. Memoize. */\n filter?: CatalogFilter;\n /**\n * The viewing org's access level. Hides partner-gated searches below\n * partner and marks verified-gated cards `locked` below verified. Omit\n * for no gating (docs/playground).\n */\n accessLevel?: OrgAccessLevel;\n } = {},\n) {\n const [category, setCategory] = useState<SearchCategory | null>(null);\n const { initialColumnFilters = [] as ColumnFilter[], filter, accessLevel } = config;\n\n const initialSearchTableData = useMemo(\n () =>\n hidePartnerGated(\n filterSearchEntries(getInitialSearchTableData(category), filter),\n accessLevel,\n ),\n [category, filter, accessLevel],\n );\n\n // Baseline (config.filter applied, but no category / column / global filter).\n // Drives the stable category-button counts so the row doesn't jump.\n const baselineTableData = useMemo(\n () =>\n hidePartnerGated(filterSearchEntries(getInitialSearchTableData(null), filter), accessLevel),\n [filter, accessLevel],\n );\n\n const table = useCatalogTable({\n columns,\n data: initialSearchTableData,\n initialState: { columnFilters: initialColumnFilters },\n });\n\n const columnFilters = table.state.columnFilters;\n\n const aggregates = useMemo(\n () => getSearchTableDataAggregates(initialSearchTableData, category),\n [category, initialSearchTableData],\n );\n\n const [globalFilterInput, setGlobalFilterInput, setGlobalFilterImmediately] = useDebounce((v) => {\n if (v === table.atoms.globalFilter.get()) return;\n table.setGlobalFilter(v);\n // Relevance order only while a query is active; empty query restores\n // catalog order.\n table.setSorting(v ? [{ id: \"search\", desc: true }] : []);\n if (v) {\n setCategory(null);\n table.setColumnFilters([]);\n }\n });\n\n const addColumnFilter = (\n id: \"inputFields\" | \"outputFields\" | \"tags\" | \"providers\",\n value: string,\n ) => {\n setGlobalFilterImmediately(\"\");\n table.setColumnFilters([{ id, value }]);\n };\n\n const resetFilters = () => {\n setGlobalFilterImmediately(\"\");\n setCategory(null);\n };\n\n const removeColumnFilter = (id: \"inputFields\" | \"outputFields\" | \"tags\" | \"providers\") => {\n table.getColumn(id)?.setFilterValue(null);\n };\n\n const handleCategoryChange = (category: SearchCategory | null) => {\n setCategory(category);\n table.setColumnFilters([]);\n setGlobalFilterImmediately(\"\");\n };\n\n const getColumnFilterValue = (id: \"inputFields\" | \"outputFields\" | \"tags\" | \"providers\") => {\n const res = columnFilters.find((f) => f.id === id)?.value;\n return res as string;\n };\n\n const rows = table.getRowModel().rows;\n const cards = useMemo<SearchCardData[]>(\n () =>\n rows.map((row) => {\n const entry = row.original;\n const latestEntry = (aggregates.searchEntriesByBaseSearch[entry.baseSearch]?.[0] ??\n entry) as SearchCatalogEntry & { searchId: SearchId };\n const gate = getSearchAccessLevel(latestEntry.searchId);\n const locked =\n accessLevel !== undefined && gate !== undefined && !isEntryAccessible(gate, accessLevel);\n return {\n ...(locked ? { locked, requiredAccessLevel: gate } : {}),\n searchId: latestEntry.searchId,\n baseSearch: entry.baseSearch,\n label: entry.label,\n description: entry.description,\n provider: entry.provider,\n providers: [entry.provider],\n startingCostPerProvider: getStartingCostPerSearchProvider(latestEntry.searchId),\n startingCreditAmount: getLoweestSearchCreditAmount(latestEntry),\n // A usage-metered search bills per operation and carries cost.credits 0,\n // so the flat mode would render it as free. Same branch the pipe and\n // effect hooks already use.\n costMode: isTokenBilledOperations(latestEntry.billableOperations ?? {})\n ? (\"usage\" as CostMode)\n : ((latestEntry.cost.mode ?? \"per_page\") as CostMode),\n defaultOutputFields: getDefaultSearchOutputFields(latestEntry.searchId),\n docPath: latestEntry.docPath,\n entry: entry as SearchCatalogTableData,\n latestEntry,\n };\n }),\n [rows, aggregates.searchEntriesByBaseSearch, accessLevel],\n );\n\n const cardsByCategory = useMemo<{ category: SearchCategory; cards: SearchCardData[] }[]>(() => {\n const groups = new Map<SearchCategory, SearchCardData[]>();\n for (const card of cards) {\n const cats = (card.entry.categories ?? []) as SearchCategory[];\n for (const cat of cats) {\n const arr = groups.get(cat);\n if (arr) arr.push(card);\n else groups.set(cat, [card]);\n }\n }\n return Array.from(groups, ([category, group]) => ({\n category,\n cards: group,\n }));\n }, [cards]);\n\n const categoryCounts = useMemo<Partial<Record<SearchCategory, number>>>(() => {\n const counts: Partial<Record<SearchCategory, number>> = {};\n for (const card of cards) {\n const cats = (card.entry.categories ?? []) as SearchCategory[];\n for (const cat of cats) {\n counts[cat] = (counts[cat] ?? 0) + 1;\n }\n }\n return counts;\n }, [cards]);\n\n // Stable counts based on the baseline (no category / column / global filter\n // applied).\n const baselineCardCount = baselineTableData.length;\n const baselineCategoryCounts = useMemo<Partial<Record<SearchCategory, number>>>(() => {\n const counts: Partial<Record<SearchCategory, number>> = {};\n for (const entry of baselineTableData) {\n const cats = (entry.categories ?? []) as SearchCategory[];\n for (const cat of cats) {\n counts[cat] = (counts[cat] ?? 0) + 1;\n }\n }\n return counts;\n }, [baselineTableData]);\n\n return {\n table,\n cards,\n cardsByCategory,\n categoryCounts,\n baselineCardCount,\n baselineCategoryCounts,\n\n category,\n setCategory: handleCategoryChange,\n globalFilterInput,\n setGlobalFilterInput,\n\n addColumnFilter,\n removeColumnFilter,\n resetFilters,\n getColumnFilterValue,\n\n sortedOutputFieldEntries: aggregates.sortedOutputFieldEntries,\n sortedTagEntries: aggregates.sortedTagEntries,\n sortedProviderEntries: aggregates.sortedProviderEntries,\n\n searchIdsByOutputField: aggregates.searchIdsByOutputField,\n searchIdsByProvider: aggregates.searchIdsByProvider,\n searchIdsByTag: aggregates.searchIdsByTag,\n };\n}\n\nexport type UseSearchCatalogTableReturn = ReturnType<typeof useSearchCatalogTable>;\n"],"mappings":";;;;;;;AA2BA,SAAS,iBACP,MACA,aACK;AACL,KAAI,gBAAgB,UAAa,gBAAgB,UAAW,QAAO;AACnE,QAAO,KAAK,QAAQ,QAAQ,qBAAqB,IAAI,SAAS,KAAK,UAAU;;AAG/E,MAAM,eAAe,2BAAmD;AAExE,MAAM,UAAU,aAAa,QAAQ;CACnC,aAAa,SAAS,YAAY;EAChC,UAAU;EACV,oBAAoB;EACrB,CAAC;CACF,aAAa,SAAS,eAAe,EACnC,oBAAoB,OACrB,CAAC;CACF,aAAa,SAAS,SAAS;EAC7B,UAA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BA5CsB,cAAuE;GAC7F,MAAM,yBAAS,IAAI,KAAuC;AAC1D,QAAK,MAAM,QAAQ,OAAO;IACxB,MAAM,OAAQ,KAAK,MAAM,cAAc,EAAE;AACzC,SAAK,MAAM,OAAO,MAAM;KACtB,MAAM,MAAM,OAAO,IAAI,IAAI;AAC3B,SAAI,IAAK,KAAI,KAAK,KAAK;SAClB,QAAO,IAAI,KAAK,CAAC,KAAK,CAAC;;;AAGhC,UAAO,MAAM,KAAK,SAAS,CAAC,UAAU,YAAY;IAChD;IACA,OAAO;IACR,EAAE;KACF,CAAC,MAAM,CAAC;EA+BT,gBA7BqB,cAAuD;GAC5E,MAAM,SAAkD,EAAE;AAC1D,QAAK,MAAM,QAAQ,OAAO;IACxB,MAAM,OAAQ,KAAK,MAAM,cAAc,EAAE;AACzC,SAAK,MAAM,OAAO,KAChB,QAAO,QAAQ,OAAO,QAAQ,KAAK;;AAGvC,UAAO;KACN,CAAC,MAAM,CAAC;EAqBT,mBAjBwB,kBAAkB;EAkB1C,wBAjB6B,cAAuD;GACpF,MAAM,SAAkD,EAAE;AAC1D,QAAK,MAAM,SAAS,mBAAmB;IACrC,MAAM,OAAQ,MAAM,cAAc,EAAE;AACpC,SAAK,MAAM,OAAO,KAChB,QAAO,QAAQ,OAAO,QAAQ,KAAK;;AAGvC,UAAO;KACN,CAAC,kBAAkB,CAAC;EAUrB;EACA,aAAa;EACb;EACA;EAEA;EACA;EACA;EACA;EAEA,0BAA0B,WAAW;EACrC,kBAAkB,WAAW;EAC7B,uBAAuB,WAAW;EAElC,wBAAwB,WAAW;EACnC,qBAAqB,WAAW;EAChC,gBAAgB,WAAW;EAC5B"}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { SearchesCardData } from "../types/catalog-adapters.mjs";
|
|
2
|
+
import { CatalogFilterMeta, CatalogSearchFeatures } from "../utils/catalog-helpers.mjs";
|
|
2
3
|
import * as _$react from "react";
|
|
3
4
|
import { CatalogFilter, SearchCategory, SearchesCatalogTableData, SearchesId } from "@pipe0/base";
|
|
4
5
|
import * as _$_tanstack_react_table0 from "@tanstack/react-table";
|
|
@@ -10,7 +11,22 @@ declare function useSearchesCatalogTable(config?: {
|
|
|
10
11
|
initialColumnFilters?: ColumnFilter[];
|
|
11
12
|
filter?: CatalogFilter;
|
|
12
13
|
}): {
|
|
13
|
-
table: _$_tanstack_react_table0.
|
|
14
|
+
table: _$_tanstack_react_table0.AppReactTable<{
|
|
15
|
+
columnFilteringFeature: _$_tanstack_react_table0.TableFeature;
|
|
16
|
+
globalFilteringFeature: _$_tanstack_react_table0.TableFeature;
|
|
17
|
+
rowSortingFeature: _$_tanstack_react_table0.TableFeature;
|
|
18
|
+
filteredRowModel: (table: _$_tanstack_react_table0.Table<any, any>) => () => _$_tanstack_react_table0.RowModel<any, any>;
|
|
19
|
+
sortedRowModel: (table: _$_tanstack_react_table0.Table<any, any>) => () => _$_tanstack_react_table0.RowModel<any, any>;
|
|
20
|
+
filterFns: {
|
|
21
|
+
includesString: _$_tanstack_react_table0.CreatedFilterFn<any, any>;
|
|
22
|
+
arrIncludes: _$_tanstack_react_table0.CreatedFilterFn<any, any>;
|
|
23
|
+
catalogSearch: _$_tanstack_react_table0.FilterFn<CatalogSearchFeatures, _$_tanstack_react_table0.RowData>;
|
|
24
|
+
};
|
|
25
|
+
sortFns: {
|
|
26
|
+
catalogSearch: _$_tanstack_react_table0.SortFn<CatalogSearchFeatures, _$_tanstack_react_table0.RowData>;
|
|
27
|
+
};
|
|
28
|
+
filterMeta: CatalogFilterMeta;
|
|
29
|
+
}, SearchesCatalogTableData, _$_tanstack_react_table0.TableState_ColumnFiltering & _$_tanstack_react_table0.TableState_GlobalFiltering & _$_tanstack_react_table0.TableState_RowSorting, {}, {}, {}>;
|
|
14
30
|
cards: SearchesCardData[];
|
|
15
31
|
cardsByCategory: {
|
|
16
32
|
category: SearchCategory;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"use-searches-catalog-table.d.mts","names":[],"sources":["../../src/hooks/use-searches-catalog-table.ts"],"mappings":"
|
|
1
|
+
{"version":3,"file":"use-searches-catalog-table.d.mts","names":[],"sources":["../../src/hooks/use-searches-catalog-table.ts"],"mappings":";;;;;;;;KAoBY,0BAAA,GAA6B,MAAA,SAAe,UAAA;AAAA,iBAyCxC,uBAAA,CACd,MAAA;EAAU,oBAAA,GAAuB,YAAA;EAAgB,MAAA,GAAS,aAAA;AAAA;;4BAAa,wBAAA,CAAA,YAAA;;;;;;;;;;;;;;;;;cAgG3B,cAAA;WAAuB,gBAAA;EAAA;;;;;0BArC3B,cAAA;;yCAAc,OAAA,CAAA,cAAA;+EAhBK,KAAA;;;;;;;;;;;KA0HjD,6BAAA,GAAgC,UAAA,QAAkB,uBAAA"}
|
|
@@ -1,12 +1,11 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { createCatalogColumnHelper, useCatalogTable } from "./catalog-table.mjs";
|
|
2
2
|
import { useDebounce } from "./use-debounce.mjs";
|
|
3
|
-
import {
|
|
3
|
+
import { useMemo, useState } from "react";
|
|
4
4
|
import { filterSearchesEntries, getDefaultSearchesOutputFields, getInitialSearchesTableData, getLoweestSearchesCreditAmount, getSearchesSearchTarget, getSearchesTableDataAggregates, getStartingCostPerSearchesProvider } from "@pipe0/base";
|
|
5
|
-
import { createColumnHelper, getCoreRowModel, getFilteredRowModel, getSortedRowModel, useReactTable } from "@tanstack/react-table";
|
|
6
5
|
|
|
7
6
|
//#region src/hooks/use-searches-catalog-table.ts
|
|
8
|
-
const columnHelper =
|
|
9
|
-
const columns = [
|
|
7
|
+
const columnHelper = createCatalogColumnHelper();
|
|
8
|
+
const columns = columnHelper.columns([
|
|
10
9
|
columnHelper.accessor("searchId", {
|
|
11
10
|
filterFn: "includesString",
|
|
12
11
|
enableGlobalFilter: false
|
|
@@ -34,31 +33,23 @@ const columns = [
|
|
|
34
33
|
id: "search",
|
|
35
34
|
enableGlobalFilter: true,
|
|
36
35
|
enableSorting: true,
|
|
37
|
-
|
|
36
|
+
sortFn: "catalogSearch"
|
|
38
37
|
})
|
|
39
|
-
];
|
|
38
|
+
]);
|
|
40
39
|
function useSearchesCatalogTable(config = {}) {
|
|
41
40
|
const [category, setCategory] = useState(null);
|
|
42
41
|
const { initialColumnFilters = [], filter } = config;
|
|
43
42
|
const initialSearchTableData = useMemo(() => filterSearchesEntries(getInitialSearchesTableData(category), filter), [category, filter]);
|
|
44
43
|
const baselineTableData = useMemo(() => filterSearchesEntries(getInitialSearchesTableData(null), filter), [filter]);
|
|
45
|
-
const table =
|
|
44
|
+
const table = useCatalogTable({
|
|
46
45
|
columns,
|
|
47
46
|
data: initialSearchTableData,
|
|
48
|
-
|
|
49
|
-
getFilteredRowModel: getFilteredRowModel(),
|
|
50
|
-
getSortedRowModel: getSortedRowModel(),
|
|
51
|
-
globalFilterFn: catalogSearchFilter,
|
|
52
|
-
getColumnCanGlobalFilter: (column) => column.columnDef.enableGlobalFilter !== false,
|
|
53
|
-
initialState: {
|
|
54
|
-
columnFilters: initialColumnFilters,
|
|
55
|
-
pagination: { pageSize: 10 }
|
|
56
|
-
}
|
|
47
|
+
initialState: { columnFilters: initialColumnFilters }
|
|
57
48
|
});
|
|
58
|
-
const columnFilters = table.
|
|
49
|
+
const columnFilters = table.state.columnFilters;
|
|
59
50
|
const aggregates = useMemo(() => getSearchesTableDataAggregates(initialSearchTableData, category), [category, initialSearchTableData]);
|
|
60
51
|
const [globalFilterInput, setGlobalFilterInput, setGlobalFilterImmediately] = useDebounce((v) => {
|
|
61
|
-
if (v === table.
|
|
52
|
+
if (v === table.atoms.globalFilter.get()) return;
|
|
62
53
|
table.setGlobalFilter(v);
|
|
63
54
|
table.setSorting(v ? [{
|
|
64
55
|
id: "search",
|
|
@@ -69,28 +60,28 @@ function useSearchesCatalogTable(config = {}) {
|
|
|
69
60
|
table.setColumnFilters([]);
|
|
70
61
|
}
|
|
71
62
|
});
|
|
72
|
-
const addColumnFilter =
|
|
63
|
+
const addColumnFilter = (id, value) => {
|
|
73
64
|
setGlobalFilterImmediately("");
|
|
74
65
|
table.setColumnFilters([{
|
|
75
66
|
id,
|
|
76
67
|
value
|
|
77
68
|
}]);
|
|
78
|
-
}
|
|
79
|
-
const resetFilters =
|
|
69
|
+
};
|
|
70
|
+
const resetFilters = () => {
|
|
80
71
|
setGlobalFilterImmediately("");
|
|
81
72
|
setCategory(null);
|
|
82
|
-
}
|
|
83
|
-
const removeColumnFilter =
|
|
73
|
+
};
|
|
74
|
+
const removeColumnFilter = (id) => {
|
|
84
75
|
table.getColumn(id)?.setFilterValue(null);
|
|
85
|
-
}
|
|
86
|
-
const handleCategoryChange =
|
|
76
|
+
};
|
|
77
|
+
const handleCategoryChange = (category) => {
|
|
87
78
|
setCategory(category);
|
|
88
79
|
table.setColumnFilters([]);
|
|
89
80
|
setGlobalFilterImmediately("");
|
|
90
|
-
}
|
|
91
|
-
const getColumnFilterValue =
|
|
81
|
+
};
|
|
82
|
+
const getColumnFilterValue = (id) => {
|
|
92
83
|
return columnFilters.find((f) => f.id === id)?.value;
|
|
93
|
-
}
|
|
84
|
+
};
|
|
94
85
|
const rows = table.getRowModel().rows;
|
|
95
86
|
const cards = useMemo(() => rows.map((row) => {
|
|
96
87
|
const entry = row.original;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"use-searches-catalog-table.mjs","names":[],"sources":["../../src/hooks/use-searches-catalog-table.ts"],"sourcesContent":["import {\n type CatalogFilter,\n filterSearchesEntries,\n getDefaultSearchesOutputFields,\n getInitialSearchesTableData,\n getLoweestSearchesCreditAmount,\n getSearchesSearchTarget,\n getSearchesTableDataAggregates,\n getStartingCostPerSearchesProvider,\n type SearchCategory,\n type SearchesCatalogEntry,\n type SearchesCatalogTableData,\n type SearchesId,\n} from \"@pipe0/base\";\nimport {\n type ColumnFilter,\n createColumnHelper,\n getCoreRowModel,\n getFilteredRowModel,\n getSortedRowModel,\n useReactTable,\n} from \"@tanstack/react-table\";\nimport { useCallback, useMemo, useState } from \"react\";\nimport type { CostMode, SearchesCardData } from \"../types/catalog-adapters.js\";\nimport { catalogSearchFilter, catalogSearchSort } from \"../utils/catalog-helpers.js\";\nimport { useDebounce } from \"./use-debounce.js\";\n\nexport type SearchesOutputFieldEntries = Record<string, SearchesId[]>;\n\nconst columnHelper = createColumnHelper<SearchesCatalogTableData>();\n\nconst columns = [\n columnHelper.accessor(\"searchId\", {\n filterFn: \"includesString\",\n enableGlobalFilter: false,\n }),\n columnHelper.accessor(\"description\", {\n enableGlobalFilter: false,\n }),\n columnHelper.accessor(\"label\", {\n filterFn: \"includesString\",\n enableGlobalFilter: false,\n }),\n columnHelper.accessor((row) => getDefaultSearchesOutputFields(row.searchId) || [], {\n id: \"outputFields\",\n filterFn: \"arrIncludes\",\n enableGlobalFilter: false,\n }),\n columnHelper.accessor((row) => row.tags || [], {\n id: \"tags\",\n filterFn: \"arrIncludes\",\n enableGlobalFilter: false,\n }),\n columnHelper.accessor((row) => row.provider, {\n id: \"providers\",\n enableGlobalFilter: false,\n }),\n // Hidden relevance column — the ONLY globally-filterable one, so the global\n // filter scores each row exactly once and catalogSearchSort can read the\n // score back from this column's filter meta.\n columnHelper.accessor((row) => getSearchesSearchTarget(row), {\n id: \"search\",\n enableGlobalFilter: true,\n enableSorting: true,\n sortingFn: catalogSearchSort,\n }),\n];\n\nexport function useSearchesCatalogTable(\n config: { initialColumnFilters?: ColumnFilter[]; filter?: CatalogFilter } = {},\n) {\n const [category, setCategory] = useState<SearchCategory | null>(null);\n const { initialColumnFilters = [] as ColumnFilter[], filter } = config;\n\n const initialSearchTableData = useMemo(\n () => filterSearchesEntries(getInitialSearchesTableData(category), filter),\n [category, filter],\n );\n\n // Baseline (config.filter applied, but no category / column / global filter).\n // Drives the stable category-button counts so the row doesn't jump.\n const baselineTableData = useMemo(\n () => filterSearchesEntries(getInitialSearchesTableData(null), filter),\n [filter],\n );\n\n const table = useReactTable({\n columns,\n data: initialSearchTableData,\n getCoreRowModel: getCoreRowModel(),\n getFilteredRowModel: getFilteredRowModel(),\n getSortedRowModel: getSortedRowModel(),\n globalFilterFn: catalogSearchFilter,\n getColumnCanGlobalFilter: (column) => column.columnDef.enableGlobalFilter !== false,\n initialState: {\n columnFilters: initialColumnFilters,\n pagination: {\n pageSize: 10,\n },\n },\n });\n\n const columnFilters = table.getState().columnFilters;\n\n const aggregates = useMemo(\n () => getSearchesTableDataAggregates(initialSearchTableData, category),\n [category, initialSearchTableData],\n );\n\n const [globalFilterInput, setGlobalFilterInput, setGlobalFilterImmediately] = useDebounce((v) => {\n if (v === table.getState().globalFilter) return;\n table.setGlobalFilter(v);\n // Relevance order only while a query is active; empty query restores\n // catalog order.\n table.setSorting(v ? [{ id: \"search\", desc: true }] : []);\n if (v) {\n setCategory(null);\n table.setColumnFilters([]);\n }\n });\n\n const addColumnFilter = useCallback(\n (id: \"inputFields\" | \"outputFields\" | \"tags\" | \"providers\", value: string) => {\n setGlobalFilterImmediately(\"\");\n table.setColumnFilters([{ id, value }]);\n },\n [setGlobalFilterImmediately, table],\n );\n\n const resetFilters = useCallback(() => {\n setGlobalFilterImmediately(\"\");\n setCategory(null);\n }, [setGlobalFilterImmediately]);\n\n const removeColumnFilter = useCallback(\n (id: \"inputFields\" | \"outputFields\" | \"tags\" | \"providers\") => {\n table.getColumn(id)?.setFilterValue(null);\n },\n [table],\n );\n\n const handleCategoryChange = useCallback(\n (category: SearchCategory | null) => {\n setCategory(category);\n table.setColumnFilters([]);\n setGlobalFilterImmediately(\"\");\n },\n [table, setGlobalFilterImmediately],\n );\n\n const getColumnFilterValue = useCallback(\n (id: \"inputFields\" | \"outputFields\" | \"tags\" | \"providers\") => {\n const res = columnFilters.find((f) => f.id === id)?.value;\n return res as string;\n },\n [columnFilters],\n );\n\n const rows = table.getRowModel().rows;\n const cards = useMemo<SearchesCardData[]>(\n () =>\n rows.map((row) => {\n const entry = row.original;\n const latestEntry = (aggregates.searchEntriesByBaseSearch[entry.baseSearch]?.[0] ??\n entry) as SearchesCatalogEntry & { searchesId: SearchesId };\n return {\n searchesId: latestEntry.searchesId,\n baseSearches: entry.baseSearch,\n label: entry.label,\n description: entry.description,\n provider: entry.provider,\n providers: [entry.provider],\n startingCostPerProvider: getStartingCostPerSearchesProvider(latestEntry.searchesId),\n startingCreditAmount: getLoweestSearchesCreditAmount(latestEntry),\n costMode: latestEntry.cost.mode as CostMode,\n defaultOutputFields: getDefaultSearchesOutputFields(latestEntry.searchesId),\n docPath: latestEntry.docPath,\n entry: entry as SearchesCatalogTableData,\n latestEntry,\n };\n }),\n [rows, aggregates.searchEntriesByBaseSearch],\n );\n\n const cardsByCategory = useMemo<{ category: SearchCategory; cards: SearchesCardData[] }[]>(() => {\n const groups = new Map<SearchCategory, SearchesCardData[]>();\n for (const card of cards) {\n const cats = (card.entry.categories ?? []) as SearchCategory[];\n for (const cat of cats) {\n const arr = groups.get(cat);\n if (arr) arr.push(card);\n else groups.set(cat, [card]);\n }\n }\n return Array.from(groups, ([category, group]) => ({\n category,\n cards: group,\n }));\n }, [cards]);\n\n const categoryCounts = useMemo<Partial<Record<SearchCategory, number>>>(() => {\n const counts: Partial<Record<SearchCategory, number>> = {};\n for (const card of cards) {\n const cats = (card.entry.categories ?? []) as SearchCategory[];\n for (const cat of cats) {\n counts[cat] = (counts[cat] ?? 0) + 1;\n }\n }\n return counts;\n }, [cards]);\n\n // Stable counts based on the baseline (no category / column / global filter\n // applied).\n const baselineCardCount = baselineTableData.length;\n const baselineCategoryCounts = useMemo<Partial<Record<SearchCategory, number>>>(() => {\n const counts: Partial<Record<SearchCategory, number>> = {};\n for (const entry of baselineTableData) {\n const cats = (entry.categories ?? []) as SearchCategory[];\n for (const cat of cats) {\n counts[cat] = (counts[cat] ?? 0) + 1;\n }\n }\n return counts;\n }, [baselineTableData]);\n\n return {\n table,\n cards,\n cardsByCategory,\n categoryCounts,\n baselineCardCount,\n baselineCategoryCounts,\n\n category,\n setCategory: handleCategoryChange,\n globalFilterInput,\n setGlobalFilterInput,\n\n addColumnFilter,\n removeColumnFilter,\n resetFilters,\n getColumnFilterValue,\n\n sortedOutputFieldEntries: aggregates.sortedOutputFieldEntries,\n sortedTagEntries: aggregates.sortedTagEntries,\n sortedProviderEntries: aggregates.sortedProviderEntries,\n\n searchIdsByOutputField: aggregates.searchIdsByOutputField,\n searchIdsByProvider: aggregates.searchIdsByProvider,\n searchIdsByTag: aggregates.searchIdsByTag,\n };\n}\n\nexport type UseSearchesCatalogTableReturn = ReturnType<typeof useSearchesCatalogTable>;\n"],"mappings":";;;;;;;AA6BA,MAAM,eAAe,oBAA8C;AAEnE,MAAM,UAAU;CACd,aAAa,SAAS,YAAY;EAChC,UAAU;EACV,oBAAoB;EACrB,CAAC;CACF,aAAa,SAAS,eAAe,EACnC,oBAAoB,OACrB,CAAC;CACF,aAAa,SAAS,SAAS;EAC7B,UAAU;EACV,oBAAoB;EACrB,CAAC;CACF,aAAa,UAAU,QAAQ,+BAA+B,IAAI,SAAS,IAAI,EAAE,EAAE;EACjF,IAAI;EACJ,UAAU;EACV,oBAAoB;EACrB,CAAC;CACF,aAAa,UAAU,QAAQ,IAAI,QAAQ,EAAE,EAAE;EAC7C,IAAI;EACJ,UAAU;EACV,oBAAoB;EACrB,CAAC;CACF,aAAa,UAAU,QAAQ,IAAI,UAAU;EAC3C,IAAI;EACJ,oBAAoB;EACrB,CAAC;CAIF,aAAa,UAAU,QAAQ,wBAAwB,IAAI,EAAE;EAC3D,IAAI;EACJ,oBAAoB;EACpB,eAAe;EACf,WAAW;EACZ,CAAC;CACH;AAED,SAAgB,wBACd,SAA4E,EAAE,EAC9E;CACA,MAAM,CAAC,UAAU,eAAe,SAAgC,KAAK;CACrE,MAAM,EAAE,uBAAuB,EAAE,EAAoB,WAAW;CAEhE,MAAM,yBAAyB,cACvB,sBAAsB,4BAA4B,SAAS,EAAE,OAAO,EAC1E,CAAC,UAAU,OAAO,CACnB;CAID,MAAM,oBAAoB,cAClB,sBAAsB,4BAA4B,KAAK,EAAE,OAAO,EACtE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M,SAAS,mBAAmB;IACrC,MAAM,OAAQ,MAAM,cAAc,EAAE;AACpC,SAAK,MAAM,OAAO,KAChB,QAAO,QAAQ,OAAO,QAAQ,KAAK;;AAGvC,UAAO;KACN,CAAC,kBAAkB,CAAC;EAUrB;EACA,aAAa;EACb;EACA;EAEA;EACA;EACA;EACA;EAEA,0BAA0B,WAAW;EACrC,kBAAkB,WAAW;EAC7B,uBAAuB,WAAW;EAElC,wBAAwB,WAAW;EACnC,qBAAqB,WAAW;EAChC,gBAAgB,WAAW;EAC5B"}
|
|
1
|
+
{"version":3,"file":"use-searches-catalog-table.mjs","names":[],"sources":["../../src/hooks/use-searches-catalog-table.ts"],"sourcesContent":["import {\n type CatalogFilter,\n filterSearchesEntries,\n getDefaultSearchesOutputFields,\n getInitialSearchesTableData,\n getLoweestSearchesCreditAmount,\n getSearchesSearchTarget,\n getSearchesTableDataAggregates,\n getStartingCostPerSearchesProvider,\n type SearchCategory,\n type SearchesCatalogEntry,\n type SearchesCatalogTableData,\n type SearchesId,\n} from \"@pipe0/base\";\nimport type { ColumnFilter } from \"@tanstack/react-table\";\nimport { useMemo, useState } from \"react\";\nimport type { CostMode, SearchesCardData } from \"../types/catalog-adapters.js\";\nimport { createCatalogColumnHelper, useCatalogTable } from \"./catalog-table.js\";\nimport { useDebounce } from \"./use-debounce.js\";\n\nexport type SearchesOutputFieldEntries = Record<string, SearchesId[]>;\n\nconst columnHelper = createCatalogColumnHelper<SearchesCatalogTableData>();\n\nconst columns = columnHelper.columns([\n columnHelper.accessor(\"searchId\", {\n filterFn: \"includesString\",\n enableGlobalFilter: false,\n }),\n columnHelper.accessor(\"description\", {\n enableGlobalFilter: false,\n }),\n columnHelper.accessor(\"label\", {\n filterFn: \"includesString\",\n enableGlobalFilter: false,\n }),\n columnHelper.accessor((row) => getDefaultSearchesOutputFields(row.searchId) || [], {\n id: \"outputFields\",\n filterFn: \"arrIncludes\",\n enableGlobalFilter: false,\n }),\n columnHelper.accessor((row) => row.tags || [], {\n id: \"tags\",\n filterFn: \"arrIncludes\",\n enableGlobalFilter: false,\n }),\n columnHelper.accessor((row) => row.provider, {\n id: \"providers\",\n enableGlobalFilter: false,\n }),\n // Hidden relevance column — the ONLY globally-filterable one, so the global\n // filter scores each row exactly once and catalogSearchSort can read the\n // score back from this column's filter meta.\n columnHelper.accessor((row) => getSearchesSearchTarget(row), {\n id: \"search\",\n enableGlobalFilter: true,\n enableSorting: true,\n sortFn: \"catalogSearch\",\n }),\n]);\n\nexport function useSearchesCatalogTable(\n config: { initialColumnFilters?: ColumnFilter[]; filter?: CatalogFilter } = {},\n) {\n const [category, setCategory] = useState<SearchCategory | null>(null);\n const { initialColumnFilters = [] as ColumnFilter[], filter } = config;\n\n const initialSearchTableData = useMemo(\n () => filterSearchesEntries(getInitialSearchesTableData(category), filter),\n [category, filter],\n );\n\n // Baseline (config.filter applied, but no category / column / global filter).\n // Drives the stable category-button counts so the row doesn't jump.\n const baselineTableData = useMemo(\n () => filterSearchesEntries(getInitialSearchesTableData(null), filter),\n [filter],\n );\n\n const table = useCatalogTable({\n columns,\n data: initialSearchTableData,\n initialState: { columnFilters: initialColumnFilters },\n });\n\n const columnFilters = table.state.columnFilters;\n\n const aggregates = useMemo(\n () => getSearchesTableDataAggregates(initialSearchTableData, category),\n [category, initialSearchTableData],\n );\n\n const [globalFilterInput, setGlobalFilterInput, setGlobalFilterImmediately] = useDebounce((v) => {\n if (v === table.atoms.globalFilter.get()) return;\n table.setGlobalFilter(v);\n // Relevance order only while a query is active; empty query restores\n // catalog order.\n table.setSorting(v ? [{ id: \"search\", desc: true }] : []);\n if (v) {\n setCategory(null);\n table.setColumnFilters([]);\n }\n });\n\n const addColumnFilter = (\n id: \"inputFields\" | \"outputFields\" | \"tags\" | \"providers\",\n value: string,\n ) => {\n setGlobalFilterImmediately(\"\");\n table.setColumnFilters([{ id, value }]);\n };\n\n const resetFilters = () => {\n setGlobalFilterImmediately(\"\");\n setCategory(null);\n };\n\n const removeColumnFilter = (id: \"inputFields\" | \"outputFields\" | \"tags\" | \"providers\") => {\n table.getColumn(id)?.setFilterValue(null);\n };\n\n const handleCategoryChange = (category: SearchCategory | null) => {\n setCategory(category);\n table.setColumnFilters([]);\n setGlobalFilterImmediately(\"\");\n };\n\n const getColumnFilterValue = (id: \"inputFields\" | \"outputFields\" | \"tags\" | \"providers\") => {\n const res = columnFilters.find((f) => f.id === id)?.value;\n return res as string;\n };\n\n const rows = table.getRowModel().rows;\n const cards = useMemo<SearchesCardData[]>(\n () =>\n rows.map((row) => {\n const entry = row.original;\n const latestEntry = (aggregates.searchEntriesByBaseSearch[entry.baseSearch]?.[0] ??\n entry) as SearchesCatalogEntry & { searchesId: SearchesId };\n return {\n searchesId: latestEntry.searchesId,\n baseSearches: entry.baseSearch,\n label: entry.label,\n description: entry.description,\n provider: entry.provider,\n providers: [entry.provider],\n startingCostPerProvider: getStartingCostPerSearchesProvider(latestEntry.searchesId),\n startingCreditAmount: getLoweestSearchesCreditAmount(latestEntry),\n costMode: latestEntry.cost.mode as CostMode,\n defaultOutputFields: getDefaultSearchesOutputFields(latestEntry.searchesId),\n docPath: latestEntry.docPath,\n entry: entry as SearchesCatalogTableData,\n latestEntry,\n };\n }),\n [rows, aggregates.searchEntriesByBaseSearch],\n );\n\n const cardsByCategory = useMemo<{ category: SearchCategory; cards: SearchesCardData[] }[]>(() => {\n const groups = new Map<SearchCategory, SearchesCardData[]>();\n for (const card of cards) {\n const cats = (card.entry.categories ?? []) as SearchCategory[];\n for (const cat of cats) {\n const arr = groups.get(cat);\n if (arr) arr.push(card);\n else groups.set(cat, [card]);\n }\n }\n return Array.from(groups, ([category, group]) => ({\n category,\n cards: group,\n }));\n }, [cards]);\n\n const categoryCounts = useMemo<Partial<Record<SearchCategory, number>>>(() => {\n const counts: Partial<Record<SearchCategory, number>> = {};\n for (const card of cards) {\n const cats = (card.entry.categories ?? []) as SearchCategory[];\n for (const cat of cats) {\n counts[cat] = (counts[cat] ?? 0) + 1;\n }\n }\n return counts;\n }, [cards]);\n\n // Stable counts based on the baseline (no category / column / global filter\n // applied).\n const baselineCardCount = baselineTableData.length;\n const baselineCategoryCounts = useMemo<Partial<Record<SearchCategory, number>>>(() => {\n const counts: Partial<Record<SearchCategory, number>> = {};\n for (const entry of baselineTableData) {\n const cats = (entry.categories ?? []) as SearchCategory[];\n for (const cat of cats) {\n counts[cat] = (counts[cat] ?? 0) + 1;\n }\n }\n return counts;\n }, [baselineTableData]);\n\n return {\n table,\n cards,\n cardsByCategory,\n categoryCounts,\n baselineCardCount,\n baselineCategoryCounts,\n\n category,\n setCategory: handleCategoryChange,\n globalFilterInput,\n setGlobalFilterInput,\n\n addColumnFilter,\n removeColumnFilter,\n resetFilters,\n getColumnFilterValue,\n\n sortedOutputFieldEntries: aggregates.sortedOutputFieldEntries,\n sortedTagEntries: aggregates.sortedTagEntries,\n sortedProviderEntries: aggregates.sortedProviderEntries,\n\n searchIdsByOutputField: aggregates.searchIdsByOutputField,\n searchIdsByProvider: aggregates.searchIdsByProvider,\n searchIdsByTag: aggregates.searchIdsByTag,\n };\n}\n\nexport type UseSearchesCatalogTableReturn = ReturnType<typeof useSearchesCatalogTable>;\n"],"mappings":";;;;;;AAsBA,MAAM,eAAe,2BAAqD;AAE1E,MAAM,UAAU,aAAa,QAAQ;CACnC,aAAa,SAAS,YAAY;EAChC,UAAU;EACV,oBAAoB;EACrB,CAAC;CACF,aAAa,SAAS,eAAe,EACnC,oBAAoB,OACrB,CAAC;CACF,aAAa,SAAS,SAAS;EAC7B,UAAU;EACV,oBAAoB;EACrB,CAAC;CACF,aAAa,UAAU,QAAQ,+BAA+B,IAAI,SAAS,IAAI,EAAE,EAAE;EACjF,IAAI;EACJ,UAAU;EACV,oBAAoB;EACrB,CAAC;CACF,aAAa,UAAU,QAAQ,IAAI,QAAQ,EAAE,EAAE;EAC7C,IAAI;EACJ,UAAU;EACV,oBAAoB;EACrB,CAAC;CACF,aAAa,UAAU,QAAQ,IAAI,UAAU;EAC3C,I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AAO;KACN,CAAC,MAAM,CAAC;EAqBT,mBAjBwB,kBAAkB;EAkB1C,wBAjB6B,cAAuD;GACpF,MAAM,SAAkD,EAAE;AAC1D,QAAK,MAAM,SAAS,mBAAmB;IACrC,MAAM,OAAQ,MAAM,cAAc,EAAE;AACpC,SAAK,MAAM,OAAO,KAChB,QAAO,QAAQ,OAAO,QAAQ,KAAK;;AAGvC,UAAO;KACN,CAAC,kBAAkB,CAAC;EAUrB;EACA,aAAa;EACb;EACA;EAEA;EACA;EACA;EACA;EAEA,0BAA0B,WAAW;EACrC,kBAAkB,WAAW;EAC7B,uBAAuB,WAAW;EAElC,wBAAwB,WAAW;EACnC,qBAAqB,WAAW;EAChC,gBAAgB,WAAW;EAC5B"}
|
package/dist/index.d.mts
CHANGED
|
@@ -93,13 +93,14 @@ import { SearchCatalogCardContext, SearchCatalogCardContextValue, useSearchCatal
|
|
|
93
93
|
import { SearchCatalogContext, SearchCatalogContextValue, useSearchCatalogContext } from "./context/search-catalog-context.mjs";
|
|
94
94
|
import { SearchesCatalogCardContext, SearchesCatalogCardContextValue, useSearchesCatalogCard } from "./context/searches-catalog-card-context.mjs";
|
|
95
95
|
import { SearchesCatalogContext, SearchesCatalogContextValue, useSearchesCatalogContext } from "./context/searches-catalog-context.mjs";
|
|
96
|
+
import { CatalogFilterMeta, CatalogSearchFeatures, catalogSearchFilter, catalogSearchSort, fuzzyFilter, getFieldFormatIcon, getFieldStatusIcon, getFieldTypeIcon } from "./utils/catalog-helpers.mjs";
|
|
97
|
+
import { CatalogTableFeatures, catalogTableFeatures, createCatalogColumnHelper, useCatalogTable } from "./hooks/catalog-table.mjs";
|
|
96
98
|
import { useFieldError } from "./hooks/use-field-error.mjs";
|
|
97
99
|
import { UsePipeFormOptions, usePipeForm } from "./hooks/use-pipe-form.mjs";
|
|
98
100
|
import { UsePlaybookFormOptions, usePlaybookForm } from "./hooks/use-playbook-form.mjs";
|
|
99
101
|
import { UseSearchFormOptions, useSearchForm } from "./hooks/use-search-form.mjs";
|
|
100
102
|
import { UseSheetEffectFormOptions, useSheetEffectForm } from "./hooks/use-sheet-effect-form.mjs";
|
|
101
103
|
import { UseStreamFormOptions, useStreamForm } from "./hooks/use-stream-form.mjs";
|
|
102
|
-
import { fuzzyFilter, getFieldStatusIcon, getFieldTypeIcon } from "./utils/catalog-helpers.mjs";
|
|
103
104
|
import { EmojiGlyph } from "./widgets/emoji-glyph.mjs";
|
|
104
105
|
import { FieldTypeBadge } from "./widgets/field-type-badge.mjs";
|
|
105
106
|
import { IconGlyph } from "./widgets/icon-glyph.mjs";
|
|
@@ -108,4 +109,4 @@ import { PricingBadge } from "./widgets/pricing-badge.mjs";
|
|
|
108
109
|
import { ProviderLogo } from "./widgets/provider-logo.mjs";
|
|
109
110
|
import { WidgetStrip } from "./widgets/widget-strip.mjs";
|
|
110
111
|
import { WidgetView } from "./widgets/widget-view.mjs";
|
|
111
|
-
export { Alert, AlertDescription, type AlertProps, AlertTitle, type AlertVariant, type AnyFieldProps as AnyFieldHandle, AvatarGroup, type AvatarGroupProps, type AvatarGroupState, CatalogCard, CatalogCardBadge, type CatalogCardBadgeProps, CatalogCardBadges, type CatalogCardBadgesProps, CatalogCardDescription, type CatalogCardDescriptionProps, CatalogCardHeader, type CatalogCardHeaderProps, type CatalogCardProps, CatalogCardTitle, type CatalogCardTitleProps, CatalogCategorySection, type CatalogCategorySectionProps, type CatalogClassNames, type CatalogComponentOverrides, type CatalogConfig, CatalogCopyId, type CatalogCopyIdProps, CatalogCreditBadge, type CatalogCreditBadgeProps, CatalogDocsBadge, type CatalogDocsBadgeProps, CatalogFieldBadge, type CatalogFieldBadgeProps, type CatalogFieldBadgeState, CatalogProvider, CatalogProviderAvatars, type CatalogProviderAvatarsProps, type CatalogProviderProps, CatalogRoot, type CostMode, type EffectCardData, EffectCatalog, EffectCatalogCard, EffectCatalogCardContext, type EffectCatalogCardContextValue, type EffectCatalogCardProps, type EffectCatalogCardState, EffectCatalogCategoryFilter, type EffectCatalogCategoryFilterProps, type EffectCatalogCategoryFilterState, EffectCatalogContext, type EffectCatalogContextValue, EffectCatalogEmpty, type EffectCatalogEmptyProps, type EffectCatalogEmptyState, type EffectCatalogInstanceProps, EffectCatalogList, type EffectCatalogListProps, type EffectCatalogListState, type EffectCatalogProps, EffectCatalogSearchFilter, type EffectCatalogSearchFilterProps, type EffectCatalogSearchFilterState, type EffectCatalogZeroConfigProps, EmojiGlyph, type FieldAdapterMap, type GeneratedFieldProps as FieldHandle, type FieldKind, type FieldMeta, FieldRenderer, FieldTypeBadge, type FormClassNames, type FormComponents, type FormConfig, type FormErrorEntry, type FormErrors, type FormFieldState, type FormHandle, FormProvider, type FormResetFieldOptions, type FormResetOptions, FormRoot, type FormSetValueOptions, type FormStateSnapshot, type GroupMap, type GroupOverride, IconGlyph, type InputFieldEntries, LogoUrl, type OutputFieldEntries, type PathMap, type PathOverride, type ActiveFilter as PipeActiveFilter, type PipeCardData, PipeCatalog, PipeCatalogActiveFilters, type PipeCatalogActiveFiltersProps, type PipeCatalogActiveFiltersState, PipeCatalogCard, PipeCatalogCardContext, type PipeCatalogCardContextValue, type PipeCatalogCardProps, PipeCatalogCategoryFilter, type PipeCatalogCategoryFilterProps, type PipeCatalogCategoryFilterState, PipeCatalogColumnFilter, type PipeCatalogColumnFilterProps, PipeCatalogColumnFilters, type PipeCatalogColumnFiltersProps, PipeCatalogContext, type PipeCatalogContextValue, PipeCatalogEmpty, type PipeCatalogEmptyProps, type PipeCatalogEmptyState, PipeCatalogInputFieldFilter, type PipeCatalogInputFieldFilterProps, type PipeCatalogInstanceProps, PipeCatalogList, type PipeCatalogListProps, type PipeCatalogListState, PipeCatalogOutputFieldFilter, type PipeCatalogOutputFieldFilterProps, type PipeCatalogProps, PipeCatalogProviderFilter, type PipeCatalogProviderFilterProps, PipeCatalogSearchFilter, type PipeCatalogSearchFilterProps, type PipeCatalogSearchFilterState, PipeCatalogTagFilter, type PipeCatalogTagFilterProps, type PipeCatalogZeroConfigProps, type PipeColumnFilterId, type ColumnFilterState as PipeColumnFilterState, PipeForm, PipeFormContent, PipeFormContext, PipeFormErrors, PipeFormField, PipeFormFooter, PipeFormGroup, PipeFormHeader, type PipeFormInstanceProps, type PipeFormProps, PipeFormSection, PipeFormSubmitButton, PipeFormTitle, type PipeFormZeroConfigProps, PricingBadge, ProviderLogo, type ActiveFilter$1 as SearchActiveFilter, type SearchCardData, SearchCatalog, SearchCatalogActiveFilters, type SearchCatalogActiveFiltersProps, type SearchCatalogActiveFiltersState, SearchCatalogCard, SearchCatalogCardContext, type SearchCatalogCardContextValue, type SearchCatalogCardProps, SearchCatalogCategoryFilter, type SearchCatalogCategoryFilterProps, type SearchCatalogCategoryFilterState, SearchCatalogColumnFilter, type SearchCatalogColumnFilterProps, SearchCatalogColumnFilters, type SearchCatalogColumnFiltersProps, SearchCatalogContext, type SearchCatalogContextValue, SearchCatalogEmpty, type SearchCatalogEmptyProps, type SearchCatalogEmptyState, type SearchCatalogInstanceProps, SearchCatalogList, type SearchCatalogListProps, type SearchCatalogListState, SearchCatalogOutputFieldFilter, type SearchCatalogOutputFieldFilterProps, type SearchCatalogProps, SearchCatalogProviderFilter, type SearchCatalogProviderFilterProps, SearchCatalogSearchFilter, type SearchCatalogSearchFilterProps, type SearchCatalogSearchFilterState, SearchCatalogTagFilter, type SearchCatalogTagFilterProps, type SearchCatalogZeroConfigProps, type SearchColumnFilterId, type ColumnFilterState$1 as SearchColumnFilterState, SearchForm, SearchFormContent, SearchFormContext, SearchFormErrors, SearchFormField, SearchFormFooter, SearchFormGroup, SearchFormHeader, type SearchFormInstanceProps, type SearchFormProps, SearchFormSection, SearchFormSubmitButton, SearchFormTitle, type SearchFormZeroConfigProps, type SearchOutputFieldEntries, type ActiveFilter$2 as SearchesActiveFilter, type SearchesCardData, SearchesCatalog, SearchesCatalogActiveFilters, type SearchesCatalogActiveFiltersProps, type SearchesCatalogActiveFiltersState, SearchesCatalogCard, SearchesCatalogCardContext, type SearchesCatalogCardContextValue, type SearchesCatalogCardProps, SearchesCatalogCategoryFilter, type SearchesCatalogCategoryFilterProps, type SearchesCatalogCategoryFilterState, SearchesCatalogColumnFilter, type SearchesCatalogColumnFilterProps, SearchesCatalogColumnFilters, type SearchesCatalogColumnFiltersProps, SearchesCatalogContext, type SearchesCatalogContextValue, SearchesCatalogEmpty, type SearchesCatalogEmptyProps, type SearchesCatalogEmptyState, type SearchesCatalogInstanceProps, SearchesCatalogList, type SearchesCatalogListProps, type SearchesCatalogListState, SearchesCatalogOutputFieldFilter, type SearchesCatalogOutputFieldFilterProps, type SearchesCatalogProps, SearchesCatalogProviderFilter, type SearchesCatalogProviderFilterProps, SearchesCatalogSearchFilter, type SearchesCatalogSearchFilterProps, type SearchesCatalogSearchFilterState, SearchesCatalogTagFilter, type SearchesCatalogTagFilterProps, type SearchesCatalogZeroConfigProps, type SearchesColumnFilterId, type ColumnFilterState$2 as SearchesColumnFilterState, type SearchesOutputFieldEntries, type SectionMap, type SectionOverride, type UseEffectCatalogTableReturn, type UsePipeCatalogTableReturn, type UsePipeFormOptions, type UsePlaybookFormOptions, type UseSearchCatalogTableReturn, type UseSearchFormOptions, type UseSearchesCatalogTableReturn, type UseSheetEffectFormOptions, type UseStreamFormOptions, WidgetStrip, WidgetView, alertVariants, defaultAdapters, fuzzyFilter, getFieldStatusIcon, getFieldTypeIcon, useCatalogConfig, useEffectCatalogCard, useEffectCatalogContext, useEffectCatalogTable, useFieldError, useFormAlert, useFormConfig, usePipeCatalogCard, usePipeCatalogContext, usePipeCatalogTable, usePipeForm, usePipeFormContext, usePlaybookForm, usePortalContainer, useSearchCatalogCard, useSearchCatalogContext, useSearchCatalogTable, useSearchForm, useSearchFormContext, useSearchesCatalogCard, useSearchesCatalogContext, useSearchesCatalogTable, useSheetEffectForm, useStreamForm };
|
|
112
|
+
export { Alert, AlertDescription, type AlertProps, AlertTitle, type AlertVariant, type AnyFieldProps as AnyFieldHandle, AvatarGroup, type AvatarGroupProps, type AvatarGroupState, CatalogCard, CatalogCardBadge, type CatalogCardBadgeProps, CatalogCardBadges, type CatalogCardBadgesProps, CatalogCardDescription, type CatalogCardDescriptionProps, CatalogCardHeader, type CatalogCardHeaderProps, type CatalogCardProps, CatalogCardTitle, type CatalogCardTitleProps, CatalogCategorySection, type CatalogCategorySectionProps, type CatalogClassNames, type CatalogComponentOverrides, type CatalogConfig, CatalogCopyId, type CatalogCopyIdProps, CatalogCreditBadge, type CatalogCreditBadgeProps, CatalogDocsBadge, type CatalogDocsBadgeProps, CatalogFieldBadge, type CatalogFieldBadgeProps, type CatalogFieldBadgeState, type CatalogFilterMeta, CatalogProvider, CatalogProviderAvatars, type CatalogProviderAvatarsProps, type CatalogProviderProps, CatalogRoot, type CatalogSearchFeatures, type CatalogTableFeatures, type CostMode, type EffectCardData, EffectCatalog, EffectCatalogCard, EffectCatalogCardContext, type EffectCatalogCardContextValue, type EffectCatalogCardProps, type EffectCatalogCardState, EffectCatalogCategoryFilter, type EffectCatalogCategoryFilterProps, type EffectCatalogCategoryFilterState, EffectCatalogContext, type EffectCatalogContextValue, EffectCatalogEmpty, type EffectCatalogEmptyProps, type EffectCatalogEmptyState, type EffectCatalogInstanceProps, EffectCatalogList, type EffectCatalogListProps, type EffectCatalogListState, type EffectCatalogProps, EffectCatalogSearchFilter, type EffectCatalogSearchFilterProps, type EffectCatalogSearchFilterState, type EffectCatalogZeroConfigProps, EmojiGlyph, type FieldAdapterMap, type GeneratedFieldProps as FieldHandle, type FieldKind, type FieldMeta, FieldRenderer, FieldTypeBadge, type FormClassNames, type FormComponents, type FormConfig, type FormErrorEntry, type FormErrors, type FormFieldState, type FormHandle, FormProvider, type FormResetFieldOptions, type FormResetOptions, FormRoot, type FormSetValueOptions, type FormStateSnapshot, type GroupMap, type GroupOverride, IconGlyph, type InputFieldEntries, LogoUrl, type OutputFieldEntries, type PathMap, type PathOverride, type ActiveFilter as PipeActiveFilter, type PipeCardData, PipeCatalog, PipeCatalogActiveFilters, type PipeCatalogActiveFiltersProps, type PipeCatalogActiveFiltersState, PipeCatalogCard, PipeCatalogCardContext, type PipeCatalogCardContextValue, type PipeCatalogCardProps, PipeCatalogCategoryFilter, type PipeCatalogCategoryFilterProps, type PipeCatalogCategoryFilterState, PipeCatalogColumnFilter, type PipeCatalogColumnFilterProps, PipeCatalogColumnFilters, type PipeCatalogColumnFiltersProps, PipeCatalogContext, type PipeCatalogContextValue, PipeCatalogEmpty, type PipeCatalogEmptyProps, type PipeCatalogEmptyState, PipeCatalogInputFieldFilter, type PipeCatalogInputFieldFilterProps, type PipeCatalogInstanceProps, PipeCatalogList, type PipeCatalogListProps, type PipeCatalogListState, PipeCatalogOutputFieldFilter, type PipeCatalogOutputFieldFilterProps, type PipeCatalogProps, PipeCatalogProviderFilter, type PipeCatalogProviderFilterProps, PipeCatalogSearchFilter, type PipeCatalogSearchFilterProps, type PipeCatalogSearchFilterState, PipeCatalogTagFilter, type PipeCatalogTagFilterProps, type PipeCatalogZeroConfigProps, type PipeColumnFilterId, type ColumnFilterState as PipeColumnFilterState, PipeForm, PipeFormContent, PipeFormContext, PipeFormErrors, PipeFormField, PipeFormFooter, PipeFormGroup, PipeFormHeader, type PipeFormInstanceProps, type PipeFormProps, PipeFormSection, PipeFormSubmitButton, PipeFormTitle, type PipeFormZeroConfigProps, PricingBadge, ProviderLogo, type ActiveFilter$1 as SearchActiveFilter, type SearchCardData, SearchCatalog, SearchCatalogActiveFilters, type SearchCatalogActiveFiltersProps, type SearchCatalogActiveFiltersState, SearchCatalogCard, SearchCatalogCardContext, type SearchCatalogCardContextValue, type SearchCatalogCardProps, SearchCatalogCategoryFilter, type SearchCatalogCategoryFilterProps, type SearchCatalogCategoryFilterState, SearchCatalogColumnFilter, type SearchCatalogColumnFilterProps, SearchCatalogColumnFilters, type SearchCatalogColumnFiltersProps, SearchCatalogContext, type SearchCatalogContextValue, SearchCatalogEmpty, type SearchCatalogEmptyProps, type SearchCatalogEmptyState, type SearchCatalogInstanceProps, SearchCatalogList, type SearchCatalogListProps, type SearchCatalogListState, SearchCatalogOutputFieldFilter, type SearchCatalogOutputFieldFilterProps, type SearchCatalogProps, SearchCatalogProviderFilter, type SearchCatalogProviderFilterProps, SearchCatalogSearchFilter, type SearchCatalogSearchFilterProps, type SearchCatalogSearchFilterState, SearchCatalogTagFilter, type SearchCatalogTagFilterProps, type SearchCatalogZeroConfigProps, type SearchColumnFilterId, type ColumnFilterState$1 as SearchColumnFilterState, SearchForm, SearchFormContent, SearchFormContext, SearchFormErrors, SearchFormField, SearchFormFooter, SearchFormGroup, SearchFormHeader, type SearchFormInstanceProps, type SearchFormProps, SearchFormSection, SearchFormSubmitButton, SearchFormTitle, type SearchFormZeroConfigProps, type SearchOutputFieldEntries, type ActiveFilter$2 as SearchesActiveFilter, type SearchesCardData, SearchesCatalog, SearchesCatalogActiveFilters, type SearchesCatalogActiveFiltersProps, type SearchesCatalogActiveFiltersState, SearchesCatalogCard, SearchesCatalogCardContext, type SearchesCatalogCardContextValue, type SearchesCatalogCardProps, SearchesCatalogCategoryFilter, type SearchesCatalogCategoryFilterProps, type SearchesCatalogCategoryFilterState, SearchesCatalogColumnFilter, type SearchesCatalogColumnFilterProps, SearchesCatalogColumnFilters, type SearchesCatalogColumnFiltersProps, SearchesCatalogContext, type SearchesCatalogContextValue, SearchesCatalogEmpty, type SearchesCatalogEmptyProps, type SearchesCatalogEmptyState, type SearchesCatalogInstanceProps, SearchesCatalogList, type SearchesCatalogListProps, type SearchesCatalogListState, SearchesCatalogOutputFieldFilter, type SearchesCatalogOutputFieldFilterProps, type SearchesCatalogProps, SearchesCatalogProviderFilter, type SearchesCatalogProviderFilterProps, SearchesCatalogSearchFilter, type SearchesCatalogSearchFilterProps, type SearchesCatalogSearchFilterState, SearchesCatalogTagFilter, type SearchesCatalogTagFilterProps, type SearchesCatalogZeroConfigProps, type SearchesColumnFilterId, type ColumnFilterState$2 as SearchesColumnFilterState, type SearchesOutputFieldEntries, type SectionMap, type SectionOverride, type UseEffectCatalogTableReturn, type UsePipeCatalogTableReturn, type UsePipeFormOptions, type UsePlaybookFormOptions, type UseSearchCatalogTableReturn, type UseSearchFormOptions, type UseSearchesCatalogTableReturn, type UseSheetEffectFormOptions, type UseStreamFormOptions, WidgetStrip, WidgetView, alertVariants, catalogSearchFilter, catalogSearchSort, catalogTableFeatures, createCatalogColumnHelper, defaultAdapters, fuzzyFilter, getFieldFormatIcon, getFieldStatusIcon, getFieldTypeIcon, useCatalogConfig, useCatalogTable, useEffectCatalogCard, useEffectCatalogContext, useEffectCatalogTable, useFieldError, useFormAlert, useFormConfig, usePipeCatalogCard, usePipeCatalogContext, usePipeCatalogTable, usePipeForm, usePipeFormContext, usePlaybookForm, usePortalContainer, useSearchCatalogCard, useSearchCatalogContext, useSearchCatalogTable, useSearchForm, useSearchFormContext, useSearchesCatalogCard, useSearchesCatalogContext, useSearchesCatalogTable, useSheetEffectForm, useStreamForm };
|
package/dist/index.mjs
CHANGED
|
@@ -13,7 +13,8 @@ import { EffectCatalogCard } from "./components/compound/effect-catalog/card.mjs
|
|
|
13
13
|
import { EffectCatalogCategoryFilter } from "./components/compound/effect-catalog/category-filter.mjs";
|
|
14
14
|
import { EffectCatalogEmpty } from "./components/compound/effect-catalog/empty.mjs";
|
|
15
15
|
import { EffectCatalogList } from "./components/compound/effect-catalog/list.mjs";
|
|
16
|
-
import { fuzzyFilter, getFieldStatusIcon, getFieldTypeIcon } from "./utils/catalog-helpers.mjs";
|
|
16
|
+
import { catalogSearchFilter, catalogSearchSort, fuzzyFilter, getFieldFormatIcon, getFieldStatusIcon, getFieldTypeIcon } from "./utils/catalog-helpers.mjs";
|
|
17
|
+
import { catalogTableFeatures, createCatalogColumnHelper, useCatalogTable } from "./hooks/catalog-table.mjs";
|
|
17
18
|
import { useEffectCatalogTable } from "./hooks/use-effect-catalog-table.mjs";
|
|
18
19
|
import { EffectCatalogSearchFilter } from "./components/compound/effect-catalog/search-filter.mjs";
|
|
19
20
|
import { EffectCatalog } from "./components/compound/effect-catalog/root.mjs";
|
|
@@ -103,4 +104,4 @@ import { usePlaybookForm } from "./hooks/use-playbook-form.mjs";
|
|
|
103
104
|
import { useSheetEffectForm } from "./hooks/use-sheet-effect-form.mjs";
|
|
104
105
|
import { useStreamForm } from "./hooks/use-stream-form.mjs";
|
|
105
106
|
|
|
106
|
-
export { Alert, AlertDescription, AlertTitle, AvatarGroup, CatalogCard, CatalogCardBadge, CatalogCardBadges, CatalogCardDescription, CatalogCardHeader, CatalogCardTitle, CatalogCategorySection, CatalogCopyId, CatalogCreditBadge, CatalogDocsBadge, CatalogFieldBadge, CatalogProvider, CatalogProviderAvatars, CatalogRoot, EffectCatalog, EffectCatalogCard, EffectCatalogCardContext, EffectCatalogCategoryFilter, EffectCatalogContext, EffectCatalogEmpty, EffectCatalogList, EffectCatalogSearchFilter, EmojiGlyph, FieldRenderer, FieldTypeBadge, FormProvider, FormRoot, IconGlyph, LogoUrl, PipeCatalog, PipeCatalogActiveFilters, PipeCatalogCard, PipeCatalogCardContext, PipeCatalogCategoryFilter, PipeCatalogColumnFilter, PipeCatalogColumnFilters, PipeCatalogContext, PipeCatalogEmpty, PipeCatalogInputFieldFilter, PipeCatalogList, PipeCatalogOutputFieldFilter, PipeCatalogProviderFilter, PipeCatalogSearchFilter, PipeCatalogTagFilter, PipeForm, PipeFormContent, PipeFormContext, PipeFormErrors, PipeFormField, PipeFormFooter, PipeFormGroup, PipeFormHeader, PipeFormSection, PipeFormSubmitButton, PipeFormTitle, PricingBadge, ProviderLogo, SearchCatalog, SearchCatalogActiveFilters, SearchCatalogCard, SearchCatalogCardContext, SearchCatalogCategoryFilter, SearchCatalogColumnFilter, SearchCatalogColumnFilters, SearchCatalogContext, SearchCatalogEmpty, SearchCatalogList, SearchCatalogOutputFieldFilter, SearchCatalogProviderFilter, SearchCatalogSearchFilter, SearchCatalogTagFilter, SearchForm, SearchFormContent, SearchFormContext, SearchFormErrors, SearchFormField, SearchFormFooter, SearchFormGroup, SearchFormHeader, SearchFormSection, SearchFormSubmitButton, SearchFormTitle, SearchesCatalog, SearchesCatalogActiveFilters, SearchesCatalogCard, SearchesCatalogCardContext, SearchesCatalogCategoryFilter, SearchesCatalogColumnFilter, SearchesCatalogColumnFilters, SearchesCatalogContext, SearchesCatalogEmpty, SearchesCatalogList, SearchesCatalogOutputFieldFilter, SearchesCatalogProviderFilter, SearchesCatalogSearchFilter, SearchesCatalogTagFilter, WidgetStrip, WidgetView, alertVariants, defaultAdapters, fuzzyFilter, getFieldStatusIcon, getFieldTypeIcon, useCatalogConfig, useEffectCatalogCard, useEffectCatalogContext, useEffectCatalogTable, useFieldError, useFormAlert, useFormConfig, usePipeCatalogCard, usePipeCatalogContext, usePipeCatalogTable, usePipeForm, usePipeFormContext, usePlaybookForm, usePortalContainer, useSearchCatalogCard, useSearchCatalogContext, useSearchCatalogTable, useSearchForm, useSearchFormContext, useSearchesCatalogCard, useSearchesCatalogContext, useSearchesCatalogTable, useSheetEffectForm, useStreamForm };
|
|
107
|
+
export { Alert, AlertDescription, AlertTitle, AvatarGroup, CatalogCard, CatalogCardBadge, CatalogCardBadges, CatalogCardDescription, CatalogCardHeader, CatalogCardTitle, CatalogCategorySection, CatalogCopyId, CatalogCreditBadge, CatalogDocsBadge, CatalogFieldBadge, CatalogProvider, CatalogProviderAvatars, CatalogRoot, EffectCatalog, EffectCatalogCard, EffectCatalogCardContext, EffectCatalogCategoryFilter, EffectCatalogContext, EffectCatalogEmpty, EffectCatalogList, EffectCatalogSearchFilter, EmojiGlyph, FieldRenderer, FieldTypeBadge, FormProvider, FormRoot, IconGlyph, LogoUrl, PipeCatalog, PipeCatalogActiveFilters, PipeCatalogCard, PipeCatalogCardContext, PipeCatalogCategoryFilter, PipeCatalogColumnFilter, PipeCatalogColumnFilters, PipeCatalogContext, PipeCatalogEmpty, PipeCatalogInputFieldFilter, PipeCatalogList, PipeCatalogOutputFieldFilter, PipeCatalogProviderFilter, PipeCatalogSearchFilter, PipeCatalogTagFilter, PipeForm, PipeFormContent, PipeFormContext, PipeFormErrors, PipeFormField, PipeFormFooter, PipeFormGroup, PipeFormHeader, PipeFormSection, PipeFormSubmitButton, PipeFormTitle, PricingBadge, ProviderLogo, SearchCatalog, SearchCatalogActiveFilters, SearchCatalogCard, SearchCatalogCardContext, SearchCatalogCategoryFilter, SearchCatalogColumnFilter, SearchCatalogColumnFilters, SearchCatalogContext, SearchCatalogEmpty, SearchCatalogList, SearchCatalogOutputFieldFilter, SearchCatalogProviderFilter, SearchCatalogSearchFilter, SearchCatalogTagFilter, SearchForm, SearchFormContent, SearchFormContext, SearchFormErrors, SearchFormField, SearchFormFooter, SearchFormGroup, SearchFormHeader, SearchFormSection, SearchFormSubmitButton, SearchFormTitle, SearchesCatalog, SearchesCatalogActiveFilters, SearchesCatalogCard, SearchesCatalogCardContext, SearchesCatalogCategoryFilter, SearchesCatalogColumnFilter, SearchesCatalogColumnFilters, SearchesCatalogContext, SearchesCatalogEmpty, SearchesCatalogList, SearchesCatalogOutputFieldFilter, SearchesCatalogProviderFilter, SearchesCatalogSearchFilter, SearchesCatalogTagFilter, WidgetStrip, WidgetView, alertVariants, catalogSearchFilter, catalogSearchSort, catalogTableFeatures, createCatalogColumnHelper, defaultAdapters, fuzzyFilter, getFieldFormatIcon, getFieldStatusIcon, getFieldTypeIcon, useCatalogConfig, useCatalogTable, useEffectCatalogCard, useEffectCatalogContext, useEffectCatalogTable, useFieldError, useFormAlert, useFormConfig, usePipeCatalogCard, usePipeCatalogContext, usePipeCatalogTable, usePipeForm, usePipeFormContext, usePlaybookForm, usePortalContainer, useSearchCatalogCard, useSearchCatalogContext, useSearchCatalogTable, useSearchForm, useSearchFormContext, useSearchesCatalogCard, useSearchesCatalogContext, useSearchesCatalogTable, useSheetEffectForm, useStreamForm };
|
|
@@ -1,12 +1,29 @@
|
|
|
1
1
|
import * as _$react from "react";
|
|
2
|
-
import {
|
|
2
|
+
import { ComponentType } from "react";
|
|
3
|
+
import { RecordFieldFormat, RecordFieldStatus, RecordFieldType } from "@pipe0/base";
|
|
3
4
|
import * as _$lucide_react0 from "lucide-react";
|
|
4
|
-
import { FilterFn } from "@tanstack/react-table";
|
|
5
|
+
import { FilterFn, RowData, SortFn, TableFeatures } from "@tanstack/react-table";
|
|
6
|
+
import { RankingInfo } from "@tanstack/match-sorter-utils";
|
|
5
7
|
|
|
6
8
|
//#region src/utils/catalog-helpers.d.ts
|
|
7
9
|
declare function getFieldTypeIcon(fieldType: RecordFieldType): _$react.ForwardRefExoticComponent<Omit<_$lucide_react0.LucideProps, "ref"> & _$react.RefAttributes<SVGSVGElement>>;
|
|
10
|
+
/**
|
|
11
|
+
* Column icon: the format is the expressive signal (an email column looks
|
|
12
|
+
* different from a date column), the type is the fallback for untyped fields.
|
|
13
|
+
*/
|
|
14
|
+
declare function getFieldFormatIcon(format: RecordFieldFormat, fieldType: RecordFieldType): ComponentType | _$react.ForwardRefExoticComponent<Omit<_$lucide_react0.LucideProps, "ref"> & _$react.RefAttributes<SVGSVGElement>>;
|
|
8
15
|
declare function getFieldStatusIcon(fieldStatus: RecordFieldStatus): _$react.ForwardRefExoticComponent<Omit<_$lucide_react0.LucideProps, "ref"> & _$react.RefAttributes<SVGSVGElement>>;
|
|
9
|
-
|
|
16
|
+
/** Filter meta the catalog filter fns attach to rows, read back by the sort fns. */
|
|
17
|
+
interface CatalogFilterMeta {
|
|
18
|
+
itemRank?: RankingInfo;
|
|
19
|
+
searchScore?: number;
|
|
20
|
+
}
|
|
21
|
+
type CatalogSearchFeatures = TableFeatures & {
|
|
22
|
+
filterMeta: CatalogFilterMeta;
|
|
23
|
+
};
|
|
24
|
+
declare const fuzzyFilter: FilterFn<CatalogSearchFeatures, RowData>;
|
|
25
|
+
declare const catalogSearchFilter: FilterFn<CatalogSearchFeatures, RowData>;
|
|
26
|
+
declare const catalogSearchSort: SortFn<CatalogSearchFeatures, RowData>;
|
|
10
27
|
//#endregion
|
|
11
|
-
export { fuzzyFilter, getFieldStatusIcon, getFieldTypeIcon };
|
|
28
|
+
export { CatalogFilterMeta, CatalogSearchFeatures, catalogSearchFilter, catalogSearchSort, fuzzyFilter, getFieldFormatIcon, getFieldStatusIcon, getFieldTypeIcon };
|
|
12
29
|
//# sourceMappingURL=catalog-helpers.d.mts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"catalog-helpers.d.mts","names":[],"sources":["../../src/utils/catalog-helpers.tsx"],"mappings":"
|
|
1
|
+
{"version":3,"file":"catalog-helpers.d.mts","names":[],"sources":["../../src/utils/catalog-helpers.tsx"],"mappings":";;;;;;;;iBAqDgB,gBAAA,CAAiB,SAAA,EAAW,eAAA,GAAe,OAAA,CAAA,yBAAA,CAAA,IAAA,CAAA,eAAA,CAAA,WAAA,WAAA,OAAA,CAAA,aAAA,CAAA,aAAA;;;;AAA3D;iBA+BgB,kBAAA,CAAmB,MAAA,EAAQ,iBAAA,EAAmB,SAAA,EAAW,eAAA,GAAe,aAAA,GAAA,OAAA,CAAA,yBAAA,CAAA,IAAA,CAAA,eAAA,CAAA,WAAA,WAAA,OAAA,CAAA,aAAA,CAAA,aAAA;AAAA,iBAIxE,kBAAA,CAAmB,WAAA,EAAa,iBAAA,GAAiB,OAAA,CAAA,yBAAA,CAAA,IAAA,CAAA,eAAA,CAAA,WAAA,WAAA,OAAA,CAAA,aAAA,CAAA,aAAA;;UAKhD,iBAAA;EACf,QAAA,GAAW,WAAA;EACX,WAAA;AAAA;AAAA,KAKU,qBAAA,GAAwB,aAAA;EAAkB,UAAA,EAAY,iBAAA;AAAA;AAAA,cAErD,WAAA,EAAa,QAAA,CAAS,qBAAA,EAAuB,OAAA;AAAA,cAc7C,mBAAA,EAAqB,QAAA,CAAS,qBAAA,EAAuB,OAAA;AAAA,cAcrD,iBAAA,EAAmB,MAAA,CAAO,qBAAA,EAAuB,OAAA"}
|