UNPKG

@finos/legend-application-marketplace

Version:
20 lines 2.67 kB
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime"; import { CheckIcon, TimesIcon, CaretRightIcon } from '@finos/legend-art'; import { unwrapProductDetails, } from '../../stores/ai/LegendMarketplaceAIChatStore.js'; const DESCRIPTION_TRUNCATION_LENGTH = 120; const UNKNOWN_PRODUCT_LABEL = 'Unknown Product'; export const MarketplaceAIProductCards = (props) => { const { products, scoredCandidates, onSelect } = props; return (_jsx("div", { className: "legend-ai__product-cards", children: products.map((product, idx) => { const candidate = scoredCandidates?.[idx]; const hasFieldInfo = candidate && (candidate.matchedFields.length > 0 || candidate.missingFields.length > 0); const { groupId, artifactId } = unwrapProductDetails(product); return (_jsxs("button", { type: "button", className: "legend-ai__product-card", onClick: () => onSelect(product), children: [_jsx("div", { className: "legend-ai__product-card-title", children: product.dataProductTitle ?? UNKNOWN_PRODUCT_LABEL }), product.dataProductDescription && (_jsx("div", { className: "legend-ai__product-card-desc", children: product.dataProductDescription.length > DESCRIPTION_TRUNCATION_LENGTH ? `${product.dataProductDescription.slice(0, DESCRIPTION_TRUNCATION_LENGTH)}...` : product.dataProductDescription })), hasFieldInfo && (_jsxs("div", { className: "legend-ai__product-card-fields", children: [candidate.matchedFields.map((f) => (_jsxs("span", { className: "legend-ai__product-card-field legend-ai__product-card-field--matched", children: [f, " ", _jsx(CheckIcon, {})] }, f))), candidate.missingFields.map((f) => (_jsxs("span", { className: "legend-ai__product-card-field legend-ai__product-card-field--missing", children: [f, " ", _jsx(TimesIcon, {})] }, f)))] })), _jsxs("div", { className: "legend-ai__product-card-meta", children: [candidate ? (_jsxs("span", { className: "legend-ai__product-card-score", children: ["Score: ", (candidate.compositeScore * 100).toFixed(0), "%"] })) : (product.similarity > 0 && (_jsxs("span", { className: "legend-ai__product-card-score", children: ["Match: ", (product.similarity * 100).toFixed(0), "%"] }))), product.tags1.length > 0 && (_jsx("span", { className: "legend-ai__product-card-tags", children: product.tags1.slice(0, 3).join(', ') }))] }), _jsxs("div", { className: "legend-ai__product-card-action", children: ["Use this product ", _jsx(CaretRightIcon, {})] })] }, `${groupId}:${artifactId}`)); }) })); }; //# sourceMappingURL=MarketplaceAIProductCards.js.map