fix six-stages clinical menifestation.
This commit is contained in:
parent
2a2c9ebc80
commit
e21b8780dd
|
|
@ -13,6 +13,7 @@ import { Spacing } from "@/theme/spacing";
|
|||
import { ContentLink } from "../../components/navigation/ContentLink";
|
||||
import { parseNavigableContentReference } from "../../utils/content-reference";
|
||||
import { humanizeKey } from "../helpers/value";
|
||||
import { BulletList } from "./BulletList";
|
||||
|
||||
export interface ContentValueProps {
|
||||
value: unknown;
|
||||
|
|
@ -20,6 +21,28 @@ export interface ContentValueProps {
|
|||
emptyText?: string | null;
|
||||
}
|
||||
|
||||
function parseBullets(text: string): string[] {
|
||||
if (text.includes("\n")) {
|
||||
return text
|
||||
.split("\n")
|
||||
.map((s) => s.replace(/^[•\-\*\d+\.]\s*/, "").trim())
|
||||
.filter((s) => s.length > 0);
|
||||
}
|
||||
if (text.includes(";")) {
|
||||
return text
|
||||
.split(";")
|
||||
.map((s) => s.trim().replace(/^and\s+/i, ""))
|
||||
.filter((s) => s.length > 0);
|
||||
}
|
||||
const parts = text.split(/,\s*(?![^()]*\))/);
|
||||
if (parts.length > 1) {
|
||||
return parts
|
||||
.map((s) => s.trim().replace(/\.$/, "").replace(/^and\s+/i, ""))
|
||||
.filter((s) => s.length > 0);
|
||||
}
|
||||
return [text];
|
||||
}
|
||||
|
||||
/**
|
||||
* Reference-aware fallback renderer for arbitrary nested attribute values.
|
||||
*
|
||||
|
|
@ -54,6 +77,10 @@ export function ContentValue({
|
|||
) : null;
|
||||
}
|
||||
|
||||
if (visible.every((item) => typeof item === "string")) {
|
||||
return <BulletList items={visible as string[]} />;
|
||||
}
|
||||
|
||||
return (
|
||||
<View style={styles.stack}>
|
||||
{visible.map((item, index) => (
|
||||
|
|
@ -84,12 +111,32 @@ export function ContentValue({
|
|||
|
||||
return (
|
||||
<View style={styles.object}>
|
||||
{entries.map(([key, child]) => (
|
||||
<View key={key} style={styles.objectRow}>
|
||||
<Text style={styles.objectLabel}>{humanizeKey(key)}</Text>
|
||||
<ContentValue value={child} textStyle={textStyle} />
|
||||
</View>
|
||||
))}
|
||||
{entries.map(([key, child]) => {
|
||||
const isClinical =
|
||||
key.toLowerCase().includes("clinical") ||
|
||||
key.toLowerCase().includes("manifestation");
|
||||
|
||||
const renderChild = () => {
|
||||
if (
|
||||
isClinical &&
|
||||
typeof child === "string" &&
|
||||
child.trim().length > 0
|
||||
) {
|
||||
const bullets = parseBullets(child);
|
||||
if (bullets.length > 1) {
|
||||
return <BulletList items={bullets} />;
|
||||
}
|
||||
}
|
||||
return <ContentValue value={child} textStyle={textStyle} />;
|
||||
};
|
||||
|
||||
return (
|
||||
<View key={key} style={styles.objectRow}>
|
||||
<Text style={styles.objectLabel}>{humanizeKey(key)}</Text>
|
||||
{renderChild()}
|
||||
</View>
|
||||
);
|
||||
})}
|
||||
</View>
|
||||
);
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue