( stringValue: string, isHighlighted: boolean, textSize: "text-xs" | "text-sm" | "text-base" | "text-lg" = "text-base", matches?: Array<Match>, maxLength: number = 68 )
| 413 | } |
| 414 | |
| 415 | function createOutputForMatch( |
| 416 | stringValue: string, |
| 417 | isHighlighted: boolean, |
| 418 | textSize: "text-xs" | "text-sm" | "text-base" | "text-lg" = "text-base", |
| 419 | matches?: Array<Match>, |
| 420 | maxLength: number = 68 |
| 421 | ): JSX.Element { |
| 422 | if (!matches || matches.length === 0) { |
| 423 | return <>{truncate(stringValue, { length: maxLength })}</>; |
| 424 | } |
| 425 | |
| 426 | const stringSlices = getStringSlices(stringValue, matches, maxLength); |
| 427 | |
| 428 | return ( |
| 429 | <> |
| 430 | {stringSlices.map((s, index) => { |
| 431 | return ( |
| 432 | <span |
| 433 | key={index} |
| 434 | className={ |
| 435 | s.isMatch |
| 436 | ? classnames( |
| 437 | textSize, |
| 438 | isHighlighted |
| 439 | ? "text-white underline underline-offset-1" |
| 440 | : "text-indigo-600 dark:text-indigo-400" |
| 441 | ) |
| 442 | : "" |
| 443 | } |
| 444 | > |
| 445 | {s.slice} |
| 446 | </span> |
| 447 | ); |
| 448 | })} |
| 449 | </> |
| 450 | ); |
| 451 | } |
no test coverage detected