@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
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,21 @@
|
|
|
1
1
|
# @pipe0/elements-react
|
|
2
2
|
|
|
3
|
+
## 1.0.31
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- 99aba2b: Add credit info to task response
|
|
8
|
+
- Updated dependencies [99aba2b]
|
|
9
|
+
- @pipe0/base@1.0.31
|
|
10
|
+
|
|
11
|
+
## 1.0.30
|
|
12
|
+
|
|
13
|
+
### Patch Changes
|
|
14
|
+
|
|
15
|
+
- b654d22: Fix changesets
|
|
16
|
+
- Updated dependencies [b654d22]
|
|
17
|
+
- @pipe0/base@1.0.30
|
|
18
|
+
|
|
3
19
|
## 1.0.29
|
|
4
20
|
|
|
5
21
|
### Patch Changes
|
|
@@ -16,7 +16,7 @@ const COLUMN_LABELS = {
|
|
|
16
16
|
function PipeCatalogActiveFilters({ className, render, ...props }) {
|
|
17
17
|
const { classNames } = useCatalogConfig();
|
|
18
18
|
const ctx = usePipeCatalogContext();
|
|
19
|
-
const filters = ctx.table.
|
|
19
|
+
const filters = ctx.table.state.columnFilters.filter((f) => f.value != null && f.value !== "").map((f) => ({
|
|
20
20
|
id: f.id,
|
|
21
21
|
value: String(f.value),
|
|
22
22
|
label: COLUMN_LABELS[f.id] ?? f.id,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"active-filters.mjs","names":[],"sources":["../../../../src/components/compound/pipe-catalog/active-filters.tsx"],"sourcesContent":["import { mergeProps } from \"@base-ui/react/merge-props\";\nimport { useRender } from \"@base-ui/react/use-render\";\nimport { useCatalogConfig } from \"../../../context/catalog-config-context.js\";\nimport { usePipeCatalogContext } from \"../../../context/pipe-catalog-context.js\";\nimport { cn } from \"../../../lib/utils.js\";\nimport { DefaultActiveFilterPill } from \"../../defaults/catalog/active-filter-pill.js\";\n\nconst COLUMN_LABELS: Record<string, string> = {\n inputFields: \"Input\",\n outputFields: \"Output\",\n providers: \"Provider\",\n tags: \"Tag\",\n};\n\nexport interface ActiveFilter {\n id: string;\n value: string;\n label: string;\n remove: () => void;\n}\n\nexport interface PipeCatalogActiveFiltersState {\n activeFilters: ActiveFilter[];\n isEmpty: boolean;\n}\n\nexport interface PipeCatalogActiveFiltersProps\n extends useRender.ComponentProps<\"div\", PipeCatalogActiveFiltersState> {}\n\nexport function PipeCatalogActiveFilters({\n className,\n render,\n ...props\n}: PipeCatalogActiveFiltersProps) {\n const { classNames } = useCatalogConfig();\n const ctx = usePipeCatalogContext();\n const filters: ActiveFilter[] = ctx.table
|
|
1
|
+
{"version":3,"file":"active-filters.mjs","names":[],"sources":["../../../../src/components/compound/pipe-catalog/active-filters.tsx"],"sourcesContent":["import { mergeProps } from \"@base-ui/react/merge-props\";\nimport { useRender } from \"@base-ui/react/use-render\";\nimport { useCatalogConfig } from \"../../../context/catalog-config-context.js\";\nimport { usePipeCatalogContext } from \"../../../context/pipe-catalog-context.js\";\nimport { cn } from \"../../../lib/utils.js\";\nimport { DefaultActiveFilterPill } from \"../../defaults/catalog/active-filter-pill.js\";\n\nconst COLUMN_LABELS: Record<string, string> = {\n inputFields: \"Input\",\n outputFields: \"Output\",\n providers: \"Provider\",\n tags: \"Tag\",\n};\n\nexport interface ActiveFilter {\n id: string;\n value: string;\n label: string;\n remove: () => void;\n}\n\nexport interface PipeCatalogActiveFiltersState {\n activeFilters: ActiveFilter[];\n isEmpty: boolean;\n}\n\nexport interface PipeCatalogActiveFiltersProps\n extends useRender.ComponentProps<\"div\", PipeCatalogActiveFiltersState> {}\n\nexport function PipeCatalogActiveFilters({\n className,\n render,\n ...props\n}: PipeCatalogActiveFiltersProps) {\n const { classNames } = useCatalogConfig();\n const ctx = usePipeCatalogContext();\n const filters: ActiveFilter[] = ctx.table.state.columnFilters\n .filter((f) => f.value != null && f.value !== \"\")\n .map((f) => ({\n id: f.id,\n value: String(f.value),\n label: COLUMN_LABELS[f.id] ?? f.id,\n remove: () =>\n ctx.removeColumnFilter(f.id as \"inputFields\" | \"outputFields\" | \"tags\" | \"providers\"),\n }));\n\n const isEmpty = filters.length === 0;\n\n const defaultBody = filters.map((f) => (\n <DefaultActiveFilterPill key={f.id} label={f.label} value={f.value} onRemove={f.remove} />\n ));\n\n const element = useRender({\n defaultTagName: \"div\",\n render,\n state: { activeFilters: filters, isEmpty },\n stateAttributesMapping: {\n activeFilters: () => null,\n },\n props: mergeProps<\"div\">(\n {\n className: cn(\n \"pz:flex pz:flex-wrap pz:items-center pz:gap-2\",\n classNames?.activeFilters,\n className,\n ),\n children: defaultBody,\n ...({ \"data-p0\": \"catalog-active-filters\" } as Record<string, string>),\n },\n props,\n ),\n });\n\n if (isEmpty) return null;\n return element;\n}\n"],"mappings":";;;;;;;;;AAOA,MAAM,gBAAwC;CAC5C,aAAa;CACb,cAAc;CACd,WAAW;CACX,MAAM;CACP;AAiBD,SAAgB,yBAAyB,EACvC,WACA,QACA,GAAG,SAC6B;CAChC,MAAM,EAAE,eAAe,kBAAkB;CACzC,MAAM,MAAM,uBAAuB;CACnC,MAAM,UAA0B,IAAI,MAAM,MAAM,cAC7C,QAAQ,MAAM,EAAE,SAAS,QAAQ,EAAE,UAAU,GAAG,CAChD,KAAK,OAAO;EACX,IAAI,EAAE;EACN,OAAO,OAAO,EAAE,MAAM;EACtB,OAAO,cAAc,EAAE,OAAO,EAAE;EAChC,cACE,IAAI,mBAAmB,EAAE,GAA4D;EACxF,EAAE;CAEL,MAAM,UAAU,QAAQ,WAAW;CAEnC,MAAM,cAAc,QAAQ,KAAK,MAC/B,oBAAC,yBAAD;EAAoC,OAAO,EAAE;EAAO,OAAO,EAAE;EAAO,UAAU,EAAE;EAAU,EAA5D,EAAE,GAA0D,CAC1F;CAEF,MAAM,UAAU,UAAU;EACxB,gBAAgB;EAChB;EACA,OAAO;GAAE,eAAe;GAAS;GAAS;EAC1C,wBAAwB,EACtB,qBAAqB,MACtB;EACD,OAAO,WACL;GACE,WAAW,GACT,iDACA,YAAY,eACZ,UACD;GACD,UAAU;GACJ,WAAW;GAClB,EACD,MACD;EACF,CAAC;AAEF,KAAI,QAAS,QAAO;AACpB,QAAO"}
|
|
@@ -15,7 +15,7 @@ const COLUMN_LABELS = {
|
|
|
15
15
|
function SearchCatalogActiveFilters({ className, render, ...props }) {
|
|
16
16
|
const { classNames } = useCatalogConfig();
|
|
17
17
|
const ctx = useSearchCatalogContext();
|
|
18
|
-
const filters = ctx.table.
|
|
18
|
+
const filters = ctx.table.state.columnFilters.filter((f) => f.value != null && f.value !== "").map((f) => ({
|
|
19
19
|
id: f.id,
|
|
20
20
|
value: String(f.value),
|
|
21
21
|
label: COLUMN_LABELS[f.id] ?? f.id,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"active-filters.mjs","names":[],"sources":["../../../../src/components/compound/search-catalog/active-filters.tsx"],"sourcesContent":["import { mergeProps } from \"@base-ui/react/merge-props\";\nimport { useRender } from \"@base-ui/react/use-render\";\nimport { useCatalogConfig } from \"../../../context/catalog-config-context.js\";\nimport { useSearchCatalogContext } from \"../../../context/search-catalog-context.js\";\nimport { cn } from \"../../../lib/utils.js\";\nimport { DefaultActiveFilterPill } from \"../../defaults/catalog/active-filter-pill.js\";\n\nconst COLUMN_LABELS: Record<string, string> = {\n outputFields: \"Output\",\n providers: \"Provider\",\n tags: \"Tag\",\n};\n\nexport interface ActiveFilter {\n id: string;\n value: string;\n label: string;\n remove: () => void;\n}\n\nexport interface SearchCatalogActiveFiltersState {\n activeFilters: ActiveFilter[];\n isEmpty: boolean;\n}\n\nexport interface SearchCatalogActiveFiltersProps\n extends useRender.ComponentProps<\"div\", SearchCatalogActiveFiltersState> {}\n\nexport function SearchCatalogActiveFilters({\n className,\n render,\n ...props\n}: SearchCatalogActiveFiltersProps) {\n const { classNames } = useCatalogConfig();\n const ctx = useSearchCatalogContext();\n const filters: ActiveFilter[] = ctx.table
|
|
1
|
+
{"version":3,"file":"active-filters.mjs","names":[],"sources":["../../../../src/components/compound/search-catalog/active-filters.tsx"],"sourcesContent":["import { mergeProps } from \"@base-ui/react/merge-props\";\nimport { useRender } from \"@base-ui/react/use-render\";\nimport { useCatalogConfig } from \"../../../context/catalog-config-context.js\";\nimport { useSearchCatalogContext } from \"../../../context/search-catalog-context.js\";\nimport { cn } from \"../../../lib/utils.js\";\nimport { DefaultActiveFilterPill } from \"../../defaults/catalog/active-filter-pill.js\";\n\nconst COLUMN_LABELS: Record<string, string> = {\n outputFields: \"Output\",\n providers: \"Provider\",\n tags: \"Tag\",\n};\n\nexport interface ActiveFilter {\n id: string;\n value: string;\n label: string;\n remove: () => void;\n}\n\nexport interface SearchCatalogActiveFiltersState {\n activeFilters: ActiveFilter[];\n isEmpty: boolean;\n}\n\nexport interface SearchCatalogActiveFiltersProps\n extends useRender.ComponentProps<\"div\", SearchCatalogActiveFiltersState> {}\n\nexport function SearchCatalogActiveFilters({\n className,\n render,\n ...props\n}: SearchCatalogActiveFiltersProps) {\n const { classNames } = useCatalogConfig();\n const ctx = useSearchCatalogContext();\n const filters: ActiveFilter[] = ctx.table.state.columnFilters\n .filter((f) => f.value != null && f.value !== \"\")\n .map((f) => ({\n id: f.id,\n value: String(f.value),\n label: COLUMN_LABELS[f.id] ?? f.id,\n remove: () =>\n ctx.removeColumnFilter(f.id as \"inputFields\" | \"outputFields\" | \"tags\" | \"providers\"),\n }));\n\n const isEmpty = filters.length === 0;\n\n const defaultBody = filters.map((f) => (\n <DefaultActiveFilterPill key={f.id} label={f.label} value={f.value} onRemove={f.remove} />\n ));\n\n const element = useRender({\n defaultTagName: \"div\",\n render,\n state: { activeFilters: filters, isEmpty },\n stateAttributesMapping: {\n activeFilters: () => null,\n },\n props: mergeProps<\"div\">(\n {\n className: cn(\n \"pz:flex pz:flex-wrap pz:items-center pz:gap-2\",\n classNames?.activeFilters,\n className,\n ),\n children: defaultBody,\n ...({ \"data-p0\": \"catalog-active-filters\" } as Record<string, string>),\n },\n props,\n ),\n });\n\n if (isEmpty) return null;\n return element;\n}\n"],"mappings":";;;;;;;;;AAOA,MAAM,gBAAwC;CAC5C,cAAc;CACd,WAAW;CACX,MAAM;CACP;AAiBD,SAAgB,2BAA2B,EACzC,WACA,QACA,GAAG,SAC+B;CAClC,MAAM,EAAE,eAAe,kBAAkB;CACzC,MAAM,MAAM,yBAAyB;CACrC,MAAM,UAA0B,IAAI,MAAM,MAAM,cAC7C,QAAQ,MAAM,EAAE,SAAS,QAAQ,EAAE,UAAU,GAAG,CAChD,KAAK,OAAO;EACX,IAAI,EAAE;EACN,OAAO,OAAO,EAAE,MAAM;EACtB,OAAO,cAAc,EAAE,OAAO,EAAE;EAChC,cACE,IAAI,mBAAmB,EAAE,GAA4D;EACxF,EAAE;CAEL,MAAM,UAAU,QAAQ,WAAW;CAEnC,MAAM,cAAc,QAAQ,KAAK,MAC/B,oBAAC,yBAAD;EAAoC,OAAO,EAAE;EAAO,OAAO,EAAE;EAAO,UAAU,EAAE;EAAU,EAA5D,EAAE,GAA0D,CAC1F;CAEF,MAAM,UAAU,UAAU;EACxB,gBAAgB;EAChB;EACA,OAAO;GAAE,eAAe;GAAS;GAAS;EAC1C,wBAAwB,EACtB,qBAAqB,MACtB;EACD,OAAO,WACL;GACE,WAAW,GACT,iDACA,YAAY,eACZ,UACD;GACD,UAAU;GACJ,WAAW;GAClB,EACD,MACD;EACF,CAAC;AAEF,KAAI,QAAS,QAAO;AACpB,QAAO"}
|
|
@@ -15,7 +15,7 @@ const COLUMN_LABELS = {
|
|
|
15
15
|
function SearchesCatalogActiveFilters({ className, render, ...props }) {
|
|
16
16
|
const { classNames } = useCatalogConfig();
|
|
17
17
|
const ctx = useSearchesCatalogContext();
|
|
18
|
-
const filters = ctx.table.
|
|
18
|
+
const filters = ctx.table.state.columnFilters.filter((f) => f.value != null && f.value !== "").map((f) => ({
|
|
19
19
|
id: f.id,
|
|
20
20
|
value: String(f.value),
|
|
21
21
|
label: COLUMN_LABELS[f.id] ?? f.id,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"active-filters.mjs","names":[],"sources":["../../../../src/components/compound/searches-catalog/active-filters.tsx"],"sourcesContent":["import { mergeProps } from \"@base-ui/react/merge-props\";\nimport { useRender } from \"@base-ui/react/use-render\";\nimport { useCatalogConfig } from \"../../../context/catalog-config-context.js\";\nimport { useSearchesCatalogContext } from \"../../../context/searches-catalog-context.js\";\nimport { cn } from \"../../../lib/utils.js\";\nimport { DefaultActiveFilterPill } from \"../../defaults/catalog/active-filter-pill.js\";\n\nconst COLUMN_LABELS: Record<string, string> = {\n outputFields: \"Output\",\n providers: \"Provider\",\n tags: \"Tag\",\n};\n\nexport interface ActiveFilter {\n id: string;\n value: string;\n label: string;\n remove: () => void;\n}\n\nexport interface SearchesCatalogActiveFiltersState {\n activeFilters: ActiveFilter[];\n isEmpty: boolean;\n}\n\nexport interface SearchesCatalogActiveFiltersProps\n extends useRender.ComponentProps<\"div\", SearchesCatalogActiveFiltersState> {}\n\nexport function SearchesCatalogActiveFilters({\n className,\n render,\n ...props\n}: SearchesCatalogActiveFiltersProps) {\n const { classNames } = useCatalogConfig();\n const ctx = useSearchesCatalogContext();\n const filters: ActiveFilter[] = ctx.table
|
|
1
|
+
{"version":3,"file":"active-filters.mjs","names":[],"sources":["../../../../src/components/compound/searches-catalog/active-filters.tsx"],"sourcesContent":["import { mergeProps } from \"@base-ui/react/merge-props\";\nimport { useRender } from \"@base-ui/react/use-render\";\nimport { useCatalogConfig } from \"../../../context/catalog-config-context.js\";\nimport { useSearchesCatalogContext } from \"../../../context/searches-catalog-context.js\";\nimport { cn } from \"../../../lib/utils.js\";\nimport { DefaultActiveFilterPill } from \"../../defaults/catalog/active-filter-pill.js\";\n\nconst COLUMN_LABELS: Record<string, string> = {\n outputFields: \"Output\",\n providers: \"Provider\",\n tags: \"Tag\",\n};\n\nexport interface ActiveFilter {\n id: string;\n value: string;\n label: string;\n remove: () => void;\n}\n\nexport interface SearchesCatalogActiveFiltersState {\n activeFilters: ActiveFilter[];\n isEmpty: boolean;\n}\n\nexport interface SearchesCatalogActiveFiltersProps\n extends useRender.ComponentProps<\"div\", SearchesCatalogActiveFiltersState> {}\n\nexport function SearchesCatalogActiveFilters({\n className,\n render,\n ...props\n}: SearchesCatalogActiveFiltersProps) {\n const { classNames } = useCatalogConfig();\n const ctx = useSearchesCatalogContext();\n const filters: ActiveFilter[] = ctx.table.state.columnFilters\n .filter((f) => f.value != null && f.value !== \"\")\n .map((f) => ({\n id: f.id,\n value: String(f.value),\n label: COLUMN_LABELS[f.id] ?? f.id,\n remove: () =>\n ctx.removeColumnFilter(f.id as \"inputFields\" | \"outputFields\" | \"tags\" | \"providers\"),\n }));\n\n const isEmpty = filters.length === 0;\n\n const defaultBody = filters.map((f) => (\n <DefaultActiveFilterPill key={f.id} label={f.label} value={f.value} onRemove={f.remove} />\n ));\n\n const element = useRender({\n defaultTagName: \"div\",\n render,\n state: { activeFilters: filters, isEmpty },\n stateAttributesMapping: {\n activeFilters: () => null,\n },\n props: mergeProps<\"div\">(\n {\n className: cn(\n \"pz:flex pz:flex-wrap pz:items-center pz:gap-2\",\n classNames?.activeFilters,\n className,\n ),\n children: defaultBody,\n ...({ \"data-p0\": \"catalog-active-filters\" } as Record<string, string>),\n },\n props,\n ),\n });\n\n if (isEmpty) return null;\n return element;\n}\n"],"mappings":";;;;;;;;;AAOA,MAAM,gBAAwC;CAC5C,cAAc;CACd,WAAW;CACX,MAAM;CACP;AAiBD,SAAgB,6BAA6B,EAC3C,WACA,QACA,GAAG,SACiC;CACpC,MAAM,EAAE,eAAe,kBAAkB;CACzC,MAAM,MAAM,2BAA2B;CACvC,MAAM,UAA0B,IAAI,MAAM,MAAM,cAC7C,QAAQ,MAAM,EAAE,SAAS,QAAQ,EAAE,UAAU,GAAG,CAChD,KAAK,OAAO;EACX,IAAI,EAAE;EACN,OAAO,OAAO,EAAE,MAAM;EACtB,OAAO,cAAc,EAAE,OAAO,EAAE;EAChC,cACE,IAAI,mBAAmB,EAAE,GAA4D;EACxF,EAAE;CAEL,MAAM,UAAU,QAAQ,WAAW;CAEnC,MAAM,cAAc,QAAQ,KAAK,MAC/B,oBAAC,yBAAD;EAAoC,OAAO,EAAE;EAAO,OAAO,EAAE;EAAO,UAAU,EAAE;EAAU,EAA5D,EAAE,GAA0D,CAC1F;CAEF,MAAM,UAAU,UAAU;EACxB,gBAAgB;EAChB;EACA,OAAO;GAAE,eAAe;GAAS;GAAS;EAC1C,wBAAwB,EACtB,qBAAqB,MACtB;EACD,OAAO,WACL;GACE,WAAW,GACT,iDACA,YAAY,eACZ,UACD;GACD,UAAU;GACJ,WAAW;GAClB,EACD,MACD;EACF,CAAC;AAEF,KAAI,QAAS,QAAO;AACpB,QAAO"}
|
|
@@ -5,7 +5,7 @@ import * as _$class_variance_authority_types0 from "class-variance-authority/typ
|
|
|
5
5
|
|
|
6
6
|
//#region src/components/ui/button.d.ts
|
|
7
7
|
declare const buttonVariants: (props?: ({
|
|
8
|
-
variant?: "
|
|
8
|
+
variant?: "link" | "default" | "outline" | "secondary" | "ghost" | "destructive" | null | undefined;
|
|
9
9
|
size?: "default" | "icon" | "sm" | "lg" | "xs" | "icon-xs" | "icon-sm" | "icon-lg" | null | undefined;
|
|
10
10
|
} & _$class_variance_authority_types0.ClassProp) | undefined) => string;
|
|
11
11
|
declare function Button$1({
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
import { CatalogFilterMeta, CatalogSearchFeatures } from "../utils/catalog-helpers.mjs";
|
|
2
|
+
import * as _$_tanstack_react_table0 from "@tanstack/react-table";
|
|
3
|
+
|
|
4
|
+
//#region src/hooks/catalog-table.d.ts
|
|
5
|
+
/**
|
|
6
|
+
* The one feature set every catalog table (pipes, searches, effects) is built
|
|
7
|
+
* on: column filters for the facet pills, a global filter for the search box,
|
|
8
|
+
* and sorting so a query can order rows by relevance. The custom search filter
|
|
9
|
+
* and sort are registered by name, so column defs and the global filter refer
|
|
10
|
+
* to `"catalogSearch"` and the score they exchange is typed via `filterMeta`.
|
|
11
|
+
*/
|
|
12
|
+
declare const catalogTableFeatures: {
|
|
13
|
+
columnFilteringFeature: _$_tanstack_react_table0.TableFeature;
|
|
14
|
+
globalFilteringFeature: _$_tanstack_react_table0.TableFeature;
|
|
15
|
+
rowSortingFeature: _$_tanstack_react_table0.TableFeature;
|
|
16
|
+
filteredRowModel: (table: _$_tanstack_react_table0.Table<any, any>) => () => _$_tanstack_react_table0.RowModel<any, any>;
|
|
17
|
+
sortedRowModel: (table: _$_tanstack_react_table0.Table<any, any>) => () => _$_tanstack_react_table0.RowModel<any, any>;
|
|
18
|
+
filterFns: {
|
|
19
|
+
includesString: _$_tanstack_react_table0.CreatedFilterFn<any, any>;
|
|
20
|
+
arrIncludes: _$_tanstack_react_table0.CreatedFilterFn<any, any>;
|
|
21
|
+
catalogSearch: _$_tanstack_react_table0.FilterFn<CatalogSearchFeatures, _$_tanstack_react_table0.RowData>;
|
|
22
|
+
};
|
|
23
|
+
sortFns: {
|
|
24
|
+
catalogSearch: _$_tanstack_react_table0.SortFn<CatalogSearchFeatures, _$_tanstack_react_table0.RowData>;
|
|
25
|
+
};
|
|
26
|
+
filterMeta: CatalogFilterMeta;
|
|
27
|
+
};
|
|
28
|
+
type CatalogTableFeatures = typeof catalogTableFeatures;
|
|
29
|
+
/**
|
|
30
|
+
* `useCatalogTable` is `useTable` with the catalog features and the global
|
|
31
|
+
* search filter pre-bound; `createCatalogColumnHelper<T>()` only needs the row
|
|
32
|
+
* type. Consumers building their own catalog UI get the same hook the compound
|
|
33
|
+
* components use.
|
|
34
|
+
*/
|
|
35
|
+
declare const useCatalogTable: <TData extends _$_tanstack_react_table0.RowData, TSelected = _$_tanstack_react_table0.TableState_ColumnFiltering & _$_tanstack_react_table0.TableState_GlobalFiltering & _$_tanstack_react_table0.TableState_RowSorting>(tableOptions: Omit<_$_tanstack_react_table0.TableOptions<{
|
|
36
|
+
columnFilteringFeature: _$_tanstack_react_table0.TableFeature;
|
|
37
|
+
globalFilteringFeature: _$_tanstack_react_table0.TableFeature;
|
|
38
|
+
rowSortingFeature: _$_tanstack_react_table0.TableFeature;
|
|
39
|
+
filteredRowModel: (table: _$_tanstack_react_table0.Table<any, any>) => () => _$_tanstack_react_table0.RowModel<any, any>;
|
|
40
|
+
sortedRowModel: (table: _$_tanstack_react_table0.Table<any, any>) => () => _$_tanstack_react_table0.RowModel<any, any>;
|
|
41
|
+
filterFns: {
|
|
42
|
+
includesString: _$_tanstack_react_table0.CreatedFilterFn<any, any>;
|
|
43
|
+
arrIncludes: _$_tanstack_react_table0.CreatedFilterFn<any, any>;
|
|
44
|
+
catalogSearch: _$_tanstack_react_table0.FilterFn<CatalogSearchFeatures, _$_tanstack_react_table0.RowData>;
|
|
45
|
+
};
|
|
46
|
+
sortFns: {
|
|
47
|
+
catalogSearch: _$_tanstack_react_table0.SortFn<CatalogSearchFeatures, _$_tanstack_react_table0.RowData>;
|
|
48
|
+
};
|
|
49
|
+
filterMeta: CatalogFilterMeta;
|
|
50
|
+
}, TData>, "features">, selector?: ((state: _$_tanstack_react_table0.TableState_ColumnFiltering & _$_tanstack_react_table0.TableState_GlobalFiltering & _$_tanstack_react_table0.TableState_RowSorting) => TSelected) | undefined) => _$_tanstack_react_table0.AppReactTable<{
|
|
51
|
+
columnFilteringFeature: _$_tanstack_react_table0.TableFeature;
|
|
52
|
+
globalFilteringFeature: _$_tanstack_react_table0.TableFeature;
|
|
53
|
+
rowSortingFeature: _$_tanstack_react_table0.TableFeature;
|
|
54
|
+
filteredRowModel: (table: _$_tanstack_react_table0.Table<any, any>) => () => _$_tanstack_react_table0.RowModel<any, any>;
|
|
55
|
+
sortedRowModel: (table: _$_tanstack_react_table0.Table<any, any>) => () => _$_tanstack_react_table0.RowModel<any, any>;
|
|
56
|
+
filterFns: {
|
|
57
|
+
includesString: _$_tanstack_react_table0.CreatedFilterFn<any, any>;
|
|
58
|
+
arrIncludes: _$_tanstack_react_table0.CreatedFilterFn<any, any>;
|
|
59
|
+
catalogSearch: _$_tanstack_react_table0.FilterFn<CatalogSearchFeatures, _$_tanstack_react_table0.RowData>;
|
|
60
|
+
};
|
|
61
|
+
sortFns: {
|
|
62
|
+
catalogSearch: _$_tanstack_react_table0.SortFn<CatalogSearchFeatures, _$_tanstack_react_table0.RowData>;
|
|
63
|
+
};
|
|
64
|
+
filterMeta: CatalogFilterMeta;
|
|
65
|
+
}, TData, TSelected, {}, {}, {}>, createCatalogColumnHelper: <TData extends _$_tanstack_react_table0.RowData>() => _$_tanstack_react_table0.AppColumnHelper<{
|
|
66
|
+
columnFilteringFeature: _$_tanstack_react_table0.TableFeature;
|
|
67
|
+
globalFilteringFeature: _$_tanstack_react_table0.TableFeature;
|
|
68
|
+
rowSortingFeature: _$_tanstack_react_table0.TableFeature;
|
|
69
|
+
filteredRowModel: (table: _$_tanstack_react_table0.Table<any, any>) => () => _$_tanstack_react_table0.RowModel<any, any>;
|
|
70
|
+
sortedRowModel: (table: _$_tanstack_react_table0.Table<any, any>) => () => _$_tanstack_react_table0.RowModel<any, any>;
|
|
71
|
+
filterFns: {
|
|
72
|
+
includesString: _$_tanstack_react_table0.CreatedFilterFn<any, any>;
|
|
73
|
+
arrIncludes: _$_tanstack_react_table0.CreatedFilterFn<any, any>;
|
|
74
|
+
catalogSearch: _$_tanstack_react_table0.FilterFn<CatalogSearchFeatures, _$_tanstack_react_table0.RowData>;
|
|
75
|
+
};
|
|
76
|
+
sortFns: {
|
|
77
|
+
catalogSearch: _$_tanstack_react_table0.SortFn<CatalogSearchFeatures, _$_tanstack_react_table0.RowData>;
|
|
78
|
+
};
|
|
79
|
+
filterMeta: CatalogFilterMeta;
|
|
80
|
+
}, TData, {}, {}>;
|
|
81
|
+
//#endregion
|
|
82
|
+
export { CatalogTableFeatures, catalogTableFeatures, createCatalogColumnHelper, useCatalogTable };
|
|
83
|
+
//# sourceMappingURL=catalog-table.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"catalog-table.d.mts","names":[],"sources":["../../src/hooks/catalog-table.ts"],"mappings":";;;;;;;;AAyBA;;;cAAa,oBAAA;0BAaX,wBAAA,CAAA,YAAA;;;;;;;;;;;;;;;KAEU,oBAAA,UAA8B,oBAAA;;;;;;;cAQd,eAAA,0CAAe,OAAA,cAAA,wBAAA,CAAA,0BAAA,GAAA,wBAAA,CAAA,0BAAA,GAAA,wBAAA,CAAA,qBAAA,EAAA,YAAA,EAAA,IAAA,0BAAA,YAAA;4BAAA,wBAAA,CAAA,YAAA;;;;;;;;;;;;;;8CAAA,wBAAA,CAAA,0BAAA;;;;;;;;;;;;;;;uGAAkD,OAAA,gCAAA,eAAA;4BAAA,wBAAA,CAAA,YAAA"}
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import { catalogSearchFilter, catalogSearchSort } from "../utils/catalog-helpers.mjs";
|
|
2
|
+
import { columnFilteringFeature, createFilteredRowModel, createSortedRowModel, createTableHook, filterFn_arrIncludes, filterFn_includesString, globalFilteringFeature, metaHelper, rowSortingFeature, tableFeatures } from "@tanstack/react-table";
|
|
3
|
+
|
|
4
|
+
//#region src/hooks/catalog-table.ts
|
|
5
|
+
/**
|
|
6
|
+
* The one feature set every catalog table (pipes, searches, effects) is built
|
|
7
|
+
* on: column filters for the facet pills, a global filter for the search box,
|
|
8
|
+
* and sorting so a query can order rows by relevance. The custom search filter
|
|
9
|
+
* and sort are registered by name, so column defs and the global filter refer
|
|
10
|
+
* to `"catalogSearch"` and the score they exchange is typed via `filterMeta`.
|
|
11
|
+
*/
|
|
12
|
+
const catalogTableFeatures = tableFeatures({
|
|
13
|
+
columnFilteringFeature,
|
|
14
|
+
globalFilteringFeature,
|
|
15
|
+
rowSortingFeature,
|
|
16
|
+
filteredRowModel: createFilteredRowModel(),
|
|
17
|
+
sortedRowModel: createSortedRowModel(),
|
|
18
|
+
filterFns: {
|
|
19
|
+
includesString: filterFn_includesString,
|
|
20
|
+
arrIncludes: filterFn_arrIncludes,
|
|
21
|
+
catalogSearch: catalogSearchFilter
|
|
22
|
+
},
|
|
23
|
+
sortFns: { catalogSearch: catalogSearchSort },
|
|
24
|
+
filterMeta: metaHelper()
|
|
25
|
+
});
|
|
26
|
+
/**
|
|
27
|
+
* `useCatalogTable` is `useTable` with the catalog features and the global
|
|
28
|
+
* search filter pre-bound; `createCatalogColumnHelper<T>()` only needs the row
|
|
29
|
+
* type. Consumers building their own catalog UI get the same hook the compound
|
|
30
|
+
* components use.
|
|
31
|
+
*/
|
|
32
|
+
const { useAppTable: useCatalogTable, createAppColumnHelper: createCatalogColumnHelper } = createTableHook({
|
|
33
|
+
features: catalogTableFeatures,
|
|
34
|
+
globalFilterFn: "catalogSearch",
|
|
35
|
+
tableComponents: {},
|
|
36
|
+
cellComponents: {},
|
|
37
|
+
headerComponents: {}
|
|
38
|
+
});
|
|
39
|
+
|
|
40
|
+
//#endregion
|
|
41
|
+
export { catalogTableFeatures, createCatalogColumnHelper, useCatalogTable };
|
|
42
|
+
//# sourceMappingURL=catalog-table.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"catalog-table.mjs","names":[],"sources":["../../src/hooks/catalog-table.ts"],"sourcesContent":["import {\n columnFilteringFeature,\n createFilteredRowModel,\n createSortedRowModel,\n createTableHook,\n filterFn_arrIncludes,\n filterFn_includesString,\n globalFilteringFeature,\n metaHelper,\n rowSortingFeature,\n tableFeatures,\n} from \"@tanstack/react-table\";\nimport {\n type CatalogFilterMeta,\n catalogSearchFilter,\n catalogSearchSort,\n} from \"../utils/catalog-helpers.js\";\n\n/**\n * The one feature set every catalog table (pipes, searches, effects) is built\n * on: column filters for the facet pills, a global filter for the search box,\n * and sorting so a query can order rows by relevance. The custom search filter\n * and sort are registered by name, so column defs and the global filter refer\n * to `\"catalogSearch\"` and the score they exchange is typed via `filterMeta`.\n */\nexport const catalogTableFeatures = tableFeatures({\n columnFilteringFeature,\n globalFilteringFeature,\n rowSortingFeature,\n filteredRowModel: createFilteredRowModel(),\n sortedRowModel: createSortedRowModel(),\n filterFns: {\n includesString: filterFn_includesString,\n arrIncludes: filterFn_arrIncludes,\n catalogSearch: catalogSearchFilter,\n },\n sortFns: { catalogSearch: catalogSearchSort },\n filterMeta: metaHelper<CatalogFilterMeta>(),\n});\n\nexport type CatalogTableFeatures = typeof catalogTableFeatures;\n\n/**\n * `useCatalogTable` is `useTable` with the catalog features and the global\n * search filter pre-bound; `createCatalogColumnHelper<T>()` only needs the row\n * type. Consumers building their own catalog UI get the same hook the compound\n * components use.\n */\nexport const { useAppTable: useCatalogTable, createAppColumnHelper: createCatalogColumnHelper } =\n createTableHook({\n features: catalogTableFeatures,\n globalFilterFn: \"catalogSearch\",\n // Passed explicitly: `createTableHook` has no defaults for its component\n // generics, so omitting these infers `Record<string, ComponentType<any>>`,\n // and that index signature is intersected into the table type in the\n // emitted declarations. Any property that does not exist on the table\n // (e.g. the removed v8 `getState()`) then types as `ComponentType<any>`\n // instead of failing with \"property does not exist\".\n tableComponents: {},\n cellComponents: {},\n headerComponents: {},\n });\n"],"mappings":";;;;;;;;;;;AAyBA,MAAa,uBAAuB,cAAc;CAChD;CACA;CACA;CACA,kBAAkB,wBAAwB;CAC1C,gBAAgB,sBAAsB;CACtC,WAAW;EACT,gBAAgB;EAChB,aAAa;EACb,eAAe;EAChB;CACD,SAAS,EAAE,eAAe,mBAAmB;CAC7C,YAAY,YAA+B;CAC5C,CAAC;;;;;;;AAUF,MAAa,EAAE,aAAa,iBAAiB,uBAAuB,8BAClE,gBAAgB;CACd,UAAU;CACV,gBAAgB;CAOhB,iBAAiB,EAAE;CACnB,gBAAgB,EAAE;CAClB,kBAAkB,EAAE;CACrB,CAAC"}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { EffectCardData } from "../types/catalog-adapters.mjs";
|
|
2
|
+
import { CatalogFilterMeta, CatalogSearchFeatures } from "../utils/catalog-helpers.mjs";
|
|
2
3
|
import * as _$react from "react";
|
|
3
4
|
import { SheetEffectCatalogTableData, SheetEffectCategory } from "@pipe0/base";
|
|
4
5
|
import * as _$_tanstack_react_table0 from "@tanstack/react-table";
|
|
@@ -13,7 +14,22 @@ declare function useEffectCatalogTable(config?: {
|
|
|
13
14
|
*/
|
|
14
15
|
filter?: (entry: SheetEffectCatalogTableData) => boolean;
|
|
15
16
|
}): {
|
|
16
|
-
table: _$_tanstack_react_table0.
|
|
17
|
+
table: _$_tanstack_react_table0.AppReactTable<{
|
|
18
|
+
columnFilteringFeature: _$_tanstack_react_table0.TableFeature;
|
|
19
|
+
globalFilteringFeature: _$_tanstack_react_table0.TableFeature;
|
|
20
|
+
rowSortingFeature: _$_tanstack_react_table0.TableFeature;
|
|
21
|
+
filteredRowModel: (table: _$_tanstack_react_table0.Table<any, any>) => () => _$_tanstack_react_table0.RowModel<any, any>;
|
|
22
|
+
sortedRowModel: (table: _$_tanstack_react_table0.Table<any, any>) => () => _$_tanstack_react_table0.RowModel<any, any>;
|
|
23
|
+
filterFns: {
|
|
24
|
+
includesString: _$_tanstack_react_table0.CreatedFilterFn<any, any>;
|
|
25
|
+
arrIncludes: _$_tanstack_react_table0.CreatedFilterFn<any, any>;
|
|
26
|
+
catalogSearch: _$_tanstack_react_table0.FilterFn<CatalogSearchFeatures, _$_tanstack_react_table0.RowData>;
|
|
27
|
+
};
|
|
28
|
+
sortFns: {
|
|
29
|
+
catalogSearch: _$_tanstack_react_table0.SortFn<CatalogSearchFeatures, _$_tanstack_react_table0.RowData>;
|
|
30
|
+
};
|
|
31
|
+
filterMeta: CatalogFilterMeta;
|
|
32
|
+
}, SheetEffectCatalogTableData, _$_tanstack_react_table0.TableState_ColumnFiltering & _$_tanstack_react_table0.TableState_GlobalFiltering & _$_tanstack_react_table0.TableState_RowSorting, {}, {}, {}>;
|
|
17
33
|
cards: EffectCardData[];
|
|
18
34
|
cardsByCategory: {
|
|
19
35
|
category: SheetEffectCategory;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"use-effect-catalog-table.d.mts","names":[],"sources":["../../src/hooks/use-effect-catalog-table.ts"],"mappings":"
|
|
1
|
+
{"version":3,"file":"use-effect-catalog-table.d.mts","names":[],"sources":["../../src/hooks/use-effect-catalog-table.ts"],"mappings":";;;;;;;;iBAwCgB,qBAAA,CACd,MAAA;EACE,oBAAA,GAAuB,YAAA;;;;;EAKvB,MAAA,IAAU,KAAA,EAAO,2BAAA;AAAA;;4BAA2B,wBAAA,CAAA,YAAA;;;;;;;;;;;;;;;;;cAmEhC,mBAAA;WAA4B,cAAA;EAAA;;;;;sBA9BN,mBAAA;;yCAAmB,OAAA,CAAA,cAAA;AAAA;AAAA,KAiF7C,2BAAA,GAA8B,UAAA,QAAkB,qBAAA"}
|
|
@@ -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 { getInitialSheetEffectTableData, getLowestSheetEffectCreditAmount, getSheetEffectSearchTarget, isTokenBilledOperations } from "@pipe0/base";
|
|
5
|
-
import { createColumnHelper, getCoreRowModel, getFilteredRowModel, getSortedRowModel, useReactTable } from "@tanstack/react-table";
|
|
6
5
|
|
|
7
6
|
//#region src/hooks/use-effect-catalog-table.ts
|
|
8
|
-
const columnHelper =
|
|
9
|
-
const columns = [
|
|
7
|
+
const columnHelper = createCatalogColumnHelper();
|
|
8
|
+
const columns = columnHelper.columns([
|
|
10
9
|
columnHelper.accessor("effectId", {
|
|
11
10
|
filterFn: "includesString",
|
|
12
11
|
enableGlobalFilter: false
|
|
@@ -20,28 +19,20 @@ const columns = [
|
|
|
20
19
|
id: "search",
|
|
21
20
|
enableGlobalFilter: true,
|
|
22
21
|
enableSorting: true,
|
|
23
|
-
|
|
22
|
+
sortFn: "catalogSearch"
|
|
24
23
|
})
|
|
25
|
-
];
|
|
24
|
+
]);
|
|
26
25
|
function useEffectCatalogTable(config = {}) {
|
|
27
26
|
const [category, setCategory] = useState(null);
|
|
28
27
|
const { initialColumnFilters = [], filter } = config;
|
|
29
28
|
const baselineTableData = useMemo(() => filter ? getInitialSheetEffectTableData().filter(filter) : getInitialSheetEffectTableData(), [filter]);
|
|
30
|
-
const table =
|
|
29
|
+
const table = useCatalogTable({
|
|
31
30
|
columns,
|
|
32
31
|
data: useMemo(() => category ? baselineTableData.filter((e) => (e.categories ?? []).includes(category)) : baselineTableData, [baselineTableData, category]),
|
|
33
|
-
|
|
34
|
-
getFilteredRowModel: getFilteredRowModel(),
|
|
35
|
-
getSortedRowModel: getSortedRowModel(),
|
|
36
|
-
globalFilterFn: catalogSearchFilter,
|
|
37
|
-
getColumnCanGlobalFilter: (column) => column.columnDef.enableGlobalFilter !== false,
|
|
38
|
-
initialState: {
|
|
39
|
-
columnFilters: initialColumnFilters,
|
|
40
|
-
pagination: { pageSize: 10 }
|
|
41
|
-
}
|
|
32
|
+
initialState: { columnFilters: initialColumnFilters }
|
|
42
33
|
});
|
|
43
34
|
const [globalFilterInput, setGlobalFilterInput, setGlobalFilterImmediately] = useDebounce((v) => {
|
|
44
|
-
if (v === table.
|
|
35
|
+
if (v === table.atoms.globalFilter.get()) return;
|
|
45
36
|
table.setGlobalFilter(v);
|
|
46
37
|
table.setSorting(v ? [{
|
|
47
38
|
id: "search",
|
|
@@ -49,10 +40,10 @@ function useEffectCatalogTable(config = {}) {
|
|
|
49
40
|
}] : []);
|
|
50
41
|
if (v) setCategory(null);
|
|
51
42
|
});
|
|
52
|
-
const handleCategoryChange =
|
|
43
|
+
const handleCategoryChange = (next) => {
|
|
53
44
|
setCategory(next);
|
|
54
45
|
setGlobalFilterImmediately("");
|
|
55
|
-
}
|
|
46
|
+
};
|
|
56
47
|
const rows = table.getRowModel().rows;
|
|
57
48
|
const cards = useMemo(() => rows.map((row) => {
|
|
58
49
|
const entry = row.original;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"use-effect-catalog-table.mjs","names":[],"sources":["../../src/hooks/use-effect-catalog-table.ts"],"sourcesContent":["import {\n getInitialSheetEffectTableData,\n getLowestSheetEffectCreditAmount,\n getSheetEffectSearchTarget,\n isTokenBilledOperations,\n type ProviderName,\n type SheetEffectCatalogTableData,\n type SheetEffectCategory,\n} from \"@pipe0/base\";\nimport
|
|
1
|
+
{"version":3,"file":"use-effect-catalog-table.mjs","names":[],"sources":["../../src/hooks/use-effect-catalog-table.ts"],"sourcesContent":["import {\n getInitialSheetEffectTableData,\n getLowestSheetEffectCreditAmount,\n getSheetEffectSearchTarget,\n isTokenBilledOperations,\n type ProviderName,\n type SheetEffectCatalogTableData,\n type SheetEffectCategory,\n} from \"@pipe0/base\";\nimport type { ColumnFilter } from \"@tanstack/react-table\";\nimport { useMemo, useState } from \"react\";\nimport type { EffectCardData } from \"../types/catalog-adapters.js\";\nimport { createCatalogColumnHelper, useCatalogTable } from \"./catalog-table.js\";\nimport { useDebounce } from \"./use-debounce.js\";\n\nconst columnHelper = createCatalogColumnHelper<SheetEffectCatalogTableData>();\n\nconst columns = columnHelper.columns([\n columnHelper.accessor(\"effectId\", {\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 // 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) => getSheetEffectSearchTarget(row), {\n id: \"search\",\n enableGlobalFilter: true,\n enableSorting: true,\n sortFn: \"catalogSearch\",\n }),\n]);\n\nexport function useEffectCatalogTable(\n config: {\n initialColumnFilters?: ColumnFilter[];\n /**\n * Optional predicate to pre-filter the catalog (e.g. by `selectionMode`\n * for the current row selection). Memoize it to keep the table stable.\n */\n filter?: (entry: SheetEffectCatalogTableData) => boolean;\n } = {},\n) {\n const [category, setCategory] = useState<SheetEffectCategory | null>(null);\n const { initialColumnFilters = [] as ColumnFilter[], filter } = config;\n\n // Baseline (config.filter applied, but no category / global filter). Drives\n // the stable category-button counts so the row doesn't jump.\n const baselineTableData = useMemo(\n () =>\n filter ? getInitialSheetEffectTableData().filter(filter) : getInitialSheetEffectTableData(),\n [filter],\n );\n\n const initialEffectTableData = useMemo(\n () =>\n category\n ? baselineTableData.filter((e) => (e.categories ?? []).includes(category))\n : baselineTableData,\n [baselineTableData, category],\n );\n\n const table = useCatalogTable({\n columns,\n data: initialEffectTableData,\n initialState: { columnFilters: initialColumnFilters },\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) setCategory(null);\n });\n\n const handleCategoryChange = (next: SheetEffectCategory | null) => {\n setCategory(next);\n setGlobalFilterImmediately(\"\");\n };\n\n const rows = table.getRowModel().rows;\n const cards = useMemo<EffectCardData[]>(\n () =>\n rows.map((row) => {\n const entry = row.original;\n const provider = (entry.managedProviders[0] ?? \"pipe0\") as ProviderName;\n return {\n effectId: entry.effectId,\n baseEffect: entry.baseEffect,\n label: entry.label,\n description: entry.description,\n provider,\n providers: entry.managedProviders.length ? entry.managedProviders : [provider],\n startingCreditAmount: getLowestSheetEffectCreditAmount(entry),\n costMode: isTokenBilledOperations(entry.billableOperations)\n ? (\"usage\" as const)\n : (\"per_result\" as const),\n selectionMode: entry.selectionMode,\n entry,\n };\n }),\n [rows],\n );\n\n const cardsByCategory = useMemo<\n { category: SheetEffectCategory; cards: EffectCardData[] }[]\n >(() => {\n const groups = new Map<SheetEffectCategory, EffectCardData[]>();\n for (const card of cards) {\n const cats = (card.entry.categories ?? []) as SheetEffectCategory[];\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]) => ({ category, cards: group }));\n }, [cards]);\n\n const categoryCounts = useMemo<Partial<Record<SheetEffectCategory, number>>>(() => {\n const counts: Partial<Record<SheetEffectCategory, number>> = {};\n for (const card of cards) {\n for (const cat of (card.entry.categories ?? []) as SheetEffectCategory[]) {\n counts[cat] = (counts[cat] ?? 0) + 1;\n }\n }\n return counts;\n }, [cards]);\n\n // Stable counts based on the baseline (no category / global filter applied).\n const baselineCardCount = baselineTableData.length;\n const baselineCategoryCounts = useMemo<Partial<Record<SheetEffectCategory, number>>>(() => {\n const counts: Partial<Record<SheetEffectCategory, number>> = {};\n for (const entry of baselineTableData) {\n for (const cat of (entry.categories ?? []) as SheetEffectCategory[]) {\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}\n\nexport type UseEffectCatalogTableReturn = ReturnType<typeof useEffectCatalogTable>;\n"],"mappings":"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"}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { PipeCardData } 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, PipeCategory, PipeEntryWithLatestVersion, PipeId } from "@pipe0/base";
|
|
4
5
|
import * as _$_tanstack_react_table0 from "@tanstack/react-table";
|
|
@@ -21,7 +22,22 @@ declare function usePipeCatalogTable(config?: {
|
|
|
21
22
|
*/
|
|
22
23
|
accessLevel?: OrgAccessLevel;
|
|
23
24
|
}): {
|
|
24
|
-
table: _$_tanstack_react_table0.
|
|
25
|
+
table: _$_tanstack_react_table0.AppReactTable<{
|
|
26
|
+
columnFilteringFeature: _$_tanstack_react_table0.TableFeature;
|
|
27
|
+
globalFilteringFeature: _$_tanstack_react_table0.TableFeature;
|
|
28
|
+
rowSortingFeature: _$_tanstack_react_table0.TableFeature;
|
|
29
|
+
filteredRowModel: (table: _$_tanstack_react_table0.Table<any, any>) => () => _$_tanstack_react_table0.RowModel<any, any>;
|
|
30
|
+
sortedRowModel: (table: _$_tanstack_react_table0.Table<any, any>) => () => _$_tanstack_react_table0.RowModel<any, any>;
|
|
31
|
+
filterFns: {
|
|
32
|
+
includesString: _$_tanstack_react_table0.CreatedFilterFn<any, any>;
|
|
33
|
+
arrIncludes: _$_tanstack_react_table0.CreatedFilterFn<any, any>;
|
|
34
|
+
catalogSearch: _$_tanstack_react_table0.FilterFn<CatalogSearchFeatures, _$_tanstack_react_table0.RowData>;
|
|
35
|
+
};
|
|
36
|
+
sortFns: {
|
|
37
|
+
catalogSearch: _$_tanstack_react_table0.SortFn<CatalogSearchFeatures, _$_tanstack_react_table0.RowData>;
|
|
38
|
+
};
|
|
39
|
+
filterMeta: CatalogFilterMeta;
|
|
40
|
+
}, PipeEntryWithLatestVersion, _$_tanstack_react_table0.TableState_ColumnFiltering & _$_tanstack_react_table0.TableState_GlobalFiltering & _$_tanstack_react_table0.TableState_RowSorting, {}, {}, {}>;
|
|
25
41
|
cards: PipeCardData[];
|
|
26
42
|
cardsByCategory: {
|
|
27
43
|
category: PipeCategory;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"use-pipe-catalog-table.d.mts","names":[],"sources":["../../src/hooks/use-pipe-catalog-table.ts"],"mappings":"
|
|
1
|
+
{"version":3,"file":"use-pipe-catalog-table.d.mts","names":[],"sources":["../../src/hooks/use-pipe-catalog-table.ts"],"mappings":";;;;;;;;KA0BY,iBAAA,GAAoB,MAAA,SAAe,MAAA;AAAA,KACnC,kBAAA,GAAqB,MAAA,SAAe,MAAA;AAAA,iBAkEhC,mBAAA,CACd,MAAA;EACE,oBAAA,GAAuB,YAAA;;;AArE3B;;EA0EI,MAAA,GAAS,aAAA;EA1EmB;;AAChC;;;EA+EI,WAAA,GAAc,cAAA;AAAA;;4BAAc,wBAAA,CAAA,YAAA;;;;;;;;;;;;;;;;;cAiHc,YAAA;WAAqB,YAAA;EAAA;;;;;0BA7DzB,YAAA;;yCAAY,OAAA,CAAA,cAAA;+EAPO,KAAA;;;;;;;;;;;;;KAiJjD,yBAAA,GAA4B,UAAA,QAAkB,mBAAA"}
|
|
@@ -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 { collectRequirementFields, filterPipeEntries, getDefaultOutputFields, getDefaultPipeProviders, getInitialTableData, getLowestPipeCreditAmount, getPipeAccessLevel, getPipeSearchTarget, getStartingCostPerPipesProvider, getTableDataAggregates, isEntryAccessible, isTokenBilledOperations } from "@pipe0/base";
|
|
5
|
-
import { createColumnHelper, getCoreRowModel, getFilteredRowModel, getSortedRowModel, useReactTable } from "@tanstack/react-table";
|
|
6
5
|
|
|
7
6
|
//#region src/hooks/use-pipe-catalog-table.ts
|
|
8
7
|
/**
|
|
@@ -15,8 +14,8 @@ function hidePartnerGated(rows, accessLevel) {
|
|
|
15
14
|
if (accessLevel === void 0 || accessLevel === "partner") return rows;
|
|
16
15
|
return rows.filter((row) => getPipeAccessLevel(row.pipeId) !== "partner");
|
|
17
16
|
}
|
|
18
|
-
const columnHelper =
|
|
19
|
-
const columns = [
|
|
17
|
+
const columnHelper = createCatalogColumnHelper();
|
|
18
|
+
const columns = columnHelper.columns([
|
|
20
19
|
columnHelper.accessor("pipeId", {
|
|
21
20
|
filterFn: "includesString",
|
|
22
21
|
enableGlobalFilter: false
|
|
@@ -47,9 +46,9 @@ const columns = [
|
|
|
47
46
|
id: "search",
|
|
48
47
|
enableGlobalFilter: true,
|
|
49
48
|
enableSorting: true,
|
|
50
|
-
|
|
49
|
+
sortFn: "catalogSearch"
|
|
51
50
|
})
|
|
52
|
-
];
|
|
51
|
+
]);
|
|
53
52
|
function usePipeCatalogTable(config = {}) {
|
|
54
53
|
const [category, setCategory] = useState(null);
|
|
55
54
|
const { initialColumnFilters = [], filter, accessLevel } = config;
|
|
@@ -59,23 +58,15 @@ function usePipeCatalogTable(config = {}) {
|
|
|
59
58
|
accessLevel
|
|
60
59
|
]);
|
|
61
60
|
const baselineTableData = useMemo(() => hidePartnerGated(filterPipeEntries(getInitialTableData(null), filter), accessLevel), [filter, accessLevel]);
|
|
62
|
-
const table =
|
|
61
|
+
const table = useCatalogTable({
|
|
63
62
|
columns,
|
|
64
63
|
data: initialTableData,
|
|
65
|
-
|
|
66
|
-
getFilteredRowModel: getFilteredRowModel(),
|
|
67
|
-
getSortedRowModel: getSortedRowModel(),
|
|
68
|
-
globalFilterFn: catalogSearchFilter,
|
|
69
|
-
getColumnCanGlobalFilter: (column) => column.columnDef.enableGlobalFilter !== false,
|
|
70
|
-
initialState: {
|
|
71
|
-
columnFilters: initialColumnFilters,
|
|
72
|
-
pagination: { pageSize: 10 }
|
|
73
|
-
}
|
|
64
|
+
initialState: { columnFilters: initialColumnFilters }
|
|
74
65
|
});
|
|
75
|
-
const columnFilters = table.
|
|
66
|
+
const columnFilters = table.state.columnFilters;
|
|
76
67
|
const aggregates = useMemo(() => getTableDataAggregates(initialTableData, category), [category, initialTableData]);
|
|
77
68
|
const [globalFilterInput, setGlobalFilterInput, setGlobalFilterImmediately] = useDebounce((v) => {
|
|
78
|
-
if (v === table.
|
|
69
|
+
if (v === table.atoms.globalFilter.get()) return;
|
|
79
70
|
table.setGlobalFilter(v);
|
|
80
71
|
table.setSorting(v ? [{
|
|
81
72
|
id: "search",
|
|
@@ -86,28 +77,28 @@ function usePipeCatalogTable(config = {}) {
|
|
|
86
77
|
table.setColumnFilters([]);
|
|
87
78
|
}
|
|
88
79
|
});
|
|
89
|
-
const addColumnFilter =
|
|
80
|
+
const addColumnFilter = (id, value) => {
|
|
90
81
|
setGlobalFilterImmediately("");
|
|
91
82
|
table.setColumnFilters([{
|
|
92
83
|
id,
|
|
93
84
|
value
|
|
94
85
|
}]);
|
|
95
|
-
}
|
|
96
|
-
const handleCategoryChange =
|
|
86
|
+
};
|
|
87
|
+
const handleCategoryChange = (category) => {
|
|
97
88
|
setCategory(category);
|
|
98
89
|
table.setColumnFilters([]);
|
|
99
90
|
setGlobalFilterImmediately("");
|
|
100
|
-
}
|
|
101
|
-
const resetFilters =
|
|
91
|
+
};
|
|
92
|
+
const resetFilters = () => {
|
|
102
93
|
setGlobalFilterImmediately("");
|
|
103
94
|
setCategory(null);
|
|
104
|
-
}
|
|
105
|
-
const removeColumnFilter =
|
|
95
|
+
};
|
|
96
|
+
const removeColumnFilter = (id) => {
|
|
106
97
|
table.getColumn(id)?.setFilterValue(null);
|
|
107
|
-
}
|
|
108
|
-
const getColumnFilterValue =
|
|
98
|
+
};
|
|
99
|
+
const getColumnFilterValue = (id) => {
|
|
109
100
|
return columnFilters.find((f) => f.id === id)?.value;
|
|
110
|
-
}
|
|
101
|
+
};
|
|
111
102
|
const rows = table.getRowModel().rows;
|
|
112
103
|
const cards = useMemo(() => rows.map((row) => {
|
|
113
104
|
const entry = row.original;
|