patterns #79
|
|
@ -4,7 +4,7 @@ import { Ionicons } from "@expo/vector-icons";
|
|||
import { moderateScale, verticalScale } from "react-native-size-matters";
|
||||
|
||||
import { Colors } from "@/theme";
|
||||
import { asNumber, asString, asStringArray } from "../helpers/value";
|
||||
import { asNumber, asString, asStringArray, humanizeKey } from "../helpers/value";
|
||||
import { CollectionScaffold } from "../shared/CollectionScaffold";
|
||||
import { ContentCountBadge } from "../shared/ContentCountBadge";
|
||||
import type {
|
||||
|
|
@ -21,15 +21,33 @@ export function ModuleCatalogCardRenderer({
|
|||
onPress,
|
||||
}: CollectionItemRendererProps) {
|
||||
const attributes = item.attributes;
|
||||
const title = asString(attributes.name) || item.title;
|
||||
const subtitle =
|
||||
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 rawLabel =
|
||||
parenSubtitle ||
|
||||
asString(attributes.sub_title) ||
|
||||
asString(attributes.subtitle) ||
|
||||
(asStringArray(attributes.alt_name).length > 0
|
||||
? asStringArray(attributes.alt_name).join(", ")
|
||||
: 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;
|
||||
|
||||
const cleanTitle = humanizeKey(title);
|
||||
const label = rawLabel ? humanizeKey(rawLabel) : null;
|
||||
|
||||
return (
|
||||
<Pressable
|
||||
accessibilityRole="button"
|
||||
|
|
@ -41,10 +59,10 @@ export function ModuleCatalogCardRenderer({
|
|||
</View>
|
||||
|
||||
<View style={styles.textContainer}>
|
||||
<Text style={styles.title}>{title}</Text>
|
||||
{subtitle ? (
|
||||
<Text style={styles.title}>{cleanTitle}</Text>
|
||||
{label ? (
|
||||
<Text numberOfLines={2} style={styles.subtitle}>
|
||||
{subtitle}
|
||||
{label}
|
||||
</Text>
|
||||
) : null}
|
||||
</View>
|
||||
|
|
|
|||
|
|
@ -0,0 +1,145 @@
|
|||
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,
|
||||
},
|
||||
});
|
||||
|
|
@ -38,7 +38,7 @@ function RelationshipRow({ label, value, chips = false }: RelationshipRowProps)
|
|||
return (
|
||||
<View style={styles.relationshipRow}>
|
||||
<Text style={styles.relationshipLabel}>{label}</Text>
|
||||
{chips ? <ReferenceChipList value={value} /> : <ContentValue value={value} />}
|
||||
{chips ? <ReferenceChipList value={value} asBulletList={false} /> : <ContentValue value={value} />}
|
||||
</View>
|
||||
);
|
||||
}
|
||||
|
|
@ -179,7 +179,11 @@ export function EovDetailRenderer({
|
|||
order: orderFor("treatment", 140),
|
||||
render: () => (
|
||||
<SectionCard title="Treatment">
|
||||
<Text style={styles.pathway}>{asString(data.treatment)}</Text>
|
||||
{typeof data.treatment === "object" ? (
|
||||
<ContentValue value={data.treatment} />
|
||||
) : (
|
||||
<Text style={styles.pathway}>{asString(data.treatment)}</Text>
|
||||
)}
|
||||
</SectionCard>
|
||||
),
|
||||
});
|
||||
|
|
|
|||
|
|
@ -8,6 +8,8 @@ import { Colors } from "@/theme";
|
|||
import type { DetailRendererProps } from "../../types/renderer.types";
|
||||
import { ContentLinkAttributeSections } from "../shared/ContentLinkAttributeSections";
|
||||
import { Hero } from "../shared/Hero";
|
||||
import { Paragraphs } from "../shared/Paragraphs";
|
||||
import { SectionCard } from "../shared/SectionCard";
|
||||
import { asRecordArray, asString, asStringArray } from "../helpers/value";
|
||||
|
||||
function resolveSequenceTargetTemplate(
|
||||
|
|
@ -195,37 +197,23 @@ export function FiveElementsDetailRenderer({
|
|||
</View>
|
||||
) : null}
|
||||
|
||||
{/* Numbered Pattern Cards from data.sections */}
|
||||
{rawSections.length > 0 ? (
|
||||
<View style={styles.sectionsContainer}>
|
||||
<Text style={styles.sectionHeading}>Patterns & Manifestations</Text>
|
||||
{rawSections.map((sec, idx) => {
|
||||
const sectionTitle = asString(sec.title) || `Pattern ${idx + 1}`;
|
||||
const sectionContent = extractParagraphs(sec.content);
|
||||
{/* Collapsible Pattern Cards from data.sections */}
|
||||
{rawSections.map((sec, idx) => {
|
||||
const sectionTitle = asString(sec.title) || `Pattern ${idx + 1}`;
|
||||
const sectionContent = extractParagraphs(sec.content);
|
||||
|
||||
return (
|
||||
<View key={idx} style={styles.patternCard}>
|
||||
<View style={styles.patternHeader}>
|
||||
<View style={styles.numberBadge}>
|
||||
<Text style={styles.numberText}>{idx + 1}</Text>
|
||||
</View>
|
||||
<Text style={styles.patternTitle}>{sectionTitle}</Text>
|
||||
</View>
|
||||
|
||||
{sectionContent.length > 0 ? (
|
||||
<View style={styles.patternBody}>
|
||||
{sectionContent.map((text, cIdx) => (
|
||||
<Text key={cIdx} style={styles.contentText}>
|
||||
{text}
|
||||
</Text>
|
||||
))}
|
||||
</View>
|
||||
) : null}
|
||||
</View>
|
||||
);
|
||||
})}
|
||||
</View>
|
||||
) : null}
|
||||
return (
|
||||
<SectionCard
|
||||
key={idx}
|
||||
title={sectionTitle}
|
||||
defaultExpanded={false}
|
||||
>
|
||||
{sectionContent.length > 0 ? (
|
||||
<Paragraphs items={sectionContent} />
|
||||
) : null}
|
||||
</SectionCard>
|
||||
);
|
||||
})}
|
||||
|
||||
<ContentLinkAttributeSections
|
||||
data={data}
|
||||
|
|
|
|||
|
|
@ -13,6 +13,7 @@ import {
|
|||
import { asRecord, asString, asStringArray } from "../helpers/value";
|
||||
import { BulletList } from "../shared/BulletList";
|
||||
import { ContentLinkAttributeSections } from "../shared/ContentLinkAttributeSections";
|
||||
import { ContentValue } from "../shared/ContentValue";
|
||||
import { Hero } from "../shared/Hero";
|
||||
import { Paragraphs } from "../shared/Paragraphs";
|
||||
import { SectionCard } from "../shared/SectionCard";
|
||||
|
|
@ -93,9 +94,12 @@ export function FourLevelsDetailRenderer({
|
|||
const tongue = asString(data.tongue);
|
||||
const pulse = asString(data.pulse);
|
||||
const pathology = asString(data.pathology);
|
||||
const treatmentPrinciple =
|
||||
asString(data.treatment_principle) ||
|
||||
asString(data["treatment principle"]);
|
||||
const treatmentPrincipleRaw =
|
||||
data.treatment_principle ?? data["treatment principle"];
|
||||
const treatmentPrincipleItems = asStringArray(treatmentPrincipleRaw).filter(
|
||||
(item) => item.trim().length > 0,
|
||||
);
|
||||
const treatmentPrinciple = asString(treatmentPrincipleRaw);
|
||||
const treatment = asString(data.treatment);
|
||||
const treatmentBullets = parseTreatmentBullets(treatment);
|
||||
const explanation = asString(data.explanation);
|
||||
|
|
@ -230,15 +234,21 @@ export function FourLevelsDetailRenderer({
|
|||
</SectionCard>
|
||||
) : null}
|
||||
|
||||
{treatmentPrinciple ? (
|
||||
{treatmentPrincipleItems.length > 0 ? (
|
||||
<SectionCard title="Treatment Principle">
|
||||
<BulletList items={treatmentPrincipleItems} />
|
||||
</SectionCard>
|
||||
) : treatmentPrinciple ? (
|
||||
<SectionCard title="Treatment Principle">
|
||||
<Paragraphs items={[treatmentPrinciple]} />
|
||||
</SectionCard>
|
||||
) : null}
|
||||
|
||||
{treatment ? (
|
||||
{data.treatment ? (
|
||||
<SectionCard title="Treatment">
|
||||
{treatmentBullets.length > 0 ? (
|
||||
{typeof data.treatment === "object" ? (
|
||||
<ContentValue value={data.treatment} />
|
||||
) : treatmentBullets.length > 0 ? (
|
||||
<BulletList items={treatmentBullets} />
|
||||
) : (
|
||||
<Paragraphs items={[treatment]} />
|
||||
|
|
|
|||
|
|
@ -1,8 +1,13 @@
|
|||
import React from "react";
|
||||
import React, { useMemo } from "react";
|
||||
import { ScrollView, StyleSheet } from "react-native";
|
||||
|
||||
import type { DetailRendererProps } from "../../types/renderer.types";
|
||||
import { asString, humanizeKey } from "../helpers/value";
|
||||
import {
|
||||
findAttributePresentationRule,
|
||||
isEmptyValue,
|
||||
presentationDisplayOrder,
|
||||
} from "../../utils/attribute-presentation";
|
||||
import { ContentLinkAttributeSections } from "../shared/ContentLinkAttributeSections";
|
||||
import { ContentValue } from "../shared/ContentValue";
|
||||
import { Hero } from "../shared/Hero";
|
||||
|
|
@ -19,18 +24,43 @@ const CATALOG_METADATA_KEYS = new Set([
|
|||
"link",
|
||||
"point_images",
|
||||
"default_image_id",
|
||||
"stage_overview",
|
||||
]);
|
||||
|
||||
export function SixStagesDetailRenderer({
|
||||
content,
|
||||
data,
|
||||
definitions,
|
||||
presentationAttributes,
|
||||
}: DetailRendererProps) {
|
||||
const title =
|
||||
const rawTitle =
|
||||
asString(data.name) ||
|
||||
asString(data.title) ||
|
||||
content.title ||
|
||||
"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 (
|
||||
<ScrollView
|
||||
|
|
@ -39,13 +69,11 @@ export function SixStagesDetailRenderer({
|
|||
>
|
||||
<Hero title={title} subtitle={content.summary ?? undefined} />
|
||||
|
||||
{Object.entries(data)
|
||||
.filter(([key]) => !RESERVED_KEYS.has(key) && !CATALOG_METADATA_KEYS.has(key))
|
||||
.map(([key, value]) => (
|
||||
<SectionCard key={key} title={humanizeKey(key)}>
|
||||
<ContentValue value={value} />
|
||||
</SectionCard>
|
||||
))}
|
||||
{orderedSections.map(({ key, value, label }) => (
|
||||
<SectionCard key={key} title={label}>
|
||||
<ContentValue value={value} />
|
||||
</SectionCard>
|
||||
))}
|
||||
|
||||
<ContentLinkAttributeSections
|
||||
data={data}
|
||||
|
|
|
|||
|
|
@ -1,25 +1,60 @@
|
|||
import React from "react";
|
||||
import React, { useMemo } from "react";
|
||||
import { ScrollView, StyleSheet } from "react-native";
|
||||
|
||||
import type { DetailRendererProps } from "../../types/renderer.types";
|
||||
import { asString, humanizeKey } from "../helpers/value";
|
||||
import {
|
||||
findAttributePresentationRule,
|
||||
isEmptyValue,
|
||||
presentationDisplayOrder,
|
||||
} from "../../utils/attribute-presentation";
|
||||
import { ContentLinkAttributeSections } from "../shared/ContentLinkAttributeSections";
|
||||
import { ContentValue } from "../shared/ContentValue";
|
||||
import { Hero } from "../shared/Hero";
|
||||
import { SectionCard } from "../shared/SectionCard";
|
||||
|
||||
const EXCLUDED_KEYS = new Set(["code"]);
|
||||
const RESERVED_KEYS = new Set([
|
||||
"id",
|
||||
"name",
|
||||
"title",
|
||||
"code",
|
||||
"sort_order",
|
||||
"link",
|
||||
]);
|
||||
|
||||
export function TcmPatternDetailRenderer({
|
||||
content,
|
||||
data,
|
||||
definitions,
|
||||
presentationAttributes,
|
||||
}: DetailRendererProps) {
|
||||
const title =
|
||||
const rawTitle =
|
||||
asString(data.name) ||
|
||||
asString(data.title) ||
|
||||
content.title ||
|
||||
"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 (
|
||||
<ScrollView
|
||||
|
|
@ -28,13 +63,11 @@ export function TcmPatternDetailRenderer({
|
|||
>
|
||||
<Hero title={title} subtitle={content.summary ?? undefined} />
|
||||
|
||||
{Object.entries(data)
|
||||
.filter(([key]) => !EXCLUDED_KEYS.has(key))
|
||||
.map(([key, value]) => (
|
||||
<SectionCard key={key} title={humanizeKey(key)}>
|
||||
<ContentValue value={value} />
|
||||
</SectionCard>
|
||||
))}
|
||||
{orderedSections.map(({ key, value, label }) => (
|
||||
<SectionCard key={key} title={label}>
|
||||
<ContentValue value={value} />
|
||||
</SectionCard>
|
||||
))}
|
||||
|
||||
<ContentLinkAttributeSections
|
||||
data={data}
|
||||
|
|
|
|||
|
|
@ -10,6 +10,7 @@ import { Hero } from "../shared/Hero";
|
|||
import { SectionCard } from "../shared/SectionCard";
|
||||
import { Paragraphs } from "../shared/Paragraphs";
|
||||
import { BulletList } from "../shared/BulletList";
|
||||
import { ContentValue } from "../shared/ContentValue";
|
||||
import { asString, asStringArray } from "../helpers/value";
|
||||
import { useContentSearchInfiniteQuery } from "../../hooks/use-content-search-infinite-query";
|
||||
|
||||
|
|
@ -18,7 +19,8 @@ interface PatternData {
|
|||
code?: string;
|
||||
clinicalManifestation?: string | string[];
|
||||
pathology?: string;
|
||||
treatment?: string;
|
||||
treatmentPrinciple?: string | string[];
|
||||
treatment?: unknown;
|
||||
}
|
||||
|
||||
function parseBullets(raw: unknown): string[] {
|
||||
|
|
@ -236,14 +238,20 @@ export function ThreeBurnersDetailRenderer({
|
|||
|
||||
const clinical = parseBullets(clinicalRaw);
|
||||
const pathology = asString(a.pathology);
|
||||
const treatment = asString(a.treatment);
|
||||
const treatmentPrincipleRaw =
|
||||
a.treatment_principle ??
|
||||
a["treatment principle"] ??
|
||||
a.treatmentPrinciple;
|
||||
const treatmentPrinciple = parseBullets(treatmentPrincipleRaw);
|
||||
const treatment = a.treatment ?? a["treatment"];
|
||||
|
||||
map.set(normalizeKey(name), {
|
||||
name,
|
||||
code: asString(a.code) || undefined,
|
||||
clinicalManifestation: clinical.length > 0 ? clinical : undefined,
|
||||
pathology: pathology || undefined,
|
||||
treatment: treatment || undefined,
|
||||
treatmentPrinciple: treatmentPrinciple.length > 0 ? treatmentPrinciple : undefined,
|
||||
treatment: treatment ?? undefined,
|
||||
});
|
||||
}
|
||||
|
||||
|
|
@ -284,13 +292,19 @@ export function ThreeBurnersDetailRenderer({
|
|||
data.clinical_manifestation;
|
||||
|
||||
const clinical = parseBullets(clinicalRaw);
|
||||
const treatmentPrincipleRaw =
|
||||
data.treatment_principle ??
|
||||
data["treatment principle"] ??
|
||||
data.treatmentPrinciple;
|
||||
const treatmentPrinciple = parseBullets(treatmentPrincipleRaw);
|
||||
|
||||
return {
|
||||
name,
|
||||
code: asString(data.code) || undefined,
|
||||
clinicalManifestation: clinical.length > 0 ? clinical : undefined,
|
||||
pathology: asString(data.pathology) || undefined,
|
||||
treatment: asString(data.treatment) || undefined,
|
||||
treatmentPrinciple: treatmentPrinciple.length > 0 ? treatmentPrinciple : undefined,
|
||||
treatment: data.treatment ?? undefined,
|
||||
};
|
||||
}
|
||||
|
||||
|
|
@ -323,9 +337,20 @@ export function ThreeBurnersDetailRenderer({
|
|||
// SCREEN 3: Pattern Leaf Detail Screen
|
||||
// ----------------------------------------------------
|
||||
if (activePatternData && (selectedPatternName || isDirectLeafPattern)) {
|
||||
const { principles, acupuncture } = parseTreatment(
|
||||
activePatternData.treatment || "",
|
||||
);
|
||||
const treatmentRaw = activePatternData.treatment;
|
||||
const { principles, acupuncture } =
|
||||
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 (
|
||||
<ScrollView
|
||||
|
|
@ -334,7 +359,14 @@ export function ThreeBurnersDetailRenderer({
|
|||
>
|
||||
<Hero title={activePatternData.name} />
|
||||
|
||||
{/* 1. Clinical Manifestations Card */}
|
||||
{/* 1. Pathology Card */}
|
||||
{activePatternData.pathology ? (
|
||||
<SectionCard title="Pathology">
|
||||
<Paragraphs items={[activePatternData.pathology]} />
|
||||
</SectionCard>
|
||||
) : null}
|
||||
|
||||
{/* 2. Clinical Manifestations Card */}
|
||||
{activePatternData.clinicalManifestation ? (
|
||||
<SectionCard title="Clinical Manifestations">
|
||||
<BulletList
|
||||
|
|
@ -347,41 +379,21 @@ export function ThreeBurnersDetailRenderer({
|
|||
</SectionCard>
|
||||
) : null}
|
||||
|
||||
{/* 2. Pathology Card */}
|
||||
{activePatternData.pathology ? (
|
||||
<SectionCard title="Pathology">
|
||||
<Paragraphs items={[activePatternData.pathology]} />
|
||||
{/* 3. Treatment Principle Card */}
|
||||
{allPrinciples && allPrinciples.length > 0 ? (
|
||||
<SectionCard title="Treatment Principle">
|
||||
<BulletList items={allPrinciples} />
|
||||
</SectionCard>
|
||||
) : null}
|
||||
|
||||
{/* 3. Treatment Card */}
|
||||
{activePatternData.treatment ? (
|
||||
{/* 4. Treatment Card */}
|
||||
{treatmentRaw ? (
|
||||
<SectionCard title="Treatment">
|
||||
{principles.length > 0 ? (
|
||||
<View style={styles.subSection}>
|
||||
<Text style={styles.subSectionTitle}>Treatment Principle:</Text>
|
||||
{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}
|
||||
{typeof treatmentRaw === "object" ? (
|
||||
<ContentValue value={treatmentRaw} />
|
||||
) : (
|
||||
<Paragraphs items={[acupuncture.length > 0 ? acupuncture.join("\n") : String(treatmentRaw)]} />
|
||||
)}
|
||||
</SectionCard>
|
||||
) : null}
|
||||
|
||||
|
|
@ -592,6 +604,9 @@ const styles = StyleSheet.create({
|
|||
},
|
||||
subSectionSpacing: {
|
||||
marginTop: verticalScale(12),
|
||||
paddingTop: verticalScale(12),
|
||||
borderTopWidth: StyleSheet.hairlineWidth,
|
||||
borderTopColor: "#E8ECEF",
|
||||
},
|
||||
subSectionTitle: {
|
||||
fontSize: moderateScale(13),
|
||||
|
|
|
|||
|
|
@ -488,7 +488,7 @@ export function TwelveChannelsDetailRenderer({
|
|||
|
||||
{(connecting as ConnectingChannelDetails).empty &&
|
||||
(connecting as ConnectingChannelDetails).empty!.length > 0 ? (
|
||||
<View style={[styles.conditionBlock, { marginTop: moderateScale(10) }]}>
|
||||
<View style={styles.conditionBlock}>
|
||||
<View style={styles.conditionHeader}>
|
||||
<View style={[styles.conditionDot, { backgroundColor: "#3B82F6" }]} />
|
||||
<Text style={styles.conditionTitle}>Empty Condition</Text>
|
||||
|
|
@ -753,7 +753,8 @@ const styles = StyleSheet.create({
|
|||
container: {
|
||||
paddingHorizontal: moderateScale(16),
|
||||
paddingTop: verticalScale(14),
|
||||
paddingBottom: verticalScale(36),
|
||||
paddingBottom: verticalScale(40),
|
||||
gap: verticalScale(14),
|
||||
},
|
||||
overviewCard: {
|
||||
backgroundColor: "#F0FDF4",
|
||||
|
|
@ -761,7 +762,6 @@ const styles = StyleSheet.create({
|
|||
borderWidth: 1,
|
||||
borderColor: "#DCFCE7",
|
||||
padding: moderateScale(16),
|
||||
marginBottom: verticalScale(14),
|
||||
},
|
||||
overviewHeader: {
|
||||
flexDirection: "row",
|
||||
|
|
@ -785,7 +785,6 @@ const styles = StyleSheet.create({
|
|||
borderWidth: 1,
|
||||
borderColor: "#E5E7EB",
|
||||
padding: moderateScale(14),
|
||||
marginBottom: verticalScale(14),
|
||||
},
|
||||
infoHeader: {
|
||||
flexDirection: "row",
|
||||
|
|
@ -891,7 +890,6 @@ const styles = StyleSheet.create({
|
|||
borderWidth: 1,
|
||||
borderColor: "#E2E8F0",
|
||||
padding: moderateScale(14),
|
||||
marginBottom: verticalScale(14),
|
||||
},
|
||||
summaryHeader: {
|
||||
flexDirection: "row",
|
||||
|
|
@ -911,13 +909,12 @@ const styles = StyleSheet.create({
|
|||
lineHeight: moderateScale(19),
|
||||
},
|
||||
channelsContainer: {
|
||||
marginTop: verticalScale(10),
|
||||
gap: verticalScale(10),
|
||||
},
|
||||
sectionHeading: {
|
||||
fontSize: moderateScale(16),
|
||||
fontWeight: "700",
|
||||
color: Colors.textPrimary,
|
||||
marginBottom: verticalScale(12),
|
||||
marginLeft: moderateScale(2),
|
||||
},
|
||||
channelRow: {
|
||||
|
|
@ -930,7 +927,6 @@ const styles = StyleSheet.create({
|
|||
borderRadius: moderateScale(14),
|
||||
borderWidth: 1,
|
||||
borderColor: "#E2EAE5",
|
||||
marginBottom: verticalScale(12),
|
||||
},
|
||||
pressed: {
|
||||
opacity: 0.72,
|
||||
|
|
@ -960,7 +956,7 @@ const styles = StyleSheet.create({
|
|||
color: Colors.textPrimary,
|
||||
},
|
||||
connectingDetailsContainer: {
|
||||
gap: moderateScale(6),
|
||||
gap: moderateScale(10),
|
||||
},
|
||||
conditionBlock: {
|
||||
backgroundColor: "#F9FAFB",
|
||||
|
|
|
|||
|
|
@ -40,6 +40,6 @@ export function asRecordArray(value: unknown): Record<string, unknown>[] {
|
|||
|
||||
export function humanizeKey(value: string): string {
|
||||
return value
|
||||
.replace(/_/g, " ")
|
||||
.replace(/[_-]/g, " ")
|
||||
.replace(/\b\w/g, (letter) => letter.toUpperCase());
|
||||
}
|
||||
|
|
|
|||
|
|
@ -45,6 +45,7 @@ import { TwelveChannelsCollectionRenderer, TwelveChannelsCardRenderer } from "./
|
|||
import { TwelveChannelsDetailRenderer } from "./details/TwelveChannelsDetailRenderer";
|
||||
import { ThreeBurnersCollectionRenderer, ThreeBurnersCardRenderer } from "./collections/ThreeBurnersRenderers";
|
||||
import { ThreeBurnersDetailRenderer } from "./details/ThreeBurnersDetailRenderer";
|
||||
import { SixStagesCollectionRenderer, SixStagesCardRenderer } from "./collections/SixStagesRenderers";
|
||||
import { SixStagesDetailRenderer } from "./details/SixStagesDetailRenderer";
|
||||
import { TcmPatternDetailRenderer } from "./details/TcmPatternDetailRenderer";
|
||||
import { ExtraOrdinaryVesselsDetailRenderer } from "./details/ExtraOrdinaryVesselsDetailRenderer";
|
||||
|
|
@ -78,6 +79,15 @@ export const collectionRenderers: Readonly<Record<string, CollectionRendererComp
|
|||
m0018_ct0002_collection: TwelveChannelsCollectionRenderer,
|
||||
three_burners_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({
|
||||
module_catalog_card: ModuleCatalogCardRenderer,
|
||||
|
|
@ -108,6 +118,15 @@ export const collectionItemRenderers: Readonly<Record<string, CollectionItemRend
|
|||
m0018_ct0002_card: TwelveChannelsCardRenderer,
|
||||
three_burners_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({
|
||||
extra_ordinary_vessel_detail: ExtraOrdinaryVesselsDetailRenderer,
|
||||
|
|
@ -232,6 +251,19 @@ export function resolveCollectionRenderer(
|
|||
if (normalizedTemplate === "m0017_ct0002" || (normalizedModule === "m0017" && normalizedTemplate?.includes("ct0002"))) {
|
||||
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];
|
||||
reportMissingRenderer("collection", code);
|
||||
|
|
@ -272,6 +304,19 @@ export function resolveCollectionItemRenderer(
|
|||
if (normalizedTemplate === "m0017_ct0002" || (normalizedModule === "m0017" && normalizedTemplate?.includes("ct0002"))) {
|
||||
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];
|
||||
reportMissingRenderer("collection-item", code);
|
||||
|
|
|
|||
|
|
@ -33,6 +33,8 @@ const DEFAULT_EXCLUDED_KEYS = new Set([
|
|||
"point_codes",
|
||||
"source_point",
|
||||
"source_points",
|
||||
"treatment",
|
||||
"treatment_principle",
|
||||
]);
|
||||
|
||||
export function ContentLinkAttributeSections({
|
||||
|
|
|
|||
|
|
@ -14,6 +14,7 @@ import { ContentLink } from "../../components/navigation/ContentLink";
|
|||
import { parseNavigableContentReference } from "../../utils/content-reference";
|
||||
import { humanizeKey } from "../helpers/value";
|
||||
import { BulletList } from "./BulletList";
|
||||
import { ReferenceChipList } from "./ReferenceChipList";
|
||||
|
||||
export interface ContentValueProps {
|
||||
value: unknown;
|
||||
|
|
@ -81,6 +82,10 @@ export function ContentValue({
|
|||
return <BulletList items={visible as string[]} />;
|
||||
}
|
||||
|
||||
if (visible.some((item) => parseNavigableContentReference(item) !== null)) {
|
||||
return <ReferenceChipList value={visible} />;
|
||||
}
|
||||
|
||||
return (
|
||||
<View style={styles.stack}>
|
||||
{visible.map((item, index) => (
|
||||
|
|
@ -111,7 +116,7 @@ export function ContentValue({
|
|||
|
||||
return (
|
||||
<View style={styles.object}>
|
||||
{entries.map(([key, child]) => {
|
||||
{entries.map(([key, child], index) => {
|
||||
const isClinical =
|
||||
key.toLowerCase().includes("clinical") ||
|
||||
key.toLowerCase().includes("manifestation");
|
||||
|
|
@ -131,7 +136,13 @@ export function ContentValue({
|
|||
};
|
||||
|
||||
return (
|
||||
<View key={key} style={styles.objectRow}>
|
||||
<View
|
||||
key={key}
|
||||
style={[
|
||||
styles.objectRow,
|
||||
index > 0 && styles.divider,
|
||||
]}
|
||||
>
|
||||
<Text style={styles.objectLabel}>{humanizeKey(key)}</Text>
|
||||
{renderChild()}
|
||||
</View>
|
||||
|
|
@ -177,6 +188,11 @@ const styles = StyleSheet.create({
|
|||
objectRow: {
|
||||
gap: 4,
|
||||
},
|
||||
divider: {
|
||||
paddingTop: 12,
|
||||
borderTopWidth: StyleSheet.hairlineWidth,
|
||||
borderTopColor: "#E8ECEF",
|
||||
},
|
||||
objectLabel: {
|
||||
fontSize: 12,
|
||||
lineHeight: 17,
|
||||
|
|
|
|||
|
|
@ -16,6 +16,7 @@ export interface DetailPageShellProps extends PropsWithChildren {
|
|||
tone?: PageTone;
|
||||
moduleCode?: string;
|
||||
hideFavorite?: boolean;
|
||||
rightAction?: React.ReactNode;
|
||||
}
|
||||
|
||||
export function DetailPageShell({
|
||||
|
|
@ -24,6 +25,7 @@ export function DetailPageShell({
|
|||
tone,
|
||||
moduleCode: propModuleCode,
|
||||
hideFavorite,
|
||||
rightAction,
|
||||
}: DetailPageShellProps) {
|
||||
const [isFavorite, setIsFavorite] = useState(false);
|
||||
const params = useLocalSearchParams<{ moduleCode?: string }>();
|
||||
|
|
@ -67,6 +69,14 @@ export function DetailPageShell({
|
|||
</Pressable>
|
||||
) : null;
|
||||
|
||||
const headerActions = searchAction || favoriteAction || rightAction ? (
|
||||
<View style={styles.actions}>
|
||||
{searchAction}
|
||||
{favoriteAction}
|
||||
{rightAction}
|
||||
</View>
|
||||
) : undefined;
|
||||
|
||||
return (
|
||||
<SafeAreaView style={styles.screen} edges={["top", "left", "right"]}>
|
||||
<ContentPageHeader
|
||||
|
|
@ -82,12 +92,7 @@ export function DetailPageShell({
|
|||
currentModuleCode ? `Open ${moduleDisplay.name} home` : moduleDisplay.name
|
||||
}
|
||||
fallbackRoute={moduleDisplay.homeRoute}
|
||||
right={
|
||||
<View style={styles.actions}>
|
||||
{searchAction}
|
||||
{favoriteAction}
|
||||
</View>
|
||||
}
|
||||
right={headerActions}
|
||||
/>
|
||||
<View style={styles.body}>{children}</View>
|
||||
</SafeAreaView>
|
||||
|
|
|
|||
|
|
@ -9,7 +9,15 @@ import { Spacing } from "@/theme/spacing";
|
|||
import { ContentLink } from "../../components/navigation/ContentLink";
|
||||
import { parseNavigableContentReference } from "../../utils/content-reference";
|
||||
|
||||
export function ReferenceChipList({ value }: { value: unknown }) {
|
||||
export interface ReferenceChipListProps {
|
||||
value: unknown;
|
||||
asBulletList?: boolean;
|
||||
}
|
||||
|
||||
export function ReferenceChipList({
|
||||
value,
|
||||
asBulletList = true,
|
||||
}: ReferenceChipListProps) {
|
||||
const values = Array.isArray(value) ? value : [value];
|
||||
const visible = values.filter(
|
||||
(item) => item !== null && item !== undefined && item !== "",
|
||||
|
|
@ -18,47 +26,70 @@ export function ReferenceChipList({ value }: { value: unknown }) {
|
|||
if (!visible.length) return null;
|
||||
|
||||
return (
|
||||
<View style={styles.list}>
|
||||
<View style={asBulletList ? styles.bulletList : styles.list}>
|
||||
{visible.map((item, index) => {
|
||||
const reference = parseNavigableContentReference(item);
|
||||
|
||||
if (reference) {
|
||||
const label =
|
||||
reference.label?.trim() ||
|
||||
(reference.type === "content_ref"
|
||||
? reference.target.source_key?.trim()
|
||||
: null) ||
|
||||
"Open";
|
||||
const renderChip = () => {
|
||||
if (reference) {
|
||||
const label =
|
||||
reference.label?.trim() ||
|
||||
(reference.type === "content_ref"
|
||||
? reference.target.source_key?.trim()
|
||||
: null) ||
|
||||
"Open";
|
||||
|
||||
return (
|
||||
<ContentLink
|
||||
key={
|
||||
reference.type === "content_ref"
|
||||
? `content-${reference.target.content_id}`
|
||||
: `template-${reference.target.module_code}-${reference.target.template_code}`
|
||||
}
|
||||
reference={reference}
|
||||
style={styles.link}
|
||||
>
|
||||
<View style={styles.linkChip}>
|
||||
<Text style={styles.linkText}>{label}</Text>
|
||||
<Ionicons
|
||||
name="chevron-forward"
|
||||
size={14}
|
||||
color={Colors.primaryDark}
|
||||
/>
|
||||
</View>
|
||||
</ContentLink>
|
||||
);
|
||||
}
|
||||
|
||||
const text = scalarLabel(item);
|
||||
if (!text) return null;
|
||||
|
||||
return (
|
||||
<ContentLink
|
||||
key={
|
||||
reference.type === "content_ref"
|
||||
? `content-${reference.target.content_id}`
|
||||
: `template-${reference.target.module_code}-${reference.target.template_code}`
|
||||
}
|
||||
reference={reference}
|
||||
style={styles.link}
|
||||
>
|
||||
<View style={styles.linkChip}>
|
||||
<Text style={styles.linkText}>{label}</Text>
|
||||
<Ionicons
|
||||
name="chevron-forward"
|
||||
size={14}
|
||||
color={Colors.primaryDark}
|
||||
/>
|
||||
</View>
|
||||
</ContentLink>
|
||||
<View key={`${text}-${index}`} style={styles.chip}>
|
||||
<Text style={styles.text}>{text}</Text>
|
||||
</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>
|
||||
);
|
||||
}
|
||||
|
||||
const text = scalarLabel(item);
|
||||
if (!text) return null;
|
||||
|
||||
return (
|
||||
<View key={`${text}-${index}`} style={styles.chip}>
|
||||
<Text style={styles.text}>{text}</Text>
|
||||
</View>
|
||||
<React.Fragment key={index}>
|
||||
{renderChip()}
|
||||
</React.Fragment>
|
||||
);
|
||||
})}
|
||||
</View>
|
||||
|
|
@ -84,6 +115,21 @@ const styles = StyleSheet.create({
|
|||
flexWrap: "wrap",
|
||||
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: {
|
||||
alignSelf: "flex-start",
|
||||
borderRadius: Radius.full,
|
||||
|
|
|
|||
Loading…
Reference in New Issue