@tscircuit/schematic-viewer 2.0.86 → 2.0.88

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/dist/index.js CHANGED
@@ -449,9 +449,13 @@ var humanizeComponentType = (ftype) => {
449
449
  };
450
450
  var getComponentDetail = (sourceComponent, schematicComponent, primaryLabel) => {
451
451
  const componentType = humanizeComponentType(sourceComponent?.ftype);
452
- let displayName;
453
- if (sourceComponent?.display_name !== primaryLabel) {
454
- displayName = sourceComponent?.display_name;
452
+ let componentDescription = componentType;
453
+ if (sourceComponent?.ftype === "simple_chip" && sourceComponent.manufacturer_part_number) {
454
+ componentDescription = sourceComponent.manufacturer_part_number;
455
+ }
456
+ const detailParts = [];
457
+ if (sourceComponent?.display_name === primaryLabel && sourceComponent.name !== primaryLabel) {
458
+ detailParts.push(sourceComponent.name);
455
459
  }
456
460
  let componentValue = sourceComponent?.display_value;
457
461
  if (!componentValue && sourceComponent) {
@@ -472,10 +476,17 @@ var getComponentDetail = (sourceComponent, schematicComponent, primaryLabel) =>
472
476
  }
473
477
  }
474
478
  componentValue ?? (componentValue = schematicComponent.symbol_display_value);
475
- if (componentType && componentValue) {
476
- return `${componentType} \xB7 ${componentValue}`;
479
+ if (componentDescription) {
480
+ detailParts.push(componentDescription);
481
+ }
482
+ if (componentValue) {
483
+ detailParts.push(componentValue);
477
484
  }
478
- return componentValue ?? displayName ?? sourceComponent?.manufacturer_part_number ?? componentType;
485
+ if (!componentDescription && !componentValue && sourceComponent?.manufacturer_part_number) {
486
+ detailParts.push(sourceComponent.manufacturer_part_number);
487
+ }
488
+ if (detailParts.length === 0) return void 0;
489
+ return detailParts.join(" \xB7 ");
479
490
  };
480
491
  var isSourceComponent = (element) => element.type === "source_component" && "source_component_id" in element;
481
492
  var isSourcePort = (element) => element.type === "source_port";
@@ -509,10 +520,14 @@ var getSchematicSearchResults = (circuitJson, query) => {
509
520
  const resultScores = /* @__PURE__ */ new Map();
510
521
  for (const component of circuitJson.filter(isSchematicComponent)) {
511
522
  const sourceComponent = component.source_component_id ? sourceComponents.get(component.source_component_id) : void 0;
512
- const primaryLabel = sourceComponent?.name ?? sourceComponent?.display_name ?? "Component";
523
+ const primaryLabel = sourceComponent?.display_name ?? sourceComponent?.name ?? "Component";
513
524
  const componentScore = Math.min(
514
- getTextMatchScore(primaryLabel, normalizedQuery),
515
- getTextMatchScore(sourceComponent?.display_name, normalizedQuery)
525
+ getTextMatchScore(sourceComponent?.name, normalizedQuery),
526
+ getTextMatchScore(sourceComponent?.display_name, normalizedQuery),
527
+ getTextMatchScore(
528
+ sourceComponent?.manufacturer_part_number,
529
+ normalizedQuery
530
+ )
516
531
  );
517
532
  if (Number.isFinite(componentScore)) {
518
533
  const result = {
@@ -2480,7 +2495,7 @@ import { useMemo as useMemo5 } from "react";
2480
2495
  // package.json
2481
2496
  var package_default = {
2482
2497
  name: "@tscircuit/schematic-viewer",
2483
- version: "2.0.85",
2498
+ version: "2.0.87",
2484
2499
  repository: {
2485
2500
  type: "git",
2486
2501
  url: "https://github.com/tscircuit/schematic-viewer"