@pipe0/react 1.0.32 → 1.0.33
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 +10 -0
- package/dist/components/defaults/catalog/card-derived.d.mts +1 -1
- package/dist/components/defaults/catalog/card-derived.mjs +0 -1
- package/dist/components/defaults/catalog/card-derived.mjs.map +1 -1
- package/dist/components/defaults/catalog/card-primitives.d.mts +2 -2
- package/dist/components/defaults/catalog/card-primitives.mjs +2 -2
- package/dist/components/defaults/catalog/card-primitives.mjs.map +1 -1
- package/dist/components/internal/LiquidEditor/ChipEditPopover.mjs +60 -14
- package/dist/components/internal/LiquidEditor/ChipEditPopover.mjs.map +1 -1
- package/dist/context/catalog-card-context.mjs +3 -7
- package/dist/context/catalog-card-context.mjs.map +1 -1
- package/dist/context/catalog-config-context.d.mts +1 -1
- package/dist/context/catalog-config-context.mjs +1 -1
- package/dist/context/catalog-config-context.mjs.map +1 -1
- package/dist/hooks/use-pipe-catalog-table.d.mts +8 -8
- package/dist/index.d.mts +2 -17
- package/dist/index.mjs +1 -16
- package/dist/types/catalog-adapters.d.mts +2 -19
- package/dist/types/catalog-adapters.d.mts.map +1 -1
- package/package.json +2 -2
- package/dist/components/compound/searches-catalog/active-filters.d.mts +0 -23
- package/dist/components/compound/searches-catalog/active-filters.d.mts.map +0 -1
- package/dist/components/compound/searches-catalog/active-filters.mjs +0 -50
- package/dist/components/compound/searches-catalog/active-filters.mjs.map +0 -1
- package/dist/components/compound/searches-catalog/card.d.mts +0 -22
- package/dist/components/compound/searches-catalog/card.d.mts.map +0 -1
- package/dist/components/compound/searches-catalog/card.mjs +0 -82
- package/dist/components/compound/searches-catalog/card.mjs.map +0 -1
- package/dist/components/compound/searches-catalog/category-filter.d.mts +0 -27
- package/dist/components/compound/searches-catalog/category-filter.d.mts.map +0 -1
- package/dist/components/compound/searches-catalog/category-filter.mjs +0 -61
- package/dist/components/compound/searches-catalog/category-filter.mjs.map +0 -1
- package/dist/components/compound/searches-catalog/column-filter.d.mts +0 -29
- package/dist/components/compound/searches-catalog/column-filter.d.mts.map +0 -1
- package/dist/components/compound/searches-catalog/column-filter.mjs +0 -64
- package/dist/components/compound/searches-catalog/column-filter.mjs.map +0 -1
- package/dist/components/compound/searches-catalog/column-filters.d.mts +0 -15
- package/dist/components/compound/searches-catalog/column-filters.d.mts.map +0 -1
- package/dist/components/compound/searches-catalog/column-filters.mjs +0 -16
- package/dist/components/compound/searches-catalog/column-filters.mjs.map +0 -1
- package/dist/components/compound/searches-catalog/empty.d.mts +0 -17
- package/dist/components/compound/searches-catalog/empty.d.mts.map +0 -1
- package/dist/components/compound/searches-catalog/empty.mjs +0 -29
- package/dist/components/compound/searches-catalog/empty.mjs.map +0 -1
- package/dist/components/compound/searches-catalog/index.d.mts +0 -12
- package/dist/components/compound/searches-catalog/list.d.mts +0 -19
- package/dist/components/compound/searches-catalog/list.d.mts.map +0 -1
- package/dist/components/compound/searches-catalog/list.mjs +0 -33
- package/dist/components/compound/searches-catalog/list.mjs.map +0 -1
- package/dist/components/compound/searches-catalog/output-field-filter.d.mts +0 -22
- package/dist/components/compound/searches-catalog/output-field-filter.d.mts.map +0 -1
- package/dist/components/compound/searches-catalog/output-field-filter.mjs +0 -22
- package/dist/components/compound/searches-catalog/output-field-filter.mjs.map +0 -1
- package/dist/components/compound/searches-catalog/provider-filter.d.mts +0 -22
- package/dist/components/compound/searches-catalog/provider-filter.d.mts.map +0 -1
- package/dist/components/compound/searches-catalog/provider-filter.mjs +0 -29
- package/dist/components/compound/searches-catalog/provider-filter.mjs.map +0 -1
- package/dist/components/compound/searches-catalog/root.d.mts +0 -33
- package/dist/components/compound/searches-catalog/root.d.mts.map +0 -1
- package/dist/components/compound/searches-catalog/root.mjs +0 -74
- package/dist/components/compound/searches-catalog/root.mjs.map +0 -1
- package/dist/components/compound/searches-catalog/search-filter.d.mts +0 -21
- package/dist/components/compound/searches-catalog/search-filter.d.mts.map +0 -1
- package/dist/components/compound/searches-catalog/search-filter.mjs +0 -47
- package/dist/components/compound/searches-catalog/search-filter.mjs.map +0 -1
- package/dist/components/compound/searches-catalog/tag-filter.d.mts +0 -22
- package/dist/components/compound/searches-catalog/tag-filter.d.mts.map +0 -1
- package/dist/components/compound/searches-catalog/tag-filter.mjs +0 -22
- package/dist/components/compound/searches-catalog/tag-filter.mjs.map +0 -1
- package/dist/context/searches-catalog-card-context.d.mts +0 -24
- package/dist/context/searches-catalog-card-context.d.mts.map +0 -1
- package/dist/context/searches-catalog-card-context.mjs +0 -13
- package/dist/context/searches-catalog-card-context.mjs.map +0 -1
- package/dist/context/searches-catalog-context.d.mts +0 -20
- package/dist/context/searches-catalog-context.d.mts.map +0 -1
- package/dist/context/searches-catalog-context.mjs +0 -13
- package/dist/context/searches-catalog-context.mjs.map +0 -1
- package/dist/hooks/use-searches-catalog-table.d.mts +0 -56
- package/dist/hooks/use-searches-catalog-table.d.mts.map +0 -1
- package/dist/hooks/use-searches-catalog-table.mjs +0 -159
- package/dist/hooks/use-searches-catalog-table.mjs.map +0 -1
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"root.mjs","names":[],"sources":["../../../../src/components/compound/searches-catalog/root.tsx"],"sourcesContent":["import type { useRender } from \"@base-ui/react/use-render\";\nimport type { CatalogFilter } from \"@pipe0/base\";\nimport type { ColumnFilter } from \"@tanstack/react-table\";\nimport type { ReactNode, SyntheticEvent } from \"react\";\nimport { useMemo, useState } from \"react\";\nimport {\n CatalogProvider,\n CatalogRoot,\n useCatalogConfig,\n} from \"../../../context/catalog-config-context.js\";\nimport {\n SearchesCatalogContext,\n type SearchesCatalogContextValue,\n} from \"../../../context/searches-catalog-context.js\";\nimport {\n type UseSearchesCatalogTableReturn,\n useSearchesCatalogTable,\n} from \"../../../hooks/use-searches-catalog-table.js\";\nimport type {\n CatalogClassNames,\n CatalogComponentOverrides,\n SearchesCardData,\n} from \"../../../types/catalog-adapters.js\";\nimport { DefaultCatalogRoot } from \"../../defaults/catalog/layout.js\";\nimport { SearchesCatalogActiveFilters } from \"./active-filters.js\";\nimport { SearchesCatalogCategoryFilter } from \"./category-filter.js\";\nimport { SearchesCatalogColumnFilters } from \"./column-filters.js\";\nimport { SearchesCatalogEmpty } from \"./empty.js\";\nimport { SearchesCatalogList } from \"./list.js\";\nimport { SearchesCatalogSearchFilter } from \"./search-filter.js\";\n\ninterface CustomizationProps {\n classNames?: CatalogClassNames;\n components?: CatalogComponentOverrides;\n className?: string;\n render?: useRender.ComponentProps<\"div\">[\"render\"];\n}\n\ninterface SelectionProps {\n /** Fires on click / keyboard activation of any `<SearchesCatalogCard>`. */\n onSelectSearches?: (searches: SearchesCardData, e: SyntheticEvent) => void;\n}\n\nexport interface SearchesCatalogInstanceProps extends CustomizationProps, SelectionProps {\n context: UseSearchesCatalogTableReturn;\n children?: ReactNode;\n}\n\nexport interface SearchesCatalogZeroConfigProps extends CustomizationProps, SelectionProps {\n filter?: CatalogFilter;\n initialColumnFilters?: ColumnFilter[];\n children?: ReactNode;\n}\n\nexport type SearchesCatalogProps = SearchesCatalogInstanceProps | SearchesCatalogZeroConfigProps;\n\nexport function SearchesCatalog(props: SearchesCatalogProps) {\n if (\"context\" in props) {\n return <SearchesCatalogWithContext {...props} />;\n }\n return <SearchesCatalogZeroConfig {...props} />;\n}\n\nfunction SearchesCatalogZeroConfig({\n filter,\n initialColumnFilters,\n ...rest\n}: SearchesCatalogZeroConfigProps) {\n const context = useSearchesCatalogTable({ filter, initialColumnFilters });\n return <SearchesCatalogWithContext context={context} {...rest} />;\n}\n\nfunction SearchesCatalogWithContext({\n context,\n children,\n className,\n classNames,\n components,\n onSelectSearches,\n render,\n}: SearchesCatalogInstanceProps) {\n const hasLocalOverrides = classNames || components;\n const [expandedCardId, setExpandedCardId] = useState<string | null>(null);\n\n const value = useMemo<SearchesCatalogContextValue>(\n () => ({\n ...context,\n onSelectCard: onSelectSearches,\n expandedCardId,\n setExpandedCardId,\n }),\n [context, onSelectSearches, expandedCardId],\n );\n\n const inner = (\n <SearchesCatalogContext.Provider value={value}>\n <SearchesCatalogShell className={className} render={render}>\n {children}\n </SearchesCatalogShell>\n </SearchesCatalogContext.Provider>\n );\n if (hasLocalOverrides) {\n return (\n <CatalogRoot>\n <CatalogProvider classNames={classNames} components={components}>\n {inner}\n </CatalogProvider>\n </CatalogRoot>\n );\n }\n return <CatalogRoot>{inner}</CatalogRoot>;\n}\n\nfunction SearchesCatalogShell({\n children,\n className,\n render,\n}: {\n children?: ReactNode;\n className?: string;\n render?: useRender.ComponentProps<\"div\">[\"render\"];\n}) {\n useCatalogConfig();\n const body =\n children !== undefined ? (\n children\n ) : (\n <>\n <SearchesCatalogSearchFilter />\n <SearchesCatalogCategoryFilter />\n <SearchesCatalogColumnFilters />\n <SearchesCatalogActiveFilters />\n <SearchesCatalogList />\n <SearchesCatalogEmpty />\n </>\n );\n return (\n <DefaultCatalogRoot className={className} render={render}>\n {body}\n </DefaultCatalogRoot>\n );\n}\n"],"mappings":";;;;;;;;;;;;;;AAwDA,SAAgB,gBAAgB,OAA6B;AAC3D,KAAI,aAAa,MACf,QAAO,oBAAC,4BAAD,EAA4B,GAAI,OAAS;AAElD,QAAO,oBAAC,2BAAD,EAA2B,GAAI,OAAS;;AAGjD,SAAS,0BAA0B,EACjC,QACA,sBACA,GAAG,QAC8B;AAEjC,QAAO,oBAAC,4BAAD;EAA4B,SADnB,wBAAwB;GAAE;GAAQ;GAAsB,CAAC;EACpB,GAAI;EAAQ;;AAGnE,SAAS,2BAA2B,EAClC,SACA,UACA,WACA,YACA,YACA,kBACA,UAC+B;CAC/B,MAAM,oBAAoB,cAAc;CACxC,MAAM,CAAC,gBAAgB,qBAAqB,SAAwB,KAAK;CAEzE,MAAM,QAAQ,eACL;EACL,GAAG;EACH,cAAc;EACd;EACA;EACD,GACD;EAAC;EAAS;EAAkB;EAAe,CAC5C;CAED,MAAM,QACJ,oBAAC,uBAAuB,UAAxB;EAAwC;YACtC,oBAAC,sBAAD;GAAiC;GAAmB;GACjD;GACoB;EACS;AAEpC,KAAI,kBACF,QACE,oBAAC,aAAD,YACE,oBAAC,iBAAD;EAA6B;EAAwB;YAClD;EACe,GACN;AAGlB,QAAO,oBAAC,aAAD,YAAc,OAAoB;;AAG3C,SAAS,qBAAqB,EAC5B,UACA,WACA,UAKC;AACD,mBAAkB;AAclB,QACE,oBAAC,oBAAD;EAA+B;EAAmB;YAblD,aAAa,SACX,WAEA;GACE,oBAAC,6BAAD,EAA+B;GAC/B,oBAAC,+BAAD,EAAiC;GACjC,oBAAC,8BAAD,EAAgC;GAChC,oBAAC,8BAAD,EAAgC;GAChC,oBAAC,qBAAD,EAAuB;GACvB,oBAAC,sBAAD,EAAwB;GACvB;EAKgB"}
|
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
import { useRender } from "@base-ui/react/use-render";
|
|
2
|
-
import * as _$react_jsx_runtime0 from "react/jsx-runtime";
|
|
3
|
-
|
|
4
|
-
//#region src/components/compound/searches-catalog/search-filter.d.ts
|
|
5
|
-
interface SearchesCatalogSearchFilterState {
|
|
6
|
-
value: string;
|
|
7
|
-
setValue: (value: string) => void;
|
|
8
|
-
isActive: boolean;
|
|
9
|
-
}
|
|
10
|
-
interface SearchesCatalogSearchFilterProps extends useRender.ComponentProps<"input", SearchesCatalogSearchFilterState> {
|
|
11
|
-
placeholder?: string;
|
|
12
|
-
}
|
|
13
|
-
declare function SearchesCatalogSearchFilter({
|
|
14
|
-
placeholder,
|
|
15
|
-
className,
|
|
16
|
-
render,
|
|
17
|
-
...props
|
|
18
|
-
}: SearchesCatalogSearchFilterProps): _$react_jsx_runtime0.JSX.Element;
|
|
19
|
-
//#endregion
|
|
20
|
-
export { SearchesCatalogSearchFilter, SearchesCatalogSearchFilterProps, SearchesCatalogSearchFilterState };
|
|
21
|
-
//# sourceMappingURL=search-filter.d.mts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"search-filter.d.mts","names":[],"sources":["../../../../src/components/compound/searches-catalog/search-filter.tsx"],"mappings":";;;;UASiB,gCAAA;EACf,KAAA;EACA,QAAA,GAAW,KAAA;EACX,QAAA;AAAA;AAAA,UAGe,gCAAA,SACP,SAAA,CAAU,cAAA,UAAwB,gCAAA;EAC1C,WAAA;AAAA;AAAA,iBAGc,2BAAA,CAAA;EACd,WAAA;EACA,SAAA;EACA,MAAA;EAAA,GACG;AAAA,GACF,gCAAA,GAAgC,oBAAA,CAAA,GAAA,CAAA,OAAA"}
|
|
@@ -1,47 +0,0 @@
|
|
|
1
|
-
import { cn } from "../../../lib/utils.mjs";
|
|
2
|
-
import { useCatalogConfig } from "../../../context/catalog-config-context.mjs";
|
|
3
|
-
import { useSearchesCatalogContext } from "../../../context/searches-catalog-context.mjs";
|
|
4
|
-
import { Input } from "../../ui/input.mjs";
|
|
5
|
-
import { mergeProps } from "@base-ui/react/merge-props";
|
|
6
|
-
import { useRender } from "@base-ui/react/use-render";
|
|
7
|
-
import { jsx, jsxs } from "react/jsx-runtime";
|
|
8
|
-
import { Search } from "lucide-react";
|
|
9
|
-
|
|
10
|
-
//#region src/components/compound/searches-catalog/search-filter.tsx
|
|
11
|
-
function SearchesCatalogSearchFilter({ placeholder = "Search searches...", className, render, ...props }) {
|
|
12
|
-
const { globalFilterInput, setGlobalFilterInput } = useSearchesCatalogContext();
|
|
13
|
-
const { classNames } = useCatalogConfig();
|
|
14
|
-
const inputElement = useRender({
|
|
15
|
-
defaultTagName: "input",
|
|
16
|
-
render,
|
|
17
|
-
state: {
|
|
18
|
-
value: globalFilterInput,
|
|
19
|
-
setValue: setGlobalFilterInput,
|
|
20
|
-
isActive: !!globalFilterInput
|
|
21
|
-
},
|
|
22
|
-
stateAttributesMapping: { setValue: () => null },
|
|
23
|
-
props: mergeProps({
|
|
24
|
-
type: "search",
|
|
25
|
-
placeholder,
|
|
26
|
-
value: globalFilterInput,
|
|
27
|
-
onChange: (e) => setGlobalFilterInput(e.target.value),
|
|
28
|
-
className: render ? cn(classNames?.searchInput, className) : void 0
|
|
29
|
-
}, props)
|
|
30
|
-
});
|
|
31
|
-
if (render) return inputElement;
|
|
32
|
-
return /* @__PURE__ */ jsxs("div", {
|
|
33
|
-
"data-p0": "catalog-search",
|
|
34
|
-
className: cn("pz:relative", classNames?.searchInputContainer),
|
|
35
|
-
children: [/* @__PURE__ */ jsx(Search, { className: "pz:absolute pz:left-2.5 pz:top-1/2 pz:-translate-y-1/2 pz:size-4 pz:text-muted-foreground pz:pointer-events-none" }), /* @__PURE__ */ jsx(Input, {
|
|
36
|
-
type: "search",
|
|
37
|
-
placeholder,
|
|
38
|
-
value: globalFilterInput,
|
|
39
|
-
onChange: (e) => setGlobalFilterInput(e.target.value),
|
|
40
|
-
className: cn("pz:pl-8", classNames?.searchInput, className)
|
|
41
|
-
})]
|
|
42
|
-
});
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
//#endregion
|
|
46
|
-
export { SearchesCatalogSearchFilter };
|
|
47
|
-
//# sourceMappingURL=search-filter.mjs.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"search-filter.mjs","names":["SearchIcon"],"sources":["../../../../src/components/compound/searches-catalog/search-filter.tsx"],"sourcesContent":["import { mergeProps } from \"@base-ui/react/merge-props\";\nimport { useRender } from \"@base-ui/react/use-render\";\nimport { Search as SearchIcon } from \"lucide-react\";\nimport type { ChangeEvent } from \"react\";\nimport { useCatalogConfig } from \"../../../context/catalog-config-context.js\";\nimport { useSearchesCatalogContext } from \"../../../context/searches-catalog-context.js\";\nimport { cn } from \"../../../lib/utils.js\";\nimport { Input } from \"../../ui/input.js\";\n\nexport interface SearchesCatalogSearchFilterState {\n value: string;\n setValue: (value: string) => void;\n isActive: boolean;\n}\n\nexport interface SearchesCatalogSearchFilterProps\n extends useRender.ComponentProps<\"input\", SearchesCatalogSearchFilterState> {\n placeholder?: string;\n}\n\nexport function SearchesCatalogSearchFilter({\n placeholder = \"Search searches...\",\n className,\n render,\n ...props\n}: SearchesCatalogSearchFilterProps) {\n const { globalFilterInput, setGlobalFilterInput } = useSearchesCatalogContext();\n const { classNames } = useCatalogConfig();\n const isActive = !!globalFilterInput;\n\n const inputElement = useRender({\n defaultTagName: \"input\",\n render,\n state: { value: globalFilterInput, setValue: setGlobalFilterInput, isActive },\n stateAttributesMapping: {\n setValue: () => null,\n },\n props: mergeProps<\"input\">(\n {\n type: \"search\",\n placeholder,\n value: globalFilterInput,\n onChange: (e: ChangeEvent<HTMLInputElement>) => setGlobalFilterInput(e.target.value),\n className: render ? cn(classNames?.searchInput, className) : undefined,\n },\n props,\n ),\n });\n\n if (render) return inputElement;\n\n return (\n <div data-p0=\"catalog-search\" className={cn(\"pz:relative\", classNames?.searchInputContainer)}>\n <SearchIcon className=\"pz:absolute pz:left-2.5 pz:top-1/2 pz:-translate-y-1/2 pz:size-4 pz:text-muted-foreground pz:pointer-events-none\" />\n <Input\n type=\"search\"\n placeholder={placeholder}\n value={globalFilterInput}\n onChange={(e) => setGlobalFilterInput(e.target.value)}\n className={cn(\"pz:pl-8\", classNames?.searchInput, className)}\n />\n </div>\n );\n}\n"],"mappings":";;;;;;;;;;AAoBA,SAAgB,4BAA4B,EAC1C,cAAc,sBACd,WACA,QACA,GAAG,SACgC;CACnC,MAAM,EAAE,mBAAmB,yBAAyB,2BAA2B;CAC/E,MAAM,EAAE,eAAe,kBAAkB;CAGzC,MAAM,eAAe,UAAU;EAC7B,gBAAgB;EAChB;EACA,OAAO;GAAE,OAAO;GAAmB,UAAU;GAAsB,UALpD,CAAC,CAAC;GAK4D;EAC7E,wBAAwB,EACtB,gBAAgB,MACjB;EACD,OAAO,WACL;GACE,MAAM;GACN;GACA,OAAO;GACP,WAAW,MAAqC,qBAAqB,EAAE,OAAO,MAAM;GACpF,WAAW,SAAS,GAAG,YAAY,aAAa,UAAU,GAAG;GAC9D,EACD,MACD;EACF,CAAC;AAEF,KAAI,OAAQ,QAAO;AAEnB,QACE,qBAAC,OAAD;EAAK,WAAQ;EAAiB,WAAW,GAAG,eAAe,YAAY,qBAAqB;YAA5F,CACE,oBAACA,QAAD,EAAY,WAAU,oHAAqH,GAC3I,oBAAC,OAAD;GACE,MAAK;GACQ;GACb,OAAO;GACP,WAAW,MAAM,qBAAqB,EAAE,OAAO,MAAM;GACrD,WAAW,GAAG,WAAW,YAAY,aAAa,UAAU;GAC5D,EACE"}
|
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
import { FilterSelectOption } from "../../defaults/catalog/filter-select.mjs";
|
|
2
|
-
import { ColumnFilterState } from "./column-filter.mjs";
|
|
3
|
-
import { useRender } from "@base-ui/react/use-render";
|
|
4
|
-
import { ReactNode } from "react";
|
|
5
|
-
import * as _$react_jsx_runtime0 from "react/jsx-runtime";
|
|
6
|
-
|
|
7
|
-
//#region src/components/compound/searches-catalog/tag-filter.d.ts
|
|
8
|
-
interface SearchesCatalogTagFilterProps {
|
|
9
|
-
options?: ReadonlyArray<FilterSelectOption>;
|
|
10
|
-
placeholder?: ReactNode;
|
|
11
|
-
className?: string;
|
|
12
|
-
render?: useRender.ComponentProps<"div", ColumnFilterState>["render"];
|
|
13
|
-
}
|
|
14
|
-
declare function SearchesCatalogTagFilter({
|
|
15
|
-
options,
|
|
16
|
-
placeholder,
|
|
17
|
-
className,
|
|
18
|
-
render
|
|
19
|
-
}: SearchesCatalogTagFilterProps): _$react_jsx_runtime0.JSX.Element;
|
|
20
|
-
//#endregion
|
|
21
|
-
export { SearchesCatalogTagFilter, SearchesCatalogTagFilterProps };
|
|
22
|
-
//# sourceMappingURL=tag-filter.d.mts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"tag-filter.d.mts","names":[],"sources":["../../../../src/components/compound/searches-catalog/tag-filter.tsx"],"mappings":";;;;;;;UAMiB,6BAAA;EACf,OAAA,GAAU,aAAA,CAAc,kBAAA;EACxB,WAAA,GAAc,SAAA;EACd,SAAA;EACA,MAAA,GAAS,SAAA,CAAU,cAAA,QAAsB,iBAAA;AAAA;AAAA,iBAS3B,wBAAA,CAAA;EACd,OAAA;EACA,WAAA;EACA,SAAA;EACA;AAAA,GACC,6BAAA,GAA6B,oBAAA,CAAA,GAAA,CAAA,OAAA"}
|
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
import { SearchesCatalogColumnFilter } from "./column-filter.mjs";
|
|
2
|
-
import { jsx, jsxs } from "react/jsx-runtime";
|
|
3
|
-
import { Tag } from "lucide-react";
|
|
4
|
-
|
|
5
|
-
//#region src/components/compound/searches-catalog/tag-filter.tsx
|
|
6
|
-
const DEFAULT_PLACEHOLDER = /* @__PURE__ */ jsxs("span", {
|
|
7
|
-
className: "pz:inline-flex pz:items-center pz:gap-1.5",
|
|
8
|
-
children: [/* @__PURE__ */ jsx(Tag, { className: "pz:size-4" }), " Tag"]
|
|
9
|
-
});
|
|
10
|
-
function SearchesCatalogTagFilter({ options, placeholder = DEFAULT_PLACEHOLDER, className, render }) {
|
|
11
|
-
return /* @__PURE__ */ jsx(SearchesCatalogColumnFilter, {
|
|
12
|
-
id: "tags",
|
|
13
|
-
placeholder,
|
|
14
|
-
options,
|
|
15
|
-
className,
|
|
16
|
-
render
|
|
17
|
-
});
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
//#endregion
|
|
21
|
-
export { SearchesCatalogTagFilter };
|
|
22
|
-
//# sourceMappingURL=tag-filter.mjs.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"tag-filter.mjs","names":[],"sources":["../../../../src/components/compound/searches-catalog/tag-filter.tsx"],"sourcesContent":["import type { useRender } from \"@base-ui/react/use-render\";\nimport { Tag } from \"lucide-react\";\nimport type { ReactNode } from \"react\";\nimport type { FilterSelectOption } from \"../../defaults/catalog/filter-select.js\";\nimport { type ColumnFilterState, SearchesCatalogColumnFilter } from \"./column-filter.js\";\n\nexport interface SearchesCatalogTagFilterProps {\n options?: ReadonlyArray<FilterSelectOption>;\n placeholder?: ReactNode;\n className?: string;\n render?: useRender.ComponentProps<\"div\", ColumnFilterState>[\"render\"];\n}\n\nconst DEFAULT_PLACEHOLDER = (\n <span className=\"pz:inline-flex pz:items-center pz:gap-1.5\">\n <Tag className=\"pz:size-4\" /> Tag\n </span>\n);\n\nexport function SearchesCatalogTagFilter({\n options,\n placeholder = DEFAULT_PLACEHOLDER,\n className,\n render,\n}: SearchesCatalogTagFilterProps) {\n return (\n <SearchesCatalogColumnFilter\n id=\"tags\"\n placeholder={placeholder}\n options={options}\n className={className}\n render={render}\n />\n );\n}\n"],"mappings":";;;;;AAaA,MAAM,sBACJ,qBAAC,QAAD;CAAM,WAAU;WAAhB,CACE,oBAAC,KAAD,EAAK,WAAU,aAAc,UACxB;;AAGT,SAAgB,yBAAyB,EACvC,SACA,cAAc,qBACd,WACA,UACgC;AAChC,QACE,oBAAC,6BAAD;EACE,IAAG;EACU;EACJ;EACE;EACH;EACR"}
|
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
import { SearchesCardData } from "../types/catalog-adapters.mjs";
|
|
2
|
-
import * as _$react from "react";
|
|
3
|
-
import { SyntheticEvent } from "react";
|
|
4
|
-
|
|
5
|
-
//#region src/context/searches-catalog-card-context.d.ts
|
|
6
|
-
interface SearchesCatalogCardContextValue {
|
|
7
|
-
card: SearchesCardData;
|
|
8
|
-
index: number;
|
|
9
|
-
selected: boolean;
|
|
10
|
-
expanded: boolean;
|
|
11
|
-
/** Selection handler — fires the catalog root's `onSelectCard`. */
|
|
12
|
-
onSelect: (e: SyntheticEvent) => void;
|
|
13
|
-
/**
|
|
14
|
-
* Open or close this card's expansion drawer. Only a single card inside a
|
|
15
|
-
* `<SearchesCatalog>` can be expanded at any time — opening one closes the
|
|
16
|
-
* previously expanded card.
|
|
17
|
-
*/
|
|
18
|
-
setExpanded: (open: boolean) => void;
|
|
19
|
-
}
|
|
20
|
-
declare const SearchesCatalogCardContext: _$react.Context<SearchesCatalogCardContextValue | null>;
|
|
21
|
-
declare function useSearchesCatalogCard(): SearchesCatalogCardContextValue;
|
|
22
|
-
//#endregion
|
|
23
|
-
export { SearchesCatalogCardContext, SearchesCatalogCardContextValue, useSearchesCatalogCard };
|
|
24
|
-
//# sourceMappingURL=searches-catalog-card-context.d.mts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"searches-catalog-card-context.d.mts","names":[],"sources":["../../src/context/searches-catalog-card-context.ts"],"mappings":";;;;;UAIiB,+BAAA;EACf,IAAA,EAAM,gBAAA;EACN,KAAA;EACA,QAAA;EACA,QAAA;;EAEA,QAAA,GAAW,CAAA,EAAG,cAAA;EALd;;;;;EAWA,WAAA,GAAc,IAAA;AAAA;AAAA,cAGH,0BAAA,EAA0B,OAAA,CAAA,OAAA,CAAA,+BAAA;AAAA,iBAIvB,sBAAA,CAAA,GAA0B,+BAAA"}
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
import { createContext, useContext } from "react";
|
|
2
|
-
|
|
3
|
-
//#region src/context/searches-catalog-card-context.ts
|
|
4
|
-
const SearchesCatalogCardContext = createContext(null);
|
|
5
|
-
function useSearchesCatalogCard() {
|
|
6
|
-
const value = useContext(SearchesCatalogCardContext);
|
|
7
|
-
if (value == null) throw new Error("useSearchesCatalogCard must be used inside <SearchesCatalogCard>.");
|
|
8
|
-
return value;
|
|
9
|
-
}
|
|
10
|
-
|
|
11
|
-
//#endregion
|
|
12
|
-
export { SearchesCatalogCardContext, useSearchesCatalogCard };
|
|
13
|
-
//# sourceMappingURL=searches-catalog-card-context.mjs.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"searches-catalog-card-context.mjs","names":[],"sources":["../../src/context/searches-catalog-card-context.ts"],"sourcesContent":["import type { SyntheticEvent } from \"react\";\nimport { createContext, useContext } from \"react\";\nimport type { SearchesCardData } from \"../types/catalog-adapters.js\";\n\nexport interface SearchesCatalogCardContextValue {\n card: SearchesCardData;\n index: number;\n selected: boolean;\n expanded: boolean;\n /** Selection handler — fires the catalog root's `onSelectCard`. */\n onSelect: (e: SyntheticEvent) => void;\n /**\n * Open or close this card's expansion drawer. Only a single card inside a\n * `<SearchesCatalog>` can be expanded at any time — opening one closes the\n * previously expanded card.\n */\n setExpanded: (open: boolean) => void;\n}\n\nexport const SearchesCatalogCardContext = createContext<SearchesCatalogCardContextValue | null>(\n null,\n);\n\nexport function useSearchesCatalogCard(): SearchesCatalogCardContextValue {\n const value = useContext(SearchesCatalogCardContext);\n if (value == null) {\n throw new Error(\"useSearchesCatalogCard must be used inside <SearchesCatalogCard>.\");\n }\n return value;\n}\n"],"mappings":";;;AAmBA,MAAa,6BAA6B,cACxC,KACD;AAED,SAAgB,yBAA0D;CACxE,MAAM,QAAQ,WAAW,2BAA2B;AACpD,KAAI,SAAS,KACX,OAAM,IAAI,MAAM,oEAAoE;AAEtF,QAAO"}
|
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
import { SearchesCardData } from "../types/catalog-adapters.mjs";
|
|
2
|
-
import { UseSearchesCatalogTableReturn } from "../hooks/use-searches-catalog-table.mjs";
|
|
3
|
-
import * as _$react from "react";
|
|
4
|
-
import { SyntheticEvent } from "react";
|
|
5
|
-
|
|
6
|
-
//#region src/context/searches-catalog-context.d.ts
|
|
7
|
-
type SearchesCatalogContextValue = UseSearchesCatalogTableReturn & {
|
|
8
|
-
onSelectCard?: (card: SearchesCardData, e: SyntheticEvent) => void;
|
|
9
|
-
/**
|
|
10
|
-
* Id of the currently expanded card row (drawer open), or `null`. Driven by
|
|
11
|
-
* the default card layout's inline drawer.
|
|
12
|
-
*/
|
|
13
|
-
expandedCardId: string | null;
|
|
14
|
-
setExpandedCardId: (id: string | null) => void;
|
|
15
|
-
};
|
|
16
|
-
declare const SearchesCatalogContext: _$react.Context<SearchesCatalogContextValue | null>;
|
|
17
|
-
declare function useSearchesCatalogContext(): SearchesCatalogContextValue;
|
|
18
|
-
//#endregion
|
|
19
|
-
export { SearchesCatalogContext, SearchesCatalogContextValue, useSearchesCatalogContext };
|
|
20
|
-
//# sourceMappingURL=searches-catalog-context.d.mts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"searches-catalog-context.d.mts","names":[],"sources":["../../src/context/searches-catalog-context.ts"],"mappings":";;;;;;KAKY,2BAAA,GAA8B,6BAAA;EACxC,YAAA,IAAgB,IAAA,EAAM,gBAAA,EAAkB,CAAA,EAAG,cAAA;;AAD7C;;;EAME,cAAA;EACA,iBAAA,GAAoB,EAAA;AAAA;AAAA,cAGT,sBAAA,EAAsB,OAAA,CAAA,OAAA,CAAA,2BAAA;AAAA,iBAEnB,yBAAA,CAAA,GAA6B,2BAAA"}
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
import { createContext, useContext } from "react";
|
|
2
|
-
|
|
3
|
-
//#region src/context/searches-catalog-context.ts
|
|
4
|
-
const SearchesCatalogContext = createContext(null);
|
|
5
|
-
function useSearchesCatalogContext() {
|
|
6
|
-
const value = useContext(SearchesCatalogContext);
|
|
7
|
-
if (value == null) throw new Error("useSearchesCatalogContext must be used inside <SearchesCatalog>. Either render <SearchesCatalog>...</SearchesCatalog> or pass `context={useSearchesCatalogTable()}`.");
|
|
8
|
-
return value;
|
|
9
|
-
}
|
|
10
|
-
|
|
11
|
-
//#endregion
|
|
12
|
-
export { SearchesCatalogContext, useSearchesCatalogContext };
|
|
13
|
-
//# sourceMappingURL=searches-catalog-context.mjs.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"searches-catalog-context.mjs","names":[],"sources":["../../src/context/searches-catalog-context.ts"],"sourcesContent":["import type { SyntheticEvent } from \"react\";\nimport { createContext, useContext } from \"react\";\nimport type { UseSearchesCatalogTableReturn } from \"../hooks/use-searches-catalog-table.js\";\nimport type { SearchesCardData } from \"../types/catalog-adapters.js\";\n\nexport type SearchesCatalogContextValue = UseSearchesCatalogTableReturn & {\n onSelectCard?: (card: SearchesCardData, e: SyntheticEvent) => void;\n /**\n * Id of the currently expanded card row (drawer open), or `null`. Driven by\n * the default card layout's inline drawer.\n */\n expandedCardId: string | null;\n setExpandedCardId: (id: string | null) => void;\n};\n\nexport const SearchesCatalogContext = createContext<SearchesCatalogContextValue | null>(null);\n\nexport function useSearchesCatalogContext(): SearchesCatalogContextValue {\n const value = useContext(SearchesCatalogContext);\n if (value == null) {\n throw new Error(\n \"useSearchesCatalogContext must be used inside <SearchesCatalog>. \" +\n \"Either render <SearchesCatalog>...</SearchesCatalog> or pass `context={useSearchesCatalogTable()}`.\",\n );\n }\n return value;\n}\n"],"mappings":";;;AAeA,MAAa,yBAAyB,cAAkD,KAAK;AAE7F,SAAgB,4BAAyD;CACvE,MAAM,QAAQ,WAAW,uBAAuB;AAChD,KAAI,SAAS,KACX,OAAM,IAAI,MACR,uKAED;AAEH,QAAO"}
|
|
@@ -1,56 +0,0 @@
|
|
|
1
|
-
import { SearchesCardData } from "../types/catalog-adapters.mjs";
|
|
2
|
-
import { CatalogFilterMeta, CatalogSearchFeatures } from "../utils/catalog-helpers.mjs";
|
|
3
|
-
import * as _$react from "react";
|
|
4
|
-
import { CatalogFilter, SearchCategory, SearchesCatalogTableData, SearchesId } from "@pipe0/base";
|
|
5
|
-
import * as _$_tanstack_react_table0 from "@tanstack/react-table";
|
|
6
|
-
import { ColumnFilter } from "@tanstack/react-table";
|
|
7
|
-
|
|
8
|
-
//#region src/hooks/use-searches-catalog-table.d.ts
|
|
9
|
-
type SearchesOutputFieldEntries = Record<string, SearchesId[]>;
|
|
10
|
-
declare function useSearchesCatalogTable(config?: {
|
|
11
|
-
initialColumnFilters?: ColumnFilter[];
|
|
12
|
-
filter?: CatalogFilter;
|
|
13
|
-
}): {
|
|
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, {}, {}, {}>;
|
|
30
|
-
cards: SearchesCardData[];
|
|
31
|
-
cardsByCategory: {
|
|
32
|
-
category: SearchCategory;
|
|
33
|
-
cards: SearchesCardData[];
|
|
34
|
-
}[];
|
|
35
|
-
categoryCounts: Partial<Record<SearchCategory, number>>;
|
|
36
|
-
baselineCardCount: number;
|
|
37
|
-
baselineCategoryCounts: Partial<Record<SearchCategory, number>>;
|
|
38
|
-
category: SearchCategory | null;
|
|
39
|
-
setCategory: (category: SearchCategory | null) => void;
|
|
40
|
-
globalFilterInput: string;
|
|
41
|
-
setGlobalFilterInput: _$react.Dispatch<_$react.SetStateAction<string>>;
|
|
42
|
-
addColumnFilter: (id: "inputFields" | "outputFields" | "tags" | "providers", value: string) => void;
|
|
43
|
-
removeColumnFilter: (id: "inputFields" | "outputFields" | "tags" | "providers") => void;
|
|
44
|
-
resetFilters: () => void;
|
|
45
|
-
getColumnFilterValue: (id: "inputFields" | "outputFields" | "tags" | "providers") => string;
|
|
46
|
-
sortedOutputFieldEntries: [string, ("companies:profiles:crustdata@1" | "people:profiles:crustdata@1" | "people:profiles:icypeas@1" | "companies:profiles:icypeas@1" | "people:profiles:clado@1" | "people:profiles:clado@2" | "people:employees:leadmagic@1" | "companies:profiles:exa@1" | "people:profiles:exa@1")[]][];
|
|
47
|
-
sortedTagEntries: [string, ("companies:profiles:crustdata@1" | "people:profiles:crustdata@1" | "people:profiles:icypeas@1" | "companies:profiles:icypeas@1" | "people:profiles:clado@1" | "people:profiles:clado@2" | "people:employees:leadmagic@1" | "companies:profiles:exa@1" | "people:profiles:exa@1")[]][];
|
|
48
|
-
sortedProviderEntries: [string, ("companies:profiles:crustdata@1" | "people:profiles:crustdata@1" | "people:profiles:icypeas@1" | "companies:profiles:icypeas@1" | "people:profiles:clado@1" | "people:profiles:clado@2" | "people:employees:leadmagic@1" | "companies:profiles:exa@1" | "people:profiles:exa@1")[]][];
|
|
49
|
-
searchIdsByOutputField: Record<string, ("companies:profiles:crustdata@1" | "people:profiles:crustdata@1" | "people:profiles:icypeas@1" | "companies:profiles:icypeas@1" | "people:profiles:clado@1" | "people:profiles:clado@2" | "people:employees:leadmagic@1" | "companies:profiles:exa@1" | "people:profiles:exa@1")[]>;
|
|
50
|
-
searchIdsByProvider: Record<string, ("companies:profiles:crustdata@1" | "people:profiles:crustdata@1" | "people:profiles:icypeas@1" | "companies:profiles:icypeas@1" | "people:profiles:clado@1" | "people:profiles:clado@2" | "people:employees:leadmagic@1" | "companies:profiles:exa@1" | "people:profiles:exa@1")[]>;
|
|
51
|
-
searchIdsByTag: Record<string, ("companies:profiles:crustdata@1" | "people:profiles:crustdata@1" | "people:profiles:icypeas@1" | "companies:profiles:icypeas@1" | "people:profiles:clado@1" | "people:profiles:clado@2" | "people:employees:leadmagic@1" | "companies:profiles:exa@1" | "people:profiles:exa@1")[]>;
|
|
52
|
-
};
|
|
53
|
-
type UseSearchesCatalogTableReturn = ReturnType<typeof useSearchesCatalogTable>;
|
|
54
|
-
//#endregion
|
|
55
|
-
export { SearchesOutputFieldEntries, UseSearchesCatalogTableReturn, useSearchesCatalogTable };
|
|
56
|
-
//# sourceMappingURL=use-searches-catalog-table.d.mts.map
|
|
@@ -1 +0,0 @@
|
|
|
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,159 +0,0 @@
|
|
|
1
|
-
import { createCatalogColumnHelper, useCatalogTable } from "./catalog-table.mjs";
|
|
2
|
-
import { useDebounce } from "./use-debounce.mjs";
|
|
3
|
-
import { useMemo, useState } from "react";
|
|
4
|
-
import { filterSearchesEntries, getDefaultSearchesOutputFields, getInitialSearchesTableData, getLoweestSearchesCreditAmount, getSearchesSearchTarget, getSearchesTableDataAggregates, getStartingCostPerSearchesProvider } from "@pipe0/base";
|
|
5
|
-
|
|
6
|
-
//#region src/hooks/use-searches-catalog-table.ts
|
|
7
|
-
const columnHelper = createCatalogColumnHelper();
|
|
8
|
-
const columns = columnHelper.columns([
|
|
9
|
-
columnHelper.accessor("searchId", {
|
|
10
|
-
filterFn: "includesString",
|
|
11
|
-
enableGlobalFilter: false
|
|
12
|
-
}),
|
|
13
|
-
columnHelper.accessor("description", { enableGlobalFilter: false }),
|
|
14
|
-
columnHelper.accessor("label", {
|
|
15
|
-
filterFn: "includesString",
|
|
16
|
-
enableGlobalFilter: false
|
|
17
|
-
}),
|
|
18
|
-
columnHelper.accessor((row) => getDefaultSearchesOutputFields(row.searchId) || [], {
|
|
19
|
-
id: "outputFields",
|
|
20
|
-
filterFn: "arrIncludes",
|
|
21
|
-
enableGlobalFilter: false
|
|
22
|
-
}),
|
|
23
|
-
columnHelper.accessor((row) => row.tags || [], {
|
|
24
|
-
id: "tags",
|
|
25
|
-
filterFn: "arrIncludes",
|
|
26
|
-
enableGlobalFilter: false
|
|
27
|
-
}),
|
|
28
|
-
columnHelper.accessor((row) => row.provider, {
|
|
29
|
-
id: "providers",
|
|
30
|
-
enableGlobalFilter: false
|
|
31
|
-
}),
|
|
32
|
-
columnHelper.accessor((row) => getSearchesSearchTarget(row), {
|
|
33
|
-
id: "search",
|
|
34
|
-
enableGlobalFilter: true,
|
|
35
|
-
enableSorting: true,
|
|
36
|
-
sortFn: "catalogSearch"
|
|
37
|
-
})
|
|
38
|
-
]);
|
|
39
|
-
function useSearchesCatalogTable(config = {}) {
|
|
40
|
-
const [category, setCategory] = useState(null);
|
|
41
|
-
const { initialColumnFilters = [], filter } = config;
|
|
42
|
-
const initialSearchTableData = useMemo(() => filterSearchesEntries(getInitialSearchesTableData(category), filter), [category, filter]);
|
|
43
|
-
const baselineTableData = useMemo(() => filterSearchesEntries(getInitialSearchesTableData(null), filter), [filter]);
|
|
44
|
-
const table = useCatalogTable({
|
|
45
|
-
columns,
|
|
46
|
-
data: initialSearchTableData,
|
|
47
|
-
initialState: { columnFilters: initialColumnFilters }
|
|
48
|
-
});
|
|
49
|
-
const columnFilters = table.state.columnFilters;
|
|
50
|
-
const aggregates = useMemo(() => getSearchesTableDataAggregates(initialSearchTableData, category), [category, initialSearchTableData]);
|
|
51
|
-
const [globalFilterInput, setGlobalFilterInput, setGlobalFilterImmediately] = useDebounce((v) => {
|
|
52
|
-
if (v === table.atoms.globalFilter.get()) return;
|
|
53
|
-
table.setGlobalFilter(v);
|
|
54
|
-
table.setSorting(v ? [{
|
|
55
|
-
id: "search",
|
|
56
|
-
desc: true
|
|
57
|
-
}] : []);
|
|
58
|
-
if (v) {
|
|
59
|
-
setCategory(null);
|
|
60
|
-
table.setColumnFilters([]);
|
|
61
|
-
}
|
|
62
|
-
});
|
|
63
|
-
const addColumnFilter = (id, value) => {
|
|
64
|
-
setGlobalFilterImmediately("");
|
|
65
|
-
table.setColumnFilters([{
|
|
66
|
-
id,
|
|
67
|
-
value
|
|
68
|
-
}]);
|
|
69
|
-
};
|
|
70
|
-
const resetFilters = () => {
|
|
71
|
-
setGlobalFilterImmediately("");
|
|
72
|
-
setCategory(null);
|
|
73
|
-
};
|
|
74
|
-
const removeColumnFilter = (id) => {
|
|
75
|
-
table.getColumn(id)?.setFilterValue(null);
|
|
76
|
-
};
|
|
77
|
-
const handleCategoryChange = (category) => {
|
|
78
|
-
setCategory(category);
|
|
79
|
-
table.setColumnFilters([]);
|
|
80
|
-
setGlobalFilterImmediately("");
|
|
81
|
-
};
|
|
82
|
-
const getColumnFilterValue = (id) => {
|
|
83
|
-
return columnFilters.find((f) => f.id === id)?.value;
|
|
84
|
-
};
|
|
85
|
-
const rows = table.getRowModel().rows;
|
|
86
|
-
const cards = useMemo(() => rows.map((row) => {
|
|
87
|
-
const entry = row.original;
|
|
88
|
-
const latestEntry = aggregates.searchEntriesByBaseSearch[entry.baseSearch]?.[0] ?? entry;
|
|
89
|
-
return {
|
|
90
|
-
searchesId: latestEntry.searchesId,
|
|
91
|
-
baseSearches: entry.baseSearch,
|
|
92
|
-
label: entry.label,
|
|
93
|
-
description: entry.description,
|
|
94
|
-
provider: entry.provider,
|
|
95
|
-
providers: [entry.provider],
|
|
96
|
-
startingCostPerProvider: getStartingCostPerSearchesProvider(latestEntry.searchesId),
|
|
97
|
-
startingCreditAmount: getLoweestSearchesCreditAmount(latestEntry),
|
|
98
|
-
costMode: latestEntry.cost.mode,
|
|
99
|
-
defaultOutputFields: getDefaultSearchesOutputFields(latestEntry.searchesId),
|
|
100
|
-
docPath: latestEntry.docPath,
|
|
101
|
-
entry,
|
|
102
|
-
latestEntry
|
|
103
|
-
};
|
|
104
|
-
}), [rows, aggregates.searchEntriesByBaseSearch]);
|
|
105
|
-
return {
|
|
106
|
-
table,
|
|
107
|
-
cards,
|
|
108
|
-
cardsByCategory: useMemo(() => {
|
|
109
|
-
const groups = /* @__PURE__ */ new Map();
|
|
110
|
-
for (const card of cards) {
|
|
111
|
-
const cats = card.entry.categories ?? [];
|
|
112
|
-
for (const cat of cats) {
|
|
113
|
-
const arr = groups.get(cat);
|
|
114
|
-
if (arr) arr.push(card);
|
|
115
|
-
else groups.set(cat, [card]);
|
|
116
|
-
}
|
|
117
|
-
}
|
|
118
|
-
return Array.from(groups, ([category, group]) => ({
|
|
119
|
-
category,
|
|
120
|
-
cards: group
|
|
121
|
-
}));
|
|
122
|
-
}, [cards]),
|
|
123
|
-
categoryCounts: useMemo(() => {
|
|
124
|
-
const counts = {};
|
|
125
|
-
for (const card of cards) {
|
|
126
|
-
const cats = card.entry.categories ?? [];
|
|
127
|
-
for (const cat of cats) counts[cat] = (counts[cat] ?? 0) + 1;
|
|
128
|
-
}
|
|
129
|
-
return counts;
|
|
130
|
-
}, [cards]),
|
|
131
|
-
baselineCardCount: baselineTableData.length,
|
|
132
|
-
baselineCategoryCounts: useMemo(() => {
|
|
133
|
-
const counts = {};
|
|
134
|
-
for (const entry of baselineTableData) {
|
|
135
|
-
const cats = entry.categories ?? [];
|
|
136
|
-
for (const cat of cats) counts[cat] = (counts[cat] ?? 0) + 1;
|
|
137
|
-
}
|
|
138
|
-
return counts;
|
|
139
|
-
}, [baselineTableData]),
|
|
140
|
-
category,
|
|
141
|
-
setCategory: handleCategoryChange,
|
|
142
|
-
globalFilterInput,
|
|
143
|
-
setGlobalFilterInput,
|
|
144
|
-
addColumnFilter,
|
|
145
|
-
removeColumnFilter,
|
|
146
|
-
resetFilters,
|
|
147
|
-
getColumnFilterValue,
|
|
148
|
-
sortedOutputFieldEntries: aggregates.sortedOutputFieldEntries,
|
|
149
|
-
sortedTagEntries: aggregates.sortedTagEntries,
|
|
150
|
-
sortedProviderEntries: aggregates.sortedProviderEntries,
|
|
151
|
-
searchIdsByOutputField: aggregates.searchIdsByOutputField,
|
|
152
|
-
searchIdsByProvider: aggregates.searchIdsByProvider,
|
|
153
|
-
searchIdsByTag: aggregates.searchIdsByTag
|
|
154
|
-
};
|
|
155
|
-
}
|
|
156
|
-
|
|
157
|
-
//#endregion
|
|
158
|
-
export { useSearchesCatalogTable };
|
|
159
|
-
//# sourceMappingURL=use-searches-catalog-table.mjs.map
|
|
@@ -1 +0,0 @@
|
|
|
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":"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"}
|