Compare commits

..

No commits in common. "98efd5899da681e913113453950986b7de8bb86a" and "aaa23fedfe0d3152c770636ae68f7f2a199dc1f0" have entirely different histories.

15 changed files with 153 additions and 504 deletions

View File

@ -4,7 +4,7 @@ import { Ionicons } from "@expo/vector-icons";
import { moderateScale, verticalScale } from "react-native-size-matters"; import { moderateScale, verticalScale } from "react-native-size-matters";
import { Colors } from "@/theme"; import { Colors } from "@/theme";
import { asNumber, asString, asStringArray, humanizeKey } from "../helpers/value"; import { asNumber, asString, asStringArray } from "../helpers/value";
import { CollectionScaffold } from "../shared/CollectionScaffold"; import { CollectionScaffold } from "../shared/CollectionScaffold";
import { ContentCountBadge } from "../shared/ContentCountBadge"; import { ContentCountBadge } from "../shared/ContentCountBadge";
import type { import type {
@ -21,33 +21,15 @@ export function ModuleCatalogCardRenderer({
onPress, onPress,
}: CollectionItemRendererProps) { }: CollectionItemRendererProps) {
const attributes = item.attributes; const attributes = item.attributes;
const rawTitle = asString(attributes.name) || item.title; const title = asString(attributes.name) || item.title;
const parenMatch = rawTitle.match(/^(.*?)\s*\(([^()]+)\)\s*(.*?)$/); const subtitle =
const title = parenMatch
? [parenMatch[1], parenMatch[3]].filter(Boolean).join(" ").trim()
: rawTitle;
const parenSubtitle = parenMatch ? parenMatch[2].trim() : null;
const rawLabel =
parenSubtitle ||
asString(attributes.sub_title) || asString(attributes.sub_title) ||
asString(attributes.subtitle) || asString(attributes.subtitle) ||
(asStringArray(attributes.alt_name).length > 0 (asStringArray(attributes.alt_name).length > 0
? asStringArray(attributes.alt_name).join(", ") ? asStringArray(attributes.alt_name).join(", ")
: asString(attributes.alt_name)) || : asString(attributes.alt_name)) ||
asString(attributes.pattern_category) ||
asString(attributes.category) ||
asString(attributes.classification) ||
(asString(attributes.title) && asString(attributes.title) !== title
? asString(attributes.title)
: null) ||
asString(attributes.description) ||
item.summary ||
null; null;
const cleanTitle = humanizeKey(title);
const label = rawLabel ? humanizeKey(rawLabel) : null;
return ( return (
<Pressable <Pressable
accessibilityRole="button" accessibilityRole="button"
@ -59,10 +41,10 @@ export function ModuleCatalogCardRenderer({
</View> </View>
<View style={styles.textContainer}> <View style={styles.textContainer}>
<Text style={styles.title}>{cleanTitle}</Text> <Text style={styles.title}>{title}</Text>
{label ? ( {subtitle ? (
<Text numberOfLines={2} style={styles.subtitle}> <Text numberOfLines={2} style={styles.subtitle}>
{label} {subtitle}
</Text> </Text>
) : null} ) : null}
</View> </View>

View File

@ -1,145 +0,0 @@
import React from "react";
import { Pressable, StyleSheet, Text, View } from "react-native";
import { Ionicons } from "@expo/vector-icons";
import { moderateScale, verticalScale } from "react-native-size-matters";
import { Colors } from "@/theme";
import { asNumber, asString, humanizeKey } from "../helpers/value";
import { CollectionScaffold } from "../shared/CollectionScaffold";
import { SectionCard } from "../shared/SectionCard";
import type {
CollectionItemRendererProps,
CollectionRendererProps,
} from "../../types/renderer.types";
export function SixStagesCollectionRenderer(props: CollectionRendererProps) {
const overviewText = asString(props.items[0]?.attributes.stage_overview).trim();
const header = overviewText ? (
<View style={styles.overviewContainer}>
<SectionCard title="Overview" defaultExpanded={true}>
<Text style={styles.overviewText}>{overviewText}</Text>
</SectionCard>
</View>
) : null;
return (
<CollectionScaffold
{...props}
header={header}
/>
);
}
export function SixStagesCardRenderer({
item,
onPress,
}: CollectionItemRendererProps) {
const attributes = item.attributes;
const rawTitle = asString(attributes.name) || item.title;
const parenMatch = rawTitle.match(/^(.*?)\s*\(([^()]+)\)\s*(.*?)$/);
const title = parenMatch
? [parenMatch[1], parenMatch[3]].filter(Boolean).join(" ").trim()
: rawTitle;
const parenSubtitle = parenMatch ? parenMatch[2].trim() : null;
const label =
parenSubtitle ||
asString(attributes.sub_title) ||
null;
const cleanTitle = humanizeKey(title);
const cleanLabel = label ? humanizeKey(label) : null;
const count = asNumber(attributes.content_count);
const rawContentLabel = asString(attributes.content_label);
const contentLabel = rawContentLabel ? humanizeKey(rawContentLabel) : null;
const badgeText =
count !== null && count > 0 && contentLabel
? `${count} ${contentLabel}`
: contentLabel || (count !== null ? `${count}` : null);
return (
<Pressable
accessibilityRole="button"
onPress={onPress}
style={({ pressed }) => [styles.row, pressed && styles.pressed]}
>
<View style={styles.iconWrapper}>
<Ionicons name="book-outline" size={22} color={Colors.primary} />
</View>
<View style={styles.textContainer}>
<Text style={styles.title}>{cleanTitle}</Text>
{cleanLabel ? (
<Text style={styles.description} numberOfLines={1}>
{cleanLabel}
</Text>
) : null}
</View>
{badgeText ? (
<View style={styles.badge}>
<Text style={styles.badgeText}>{badgeText}</Text>
</View>
) : null}
<Ionicons name="chevron-forward" size={20} color="#9CA3AF" />
</Pressable>
);
}
const styles = StyleSheet.create({
overviewContainer: {
marginBottom: verticalScale(14),
},
overviewText: {
fontSize: moderateScale(14),
lineHeight: moderateScale(22),
color: "#374151",
},
row: {
minHeight: moderateScale(68),
flexDirection: "row",
alignItems: "center",
padding: moderateScale(14),
},
pressed: {
opacity: 0.72,
},
iconWrapper: {
width: moderateScale(40),
height: moderateScale(40),
borderRadius: moderateScale(20),
justifyContent: "center",
alignItems: "center",
backgroundColor: "#E8F5E9",
},
textContainer: {
flex: 1,
marginLeft: moderateScale(12),
marginRight: moderateScale(10),
},
title: {
fontSize: moderateScale(15),
fontWeight: "600",
color: Colors.textPrimary,
marginBottom: verticalScale(2),
},
description: {
fontSize: moderateScale(12),
color: Colors.textSecondary,
},
badge: {
backgroundColor: "#F3F4F6",
borderRadius: moderateScale(12),
paddingHorizontal: moderateScale(9),
paddingVertical: verticalScale(5),
marginRight: moderateScale(8),
},
badgeText: {
fontSize: moderateScale(11),
fontWeight: "700",
color: Colors.textSecondary,
},
});

View File

@ -38,7 +38,7 @@ function RelationshipRow({ label, value, chips = false }: RelationshipRowProps)
return ( return (
<View style={styles.relationshipRow}> <View style={styles.relationshipRow}>
<Text style={styles.relationshipLabel}>{label}</Text> <Text style={styles.relationshipLabel}>{label}</Text>
{chips ? <ReferenceChipList value={value} asBulletList={false} /> : <ContentValue value={value} />} {chips ? <ReferenceChipList value={value} /> : <ContentValue value={value} />}
</View> </View>
); );
} }
@ -179,11 +179,7 @@ export function EovDetailRenderer({
order: orderFor("treatment", 140), order: orderFor("treatment", 140),
render: () => ( render: () => (
<SectionCard title="Treatment"> <SectionCard title="Treatment">
{typeof data.treatment === "object" ? (
<ContentValue value={data.treatment} />
) : (
<Text style={styles.pathway}>{asString(data.treatment)}</Text> <Text style={styles.pathway}>{asString(data.treatment)}</Text>
)}
</SectionCard> </SectionCard>
), ),
}); });

View File

@ -8,8 +8,6 @@ import { Colors } from "@/theme";
import type { DetailRendererProps } from "../../types/renderer.types"; import type { DetailRendererProps } from "../../types/renderer.types";
import { ContentLinkAttributeSections } from "../shared/ContentLinkAttributeSections"; import { ContentLinkAttributeSections } from "../shared/ContentLinkAttributeSections";
import { Hero } from "../shared/Hero"; import { Hero } from "../shared/Hero";
import { Paragraphs } from "../shared/Paragraphs";
import { SectionCard } from "../shared/SectionCard";
import { asRecordArray, asString, asStringArray } from "../helpers/value"; import { asRecordArray, asString, asStringArray } from "../helpers/value";
function resolveSequenceTargetTemplate( function resolveSequenceTargetTemplate(
@ -197,23 +195,37 @@ export function FiveElementsDetailRenderer({
</View> </View>
) : null} ) : null}
{/* Collapsible Pattern Cards from data.sections */} {/* Numbered Pattern Cards from data.sections */}
{rawSections.length > 0 ? (
<View style={styles.sectionsContainer}>
<Text style={styles.sectionHeading}>Patterns & Manifestations</Text>
{rawSections.map((sec, idx) => { {rawSections.map((sec, idx) => {
const sectionTitle = asString(sec.title) || `Pattern ${idx + 1}`; const sectionTitle = asString(sec.title) || `Pattern ${idx + 1}`;
const sectionContent = extractParagraphs(sec.content); const sectionContent = extractParagraphs(sec.content);
return ( return (
<SectionCard <View key={idx} style={styles.patternCard}>
key={idx} <View style={styles.patternHeader}>
title={sectionTitle} <View style={styles.numberBadge}>
defaultExpanded={false} <Text style={styles.numberText}>{idx + 1}</Text>
> </View>
<Text style={styles.patternTitle}>{sectionTitle}</Text>
</View>
{sectionContent.length > 0 ? ( {sectionContent.length > 0 ? (
<Paragraphs items={sectionContent} /> <View style={styles.patternBody}>
{sectionContent.map((text, cIdx) => (
<Text key={cIdx} style={styles.contentText}>
{text}
</Text>
))}
</View>
) : null} ) : null}
</SectionCard> </View>
); );
})} })}
</View>
) : null}
<ContentLinkAttributeSections <ContentLinkAttributeSections
data={data} data={data}

View File

@ -13,7 +13,6 @@ import {
import { asRecord, asString, asStringArray } from "../helpers/value"; import { asRecord, asString, asStringArray } from "../helpers/value";
import { BulletList } from "../shared/BulletList"; import { BulletList } from "../shared/BulletList";
import { ContentLinkAttributeSections } from "../shared/ContentLinkAttributeSections"; import { ContentLinkAttributeSections } from "../shared/ContentLinkAttributeSections";
import { ContentValue } from "../shared/ContentValue";
import { Hero } from "../shared/Hero"; import { Hero } from "../shared/Hero";
import { Paragraphs } from "../shared/Paragraphs"; import { Paragraphs } from "../shared/Paragraphs";
import { SectionCard } from "../shared/SectionCard"; import { SectionCard } from "../shared/SectionCard";
@ -94,12 +93,9 @@ export function FourLevelsDetailRenderer({
const tongue = asString(data.tongue); const tongue = asString(data.tongue);
const pulse = asString(data.pulse); const pulse = asString(data.pulse);
const pathology = asString(data.pathology); const pathology = asString(data.pathology);
const treatmentPrincipleRaw = const treatmentPrinciple =
data.treatment_principle ?? data["treatment principle"]; asString(data.treatment_principle) ||
const treatmentPrincipleItems = asStringArray(treatmentPrincipleRaw).filter( asString(data["treatment principle"]);
(item) => item.trim().length > 0,
);
const treatmentPrinciple = asString(treatmentPrincipleRaw);
const treatment = asString(data.treatment); const treatment = asString(data.treatment);
const treatmentBullets = parseTreatmentBullets(treatment); const treatmentBullets = parseTreatmentBullets(treatment);
const explanation = asString(data.explanation); const explanation = asString(data.explanation);
@ -234,21 +230,15 @@ export function FourLevelsDetailRenderer({
</SectionCard> </SectionCard>
) : null} ) : null}
{treatmentPrincipleItems.length > 0 ? ( {treatmentPrinciple ? (
<SectionCard title="Treatment Principle">
<BulletList items={treatmentPrincipleItems} />
</SectionCard>
) : treatmentPrinciple ? (
<SectionCard title="Treatment Principle"> <SectionCard title="Treatment Principle">
<Paragraphs items={[treatmentPrinciple]} /> <Paragraphs items={[treatmentPrinciple]} />
</SectionCard> </SectionCard>
) : null} ) : null}
{data.treatment ? ( {treatment ? (
<SectionCard title="Treatment"> <SectionCard title="Treatment">
{typeof data.treatment === "object" ? ( {treatmentBullets.length > 0 ? (
<ContentValue value={data.treatment} />
) : treatmentBullets.length > 0 ? (
<BulletList items={treatmentBullets} /> <BulletList items={treatmentBullets} />
) : ( ) : (
<Paragraphs items={[treatment]} /> <Paragraphs items={[treatment]} />

View File

@ -1,13 +1,8 @@
import React, { useMemo } from "react"; import React from "react";
import { ScrollView, StyleSheet } from "react-native"; import { ScrollView, StyleSheet } from "react-native";
import type { DetailRendererProps } from "../../types/renderer.types"; import type { DetailRendererProps } from "../../types/renderer.types";
import { asString, humanizeKey } from "../helpers/value"; import { asString, humanizeKey } from "../helpers/value";
import {
findAttributePresentationRule,
isEmptyValue,
presentationDisplayOrder,
} from "../../utils/attribute-presentation";
import { ContentLinkAttributeSections } from "../shared/ContentLinkAttributeSections"; import { ContentLinkAttributeSections } from "../shared/ContentLinkAttributeSections";
import { ContentValue } from "../shared/ContentValue"; import { ContentValue } from "../shared/ContentValue";
import { Hero } from "../shared/Hero"; import { Hero } from "../shared/Hero";
@ -24,43 +19,18 @@ const CATALOG_METADATA_KEYS = new Set([
"link", "link",
"point_images", "point_images",
"default_image_id", "default_image_id",
"stage_overview",
]); ]);
export function SixStagesDetailRenderer({ export function SixStagesDetailRenderer({
content, content,
data, data,
definitions,
presentationAttributes, presentationAttributes,
}: DetailRendererProps) { }: DetailRendererProps) {
const rawTitle = const title =
asString(data.name) || asString(data.name) ||
asString(data.title) || asString(data.title) ||
content.title || content.title ||
"Six Stages"; "Six Stages";
const title = humanizeKey(rawTitle);
const orderedSections = useMemo(() => {
const definitionByLabel = new Map(
(definitions ?? []).map((d) => [d.code, d.label]),
);
return Object.entries(data)
.filter(
([key, value]) =>
!RESERVED_KEYS.has(key) &&
!CATALOG_METADATA_KEYS.has(key) &&
!isEmptyValue(value),
)
.map(([key, value]) => {
const rule = findAttributePresentationRule(key, presentationAttributes);
const order = presentationDisplayOrder(rule);
const rawLabel = definitionByLabel.get(key) || key;
const label = humanizeKey(rawLabel);
return { key, value, order, label };
})
.sort((a, b) => a.order - b.order || a.label.localeCompare(b.label));
}, [data, definitions, presentationAttributes]);
return ( return (
<ScrollView <ScrollView
@ -69,8 +39,10 @@ export function SixStagesDetailRenderer({
> >
<Hero title={title} subtitle={content.summary ?? undefined} /> <Hero title={title} subtitle={content.summary ?? undefined} />
{orderedSections.map(({ key, value, label }) => ( {Object.entries(data)
<SectionCard key={key} title={label}> .filter(([key]) => !RESERVED_KEYS.has(key) && !CATALOG_METADATA_KEYS.has(key))
.map(([key, value]) => (
<SectionCard key={key} title={humanizeKey(key)}>
<ContentValue value={value} /> <ContentValue value={value} />
</SectionCard> </SectionCard>
))} ))}

View File

@ -1,60 +1,25 @@
import React, { useMemo } from "react"; import React from "react";
import { ScrollView, StyleSheet } from "react-native"; import { ScrollView, StyleSheet } from "react-native";
import type { DetailRendererProps } from "../../types/renderer.types"; import type { DetailRendererProps } from "../../types/renderer.types";
import { asString, humanizeKey } from "../helpers/value"; import { asString, humanizeKey } from "../helpers/value";
import {
findAttributePresentationRule,
isEmptyValue,
presentationDisplayOrder,
} from "../../utils/attribute-presentation";
import { ContentLinkAttributeSections } from "../shared/ContentLinkAttributeSections"; import { ContentLinkAttributeSections } from "../shared/ContentLinkAttributeSections";
import { ContentValue } from "../shared/ContentValue"; import { ContentValue } from "../shared/ContentValue";
import { Hero } from "../shared/Hero"; import { Hero } from "../shared/Hero";
import { SectionCard } from "../shared/SectionCard"; import { SectionCard } from "../shared/SectionCard";
const RESERVED_KEYS = new Set([ const EXCLUDED_KEYS = new Set(["code"]);
"id",
"name",
"title",
"code",
"sort_order",
"link",
]);
export function TcmPatternDetailRenderer({ export function TcmPatternDetailRenderer({
content, content,
data, data,
definitions,
presentationAttributes, presentationAttributes,
}: DetailRendererProps) { }: DetailRendererProps) {
const rawTitle = const title =
asString(data.name) || asString(data.name) ||
asString(data.title) || asString(data.title) ||
content.title || content.title ||
"TCM Pattern"; "TCM Pattern";
const title = humanizeKey(rawTitle);
const orderedSections = useMemo(() => {
const definitionByLabel = new Map(
(definitions ?? []).map((d) => [d.code, d.label]),
);
return Object.entries(data)
.filter(
([key, value]) =>
!RESERVED_KEYS.has(key) &&
!isEmptyValue(value),
)
.map(([key, value]) => {
const rule = findAttributePresentationRule(key, presentationAttributes);
const order = presentationDisplayOrder(rule);
const rawLabel = definitionByLabel.get(key) || key;
const label = humanizeKey(rawLabel);
return { key, value, order, label };
})
.sort((a, b) => a.order - b.order || a.label.localeCompare(b.label));
}, [data, definitions, presentationAttributes]);
return ( return (
<ScrollView <ScrollView
@ -63,8 +28,10 @@ export function TcmPatternDetailRenderer({
> >
<Hero title={title} subtitle={content.summary ?? undefined} /> <Hero title={title} subtitle={content.summary ?? undefined} />
{orderedSections.map(({ key, value, label }) => ( {Object.entries(data)
<SectionCard key={key} title={label}> .filter(([key]) => !EXCLUDED_KEYS.has(key))
.map(([key, value]) => (
<SectionCard key={key} title={humanizeKey(key)}>
<ContentValue value={value} /> <ContentValue value={value} />
</SectionCard> </SectionCard>
))} ))}

View File

@ -10,7 +10,6 @@ import { Hero } from "../shared/Hero";
import { SectionCard } from "../shared/SectionCard"; import { SectionCard } from "../shared/SectionCard";
import { Paragraphs } from "../shared/Paragraphs"; import { Paragraphs } from "../shared/Paragraphs";
import { BulletList } from "../shared/BulletList"; import { BulletList } from "../shared/BulletList";
import { ContentValue } from "../shared/ContentValue";
import { asString, asStringArray } from "../helpers/value"; import { asString, asStringArray } from "../helpers/value";
import { useContentSearchInfiniteQuery } from "../../hooks/use-content-search-infinite-query"; import { useContentSearchInfiniteQuery } from "../../hooks/use-content-search-infinite-query";
@ -19,8 +18,7 @@ interface PatternData {
code?: string; code?: string;
clinicalManifestation?: string | string[]; clinicalManifestation?: string | string[];
pathology?: string; pathology?: string;
treatmentPrinciple?: string | string[]; treatment?: string;
treatment?: unknown;
} }
function parseBullets(raw: unknown): string[] { function parseBullets(raw: unknown): string[] {
@ -238,20 +236,14 @@ export function ThreeBurnersDetailRenderer({
const clinical = parseBullets(clinicalRaw); const clinical = parseBullets(clinicalRaw);
const pathology = asString(a.pathology); const pathology = asString(a.pathology);
const treatmentPrincipleRaw = const treatment = asString(a.treatment);
a.treatment_principle ??
a["treatment principle"] ??
a.treatmentPrinciple;
const treatmentPrinciple = parseBullets(treatmentPrincipleRaw);
const treatment = a.treatment ?? a["treatment"];
map.set(normalizeKey(name), { map.set(normalizeKey(name), {
name, name,
code: asString(a.code) || undefined, code: asString(a.code) || undefined,
clinicalManifestation: clinical.length > 0 ? clinical : undefined, clinicalManifestation: clinical.length > 0 ? clinical : undefined,
pathology: pathology || undefined, pathology: pathology || undefined,
treatmentPrinciple: treatmentPrinciple.length > 0 ? treatmentPrinciple : undefined, treatment: treatment || undefined,
treatment: treatment ?? undefined,
}); });
} }
@ -292,19 +284,13 @@ export function ThreeBurnersDetailRenderer({
data.clinical_manifestation; data.clinical_manifestation;
const clinical = parseBullets(clinicalRaw); const clinical = parseBullets(clinicalRaw);
const treatmentPrincipleRaw =
data.treatment_principle ??
data["treatment principle"] ??
data.treatmentPrinciple;
const treatmentPrinciple = parseBullets(treatmentPrincipleRaw);
return { return {
name, name,
code: asString(data.code) || undefined, code: asString(data.code) || undefined,
clinicalManifestation: clinical.length > 0 ? clinical : undefined, clinicalManifestation: clinical.length > 0 ? clinical : undefined,
pathology: asString(data.pathology) || undefined, pathology: asString(data.pathology) || undefined,
treatmentPrinciple: treatmentPrinciple.length > 0 ? treatmentPrinciple : undefined, treatment: asString(data.treatment) || undefined,
treatment: data.treatment ?? undefined,
}; };
} }
@ -337,20 +323,9 @@ export function ThreeBurnersDetailRenderer({
// SCREEN 3: Pattern Leaf Detail Screen // SCREEN 3: Pattern Leaf Detail Screen
// ---------------------------------------------------- // ----------------------------------------------------
if (activePatternData && (selectedPatternName || isDirectLeafPattern)) { if (activePatternData && (selectedPatternName || isDirectLeafPattern)) {
const treatmentRaw = activePatternData.treatment; const { principles, acupuncture } = parseTreatment(
const { principles, acupuncture } = activePatternData.treatment || "",
typeof treatmentRaw === "string" );
? parseTreatment(treatmentRaw)
: { principles: [], acupuncture: [] };
const rawPrinciples =
activePatternData.treatmentPrinciple &&
(Array.isArray(activePatternData.treatmentPrinciple)
? activePatternData.treatmentPrinciple
: parseBullets(activePatternData.treatmentPrinciple));
const allPrinciples =
rawPrinciples && rawPrinciples.length > 0 ? rawPrinciples : principles;
return ( return (
<ScrollView <ScrollView
@ -359,14 +334,7 @@ export function ThreeBurnersDetailRenderer({
> >
<Hero title={activePatternData.name} /> <Hero title={activePatternData.name} />
{/* 1. Pathology Card */} {/* 1. Clinical Manifestations Card */}
{activePatternData.pathology ? (
<SectionCard title="Pathology">
<Paragraphs items={[activePatternData.pathology]} />
</SectionCard>
) : null}
{/* 2. Clinical Manifestations Card */}
{activePatternData.clinicalManifestation ? ( {activePatternData.clinicalManifestation ? (
<SectionCard title="Clinical Manifestations"> <SectionCard title="Clinical Manifestations">
<BulletList <BulletList
@ -379,21 +347,41 @@ export function ThreeBurnersDetailRenderer({
</SectionCard> </SectionCard>
) : null} ) : null}
{/* 3. Treatment Principle Card */} {/* 2. Pathology Card */}
{allPrinciples && allPrinciples.length > 0 ? ( {activePatternData.pathology ? (
<SectionCard title="Treatment Principle"> <SectionCard title="Pathology">
<BulletList items={allPrinciples} /> <Paragraphs items={[activePatternData.pathology]} />
</SectionCard> </SectionCard>
) : null} ) : null}
{/* 4. Treatment Card */} {/* 3. Treatment Card */}
{treatmentRaw ? ( {activePatternData.treatment ? (
<SectionCard title="Treatment"> <SectionCard title="Treatment">
{typeof treatmentRaw === "object" ? ( {principles.length > 0 ? (
<ContentValue value={treatmentRaw} /> <View style={styles.subSection}>
) : ( <Text style={styles.subSectionTitle}>Treatment Principle:</Text>
<Paragraphs items={[acupuncture.length > 0 ? acupuncture.join("\n") : String(treatmentRaw)]} /> {principles.map((p, i) => (
)} <Text key={i} style={styles.bulletItem}>
• {p}
</Text>
))}
</View>
) : null}
{acupuncture.length > 0 ? (
<View style={[styles.subSection, principles.length > 0 && styles.subSectionSpacing]}>
<Text style={styles.subSectionTitle}>Acupuncture Points:</Text>
{acupuncture.map((a, i) => (
<Text key={i} style={styles.bodyText}>
{a}
</Text>
))}
</View>
) : null}
{principles.length === 0 && acupuncture.length === 0 ? (
<Paragraphs items={[activePatternData.treatment]} />
) : null}
</SectionCard> </SectionCard>
) : null} ) : null}
@ -604,9 +592,6 @@ const styles = StyleSheet.create({
}, },
subSectionSpacing: { subSectionSpacing: {
marginTop: verticalScale(12), marginTop: verticalScale(12),
paddingTop: verticalScale(12),
borderTopWidth: StyleSheet.hairlineWidth,
borderTopColor: "#E8ECEF",
}, },
subSectionTitle: { subSectionTitle: {
fontSize: moderateScale(13), fontSize: moderateScale(13),

View File

@ -488,7 +488,7 @@ export function TwelveChannelsDetailRenderer({
{(connecting as ConnectingChannelDetails).empty && {(connecting as ConnectingChannelDetails).empty &&
(connecting as ConnectingChannelDetails).empty!.length > 0 ? ( (connecting as ConnectingChannelDetails).empty!.length > 0 ? (
<View style={styles.conditionBlock}> <View style={[styles.conditionBlock, { marginTop: moderateScale(10) }]}>
<View style={styles.conditionHeader}> <View style={styles.conditionHeader}>
<View style={[styles.conditionDot, { backgroundColor: "#3B82F6" }]} /> <View style={[styles.conditionDot, { backgroundColor: "#3B82F6" }]} />
<Text style={styles.conditionTitle}>Empty Condition</Text> <Text style={styles.conditionTitle}>Empty Condition</Text>
@ -753,8 +753,7 @@ const styles = StyleSheet.create({
container: { container: {
paddingHorizontal: moderateScale(16), paddingHorizontal: moderateScale(16),
paddingTop: verticalScale(14), paddingTop: verticalScale(14),
paddingBottom: verticalScale(40), paddingBottom: verticalScale(36),
gap: verticalScale(14),
}, },
overviewCard: { overviewCard: {
backgroundColor: "#F0FDF4", backgroundColor: "#F0FDF4",
@ -762,6 +761,7 @@ const styles = StyleSheet.create({
borderWidth: 1, borderWidth: 1,
borderColor: "#DCFCE7", borderColor: "#DCFCE7",
padding: moderateScale(16), padding: moderateScale(16),
marginBottom: verticalScale(14),
}, },
overviewHeader: { overviewHeader: {
flexDirection: "row", flexDirection: "row",
@ -785,6 +785,7 @@ const styles = StyleSheet.create({
borderWidth: 1, borderWidth: 1,
borderColor: "#E5E7EB", borderColor: "#E5E7EB",
padding: moderateScale(14), padding: moderateScale(14),
marginBottom: verticalScale(14),
}, },
infoHeader: { infoHeader: {
flexDirection: "row", flexDirection: "row",
@ -890,6 +891,7 @@ const styles = StyleSheet.create({
borderWidth: 1, borderWidth: 1,
borderColor: "#E2E8F0", borderColor: "#E2E8F0",
padding: moderateScale(14), padding: moderateScale(14),
marginBottom: verticalScale(14),
}, },
summaryHeader: { summaryHeader: {
flexDirection: "row", flexDirection: "row",
@ -909,12 +911,13 @@ const styles = StyleSheet.create({
lineHeight: moderateScale(19), lineHeight: moderateScale(19),
}, },
channelsContainer: { channelsContainer: {
gap: verticalScale(10), marginTop: verticalScale(10),
}, },
sectionHeading: { sectionHeading: {
fontSize: moderateScale(16), fontSize: moderateScale(16),
fontWeight: "700", fontWeight: "700",
color: Colors.textPrimary, color: Colors.textPrimary,
marginBottom: verticalScale(12),
marginLeft: moderateScale(2), marginLeft: moderateScale(2),
}, },
channelRow: { channelRow: {
@ -927,6 +930,7 @@ const styles = StyleSheet.create({
borderRadius: moderateScale(14), borderRadius: moderateScale(14),
borderWidth: 1, borderWidth: 1,
borderColor: "#E2EAE5", borderColor: "#E2EAE5",
marginBottom: verticalScale(12),
}, },
pressed: { pressed: {
opacity: 0.72, opacity: 0.72,
@ -956,7 +960,7 @@ const styles = StyleSheet.create({
color: Colors.textPrimary, color: Colors.textPrimary,
}, },
connectingDetailsContainer: { connectingDetailsContainer: {
gap: moderateScale(10), gap: moderateScale(6),
}, },
conditionBlock: { conditionBlock: {
backgroundColor: "#F9FAFB", backgroundColor: "#F9FAFB",

View File

@ -40,6 +40,6 @@ export function asRecordArray(value: unknown): Record<string, unknown>[] {
export function humanizeKey(value: string): string { export function humanizeKey(value: string): string {
return value return value
.replace(/[_-]/g, " ") .replace(/_/g, " ")
.replace(/\b\w/g, (letter) => letter.toUpperCase()); .replace(/\b\w/g, (letter) => letter.toUpperCase());
} }

View File

@ -45,7 +45,6 @@ import { TwelveChannelsCollectionRenderer, TwelveChannelsCardRenderer } from "./
import { TwelveChannelsDetailRenderer } from "./details/TwelveChannelsDetailRenderer"; import { TwelveChannelsDetailRenderer } from "./details/TwelveChannelsDetailRenderer";
import { ThreeBurnersCollectionRenderer, ThreeBurnersCardRenderer } from "./collections/ThreeBurnersRenderers"; import { ThreeBurnersCollectionRenderer, ThreeBurnersCardRenderer } from "./collections/ThreeBurnersRenderers";
import { ThreeBurnersDetailRenderer } from "./details/ThreeBurnersDetailRenderer"; import { ThreeBurnersDetailRenderer } from "./details/ThreeBurnersDetailRenderer";
import { SixStagesCollectionRenderer, SixStagesCardRenderer } from "./collections/SixStagesRenderers";
import { SixStagesDetailRenderer } from "./details/SixStagesDetailRenderer"; import { SixStagesDetailRenderer } from "./details/SixStagesDetailRenderer";
import { TcmPatternDetailRenderer } from "./details/TcmPatternDetailRenderer"; import { TcmPatternDetailRenderer } from "./details/TcmPatternDetailRenderer";
import { ExtraOrdinaryVesselsDetailRenderer } from "./details/ExtraOrdinaryVesselsDetailRenderer"; import { ExtraOrdinaryVesselsDetailRenderer } from "./details/ExtraOrdinaryVesselsDetailRenderer";
@ -79,15 +78,6 @@ export const collectionRenderers: Readonly<Record<string, CollectionRendererComp
m0018_ct0002_collection: TwelveChannelsCollectionRenderer, m0018_ct0002_collection: TwelveChannelsCollectionRenderer,
three_burners_collection: ThreeBurnersCollectionRenderer, three_burners_collection: ThreeBurnersCollectionRenderer,
m0017_ct0002_collection: ThreeBurnersCollectionRenderer, m0017_ct0002_collection: ThreeBurnersCollectionRenderer,
six_stages_collection: SixStagesCollectionRenderer,
m0015_ct0001_collection: SixStagesCollectionRenderer,
m0015_ct0002_collection: SixStagesCollectionRenderer,
m0015_ct0003_collection: SixStagesCollectionRenderer,
m0015_ct0004_collection: SixStagesCollectionRenderer,
m0015_ct0005_collection: SixStagesCollectionRenderer,
m0015_ct0006_collection: SixStagesCollectionRenderer,
tcm_pattern_list_collection: ModuleCatalogCollectionRenderer,
m0012_ct0001_collection: ModuleCatalogCollectionRenderer,
}); });
export const collectionItemRenderers: Readonly<Record<string, CollectionItemRendererComponent>> = Object.freeze({ export const collectionItemRenderers: Readonly<Record<string, CollectionItemRendererComponent>> = Object.freeze({
module_catalog_card: ModuleCatalogCardRenderer, module_catalog_card: ModuleCatalogCardRenderer,
@ -118,15 +108,6 @@ export const collectionItemRenderers: Readonly<Record<string, CollectionItemRend
m0018_ct0002_card: TwelveChannelsCardRenderer, m0018_ct0002_card: TwelveChannelsCardRenderer,
three_burners_card: ThreeBurnersCardRenderer, three_burners_card: ThreeBurnersCardRenderer,
m0017_ct0002_card: ThreeBurnersCardRenderer, m0017_ct0002_card: ThreeBurnersCardRenderer,
six_stages_card: SixStagesCardRenderer,
m0015_ct0001_card: SixStagesCardRenderer,
m0015_ct0002_card: SixStagesCardRenderer,
m0015_ct0003_card: SixStagesCardRenderer,
m0015_ct0004_card: SixStagesCardRenderer,
m0015_ct0005_card: SixStagesCardRenderer,
m0015_ct0006_card: SixStagesCardRenderer,
tcm_pattern_list_card: ModuleCatalogCardRenderer,
m0012_ct0001_card: ModuleCatalogCardRenderer,
}); });
export const detailRenderers: Readonly<Record<string, DetailRendererComponent>> = Object.freeze({ export const detailRenderers: Readonly<Record<string, DetailRendererComponent>> = Object.freeze({
extra_ordinary_vessel_detail: ExtraOrdinaryVesselsDetailRenderer, extra_ordinary_vessel_detail: ExtraOrdinaryVesselsDetailRenderer,
@ -251,19 +232,6 @@ export function resolveCollectionRenderer(
if (normalizedTemplate === "m0017_ct0002" || (normalizedModule === "m0017" && normalizedTemplate?.includes("ct0002"))) { if (normalizedTemplate === "m0017_ct0002" || (normalizedModule === "m0017" && normalizedTemplate?.includes("ct0002"))) {
return ThreeBurnersCollectionRenderer; return ThreeBurnersCollectionRenderer;
} }
if (
normalizedTemplate?.startsWith("m0015_ct000") &&
normalizedTemplate !== "m0015_ct0007"
) {
return SixStagesCollectionRenderer;
}
if (
normalizedTemplate === "m0012_ct0001" ||
(normalizedModule === "m0012" && (code === "tcm_pattern_list_collection" || !code)) ||
code === "tcm_pattern_list_collection"
) {
return ModuleCatalogCollectionRenderer;
}
if (code && collectionRenderers[code]) return collectionRenderers[code]; if (code && collectionRenderers[code]) return collectionRenderers[code];
reportMissingRenderer("collection", code); reportMissingRenderer("collection", code);
@ -304,19 +272,6 @@ export function resolveCollectionItemRenderer(
if (normalizedTemplate === "m0017_ct0002" || (normalizedModule === "m0017" && normalizedTemplate?.includes("ct0002"))) { if (normalizedTemplate === "m0017_ct0002" || (normalizedModule === "m0017" && normalizedTemplate?.includes("ct0002"))) {
return ThreeBurnersCardRenderer; return ThreeBurnersCardRenderer;
} }
if (
normalizedTemplate?.startsWith("m0015_ct000") &&
normalizedTemplate !== "m0015_ct0007"
) {
return SixStagesCardRenderer;
}
if (
normalizedTemplate === "m0012_ct0001" ||
(normalizedModule === "m0012" && (code === "tcm_pattern_list_card" || !code)) ||
code === "tcm_pattern_list_card"
) {
return ModuleCatalogCardRenderer;
}
if (code && collectionItemRenderers[code]) return collectionItemRenderers[code]; if (code && collectionItemRenderers[code]) return collectionItemRenderers[code];
reportMissingRenderer("collection-item", code); reportMissingRenderer("collection-item", code);

View File

@ -33,8 +33,6 @@ const DEFAULT_EXCLUDED_KEYS = new Set([
"point_codes", "point_codes",
"source_point", "source_point",
"source_points", "source_points",
"treatment",
"treatment_principle",
]); ]);
export function ContentLinkAttributeSections({ export function ContentLinkAttributeSections({

View File

@ -14,7 +14,6 @@ import { ContentLink } from "../../components/navigation/ContentLink";
import { parseNavigableContentReference } from "../../utils/content-reference"; import { parseNavigableContentReference } from "../../utils/content-reference";
import { humanizeKey } from "../helpers/value"; import { humanizeKey } from "../helpers/value";
import { BulletList } from "./BulletList"; import { BulletList } from "./BulletList";
import { ReferenceChipList } from "./ReferenceChipList";
export interface ContentValueProps { export interface ContentValueProps {
value: unknown; value: unknown;
@ -82,10 +81,6 @@ export function ContentValue({
return <BulletList items={visible as string[]} />; return <BulletList items={visible as string[]} />;
} }
if (visible.some((item) => parseNavigableContentReference(item) !== null)) {
return <ReferenceChipList value={visible} />;
}
return ( return (
<View style={styles.stack}> <View style={styles.stack}>
{visible.map((item, index) => ( {visible.map((item, index) => (
@ -116,7 +111,7 @@ export function ContentValue({
return ( return (
<View style={styles.object}> <View style={styles.object}>
{entries.map(([key, child], index) => { {entries.map(([key, child]) => {
const isClinical = const isClinical =
key.toLowerCase().includes("clinical") || key.toLowerCase().includes("clinical") ||
key.toLowerCase().includes("manifestation"); key.toLowerCase().includes("manifestation");
@ -136,13 +131,7 @@ export function ContentValue({
}; };
return ( return (
<View <View key={key} style={styles.objectRow}>
key={key}
style={[
styles.objectRow,
index > 0 && styles.divider,
]}
>
<Text style={styles.objectLabel}>{humanizeKey(key)}</Text> <Text style={styles.objectLabel}>{humanizeKey(key)}</Text>
{renderChild()} {renderChild()}
</View> </View>
@ -188,11 +177,6 @@ const styles = StyleSheet.create({
objectRow: { objectRow: {
gap: 4, gap: 4,
}, },
divider: {
paddingTop: 12,
borderTopWidth: StyleSheet.hairlineWidth,
borderTopColor: "#E8ECEF",
},
objectLabel: { objectLabel: {
fontSize: 12, fontSize: 12,
lineHeight: 17, lineHeight: 17,

View File

@ -16,7 +16,6 @@ export interface DetailPageShellProps extends PropsWithChildren {
tone?: PageTone; tone?: PageTone;
moduleCode?: string; moduleCode?: string;
hideFavorite?: boolean; hideFavorite?: boolean;
rightAction?: React.ReactNode;
} }
export function DetailPageShell({ export function DetailPageShell({
@ -25,7 +24,6 @@ export function DetailPageShell({
tone, tone,
moduleCode: propModuleCode, moduleCode: propModuleCode,
hideFavorite, hideFavorite,
rightAction,
}: DetailPageShellProps) { }: DetailPageShellProps) {
const [isFavorite, setIsFavorite] = useState(false); const [isFavorite, setIsFavorite] = useState(false);
const params = useLocalSearchParams<{ moduleCode?: string }>(); const params = useLocalSearchParams<{ moduleCode?: string }>();
@ -69,14 +67,6 @@ export function DetailPageShell({
</Pressable> </Pressable>
) : null; ) : null;
const headerActions = searchAction || favoriteAction || rightAction ? (
<View style={styles.actions}>
{searchAction}
{favoriteAction}
{rightAction}
</View>
) : undefined;
return ( return (
<SafeAreaView style={styles.screen} edges={["top", "left", "right"]}> <SafeAreaView style={styles.screen} edges={["top", "left", "right"]}>
<ContentPageHeader <ContentPageHeader
@ -92,7 +82,12 @@ export function DetailPageShell({
currentModuleCode ? `Open ${moduleDisplay.name} home` : moduleDisplay.name currentModuleCode ? `Open ${moduleDisplay.name} home` : moduleDisplay.name
} }
fallbackRoute={moduleDisplay.homeRoute} fallbackRoute={moduleDisplay.homeRoute}
right={headerActions} right={
<View style={styles.actions}>
{searchAction}
{favoriteAction}
</View>
}
/> />
<View style={styles.body}>{children}</View> <View style={styles.body}>{children}</View>
</SafeAreaView> </SafeAreaView>

View File

@ -9,15 +9,7 @@ import { Spacing } from "@/theme/spacing";
import { ContentLink } from "../../components/navigation/ContentLink"; import { ContentLink } from "../../components/navigation/ContentLink";
import { parseNavigableContentReference } from "../../utils/content-reference"; import { parseNavigableContentReference } from "../../utils/content-reference";
export interface ReferenceChipListProps { export function ReferenceChipList({ value }: { value: unknown }) {
value: unknown;
asBulletList?: boolean;
}
export function ReferenceChipList({
value,
asBulletList = true,
}: ReferenceChipListProps) {
const values = Array.isArray(value) ? value : [value]; const values = Array.isArray(value) ? value : [value];
const visible = values.filter( const visible = values.filter(
(item) => item !== null && item !== undefined && item !== "", (item) => item !== null && item !== undefined && item !== "",
@ -26,11 +18,10 @@ export function ReferenceChipList({
if (!visible.length) return null; if (!visible.length) return null;
return ( return (
<View style={asBulletList ? styles.bulletList : styles.list}> <View style={styles.list}>
{visible.map((item, index) => { {visible.map((item, index) => {
const reference = parseNavigableContentReference(item); const reference = parseNavigableContentReference(item);
const renderChip = () => {
if (reference) { if (reference) {
const label = const label =
reference.label?.trim() || reference.label?.trim() ||
@ -69,28 +60,6 @@ export function ReferenceChipList({
<Text style={styles.text}>{text}</Text> <Text style={styles.text}>{text}</Text>
</View> </View>
); );
};
if (asBulletList) {
const key = reference
? (reference.type === "content_ref"
? `bullet-${reference.target.content_id}-${index}`
: `bullet-${reference.target.module_code}-${reference.target.template_code}-${index}`)
: `bullet-${index}`;
return (
<View key={key} style={styles.bulletRow}>
<View style={styles.dot} />
{renderChip()}
</View>
);
}
return (
<React.Fragment key={index}>
{renderChip()}
</React.Fragment>
);
})} })}
</View> </View>
); );
@ -115,21 +84,6 @@ const styles = StyleSheet.create({
flexWrap: "wrap", flexWrap: "wrap",
gap: Spacing.sm, gap: Spacing.sm,
}, },
bulletList: {
gap: 10,
alignItems: "flex-start",
},
bulletRow: {
flexDirection: "row",
alignItems: "center",
gap: 10,
},
dot: {
width: 6,
height: 6,
borderRadius: 3,
backgroundColor: Colors.primary,
},
link: { link: {
alignSelf: "flex-start", alignSelf: "flex-start",
borderRadius: Radius.full, borderRadius: Radius.full,