Added neat UI
This commit is contained in:
parent
812179a017
commit
d647fb0684
|
|
@ -36,6 +36,7 @@ yarn-error.*
|
|||
# typescript
|
||||
*.tsbuildinfo
|
||||
|
||||
versions
|
||||
example
|
||||
|
||||
# generated native folders
|
||||
|
|
|
|||
|
|
@ -1,102 +0,0 @@
|
|||
import React, { useEffect, useMemo, useState } from "react";
|
||||
import { SafeAreaView } from "react-native-safe-area-context";
|
||||
import { StyleSheet, Text, View } from "react-native";
|
||||
import { moderateScale, verticalScale } from "react-native-size-matters";
|
||||
|
||||
import { Colors } from "@/theme";
|
||||
import { ContentPageHeader } from "../components/layout/ContentPageHeader";
|
||||
import { ContractSortModal } from "../components/search/ContractSortModal";
|
||||
import { SearchAttributeModal } from "../components/search/SearchAttributeModal";
|
||||
import { FilterSummary } from "../components/search/FilterSummary";
|
||||
import { SearchHeader } from "../components/search/SearchHeader";
|
||||
import { ModuleFilterBuilderModal } from "../components/search/ModuleFilterBuilderModal";
|
||||
import { ModuleFilterChips } from "../components/search/ModuleFilterChips";
|
||||
import { ModuleSearchResults } from "../components/search/ModuleSearchResults";
|
||||
import { ScreenError } from "../components/ContentScreenState";
|
||||
import { useContentSearchInfiniteQuery } from "../hooks/use-content-search-infinite-query";
|
||||
import { useModuleContentSearchInfiniteQuery } from "../hooks/use-module-content-search-infinite-query";
|
||||
import { useModuleSearchContractQuery } from "../hooks/use-module-search-contract-query";
|
||||
import { useTemplateSearchController } from "../hooks/use-template-search-controller";
|
||||
import { useDebouncedValue } from "../hooks/use-debounced-value";
|
||||
import { resolveCollectionItemRenderer, resolveCollectionRenderer } from "../renderers/registry";
|
||||
import type { LogicalOperator, ModuleSearchContentItem, SearchContentItem, SearchCriterion, SortCriterion, TemplateContractResponse } from "../types/presentation.types";
|
||||
|
||||
export interface CollectionTemplateScreenProps {
|
||||
moduleCode: string;
|
||||
moduleName: string;
|
||||
templateCode: string;
|
||||
contract: TemplateContractResponse;
|
||||
onItemPress: (item: SearchContentItem) => void;
|
||||
onModuleSearchItemPress: (item: ModuleSearchContentItem) => void;
|
||||
onOpenSort?: () => void;
|
||||
}
|
||||
|
||||
export function CollectionTemplateScreen({ moduleCode, moduleName, templateCode, contract, onItemPress, onModuleSearchItemPress, onOpenSort }: CollectionTemplateScreenProps) {
|
||||
const [filterBuilderVisible, setFilterBuilderVisible] = useState(false);
|
||||
const [sortVisible, setSortVisible] = useState(false);
|
||||
const [searchAttributesVisible, setSearchAttributesVisible] = useState(false);
|
||||
const [moduleQuery, setModuleQuery] = useState("");
|
||||
const debouncedModuleQuery = useDebouncedValue(moduleQuery.trim(), 350);
|
||||
const [moduleLogic, setModuleLogic] = useState<LogicalOperator>("and");
|
||||
const [moduleFilters, setModuleFilters] = useState<SearchCriterion[]>([]);
|
||||
const [moduleSearchAttributes, setModuleSearchAttributes] = useState<string[]>([]);
|
||||
const [moduleSort, setModuleSort] = useState<SortCriterion[]>([]);
|
||||
|
||||
const moduleContractQuery = useModuleSearchContractQuery(moduleCode);
|
||||
const moduleContract = moduleContractQuery.data;
|
||||
|
||||
useEffect(() => {
|
||||
if (!moduleContract) return;
|
||||
setModuleSort((current) =>
|
||||
current.length > 0 ? current : moduleContract.default_sort,
|
||||
);
|
||||
}, [moduleContract]);
|
||||
const searchableFields = useMemo(() => (moduleContract?.fields ?? []).filter((field) => field.is_searchable).map((field) => ({ attribute_key: field.attribute_key, label: `${field.label} · ${field.template_name}` })), [moduleContract?.fields]);
|
||||
const filterableFields = useMemo(() => (moduleContract?.fields ?? []).filter((field) => field.is_filterable), [moduleContract?.fields]);
|
||||
const moduleSearchActive = Boolean(debouncedModuleQuery) || moduleFilters.length > 0;
|
||||
|
||||
const templateSearch = useTemplateSearchController({ moduleCode, templateCode, contract });
|
||||
const templateQuery = useContentSearchInfiniteQuery({ module_code: moduleCode, template_code: templateCode, logic: contract.search.default_logic, filters: [], sort: templateSearch.sort, page_size: 25 }, { enabled: !moduleSearchActive });
|
||||
const moduleQueryResult = useModuleContentSearchInfiniteQuery({ module_code: moduleCode, query: debouncedModuleQuery || undefined, search_attributes: moduleSearchAttributes.length ? moduleSearchAttributes : undefined, logic: moduleLogic, filters: moduleFilters, sort: moduleSort, page_size: 25 }, { enabled: moduleSearchActive });
|
||||
|
||||
const templateMerged = useMemo(() => { const pages = templateQuery.data?.pages ?? []; return { total: pages[0]?.total ?? 0, items: pages.flatMap((page) => page.items) }; }, [templateQuery.data]);
|
||||
const moduleMerged = useMemo(() => { const pages = moduleQueryResult.data?.pages ?? []; return { total: pages[0]?.total ?? 0, items: pages.flatMap((page) => page.items) }; }, [moduleQueryResult.data]);
|
||||
|
||||
const rendererResolution = useMemo(() => {
|
||||
try {
|
||||
const collectionCode = contract.presentation.renderers.collection;
|
||||
const itemCode = contract.presentation.renderers.collection_item;
|
||||
if (!collectionCode || !itemCode) throw new Error("This content collection is missing its renderer configuration.");
|
||||
return { CollectionRenderer: resolveCollectionRenderer(collectionCode), ItemRenderer: resolveCollectionItemRenderer(itemCode), error: null as Error | null };
|
||||
} catch (error) {
|
||||
return { CollectionRenderer: null, ItemRenderer: null, error: error instanceof Error ? error : new Error("Renderer resolution failed.") };
|
||||
}
|
||||
}, [contract.presentation.renderers.collection, contract.presentation.renderers.collection_item]);
|
||||
|
||||
if (rendererResolution.error || !rendererResolution.CollectionRenderer || !rendererResolution.ItemRenderer) return <ScreenError title="Renderer configuration error" message={rendererResolution.error?.message} />;
|
||||
if (moduleContractQuery.isError) return <ScreenError title="Unable to load search options" message="The module search configuration request failed." onRetry={() => void moduleContractQuery.refetch()} />;
|
||||
if (moduleSearchActive && moduleQueryResult.isError) return <ScreenError title="Unable to search module" message="The module-wide content search request failed." onRetry={() => void moduleQueryResult.refetch()} />;
|
||||
if (!moduleSearchActive && templateQuery.isError) return <ScreenError title="Unable to load content" message="The content request failed." onRetry={() => void templateQuery.refetch()} />;
|
||||
|
||||
const CollectionRenderer = rendererResolution.CollectionRenderer;
|
||||
const ItemRenderer = rendererResolution.ItemRenderer;
|
||||
const hasFilters = filterableFields.length > 0;
|
||||
const hasSearchAttributes = searchableFields.length > 0;
|
||||
const hasSort = contract.search.sort_fields.length > 0;
|
||||
|
||||
return <SafeAreaView style={styles.safeArea} edges={["top","left","right"]}>
|
||||
<ContentPageHeader title={moduleName || "Content"} />
|
||||
<SearchHeader value={moduleQuery} onChangeText={setModuleQuery} placeholder="Search across this module…" />
|
||||
<FilterSummary filterCount={moduleFilters.length} searchAttributeCount={moduleSearchAttributes.length} sortCount={moduleSearchActive ? moduleSort.length : templateSearch.sort.length} showFilters={hasFilters} showSearchAttributes={hasSearchAttributes} showSort={hasSort} onFilter={() => setFilterBuilderVisible(true)} onSearchAttributes={() => setSearchAttributesVisible(true)} onSort={() => { if (onOpenSort) onOpenSort(); else setSortVisible(true); }} />
|
||||
<ModuleFilterChips fields={filterableFields} filters={moduleFilters} logic={moduleLogic} onLogicChange={setModuleLogic} onRemove={(index) => setModuleFilters((current) => current.filter((_, itemIndex) => itemIndex !== index))} onClear={() => setModuleFilters([])} />
|
||||
{moduleQuery !== debouncedModuleQuery ? <View style={styles.searchingRow}><Text style={styles.searchingText}>Searching…</Text></View> : null}
|
||||
<View style={styles.collectionContainer}>
|
||||
{moduleSearchActive ? <ModuleSearchResults items={moduleMerged.items} total={moduleMerged.total} isLoading={moduleQueryResult.isLoading} isRefreshing={moduleQueryResult.isRefetching && !moduleQueryResult.isFetchingNextPage} isFetchingNextPage={moduleQueryResult.isFetchingNextPage} onRefresh={() => void moduleQueryResult.refetch()} onLoadMore={() => { if (moduleQueryResult.hasNextPage && !moduleQueryResult.isFetchingNextPage) void moduleQueryResult.fetchNextPage(); }} onItemPress={onModuleSearchItemPress} /> : <CollectionRenderer items={templateMerged.items} total={templateMerged.total} isLoading={templateQuery.isLoading} isRefreshing={templateQuery.isRefetching && !templateQuery.isFetchingNextPage} isFetchingNextPage={templateQuery.isFetchingNextPage} onRefresh={() => void templateQuery.refetch()} onLoadMore={() => { if (templateQuery.hasNextPage && !templateQuery.isFetchingNextPage) void templateQuery.fetchNextPage(); }} onItemPress={onItemPress} renderItem={({item,onPress}) => <ItemRenderer item={item} onPress={onPress} />} />}
|
||||
</View>
|
||||
{hasFilters ? <ModuleFilterBuilderModal visible={filterBuilderVisible} fields={filterableFields} onClose={() => setFilterBuilderVisible(false)} onAdd={(criterion) => setModuleFilters((current) => [...current, criterion])} /> : null}
|
||||
{hasSearchAttributes ? <SearchAttributeModal visible={searchAttributesVisible} fields={searchableFields} selected={moduleSearchAttributes} onClose={() => setSearchAttributesVisible(false)} onApply={setModuleSearchAttributes} /> : null}
|
||||
{hasSort && !onOpenSort ? <ContractSortModal visible={sortVisible} fields={moduleSearchActive ? (moduleContract?.sort_fields ?? []) : contract.search.sort_fields} sort={moduleSearchActive ? moduleSort : templateSearch.sort} defaultSort={moduleSearchActive ? (moduleContract?.default_sort ?? []) : contract.search.default_sort} onClose={() => setSortVisible(false)} onApply={moduleSearchActive ? setModuleSort : templateSearch.setSort} /> : null}
|
||||
</SafeAreaView>;
|
||||
}
|
||||
|
||||
const styles=StyleSheet.create({safeArea:{flex:1,backgroundColor:Colors.surface},searchingRow:{paddingHorizontal:moderateScale(24),paddingBottom:verticalScale(6)},searchingText:{fontSize:moderateScale(12),color:Colors.textSecondary},collectionContainer:{flex:1}});
|
||||
|
|
@ -1,154 +0,0 @@
|
|||
import React from "react";
|
||||
import { useRouter } from "expo-router";
|
||||
import { ScreenError, ScreenLoading } from "../components/ContentScreenState";
|
||||
import { useTemplateContractQuery } from "../hooks/use-template-contract-query";
|
||||
import { useModuleDisplayName } from "../hooks/use-module-display-name";
|
||||
import type { ModuleSearchContentItem, SearchContentItem, TemplateContractResponse } from "../types/presentation.types";
|
||||
import { buildContentReferenceRoute, getSingleNavigableContentReference } from "../utils/content-reference";
|
||||
import { CollectionTemplateScreen } from "./CollectionTemplateScreen";
|
||||
import { SingleTemplateScreen } from "./SingleTemplateScreen";
|
||||
|
||||
export interface TemplateScreenProps {
|
||||
moduleCode: string;
|
||||
templateCode: string;
|
||||
onContentPress?: (contentId: string) => void;
|
||||
onOpenFilters?: () => void;
|
||||
onOpenSort?: () => void;
|
||||
}
|
||||
|
||||
function normalized(value: string): string {
|
||||
return value.trim();
|
||||
}
|
||||
|
||||
function buildItemTarget(
|
||||
moduleCode: string,
|
||||
templateCode: string,
|
||||
contract: TemplateContractResponse,
|
||||
item: SearchContentItem,
|
||||
): string {
|
||||
// Data-level hydrated content references are authoritative for the selected
|
||||
// content row when exactly one valid target exists. Multiple row links are
|
||||
// intentionally not guessed; semantic renderers should expose them explicitly.
|
||||
const rowReference = getSingleNavigableContentReference(item.attributes.link);
|
||||
if (rowReference) {
|
||||
return buildContentReferenceRoute(rowReference);
|
||||
}
|
||||
|
||||
const itemLink = contract.presentation.item_link;
|
||||
const targetTemplate = itemLink?.target_template_code?.trim() || templateCode;
|
||||
|
||||
if (itemLink?.action === "template") {
|
||||
return `/modules/${encodeURIComponent(moduleCode)}/${encodeURIComponent(targetTemplate)}`;
|
||||
}
|
||||
|
||||
const configuredContentIdKey = itemLink?.target_content_id_attribute?.trim();
|
||||
const configuredContentId = configuredContentIdKey
|
||||
? item.attributes[configuredContentIdKey]
|
||||
: undefined;
|
||||
const targetContentId =
|
||||
typeof configuredContentId === "string" && configuredContentId.trim()
|
||||
? configuredContentId.trim()
|
||||
: item.id;
|
||||
|
||||
return `/modules/${encodeURIComponent(moduleCode)}/${encodeURIComponent(targetTemplate)}/${encodeURIComponent(targetContentId)}`;
|
||||
}
|
||||
|
||||
export function TemplateScreen({
|
||||
moduleCode,
|
||||
templateCode,
|
||||
onContentPress,
|
||||
onOpenFilters,
|
||||
onOpenSort,
|
||||
}: TemplateScreenProps) {
|
||||
const router = useRouter();
|
||||
const module = normalized(moduleCode);
|
||||
const template = normalized(templateCode);
|
||||
|
||||
if (!module || !template) {
|
||||
return <ScreenError title="Invalid content route" message="Required content route information is missing." />;
|
||||
}
|
||||
|
||||
return (
|
||||
<TemplateScreenResolved
|
||||
moduleCode={module}
|
||||
templateCode={template}
|
||||
onContentPress={onContentPress}
|
||||
onOpenFilters={onOpenFilters}
|
||||
onOpenSort={onOpenSort}
|
||||
navigate={(target) => router.push(target as never)}
|
||||
/>
|
||||
);
|
||||
}
|
||||
|
||||
function TemplateScreenResolved({
|
||||
moduleCode,
|
||||
templateCode,
|
||||
onContentPress,
|
||||
onOpenFilters,
|
||||
onOpenSort,
|
||||
navigate,
|
||||
}: TemplateScreenProps & { navigate: (target: string) => void }) {
|
||||
const contractQuery = useTemplateContractQuery(templateCode);
|
||||
const moduleDisplay = useModuleDisplayName(moduleCode);
|
||||
|
||||
if (contractQuery.isLoading) return <ScreenLoading message="Loading content…" />;
|
||||
|
||||
if (contractQuery.isError) {
|
||||
return (
|
||||
<ScreenError
|
||||
title="Unable to load content"
|
||||
message="The content configuration request failed."
|
||||
onRetry={() => void contractQuery.refetch()}
|
||||
/>
|
||||
);
|
||||
}
|
||||
|
||||
const contract = contractQuery.data;
|
||||
if (!contract) return <ScreenError title="Content unavailable" message="The content configuration response was empty." />;
|
||||
|
||||
if (contract.template_code !== templateCode) {
|
||||
return <ScreenError title="Content configuration mismatch" message="The requested content screen does not match its configured template." />;
|
||||
}
|
||||
|
||||
if (contract.module_code && contract.module_code !== moduleCode) {
|
||||
return <ScreenError title="Content configuration mismatch" message="This content screen is not configured for the selected module." />;
|
||||
}
|
||||
|
||||
if (contract.presentation.mode === "single") {
|
||||
return <SingleTemplateScreen moduleCode={moduleCode} templateCode={templateCode} contract={contract} />;
|
||||
}
|
||||
|
||||
if (contract.presentation.mode === "collection") {
|
||||
return (
|
||||
<CollectionTemplateScreen
|
||||
moduleCode={moduleCode}
|
||||
moduleName={moduleDisplay.name}
|
||||
templateCode={templateCode}
|
||||
contract={contract}
|
||||
onModuleSearchItemPress={(item: ModuleSearchContentItem) => {
|
||||
navigate(`/modules/${encodeURIComponent(moduleCode)}/${encodeURIComponent(item.template_code)}/${encodeURIComponent(item.id)}`);
|
||||
}}
|
||||
onItemPress={(item) => {
|
||||
const rowReference = getSingleNavigableContentReference(item.attributes.link);
|
||||
|
||||
// A hydrated data-level reference is more specific than the optional
|
||||
// legacy callback because it identifies the actual destination content.
|
||||
if (rowReference) {
|
||||
navigate(buildContentReferenceRoute(rowReference));
|
||||
return;
|
||||
}
|
||||
|
||||
if (onContentPress && !contract.presentation.item_link) {
|
||||
onContentPress(item.id);
|
||||
return;
|
||||
}
|
||||
|
||||
navigate(buildItemTarget(moduleCode, templateCode, contract, item));
|
||||
}}
|
||||
onOpenSort={onOpenSort}
|
||||
/>
|
||||
);
|
||||
}
|
||||
|
||||
return <ScreenError title="Unsupported content layout" message="This content screen returned an unsupported presentation mode." />;
|
||||
}
|
||||
|
|
@ -15,6 +15,44 @@ export type AttributePresentationMap = ReadonlyMap<
|
|||
TemplateAttributePresentationContract
|
||||
>;
|
||||
|
||||
/** Returns the data-facing key from a canonical contract key. */
|
||||
export function bareAttributeKey(attributeKey: string): string {
|
||||
const normalized = attributeKey.trim();
|
||||
const index = normalized.lastIndexOf(".");
|
||||
return index >= 0 ? normalized.slice(index + 1) : normalized;
|
||||
}
|
||||
|
||||
/**
|
||||
* Resolves a presentation rule for either a canonical key
|
||||
* (`M0001_CT0003.location`) or the reconstructed API key (`location`).
|
||||
*/
|
||||
export function findAttributePresentationRule(
|
||||
attributeKey: string,
|
||||
rules: readonly TemplateAttributePresentationContract[] | null | undefined,
|
||||
): TemplateAttributePresentationContract | undefined {
|
||||
const normalized = attributeKey.trim();
|
||||
if (!normalized) return undefined;
|
||||
const bare = bareAttributeKey(normalized);
|
||||
return (rules ?? []).find((rule) => {
|
||||
const ruleKey = rule.attribute_key.trim();
|
||||
return ruleKey === normalized || bareAttributeKey(ruleKey) === bare;
|
||||
});
|
||||
}
|
||||
|
||||
export function presentationDisplayOrder(
|
||||
rule: TemplateAttributePresentationContract | null | undefined,
|
||||
definitionSortOrder?: number | null,
|
||||
contractIndex?: number,
|
||||
): number {
|
||||
if (typeof rule?.display_order === "number" && Number.isFinite(rule.display_order)) {
|
||||
return rule.display_order;
|
||||
}
|
||||
if (typeof definitionSortOrder === "number" && Number.isFinite(definitionSortOrder)) {
|
||||
return definitionSortOrder;
|
||||
}
|
||||
return 1_000_000 + (contractIndex ?? 0);
|
||||
}
|
||||
|
||||
function isPlainObject(value: unknown): value is Record<string, unknown> {
|
||||
if (value === null || typeof value !== "object") {
|
||||
return false;
|
||||
|
|
@ -111,8 +149,10 @@ export function getAttributePresentationRule(
|
|||
}
|
||||
|
||||
const rule = rules instanceof Map
|
||||
? rules.get(normalizedKey)
|
||||
: (rules ?? []).find((item) => item.attribute_key === normalizedKey);
|
||||
? rules.get(normalizedKey) ?? Array.from(rules.values()).find(
|
||||
(item) => bareAttributeKey(item.attribute_key) === bareAttributeKey(normalizedKey),
|
||||
)
|
||||
: findAttributePresentationRule(normalizedKey, rules);
|
||||
|
||||
return rule ?? {
|
||||
attribute_key: normalizedKey,
|
||||
|
|
@ -157,3 +197,45 @@ export function getEmptyDisplayText(
|
|||
const text = rule.empty_text?.trim();
|
||||
return text ? text : null;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Applies the effective presentation contract before semantic renderers receive
|
||||
* attribute data. This keeps visibility and empty behavior consistent even for
|
||||
* legacy/specialized renderers that read fields directly.
|
||||
*
|
||||
* `code` is presentation-only noise in the mobile reading UI and is removed at
|
||||
* this boundary. Domain-specific values such as `point_code` remain available.
|
||||
*/
|
||||
export function applyPresentationContractToData(
|
||||
data: Record<string, unknown>,
|
||||
attributes: readonly TemplateAttributePresentationContract[] | null | undefined,
|
||||
): Record<string, unknown> {
|
||||
const output: Record<string, unknown> = {};
|
||||
|
||||
for (const [key, value] of Object.entries(data)) {
|
||||
if (key === "code") continue;
|
||||
|
||||
const rule = findAttributePresentationRule(key, attributes);
|
||||
if (rule?.visibility === "hide") continue;
|
||||
|
||||
if (!isEmptyValue(value)) {
|
||||
output[key] = value;
|
||||
continue;
|
||||
}
|
||||
|
||||
if (rule?.empty_behavior !== "show") continue;
|
||||
output[key] = rule.empty_text?.trim() || "—";
|
||||
}
|
||||
|
||||
// Empty-show rules can refer to canonical keys while reconstructed data uses
|
||||
// bare keys. Materialize the bare key so semantic renderers can consume it.
|
||||
for (const rule of attributes ?? []) {
|
||||
const key = bareAttributeKey(rule.attribute_key);
|
||||
if (!key || key === "code" || Object.prototype.hasOwnProperty.call(output, key)) continue;
|
||||
if (rule.visibility === "hide" || rule.empty_behavior !== "show") continue;
|
||||
output[key] = rule.empty_text?.trim() || "—";
|
||||
}
|
||||
|
||||
return output;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -8,6 +8,7 @@ import { Colors } from "@/theme";
|
|||
|
||||
export interface ContentPageHeaderProps {
|
||||
title: string;
|
||||
subtitle?: string;
|
||||
right?: ReactNode;
|
||||
fallbackRoute?: string;
|
||||
onTitlePress?: () => void;
|
||||
|
|
@ -16,6 +17,7 @@ export interface ContentPageHeaderProps {
|
|||
|
||||
export function ContentPageHeader({
|
||||
title,
|
||||
subtitle,
|
||||
right,
|
||||
fallbackRoute = "/modules",
|
||||
onTitlePress,
|
||||
|
|
@ -31,9 +33,16 @@ export function ContentPageHeader({
|
|||
};
|
||||
|
||||
const titleContent = (
|
||||
<Text numberOfLines={1} style={styles.title}>
|
||||
{title}
|
||||
</Text>
|
||||
<View style={styles.titleContent}>
|
||||
<Text numberOfLines={1} style={styles.title}>
|
||||
{title}
|
||||
</Text>
|
||||
{subtitle ? (
|
||||
<Text numberOfLines={1} style={styles.subtitle}>
|
||||
{subtitle}
|
||||
</Text>
|
||||
) : null}
|
||||
</View>
|
||||
);
|
||||
|
||||
return (
|
||||
|
|
@ -76,31 +85,31 @@ export function ContentPageHeader({
|
|||
<View style={styles.titleButton}>{titleContent}</View>
|
||||
)}
|
||||
|
||||
<View style={[styles.sideSlot, styles.rightSlot]}>
|
||||
{right}
|
||||
</View>
|
||||
<View style={[styles.sideSlot, styles.rightSlot]}>{right}</View>
|
||||
</View>
|
||||
);
|
||||
}
|
||||
|
||||
const styles = StyleSheet.create({
|
||||
header: {
|
||||
height: 60,
|
||||
minHeight: 60,
|
||||
flexDirection: "row",
|
||||
alignItems: "center",
|
||||
paddingHorizontal: moderateScale(12),
|
||||
justifyContent: "space-between",
|
||||
paddingHorizontal: moderateScale(16),
|
||||
borderBottomWidth: 1,
|
||||
borderBottomColor: "#ECECEC",
|
||||
backgroundColor: "#FFFFFF",
|
||||
},
|
||||
sideSlot: {
|
||||
width: 88,
|
||||
width: 82,
|
||||
height: 40,
|
||||
flexDirection: "row",
|
||||
alignItems: "center",
|
||||
justifyContent: "flex-start",
|
||||
alignItems: "flex-start",
|
||||
justifyContent: "center",
|
||||
},
|
||||
rightSlot: {
|
||||
flexDirection: "row",
|
||||
alignItems: "center",
|
||||
justifyContent: "flex-end",
|
||||
},
|
||||
iconButton: {
|
||||
|
|
@ -116,10 +125,16 @@ const styles = StyleSheet.create({
|
|||
titleButton: {
|
||||
flex: 1,
|
||||
minHeight: 40,
|
||||
marginHorizontal: moderateScale(4),
|
||||
marginHorizontal: moderateScale(12),
|
||||
alignItems: "center",
|
||||
justifyContent: "center",
|
||||
},
|
||||
titleContent: {
|
||||
width: "100%",
|
||||
alignItems: "center",
|
||||
justifyContent: "center",
|
||||
gap: 1,
|
||||
},
|
||||
title: {
|
||||
width: "100%",
|
||||
textAlign: "center",
|
||||
|
|
@ -127,4 +142,12 @@ const styles = StyleSheet.create({
|
|||
fontWeight: "700",
|
||||
color: Colors.textPrimary,
|
||||
},
|
||||
subtitle: {
|
||||
width: "100%",
|
||||
textAlign: "center",
|
||||
fontSize: moderateScale(12),
|
||||
lineHeight: moderateScale(16),
|
||||
fontWeight: "500",
|
||||
color: Colors.textSecondary,
|
||||
},
|
||||
});
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@ import React from "react";
|
|||
import { asString } from "../../renderers/helpers/value";
|
||||
import { Hero } from "../../renderers/shared/Hero";
|
||||
import { DescriptionList, ObjectArrayCards, ObjectArrayTable, ObjectCard, PointCodes, Strings } from "../../renderers/details/categoryParts";
|
||||
export const CategoryHero=({data,title}:{data:Record<string,unknown>;title:string})=><Hero eyebrow={asString(data.code)} title={asString(data.title)||asString(data.name)||title}/>;
|
||||
export const CategoryHero=({data,title}:{data:Record<string,unknown>;title:string})=><Hero title={asString(data.title)||asString(data.name)||title}/>;
|
||||
export const SourcePointTable=({data}:{data:Record<string,unknown>})=><ObjectArrayTable title="Source Points" value={data.source_point} columns={["meridian","point"]}/>;
|
||||
export const ClinicalFeatureList=({data}:{data:Record<string,unknown>})=><Strings title="Key Clinical Features" value={data.key_clinical_feature}/>;
|
||||
export const YinYangSection=({data}:{data:Record<string,unknown>})=><Strings title="Yin vs Yang" value={data.yin_vs_yang}/>;
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
import React from "react"; import { Text } from "react-native";
|
||||
import { asRecordArray, asString, asStringArray } from "../../renderers/helpers/value";
|
||||
import { Hero } from "../../renderers/shared/Hero"; import { SectionCard } from "../../renderers/shared/SectionCard"; import { KeyValueGrid } from "../../renderers/shared/KeyValueGrid"; import { ChipList } from "../../renderers/shared/ChipList"; import { BulletList } from "../../renderers/shared/BulletList"; import { ImageGallery } from "../../renderers/shared/ImageGallery";
|
||||
export const VesselHero=({data,title}:{data:Record<string,unknown>;title:string})=><Hero eyebrow={asString(data.code)} title={asString(data.name)||title} subtitle={asStringArray(data.alt_name).join(" · ")}/>;
|
||||
export const VesselHero=({data,title}:{data:Record<string,unknown>;title:string})=><Hero title={asString(data.name)||title} subtitle={asStringArray(data.alt_name).join(" · ")}/>;
|
||||
export const PointRelationsGrid=({data}:{data:Record<string,unknown>})=><SectionCard title="Point Relationships"><KeyValueGrid rows={[{label:"Master Point",value:asString(data.master_point)},{label:"Coupled Point",value:asString(data.coupled_point)},{label:"Luo Point",value:asString(data.luo_point)},{label:"Xi-Cleft Point",value:asString(data.xi_cleft_point)},{label:"Paired Meridian",value:asString(data.paired_meridian)}]}/><ChipList items={asStringArray(data.intersection_points)}/></SectionCard>;
|
||||
export const AreasOfEffectChips=({data}:{data:Record<string,unknown>})=><SectionCard title="Areas of Effect"><ChipList items={asStringArray(data.areas_of_effect)}/></SectionCard>;
|
||||
export const FunctionsList=({data}:{data:Record<string,unknown>})=><SectionCard title="Functions"><BulletList items={asStringArray(data.functions)}/></SectionCard>;
|
||||
|
|
|
|||
|
|
@ -1,15 +1,83 @@
|
|||
import React from "react";
|
||||
import { asRecord, asRecordArray, asString, asStringArray } from "../../renderers/helpers/value";
|
||||
import { Hero } from "../../renderers/shared/Hero"; import { SectionCard } from "../../renderers/shared/SectionCard"; import { BulletList } from "../../renderers/shared/BulletList"; import { ObjectSections } from "../../renderers/shared/ObjectSections"; import { ChipList } from "../../renderers/shared/ChipList"; import { RecordCards } from "../../renderers/shared/RecordCards";
|
||||
export const MeridianHero=({data,title}:{data:Record<string,unknown>;title:string})=><Hero eyebrow={asString(data.code)} title={asString(data.title)||title} subtitle={asString(data.name)}/>;
|
||||
export const PrimaryChannelPathway=({data}:{data:Record<string,unknown>})=><SectionCard title="Primary Channel Pathway"><BulletList items={asStringArray(data.primary_channel_pathway)}/></SectionCard>;
|
||||
export const SecondaryBranches=({data}:{data:Record<string,unknown>})=><SectionCard title="Secondary Branches"><ObjectSections value={asRecord(data.secondary_branches)}/></SectionCard>;
|
||||
export const DivergentChannel=({data}:{data:Record<string,unknown>})=><SectionCard title="Divergent Channel"><BulletList items={asStringArray(data.divergent_channel)}/></SectionCard>;
|
||||
export const LuoChannel=({data}:{data:Record<string,unknown>})=><SectionCard title="Luo-Connecting Channel"><BulletList items={asStringArray(data.luo_connecting_channel)}/><ObjectSections value={asRecord(data.luo_connecting_vessel)}/></SectionCard>;
|
||||
export const SinewChannel=({data}:{data:Record<string,unknown>})=><SectionCard title="Sinew Channel"><BulletList items={asStringArray(data.sinew_channel)}/></SectionCard>;
|
||||
export const SymptomsSections=({data}:{data:Record<string,unknown>})=><SectionCard title="Symptoms"><ObjectSections value={asRecord(data.symptoms)}/></SectionCard>;
|
||||
export const MeetingPoints=({data}:{data:Record<string,unknown>})=><SectionCard title="Meeting Points"><ChipList items={asStringArray(data.meeting_points)}/></SectionCard>;
|
||||
export const PointCategoriesGrid=({data}:{data:Record<string,unknown>})=><SectionCard title="Point Categories"><RecordCards rows={asRecordArray(data.point_categories)}/></SectionCard>;
|
||||
export const ClinicalManifestations=({data}:{data:Record<string,unknown>})=><SectionCard title="Clinical Manifestations"><RecordCards rows={asRecordArray(data.indications_clinical_manifestations)}/></SectionCard>;
|
||||
export const SpecificPoints=({data}:{data:Record<string,unknown>})=><SectionCard title="Specific Points"><RecordCards rows={asRecordArray(data.specific_points_according_to_functions)}/></SectionCard>;
|
||||
export const FiveShuTable=({data}:{data:Record<string,unknown>})=><SectionCard title="Five-Shu Transporting Points"><RecordCards rows={asRecordArray(data.five_shu_transporting_points)}/></SectionCard>;
|
||||
|
||||
import { asRecord, asString, asStringArray } from "../../renderers/helpers/value";
|
||||
import { BulletList } from "../../renderers/shared/BulletList";
|
||||
import { ContentValue } from "../../renderers/shared/ContentValue";
|
||||
import { Hero } from "../../renderers/shared/Hero";
|
||||
import { ObjectSections } from "../../renderers/shared/ObjectSections";
|
||||
import { SectionCard } from "../../renderers/shared/SectionCard";
|
||||
|
||||
export const MeridianHero = ({
|
||||
data,
|
||||
title,
|
||||
}: {
|
||||
data: Record<string, unknown>;
|
||||
title: string;
|
||||
}) => <Hero title={asString(data.title) || title} subtitle={asString(data.name)} />;
|
||||
|
||||
export const PrimaryChannelPathway = ({ data }: { data: Record<string, unknown> }) => (
|
||||
<SectionCard title="Primary Channel Pathway">
|
||||
<BulletList items={asStringArray(data.primary_channel_pathway)} />
|
||||
</SectionCard>
|
||||
);
|
||||
|
||||
export const SecondaryBranches = ({ data }: { data: Record<string, unknown> }) => (
|
||||
<SectionCard title="Secondary Branches">
|
||||
<ObjectSections value={asRecord(data.secondary_branches)} />
|
||||
</SectionCard>
|
||||
);
|
||||
|
||||
export const DivergentChannel = ({ data }: { data: Record<string, unknown> }) => (
|
||||
<SectionCard title="Divergent Channel">
|
||||
<BulletList items={asStringArray(data.divergent_channel)} />
|
||||
</SectionCard>
|
||||
);
|
||||
|
||||
export const LuoChannel = ({ data }: { data: Record<string, unknown> }) => (
|
||||
<SectionCard title="Luo-Connecting Channel">
|
||||
<BulletList items={asStringArray(data.luo_connecting_channel)} />
|
||||
<ObjectSections value={asRecord(data.luo_connecting_vessel)} />
|
||||
</SectionCard>
|
||||
);
|
||||
|
||||
export const SinewChannel = ({ data }: { data: Record<string, unknown> }) => (
|
||||
<SectionCard title="Sinew Channel">
|
||||
<BulletList items={asStringArray(data.sinew_channel)} />
|
||||
</SectionCard>
|
||||
);
|
||||
|
||||
export const SymptomsSections = ({ data }: { data: Record<string, unknown> }) => (
|
||||
<SectionCard title="Symptoms">
|
||||
<ObjectSections value={asRecord(data.symptoms)} />
|
||||
</SectionCard>
|
||||
);
|
||||
|
||||
export const MeetingPoints = ({ data }: { data: Record<string, unknown> }) => (
|
||||
<SectionCard title="Meeting Points">
|
||||
<ContentValue value={data.meeting_points} />
|
||||
</SectionCard>
|
||||
);
|
||||
|
||||
export const PointCategoriesGrid = ({ data }: { data: Record<string, unknown> }) => (
|
||||
<SectionCard title="Point Categories">
|
||||
<ObjectSections value={asRecord(data.point_categories)} />
|
||||
</SectionCard>
|
||||
);
|
||||
|
||||
export const ClinicalManifestations = ({ data }: { data: Record<string, unknown> }) => (
|
||||
<SectionCard title="Clinical Manifestations">
|
||||
<BulletList items={asStringArray(data.indications_clinical_manifestations)} />
|
||||
</SectionCard>
|
||||
);
|
||||
|
||||
export const SpecificPoints = ({ data }: { data: Record<string, unknown> }) => (
|
||||
<SectionCard title="Specific Points">
|
||||
<ObjectSections value={asRecord(data.specific_points_according_to_functions)} />
|
||||
</SectionCard>
|
||||
);
|
||||
|
||||
export const FiveShuTable = ({ data }: { data: Record<string, unknown> }) => (
|
||||
<SectionCard title="Five-Shu Transporting Points">
|
||||
<ObjectSections value={asRecord(data.five_shu_transporting_points)} />
|
||||
</SectionCard>
|
||||
);
|
||||
|
|
|
|||
|
|
@ -8,7 +8,7 @@ import { KeyValueGrid } from "../../renderers/shared/KeyValueGrid";
|
|||
import { ObjectSections } from "../../renderers/shared/ObjectSections";
|
||||
import { ImageGallery } from "../../renderers/shared/ImageGallery";
|
||||
import { SectionCard } from "../../renderers/shared/SectionCard";
|
||||
export const PointHero=({data,title}:{data:Record<string,unknown>;title:string})=><Hero eyebrow={asString(data.code)} title={title} subtitle={[asString(data.alt_name_1),asString(data.alt_name_2)].filter(Boolean).join(" · ")}/>;
|
||||
export const PointHero=({data,title}:{data:Record<string,unknown>;title:string})=><Hero title={title} subtitle={[asString(data.alt_name_1),asString(data.alt_name_2)].filter(Boolean).join(" · ")}/>;
|
||||
export const AlternativeNames=({data}:{data:Record<string,unknown>})=><ChipList items={[asString(data.alt_name_1),asString(data.alt_name_2)].filter(Boolean)}/>;
|
||||
export const PointTypeChips=({data}:{data:Record<string,unknown>})=><ChipList items={asStringArray(data.point_type)}/>;
|
||||
export const ChannelSection=({data}:{data:Record<string,unknown>})=>asString(data.channel)?<SectionCard title="Channel"><Text>{asString(data.channel)}</Text></SectionCard>:null;
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
import { useMemo } from "react";
|
||||
import { useModuleContentDetailQuery } from "./use-content-queries";
|
||||
import { useModuleContentDetailQuery, useTemplateDefinitionsQuery } from "./use-content-queries";
|
||||
import { useTemplateContractQuery } from "./use-template-contract-query";
|
||||
|
||||
export function useContentDetailScreen({
|
||||
|
|
@ -12,6 +12,7 @@ export function useContentDetailScreen({
|
|||
contentId: string;
|
||||
}) {
|
||||
const contractQuery = useTemplateContractQuery(templateCode);
|
||||
const definitionsQuery = useTemplateDefinitionsQuery(templateCode);
|
||||
const contentQuery = useModuleContentDetailQuery(
|
||||
{ module_code: moduleCode },
|
||||
contentId,
|
||||
|
|
@ -25,11 +26,12 @@ export function useContentDetailScreen({
|
|||
return {
|
||||
contractQuery,
|
||||
contentQuery,
|
||||
definitionsQuery,
|
||||
moduleMismatch,
|
||||
isLoading: contractQuery.isLoading || contentQuery.isLoading,
|
||||
isError: contractQuery.isError || contentQuery.isError || moduleMismatch,
|
||||
isLoading: contractQuery.isLoading || contentQuery.isLoading || definitionsQuery.isLoading,
|
||||
isError: contractQuery.isError || contentQuery.isError || definitionsQuery.isError || moduleMismatch,
|
||||
refetch: async () => {
|
||||
await Promise.all([contractQuery.refetch(), contentQuery.refetch()]);
|
||||
await Promise.all([contractQuery.refetch(), contentQuery.refetch(), definitionsQuery.refetch()]);
|
||||
},
|
||||
};
|
||||
}
|
||||
|
|
|
|||
|
|
@ -132,7 +132,7 @@ const GalleryImage = memo(function GalleryImage({
|
|||
previous.item.caption === next.item.caption
|
||||
);
|
||||
|
||||
export function ContentMediaGallery({ media, title = "Images" }: ContentMediaGalleryProps) {
|
||||
export function ContentMediaGallery({ media, title = "Visual reference" }: ContentMediaGalleryProps) {
|
||||
const items = useMemo(() => sortMedia(media ?? []), [media]);
|
||||
const { width: windowWidth } = useWindowDimensions();
|
||||
const carouselWidth = Math.max(windowWidth - Spacing.md * 2, 280);
|
||||
|
|
@ -217,18 +217,18 @@ export function ContentMediaGallery({ media, title = "Images" }: ContentMediaGal
|
|||
}
|
||||
|
||||
const styles = StyleSheet.create({
|
||||
root: { gap: 10 },
|
||||
root: { gap: 10, marginBottom: 2 },
|
||||
headingRow: { flexDirection: "row", alignItems: "center", justifyContent: "space-between" },
|
||||
title: { color: Colors.textPrimary, fontSize: 18, fontWeight: "800" },
|
||||
title: { color: Colors.textPrimary, fontSize: 15, fontWeight: "700" },
|
||||
count: { color: Colors.textSecondary, fontSize: 13, fontWeight: "600" },
|
||||
carousel: {
|
||||
overflow: "hidden",
|
||||
borderRadius: 16,
|
||||
borderRadius: 18,
|
||||
backgroundColor: Colors.surface,
|
||||
borderWidth: StyleSheet.hairlineWidth,
|
||||
borderColor: Colors.border,
|
||||
},
|
||||
slide: { height: 260, alignItems: "center", justifyContent: "center" },
|
||||
slide: { height: 290, alignItems: "center", justifyContent: "center" },
|
||||
image: { width: "100%", height: "100%", backgroundColor: Colors.surface },
|
||||
loadingOverlay: {
|
||||
...StyleSheet.absoluteFillObject,
|
||||
|
|
|
|||
|
|
@ -1,6 +1,32 @@
|
|||
import React from "react";
|
||||
import { ScrollView, Text, View } from "react-native";
|
||||
import { DetailRendererProps } from "../types/renderer.types";
|
||||
import { ScrollView } from "react-native";
|
||||
import type { DetailRendererProps } from "../types/renderer.types";
|
||||
import { Hero } from "./shared/Hero";
|
||||
import { SectionCard } from "./shared/SectionCard";
|
||||
import { ImageGallery } from "./shared/ImageGallery";
|
||||
import { ContentValue } from "./shared/ContentValue";
|
||||
import { humanizeKey } from "./helpers/value";
|
||||
|
||||
export function GenericDetailRenderer({ content, data }: DetailRendererProps) {
|
||||
return <ScrollView contentContainerStyle={{padding:16,gap:16}}><Text style={{fontSize:28,fontWeight:"700"}}>{content.title}</Text>{Object.entries(data).map(([key,value])=><View key={key}><Text style={{fontWeight:"700"}}>{key}</Text><Text>{JSON.stringify(value,null,2)}</Text></View>)}</ScrollView>;
|
||||
return (
|
||||
<ScrollView
|
||||
contentContainerStyle={{
|
||||
paddingHorizontal: 18,
|
||||
paddingTop: 16,
|
||||
paddingBottom: 40,
|
||||
gap: 14,
|
||||
}}
|
||||
showsVerticalScrollIndicator={false}
|
||||
>
|
||||
<Hero title={content.title} subtitle={content.summary ?? undefined} />
|
||||
<ImageGallery images={[]} />
|
||||
{Object.entries(data)
|
||||
.filter(([key]) => key !== "code")
|
||||
.map(([key, value]) => (
|
||||
<SectionCard key={key} title={humanizeKey(key)}>
|
||||
<ContentValue value={value} />
|
||||
</SectionCard>
|
||||
))}
|
||||
</ScrollView>
|
||||
);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -2,7 +2,6 @@ import React from "react";
|
|||
import { Pressable, Text, View } from "react-native";
|
||||
import { CollectionItemRendererProps } from "../../types/renderer.types";
|
||||
export function AcuPointCardRenderer({ item, onPress }: CollectionItemRendererProps) {
|
||||
const code=typeof item.attributes.point_code==="string"?item.attributes.point_code:"";
|
||||
const meridian=typeof item.attributes.meridian==="string"?item.attributes.meridian:"";
|
||||
return <Pressable onPress={onPress}><View style={{padding:16,borderBottomWidth:1}}><View style={{flexDirection:"row",gap:10}}><Text style={{fontWeight:"700",minWidth:52}}>{code}</Text><Text style={{fontSize:17,fontWeight:"600",flex:1}}>{item.title}</Text></View>{meridian?<Text style={{marginTop:6}}>{meridian}</Text>:null}</View></Pressable>;
|
||||
return <Pressable onPress={onPress}><View style={{padding:16,borderBottomWidth:1}}><Text style={{fontSize:17,fontWeight:"600",flex:1}}>{item.title}</Text>{meridian?<Text style={{marginTop:6}}>{meridian}</Text>:null}</View></Pressable>;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -3,8 +3,7 @@ import { ScrollView, Text, View } from "react-native";
|
|||
import { DetailRendererProps } from "../../types/renderer.types";
|
||||
const Section=({title,children}:{title:string;children:React.ReactNode})=><View style={{gap:8}}><Text style={{fontSize:18,fontWeight:"700"}}>{title}</Text>{children}</View>;
|
||||
export function AcuPointDetailRenderer({ content, data }: DetailRendererProps) {
|
||||
const pointCode=typeof data.point_code==="string"?data.point_code:"";
|
||||
const location=typeof data.location==="string"?data.location:"";
|
||||
const indications=Array.isArray(data.indications)?data.indications:[];
|
||||
return <ScrollView contentContainerStyle={{padding:16,gap:20}}><View><Text style={{fontWeight:"700"}}>{pointCode}</Text><Text style={{fontSize:30,fontWeight:"700"}}>{content.title}</Text></View>{location?<Section title="Location"><Text>{location}</Text></Section>:null}{indications.length?<Section title="Indications"><View>{indications.map((x,i)=><Text key={i}>• {String(x)}</Text>)}</View></Section>:null}</ScrollView>;
|
||||
return <ScrollView contentContainerStyle={{padding:16,gap:20}}><View><Text style={{fontSize:30,fontWeight:"700"}}>{content.title}</Text></View>{location?<Section title="Location"><Text>{location}</Text></Section>:null}{indications.length?<Section title="Indications"><View>{indications.map((x,i)=><Text key={i}>• {String(x)}</Text>)}</View></Section>:null}</ScrollView>;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -2,10 +2,36 @@ import React from "react";
|
|||
import { Pressable, Text, View } from "react-native";
|
||||
import { asNumber, asString, asStringArray } from "../helpers/value";
|
||||
import { CollectionScaffold } from "../shared/CollectionScaffold";
|
||||
import { ContentCountBadge } from "../shared/ContentCountBadge";
|
||||
import { ChipList } from "../shared/ChipList";
|
||||
import { StandardIndexCard } from "../shared/StandardIndexCard";
|
||||
import type { CollectionItemRendererProps, CollectionRendererProps } from "../../types/renderer.types";
|
||||
export function EovIndexCollectionRenderer(props:CollectionRendererProps){ return <CollectionScaffold {...props}/>; }
|
||||
export function EovCollectionRenderer(props:CollectionRendererProps){ return <CollectionScaffold {...props}/>; }
|
||||
export function EovIndexCardRenderer({item,onPress}:CollectionItemRendererProps){ const a=item.attributes; return <Pressable onPress={onPress}><View style={{padding:14,borderBottomWidth:1,flexDirection:"row",gap:10}}><View style={{flex:1}}><Text style={{fontSize:17,fontWeight:"700"}}>{asString(a.name)||item.title}</Text><Text>{asString(a.code)}</Text></View><ContentCountBadge count={asNumber(a.content_count)} label={asString(a.content_label)}/></View></Pressable>; }
|
||||
export function EovCardRenderer({item,onPress}:CollectionItemRendererProps){ const a=item.attributes; return <Pressable onPress={onPress}><View style={{padding:14,borderBottomWidth:1,gap:6}}><Text style={{fontSize:17,fontWeight:"700"}}>{asString(a.name)||item.title}</Text><ChipList items={asStringArray(a.alt_name)}/><Text>Master: {asString(a.master_point)} · Paired: {asString(a.paired_meridian)}</Text></View></Pressable>; }
|
||||
|
||||
export function EovIndexCollectionRenderer(props: CollectionRendererProps) {
|
||||
return <CollectionScaffold {...props} />;
|
||||
}
|
||||
export function EovCollectionRenderer(props: CollectionRendererProps) {
|
||||
return <CollectionScaffold {...props} />;
|
||||
}
|
||||
export function EovIndexCardRenderer({ item, onPress }: CollectionItemRendererProps) {
|
||||
const a = item.attributes;
|
||||
return (
|
||||
<StandardIndexCard
|
||||
title={asString(a.name) || item.title}
|
||||
count={asNumber(a.content_count)}
|
||||
countLabel={asString(a.content_label) || null}
|
||||
onPress={onPress}
|
||||
/>
|
||||
);
|
||||
}
|
||||
export function EovCardRenderer({ item, onPress }: CollectionItemRendererProps) {
|
||||
const a = item.attributes;
|
||||
return (
|
||||
<Pressable onPress={onPress}>
|
||||
<View style={{ padding: 14, gap: 6 }}>
|
||||
<Text style={{ fontSize: 17, fontWeight: "700" }}>{asString(a.name) || item.title}</Text>
|
||||
<ChipList items={asStringArray(a.alt_name)} />
|
||||
<Text>Master: {asString(a.master_point)} · Paired: {asString(a.paired_meridian)}</Text>
|
||||
</View>
|
||||
</Pressable>
|
||||
);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -2,9 +2,34 @@ import React from "react";
|
|||
import { Pressable, Text, View } from "react-native";
|
||||
import { asNumber, asString, asStringArray } from "../helpers/value";
|
||||
import { CollectionScaffold } from "../shared/CollectionScaffold";
|
||||
import { ContentCountBadge } from "../shared/ContentCountBadge";
|
||||
import { StandardIndexCard } from "../shared/StandardIndexCard";
|
||||
import type { CollectionItemRendererProps, CollectionRendererProps } from "../../types/renderer.types";
|
||||
export function MeridianIndexCollectionRenderer(props:CollectionRendererProps){ return <CollectionScaffold {...props}/>; }
|
||||
export function MeridianCollectionRenderer(props:CollectionRendererProps){ return <CollectionScaffold {...props}/>; }
|
||||
export function MeridianIndexCardRenderer({item,onPress}:CollectionItemRendererProps){ const a=item.attributes; return <Pressable onPress={onPress}><View style={{padding:14,borderBottomWidth:1,flexDirection:"row",gap:10,alignItems:"center"}}><View style={{flex:1}}><Text style={{fontSize:17,fontWeight:"700"}}>{asString(a.name)||item.title}</Text><Text>{asString(a.code)}</Text></View><ContentCountBadge count={asNumber(a.content_count)}/></View></Pressable>; }
|
||||
export function MeridianCardRenderer({item,onPress}:CollectionItemRendererProps){ const a=item.attributes; return <Pressable onPress={onPress}><View style={{padding:14,borderBottomWidth:1,gap:5}}><Text style={{fontSize:17,fontWeight:"700"}}>{asString(a.title)||item.title}</Text><Text>{asString(a.name)}</Text><Text>{asStringArray(a.point_codes).length} referenced points</Text></View></Pressable>; }
|
||||
|
||||
export function MeridianIndexCollectionRenderer(props: CollectionRendererProps) {
|
||||
return <CollectionScaffold {...props} />;
|
||||
}
|
||||
export function MeridianCollectionRenderer(props: CollectionRendererProps) {
|
||||
return <CollectionScaffold {...props} />;
|
||||
}
|
||||
export function MeridianIndexCardRenderer({ item, onPress }: CollectionItemRendererProps) {
|
||||
const a = item.attributes;
|
||||
return (
|
||||
<StandardIndexCard
|
||||
title={asString(a.name) || item.title}
|
||||
count={asNumber(a.content_count)}
|
||||
onPress={onPress}
|
||||
/>
|
||||
);
|
||||
}
|
||||
export function MeridianCardRenderer({ item, onPress }: CollectionItemRendererProps) {
|
||||
const a = item.attributes;
|
||||
return (
|
||||
<Pressable onPress={onPress}>
|
||||
<View style={{ padding: 14, gap: 5 }}>
|
||||
<Text style={{ fontSize: 17, fontWeight: "700" }}>{asString(a.title) || item.title}</Text>
|
||||
<Text>{asString(a.name)}</Text>
|
||||
<Text>{asStringArray(a.point_codes).length} referenced points</Text>
|
||||
</View>
|
||||
</Pressable>
|
||||
);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,8 +1,86 @@
|
|||
import React from "react";
|
||||
import { Pressable, Text, View } from "react-native";
|
||||
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 } from "../helpers/value";
|
||||
import { CollectionScaffold } from "../shared/CollectionScaffold";
|
||||
import { ContentCountBadge } from "../shared/ContentCountBadge";
|
||||
import type { CollectionItemRendererProps, CollectionRendererProps } from "../../types/renderer.types";
|
||||
export function ModuleCatalogCollectionRenderer(props: CollectionRendererProps){ return <CollectionScaffold {...props}/>; }
|
||||
export function ModuleCatalogCardRenderer({item,onPress}:CollectionItemRendererProps){ const a=item.attributes; return <Pressable onPress={onPress}><View style={{padding:16,borderBottomWidth:1,flexDirection:"row",alignItems:"center",gap:12}}><View style={{flex:1,gap:4}}><Text style={{fontSize:18,fontWeight:"700"}}>{asString(a.name)||item.title}</Text><Text>{asString(a.content_label)}</Text></View><ContentCountBadge count={asNumber(a.content_count)} label={asString(a.content_label)}/><Text>›</Text></View></Pressable>; }
|
||||
import type {
|
||||
CollectionItemRendererProps,
|
||||
CollectionRendererProps,
|
||||
} from "../../types/renderer.types";
|
||||
|
||||
export function ModuleCatalogCollectionRenderer(props: CollectionRendererProps) {
|
||||
return <CollectionScaffold {...props} />;
|
||||
}
|
||||
|
||||
export function ModuleCatalogCardRenderer({
|
||||
item,
|
||||
onPress,
|
||||
}: CollectionItemRendererProps) {
|
||||
const attributes = item.attributes;
|
||||
const title = asString(attributes.name) || item.title;
|
||||
const label = asString(attributes.content_label) || item.summary || "Open content";
|
||||
|
||||
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}>{title}</Text>
|
||||
<Text style={styles.description} numberOfLines={1}>
|
||||
{label}
|
||||
</Text>
|
||||
</View>
|
||||
|
||||
<ContentCountBadge
|
||||
count={asNumber(attributes.content_count)}
|
||||
label={asString(attributes.content_label)}
|
||||
/>
|
||||
<Ionicons name="chevron-forward" size={20} color="#9CA3AF" />
|
||||
</Pressable>
|
||||
);
|
||||
}
|
||||
|
||||
const styles = StyleSheet.create({
|
||||
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,
|
||||
},
|
||||
});
|
||||
|
|
|
|||
|
|
@ -1,8 +1,20 @@
|
|||
import React from "react";
|
||||
import { Pressable, Text, View } from "react-native";
|
||||
import { asNumber, asString } from "../helpers/value";
|
||||
import { CollectionScaffold } from "../shared/CollectionScaffold";
|
||||
import { ContentCountBadge } from "../shared/ContentCountBadge";
|
||||
import { StandardIndexCard } from "../shared/StandardIndexCard";
|
||||
import type { CollectionItemRendererProps, CollectionRendererProps } from "../../types/renderer.types";
|
||||
export function PointCategoryIndexCollectionRenderer(props:CollectionRendererProps){ return <CollectionScaffold {...props}/>; }
|
||||
export function PointCategoryIndexCardRenderer({item,onPress}:CollectionItemRendererProps){ const a=item.attributes; return <Pressable onPress={onPress}><View style={{padding:14,borderBottomWidth:1,flexDirection:"row",alignItems:"center",gap:10}}><Text style={{flex:1,fontSize:17,fontWeight:"700"}}>{asString(a.name)||item.title}</Text><ContentCountBadge count={asNumber(a.content_count)} label={asString(a.content_label)}/><Text>›</Text></View></Pressable>; }
|
||||
|
||||
export function PointCategoryIndexCollectionRenderer(props: CollectionRendererProps) {
|
||||
return <CollectionScaffold {...props} />;
|
||||
}
|
||||
export function PointCategoryIndexCardRenderer({ item, onPress }: CollectionItemRendererProps) {
|
||||
const a = item.attributes;
|
||||
return (
|
||||
<StandardIndexCard
|
||||
title={asString(a.name) || item.title}
|
||||
count={asNumber(a.content_count)}
|
||||
countLabel={asString(a.content_label) || null}
|
||||
onPress={onPress}
|
||||
/>
|
||||
);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -3,8 +3,37 @@ import { Pressable, Text, View } from "react-native";
|
|||
import { asString, asStringArray } from "../helpers/value";
|
||||
import { CollectionScaffold } from "../shared/CollectionScaffold";
|
||||
import { ChipList } from "../shared/ChipList";
|
||||
import { StandardIndexCard } from "../shared/StandardIndexCard";
|
||||
import type { CollectionItemRendererProps, CollectionRendererProps } from "../../types/renderer.types";
|
||||
export function AcuPointIndexCollectionRenderer(props:CollectionRendererProps){ return <CollectionScaffold {...props}/>; }
|
||||
export function AcuPointCollectionRenderer(props:CollectionRendererProps){ return <CollectionScaffold {...props}/>; }
|
||||
export function AcuPointIndexCardRenderer({item,onPress}:CollectionItemRendererProps){ const a=item.attributes; return <Pressable onPress={onPress}><View style={{padding:14,borderBottomWidth:1,gap:4}}><Text style={{fontSize:17,fontWeight:"700"}}>{asString(a.code)||item.title}</Text><Text>{asString(a.alt_name_1)}</Text><Text>{asString(a.alt_name_2)}</Text></View></Pressable>; }
|
||||
export function AcuPointCardRenderer({item,onPress}:CollectionItemRendererProps){ const a=item.attributes; return <Pressable onPress={onPress}><View style={{padding:14,borderBottomWidth:1,gap:7}}><View style={{flexDirection:"row",gap:10}}><Text style={{minWidth:55,fontWeight:"700"}}>{asString(a.code)}</Text><Text style={{flex:1,fontSize:17,fontWeight:"600"}}>{item.title}</Text></View><Text>{asString(a.channel)}</Text><ChipList items={asStringArray(a.point_type).slice(0,3)}/></View></Pressable>; }
|
||||
|
||||
export function AcuPointIndexCollectionRenderer(props: CollectionRendererProps) {
|
||||
return <CollectionScaffold {...props} />;
|
||||
}
|
||||
export function AcuPointCollectionRenderer(props: CollectionRendererProps) {
|
||||
return <CollectionScaffold {...props} />;
|
||||
}
|
||||
export function AcuPointIndexCardRenderer({ item, onPress }: CollectionItemRendererProps) {
|
||||
const a = item.attributes;
|
||||
const altNames = [asString(a.alt_name_1), asString(a.alt_name_2)].filter(Boolean).join(" · ");
|
||||
return (
|
||||
<StandardIndexCard
|
||||
title={asString(a.point_name) || asString(a.name) || item.title}
|
||||
subtitle={altNames || null}
|
||||
onPress={onPress}
|
||||
/>
|
||||
);
|
||||
}
|
||||
export function AcuPointCardRenderer({ item, onPress }: CollectionItemRendererProps) {
|
||||
const a = item.attributes;
|
||||
return (
|
||||
<Pressable onPress={onPress}>
|
||||
<View style={{ padding: 14, gap: 7 }}>
|
||||
<View style={{ flexDirection: "row", gap: 10 }}>
|
||||
<Text style={{ flex: 1, fontSize: 17, fontWeight: "600" }}>{asString(a.point_name) || asString(a.name) || item.title}</Text>
|
||||
</View>
|
||||
<Text>{asString(a.channel)}</Text>
|
||||
<ChipList items={asStringArray(a.point_type).slice(0, 3)} />
|
||||
</View>
|
||||
</Pressable>
|
||||
);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,6 +1,176 @@
|
|||
import React from "react";
|
||||
import React, { useMemo } from "react";
|
||||
import { ScrollView, Text } from "react-native";
|
||||
|
||||
import type { DetailRendererProps } from "../../types/renderer.types";
|
||||
import { asRecord, asRecordArray, asString, asStringArray } from "../helpers/value";
|
||||
import { Hero } from "../shared/Hero"; import { SectionCard } from "../shared/SectionCard"; import { ChipList } from "../shared/ChipList"; import { BulletList } from "../shared/BulletList"; import { KeyValueGrid } from "../shared/KeyValueGrid"; import { ObjectSections } from "../shared/ObjectSections"; import { ImageGallery } from "../shared/ImageGallery";
|
||||
export function AcuPointDetailRenderer({content,data}:DetailRendererProps){ const methods=asRecord(data.methods); return <ScrollView contentContainerStyle={{padding:16,gap:16}}><Hero eyebrow={asString(data.code)} title={content.title} subtitle={[asString(data.alt_name_1),asString(data.alt_name_2)].filter(Boolean).join(" · ")}/><ChipList items={asStringArray(data.point_type)}/><SectionCard title="Channel"><Text>{asString(data.channel)}</Text></SectionCard><SectionCard title="Location"><Text>{asString(data.location)}</Text>{asString(data.location_note)?<Text>{asString(data.location_note)}</Text>:null}</SectionCard><SectionCard title="Indications"><BulletList items={asStringArray(data.indications)}/></SectionCard><SectionCard title="Actions"><BulletList items={asStringArray(data.actions)}/></SectionCard><SectionCard title="Methods"><KeyValueGrid rows={[{label:"Needling",value:asString(methods.needling)||asString(data.needling)},{label:"Response",value:asString(methods.needling_response)||asString(data.needling_response)},{label:"Moxibustion",value:asString(methods.moxibustion)||asString(data.moxibustion)},{label:"Additional",value:asString(methods.additional_method)||asString(data.additional_method)}]}/></SectionCard><SectionCard title="Regional Anatomy"><ObjectSections value={asRecord(data.regional_anatomy)}/></SectionCard>{asString(data.caution)?<SectionCard title="Caution"><Text>{asString(data.caution)}</Text></SectionCard>:null}<ImageGallery images={asRecordArray(data.point_images)}/></ScrollView>; }
|
||||
import {
|
||||
bareAttributeKey,
|
||||
findAttributePresentationRule,
|
||||
getEmptyDisplayText,
|
||||
presentationDisplayOrder,
|
||||
shouldRenderAttribute,
|
||||
} from "../../utils/attribute-presentation";
|
||||
import { asRecord, asRecordArray, asString, asStringArray, humanizeKey } from "../helpers/value";
|
||||
import { BulletList } from "../shared/BulletList";
|
||||
import { ChipList } from "../shared/ChipList";
|
||||
import { ContentValue } from "../shared/ContentValue";
|
||||
import { Hero } from "../shared/Hero";
|
||||
import { ImageGallery } from "../shared/ImageGallery";
|
||||
import { KeyValueGrid } from "../shared/KeyValueGrid";
|
||||
import { ObjectSections } from "../shared/ObjectSections";
|
||||
import { SectionCard } from "../shared/SectionCard";
|
||||
|
||||
const RESERVED_KEYS = new Set([
|
||||
"point_name",
|
||||
"name",
|
||||
"title",
|
||||
"alt_name_1",
|
||||
"alt_name_2",
|
||||
"point_images",
|
||||
"images",
|
||||
"code",
|
||||
"sort_order",
|
||||
"link",
|
||||
]);
|
||||
|
||||
function isStringArray(value: unknown): value is string[] {
|
||||
return Array.isArray(value) && value.every((item) => typeof item === "string");
|
||||
}
|
||||
|
||||
function hasRenderableMethodValues(value: unknown): boolean {
|
||||
const record = asRecord(value);
|
||||
return ["needling", "needling_response", "moxibustion", "additional_method"].some(
|
||||
(key) => typeof record[key] === "string" && record[key].trim().length > 0,
|
||||
);
|
||||
}
|
||||
|
||||
export function AcuPointDetailRenderer({
|
||||
content,
|
||||
data,
|
||||
definitions,
|
||||
presentationAttributes,
|
||||
}: DetailRendererProps) {
|
||||
const orderedAttributes = useMemo(() => {
|
||||
const rootDefinitions = definitions.filter((definition) => definition.is_root);
|
||||
const definitionByBareKey = new Map(
|
||||
rootDefinitions.map((definition) => [
|
||||
definition.code || bareAttributeKey(definition.attribute_key),
|
||||
definition,
|
||||
]),
|
||||
);
|
||||
const contractIndex = new Map(
|
||||
presentationAttributes.map((rule, index) => [rule.attribute_key, index]),
|
||||
);
|
||||
|
||||
const keys: string[] = [];
|
||||
const seen = new Set<string>();
|
||||
|
||||
for (const definition of rootDefinitions) {
|
||||
const key = definition.code || bareAttributeKey(definition.attribute_key);
|
||||
if (!key || seen.has(key)) continue;
|
||||
seen.add(key);
|
||||
keys.push(key);
|
||||
}
|
||||
|
||||
// Backward-compatible fallback when definitions are incomplete: add only
|
||||
// contract attributes that correspond to reconstructed root data keys.
|
||||
for (const rule of presentationAttributes) {
|
||||
const key = bareAttributeKey(rule.attribute_key);
|
||||
if (!key || seen.has(key) || !Object.prototype.hasOwnProperty.call(data, key)) continue;
|
||||
seen.add(key);
|
||||
keys.push(key);
|
||||
}
|
||||
|
||||
return keys
|
||||
.flatMap((key) => {
|
||||
if (RESERVED_KEYS.has(key)) return [];
|
||||
|
||||
const value = data[key];
|
||||
const definition = definitionByBareKey.get(key);
|
||||
const rule = findAttributePresentationRule(definition?.attribute_key ?? key, presentationAttributes);
|
||||
if (!shouldRenderAttribute(value, rule)) return [];
|
||||
|
||||
const label = definition?.label?.trim() || humanizeKey(key);
|
||||
const emptyText = getEmptyDisplayText(value, rule);
|
||||
const index = rule ? contractIndex.get(rule.attribute_key) ?? 0 : 0;
|
||||
const order = presentationDisplayOrder(rule, definition?.sort_order, index);
|
||||
|
||||
return [{ key, label, value, emptyText, order }];
|
||||
})
|
||||
.sort((a, b) => a.order - b.order || a.label.localeCompare(b.label));
|
||||
}, [data, definitions, presentationAttributes]);
|
||||
|
||||
const renderAttributeValue = (key: string, value: unknown, emptyText: string | null) => {
|
||||
if (key === "point_type" && isStringArray(value)) {
|
||||
return <ChipList items={asStringArray(value)} />;
|
||||
}
|
||||
|
||||
if ((key === "indications" || key === "actions") && isStringArray(value)) {
|
||||
return <BulletList items={asStringArray(value)} />;
|
||||
}
|
||||
|
||||
if ((key === "channel" || key === "location" || key === "location_note") && typeof value === "string") {
|
||||
return (
|
||||
<Text style={{ fontSize: 16, lineHeight: 25, color: key === "location_note" ? "#64748B" : "#334155" }}>
|
||||
{value}
|
||||
</Text>
|
||||
);
|
||||
}
|
||||
|
||||
if (key === "caution" && typeof value === "string") {
|
||||
return (
|
||||
<Text style={{ fontSize: 16, lineHeight: 25, color: "#6B3E3E" }}>
|
||||
{value}
|
||||
</Text>
|
||||
);
|
||||
}
|
||||
|
||||
if (key === "regional_anatomy" && value !== null && typeof value === "object" && !Array.isArray(value)) {
|
||||
return <ObjectSections value={asRecord(value)} />;
|
||||
}
|
||||
|
||||
if (key === "methods" && hasRenderableMethodValues(value)) {
|
||||
const methods = asRecord(value);
|
||||
return (
|
||||
<KeyValueGrid
|
||||
rows={[
|
||||
{ label: "Needling", value: asString(methods.needling) },
|
||||
{ label: "Response", value: asString(methods.needling_response) },
|
||||
{ label: "Moxibustion", value: asString(methods.moxibustion) },
|
||||
{ label: "Additional", value: asString(methods.additional_method) },
|
||||
]}
|
||||
/>
|
||||
);
|
||||
}
|
||||
|
||||
// Specialized-field fallback: any unexpected runtime shape is still
|
||||
// rendered through the generic reference-aware value renderer.
|
||||
return <ContentValue value={value} emptyText={emptyText ?? undefined} />;
|
||||
};
|
||||
|
||||
return (
|
||||
<ScrollView
|
||||
contentContainerStyle={{
|
||||
paddingHorizontal: 18,
|
||||
paddingTop: 16,
|
||||
paddingBottom: 40,
|
||||
gap: 14,
|
||||
}}
|
||||
showsVerticalScrollIndicator={false}
|
||||
>
|
||||
<Hero
|
||||
title={asString(data.point_name) || asString(data.name) || content.title}
|
||||
subtitle={[asString(data.alt_name_1), asString(data.alt_name_2)]
|
||||
.filter(Boolean)
|
||||
.join(" · ")}
|
||||
/>
|
||||
|
||||
<ImageGallery images={asRecordArray(data.point_images)} />
|
||||
|
||||
{orderedAttributes.map((attribute) => (
|
||||
<SectionCard key={attribute.key} title={attribute.label}>
|
||||
{renderAttributeValue(attribute.key, attribute.value, attribute.emptyText)}
|
||||
</SectionCard>
|
||||
))}
|
||||
</ScrollView>
|
||||
);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,7 +1,8 @@
|
|||
import React from "react";
|
||||
import { ScrollView } from "react-native";
|
||||
import type { DetailRendererProps } from "../../types/renderer.types";
|
||||
import { ContentLinkAttributeSections } from "../shared/ContentLinkAttributeSections";
|
||||
import { asString } from "../helpers/value";
|
||||
import { Hero } from "../shared/Hero";
|
||||
import { DescriptionList, Images, ObjectArrayCards, ObjectArrayTable, ObjectCard, PointCodes, Strings } from "./categoryParts";
|
||||
export function BackShuDetailRenderer({content,data}:DetailRendererProps){ return <ScrollView contentContainerStyle={{padding:16,gap:16}}><Hero eyebrow={asString(data.code)} title={asString(data.title)||asString(data.name)||content.title}/><PointCodes data={data}/><ObjectArrayTable title="Back-Shu Points" value={data.points}/><ObjectCard title="Functions" value={data.functions}/><ObjectCard title="Clinical Application" value={data.clinical_application}/><Images data={data}/></ScrollView>; }
|
||||
export function BackShuDetailRenderer({content,data,definitions,presentationAttributes}:DetailRendererProps){ return <ScrollView contentContainerStyle={{paddingHorizontal:18,paddingTop:16,paddingBottom:40,gap:14}}><Hero title={asString(data.title)||asString(data.name)||content.title}/><Images data={data}/><PointCodes data={data}/><ObjectArrayTable title="Back-Shu Points" value={data.points}/><ObjectCard title="Functions" value={data.functions}/><ObjectCard title="Clinical Application" value={data.clinical_application}/><ContentLinkAttributeSections data={data} definitions={definitions} presentationAttributes={presentationAttributes}/></ScrollView>; }
|
||||
|
|
|
|||
|
|
@ -1,7 +1,8 @@
|
|||
import React from "react";
|
||||
import { ScrollView } from "react-native";
|
||||
import type { DetailRendererProps } from "../../types/renderer.types";
|
||||
import { ContentLinkAttributeSections } from "../shared/ContentLinkAttributeSections";
|
||||
import { asString } from "../helpers/value";
|
||||
import { Hero } from "../shared/Hero";
|
||||
import { DescriptionList, Images, ObjectArrayCards, ObjectArrayTable, ObjectCard, PointCodes, Strings } from "./categoryParts";
|
||||
export function ConfluentPointsDetailRenderer({content,data}:DetailRendererProps){ return <ScrollView contentContainerStyle={{padding:16,gap:16}}><Hero eyebrow={asString(data.code)} title={asString(data.title)||asString(data.name)||content.title}/><PointCodes data={data}/><Strings title="Description" value={data.description}/><ObjectArrayCards title="Confluent Points" value={data.confluent_points}/><Images data={data}/></ScrollView>; }
|
||||
export function ConfluentPointsDetailRenderer({content,data,definitions,presentationAttributes}:DetailRendererProps){ return <ScrollView contentContainerStyle={{paddingHorizontal:18,paddingTop:16,paddingBottom:40,gap:14}}><Hero title={asString(data.title)||asString(data.name)||content.title}/><Images data={data}/><PointCodes data={data}/><Strings title="Description" value={data.description}/><ObjectArrayCards title="Confluent Points" value={data.confluent_points}/><ContentLinkAttributeSections data={data} definitions={definitions} presentationAttributes={presentationAttributes}/></ScrollView>; }
|
||||
|
|
|
|||
|
|
@ -1,7 +1,8 @@
|
|||
import React from "react";
|
||||
import { ScrollView } from "react-native";
|
||||
import type { DetailRendererProps } from "../../types/renderer.types";
|
||||
import { ContentLinkAttributeSections } from "../shared/ContentLinkAttributeSections";
|
||||
import { asString } from "../helpers/value";
|
||||
import { Hero } from "../shared/Hero";
|
||||
import { DescriptionList, Images, ObjectArrayCards, ObjectArrayTable, ObjectCard, PointCodes, Strings } from "./categoryParts";
|
||||
export function EntryExitPointsDetailRenderer({content,data}:DetailRendererProps){ return <ScrollView contentContainerStyle={{padding:16,gap:16}}><Hero eyebrow={asString(data.code)} title={asString(data.title)||asString(data.name)||content.title}/><PointCodes data={data}/><Strings title="Description" value={data.description}/><ObjectCard title="Entry / Exit Points" value={data.entry_exit_points}/><ObjectCard title="Clinical Significance" value={data.clinical_significance}/><Images data={data}/></ScrollView>; }
|
||||
export function EntryExitPointsDetailRenderer({content,data,definitions,presentationAttributes}:DetailRendererProps){ return <ScrollView contentContainerStyle={{paddingHorizontal:18,paddingTop:16,paddingBottom:40,gap:14}}><Hero title={asString(data.title)||asString(data.name)||content.title}/><Images data={data}/><PointCodes data={data}/><Strings title="Description" value={data.description}/><ObjectCard title="Entry / Exit Points" value={data.entry_exit_points}/><ObjectCard title="Clinical Significance" value={data.clinical_significance}/><ContentLinkAttributeSections data={data} definitions={definitions} presentationAttributes={presentationAttributes}/></ScrollView>; }
|
||||
|
|
|
|||
|
|
@ -1,6 +1,7 @@
|
|||
import React from "react";
|
||||
import { ScrollView, Text } from "react-native";
|
||||
import type { DetailRendererProps } from "../../types/renderer.types";
|
||||
import { ContentLinkAttributeSections } from "../shared/ContentLinkAttributeSections";
|
||||
import { asRecordArray, asString, asStringArray } from "../helpers/value";
|
||||
import { Hero } from "../shared/Hero"; import { SectionCard } from "../shared/SectionCard"; import { ChipList } from "../shared/ChipList"; import { BulletList } from "../shared/BulletList"; import { KeyValueGrid } from "../shared/KeyValueGrid"; import { ImageGallery } from "../shared/ImageGallery";
|
||||
export function EovDetailRenderer({content,data}:DetailRendererProps){ return <ScrollView contentContainerStyle={{padding:16,gap:16}}><Hero eyebrow={asString(data.code)} title={asString(data.name)||content.title} subtitle={asStringArray(data.alt_name).join(" · ")}/><SectionCard title="Point Relationships"><KeyValueGrid rows={[{label:"Master Point",value:asString(data.master_point)},{label:"Coupled Point",value:asString(data.coupled_point)},{label:"Luo Point",value:asString(data.luo_point)},{label:"Xi-Cleft Point",value:asString(data.xi_cleft_point)},{label:"Paired Meridian",value:asString(data.paired_meridian)}]}/><ChipList items={asStringArray(data.intersection_points)}/></SectionCard><SectionCard title="Areas of Effect"><ChipList items={asStringArray(data.areas_of_effect)}/></SectionCard><SectionCard title="Functions"><BulletList items={asStringArray(data.functions)}/></SectionCard><SectionCard title="Pathway"><Text style={{fontSize:16,lineHeight:24}}>{asString(data.pathway)}</Text></SectionCard><ImageGallery images={asRecordArray(data.images)}/></ScrollView>; }
|
||||
export function EovDetailRenderer({content,data,definitions,presentationAttributes}:DetailRendererProps){ return <ScrollView contentContainerStyle={{paddingHorizontal:18,paddingTop:16,paddingBottom:40,gap:14}}><Hero title={asString(data.name)||content.title} subtitle={asStringArray(data.alt_name).join(" · ")}/><ImageGallery images={asRecordArray(data.images)}/><SectionCard title="Point Relationships"><KeyValueGrid rows={[{label:"Master Point",value:asString(data.master_point)},{label:"Coupled Point",value:asString(data.coupled_point)},{label:"Luo Point",value:asString(data.luo_point)},{label:"Xi-Cleft Point",value:asString(data.xi_cleft_point)},{label:"Paired Meridian",value:asString(data.paired_meridian)}]}/><ChipList items={asStringArray(data.intersection_points)}/></SectionCard><SectionCard title="Areas of Effect"><ChipList items={asStringArray(data.areas_of_effect)}/></SectionCard><SectionCard title="Functions"><BulletList items={asStringArray(data.functions)}/></SectionCard><SectionCard title="Pathway"><Text style={{fontSize:16,lineHeight:26,color:"#334155"}}>{asString(data.pathway)}</Text></SectionCard><ContentLinkAttributeSections data={data} definitions={definitions} presentationAttributes={presentationAttributes}/></ScrollView>; }
|
||||
|
|
|
|||
|
|
@ -1,7 +1,8 @@
|
|||
import React from "react";
|
||||
import { ScrollView } from "react-native";
|
||||
import type { DetailRendererProps } from "../../types/renderer.types";
|
||||
import { ContentLinkAttributeSections } from "../shared/ContentLinkAttributeSections";
|
||||
import { asString } from "../helpers/value";
|
||||
import { Hero } from "../shared/Hero";
|
||||
import { DescriptionList, Images, ObjectArrayCards, ObjectArrayTable, ObjectCard, PointCodes, Strings } from "./categoryParts";
|
||||
export function FiveShuDetailRenderer({content,data}:DetailRendererProps){ return <ScrollView contentContainerStyle={{padding:16,gap:16}}><Hero eyebrow={asString(data.code)} title={asString(data.title)||asString(data.name)||content.title}/><PointCodes data={data}/><Strings title="Description" value={data.description}/><ObjectArrayTable title="Phases of Yin Channels" value={data.phases_of_yin_channels}/><ObjectArrayTable title="Points of Yin Channels" value={data.points_of_yin_channels}/><ObjectArrayTable title="Phases of Yang Channels" value={data.phases_of_yang_channels}/><ObjectArrayTable title="Points of Yang Channels" value={data.points_of_yang_channels}/><ObjectCard title="Clinical Application" value={data.clinical_application}/><ObjectCard title="Jing-Well Points" value={data.jing_well_points}/><ObjectCard title="Ying-Spring Points" value={data.ying_spring_points}/><ObjectCard title="Shu-Stream Points" value={data.shu_stream_points}/><ObjectCard title="Jing-River Points" value={data.jing_river_points}/><ObjectCard title="He-Sea Points" value={data.he_sea_points}/><Images data={data}/></ScrollView>; }
|
||||
export function FiveShuDetailRenderer({content,data,definitions,presentationAttributes}:DetailRendererProps){ return <ScrollView contentContainerStyle={{paddingHorizontal:18,paddingTop:16,paddingBottom:40,gap:14}}><Hero title={asString(data.title)||asString(data.name)||content.title}/><Images data={data}/><PointCodes data={data}/><Strings title="Description" value={data.description}/><ObjectArrayTable title="Phases of Yin Channels" value={data.phases_of_yin_channels}/><ObjectArrayTable title="Points of Yin Channels" value={data.points_of_yin_channels}/><ObjectArrayTable title="Phases of Yang Channels" value={data.phases_of_yang_channels}/><ObjectArrayTable title="Points of Yang Channels" value={data.points_of_yang_channels}/><ObjectCard title="Clinical Application" value={data.clinical_application}/><ObjectCard title="Jing-Well Points" value={data.jing_well_points}/><ObjectCard title="Ying-Spring Points" value={data.ying_spring_points}/><ObjectCard title="Shu-Stream Points" value={data.shu_stream_points}/><ObjectCard title="Jing-River Points" value={data.jing_river_points}/><ObjectCard title="He-Sea Points" value={data.he_sea_points}/><ContentLinkAttributeSections data={data} definitions={definitions} presentationAttributes={presentationAttributes}/></ScrollView>; }
|
||||
|
|
|
|||
|
|
@ -1,7 +1,8 @@
|
|||
import React from "react";
|
||||
import { ScrollView } from "react-native";
|
||||
import type { DetailRendererProps } from "../../types/renderer.types";
|
||||
import { ContentLinkAttributeSections } from "../shared/ContentLinkAttributeSections";
|
||||
import { asString } from "../helpers/value";
|
||||
import { Hero } from "../shared/Hero";
|
||||
import { DescriptionList, Images, ObjectArrayCards, ObjectArrayTable, ObjectCard, PointCodes, Strings } from "./categoryParts";
|
||||
export function FourSeasDetailRenderer({content,data}:DetailRendererProps){ return <ScrollView contentContainerStyle={{padding:16,gap:16}}><Hero eyebrow={asString(data.code)} title={asString(data.title)||asString(data.name)||content.title}/><PointCodes data={data}/><Strings title="Description" value={data.description}/><ObjectArrayCards title="The Four Seas" value={data.four_seas}/><Images data={data}/></ScrollView>; }
|
||||
export function FourSeasDetailRenderer({content,data,definitions,presentationAttributes}:DetailRendererProps){ return <ScrollView contentContainerStyle={{paddingHorizontal:18,paddingTop:16,paddingBottom:40,gap:14}}><Hero title={asString(data.title)||asString(data.name)||content.title}/><Images data={data}/><PointCodes data={data}/><Strings title="Description" value={data.description}/><ObjectArrayCards title="The Four Seas" value={data.four_seas}/><ContentLinkAttributeSections data={data} definitions={definitions} presentationAttributes={presentationAttributes}/></ScrollView>; }
|
||||
|
|
|
|||
|
|
@ -1,7 +1,8 @@
|
|||
import React from "react";
|
||||
import { ScrollView } from "react-native";
|
||||
import type { DetailRendererProps } from "../../types/renderer.types";
|
||||
import { ContentLinkAttributeSections } from "../shared/ContentLinkAttributeSections";
|
||||
import { asString } from "../helpers/value";
|
||||
import { Hero } from "../shared/Hero";
|
||||
import { DescriptionList, Images, ObjectArrayCards, ObjectArrayTable, ObjectCard, PointCodes, Strings } from "./categoryParts";
|
||||
export function FrontMuDetailRenderer({content,data}:DetailRendererProps){ return <ScrollView contentContainerStyle={{padding:16,gap:16}}><Hero eyebrow={asString(data.code)} title={asString(data.title)||asString(data.name)||content.title}/><PointCodes data={data}/><ObjectArrayTable title="Front-Mu Points" value={data.front_mu_points}/><Strings title="Description" value={data.description}/><ObjectCard title="Clinical Application" value={data.clinical_application}/><Images data={data}/></ScrollView>; }
|
||||
export function FrontMuDetailRenderer({content,data,definitions,presentationAttributes}:DetailRendererProps){ return <ScrollView contentContainerStyle={{paddingHorizontal:18,paddingTop:16,paddingBottom:40,gap:14}}><Hero title={asString(data.title)||asString(data.name)||content.title}/><Images data={data}/><PointCodes data={data}/><ObjectArrayTable title="Front-Mu Points" value={data.front_mu_points}/><Strings title="Description" value={data.description}/><ObjectCard title="Clinical Application" value={data.clinical_application}/><ContentLinkAttributeSections data={data} definitions={definitions} presentationAttributes={presentationAttributes}/></ScrollView>; }
|
||||
|
|
|
|||
|
|
@ -1,7 +1,8 @@
|
|||
import React from "react";
|
||||
import { ScrollView } from "react-native";
|
||||
import type { DetailRendererProps } from "../../types/renderer.types";
|
||||
import { ContentLinkAttributeSections } from "../shared/ContentLinkAttributeSections";
|
||||
import { asString } from "../helpers/value";
|
||||
import { Hero } from "../shared/Hero";
|
||||
import { DescriptionList, Images, ObjectArrayCards, ObjectArrayTable, ObjectCard, PointCodes, Strings } from "./categoryParts";
|
||||
export function GaoWuCommandDetailRenderer({content,data}:DetailRendererProps){ return <ScrollView contentContainerStyle={{padding:16,gap:16}}><Hero eyebrow={asString(data.code)} title={asString(data.title)||asString(data.name)||content.title}/><PointCodes data={data}/><ObjectArrayTable title="Gao Wu Command Points" value={data.gao_wu_command_points}/><Images data={data}/></ScrollView>; }
|
||||
export function GaoWuCommandDetailRenderer({content,data,definitions,presentationAttributes}:DetailRendererProps){ return <ScrollView contentContainerStyle={{paddingHorizontal:18,paddingTop:16,paddingBottom:40,gap:14}}><Hero title={asString(data.title)||asString(data.name)||content.title}/><Images data={data}/><PointCodes data={data}/><ObjectArrayTable title="Gao Wu Command Points" value={data.gao_wu_command_points}/><ContentLinkAttributeSections data={data} definitions={definitions} presentationAttributes={presentationAttributes}/></ScrollView>; }
|
||||
|
|
|
|||
|
|
@ -1,7 +1,8 @@
|
|||
import React from "react";
|
||||
import { ScrollView } from "react-native";
|
||||
import type { DetailRendererProps } from "../../types/renderer.types";
|
||||
import { ContentLinkAttributeSections } from "../shared/ContentLinkAttributeSections";
|
||||
import { asString } from "../helpers/value";
|
||||
import { Hero } from "../shared/Hero";
|
||||
import { DescriptionList, Images, ObjectArrayCards, ObjectArrayTable, ObjectCard, PointCodes, Strings } from "./categoryParts";
|
||||
export function GhostPointsDetailRenderer({content,data}:DetailRendererProps){ return <ScrollView contentContainerStyle={{padding:16,gap:16}}><Hero eyebrow={asString(data.code)} title={asString(data.title)||asString(data.name)||content.title}/><PointCodes data={data}/><Strings title="Description" value={data.description}/><ObjectArrayTable title="Ghost Points" value={data.ghost_points} columns={["point_name","point_code"]}/><Strings title="Historical Notes" value={data.historical_notes}/><ObjectCard title="Gao Wu Alternative List" value={data.gao_wu_alternative_list}/><Images data={data}/></ScrollView>; }
|
||||
export function GhostPointsDetailRenderer({content,data,definitions,presentationAttributes}:DetailRendererProps){ return <ScrollView contentContainerStyle={{paddingHorizontal:18,paddingTop:16,paddingBottom:40,gap:14}}><Hero title={asString(data.title)||asString(data.name)||content.title}/><Images data={data}/><PointCodes data={data}/><Strings title="Description" value={data.description}/><ObjectArrayTable title="Ghost Points" value={data.ghost_points} columns={["point_name","point_code"]}/><Strings title="Historical Notes" value={data.historical_notes}/><ObjectCard title="Gao Wu Alternative List" value={data.gao_wu_alternative_list}/><ContentLinkAttributeSections data={data} definitions={definitions} presentationAttributes={presentationAttributes}/></ScrollView>; }
|
||||
|
|
|
|||
|
|
@ -1,7 +1,8 @@
|
|||
import React from "react";
|
||||
import { ScrollView } from "react-native";
|
||||
import type { DetailRendererProps } from "../../types/renderer.types";
|
||||
import { ContentLinkAttributeSections } from "../shared/ContentLinkAttributeSections";
|
||||
import { asString } from "../helpers/value";
|
||||
import { Hero } from "../shared/Hero";
|
||||
import { DescriptionList, Images, ObjectArrayCards, ObjectArrayTable, ObjectCard, PointCodes, Strings } from "./categoryParts";
|
||||
export function HoraryPointsDetailRenderer({content,data}:DetailRendererProps){ return <ScrollView contentContainerStyle={{padding:16,gap:16}}><Hero eyebrow={asString(data.code)} title={asString(data.title)||asString(data.name)||content.title}/><PointCodes data={data}/><Strings title="Description" value={data.description}/><ObjectArrayTable title="Horary Points" value={data.horary_points}/><Images data={data}/></ScrollView>; }
|
||||
export function HoraryPointsDetailRenderer({content,data,definitions,presentationAttributes}:DetailRendererProps){ return <ScrollView contentContainerStyle={{paddingHorizontal:18,paddingTop:16,paddingBottom:40,gap:14}}><Hero title={asString(data.title)||asString(data.name)||content.title}/><Images data={data}/><PointCodes data={data}/><Strings title="Description" value={data.description}/><ObjectArrayTable title="Horary Points" value={data.horary_points}/><ContentLinkAttributeSections data={data} definitions={definitions} presentationAttributes={presentationAttributes}/></ScrollView>; }
|
||||
|
|
|
|||
|
|
@ -1,7 +1,8 @@
|
|||
import React from "react";
|
||||
import { ScrollView } from "react-native";
|
||||
import type { DetailRendererProps } from "../../types/renderer.types";
|
||||
import { ContentLinkAttributeSections } from "../shared/ContentLinkAttributeSections";
|
||||
import { asString } from "../helpers/value";
|
||||
import { Hero } from "../shared/Hero";
|
||||
import { DescriptionList, Images, ObjectArrayCards, ObjectArrayTable, ObjectCard, PointCodes, Strings } from "./categoryParts";
|
||||
export function HuiMeetingDetailRenderer({content,data}:DetailRendererProps){ return <ScrollView contentContainerStyle={{padding:16,gap:16}}><Hero eyebrow={asString(data.code)} title={asString(data.title)||asString(data.name)||content.title}/><PointCodes data={data}/><Strings title="Description" value={data.description}/><ObjectArrayCards title="Hui-Meeting Points" value={data.points}/><Images data={data}/></ScrollView>; }
|
||||
export function HuiMeetingDetailRenderer({content,data,definitions,presentationAttributes}:DetailRendererProps){ return <ScrollView contentContainerStyle={{paddingHorizontal:18,paddingTop:16,paddingBottom:40,gap:14}}><Hero title={asString(data.title)||asString(data.name)||content.title}/><Images data={data}/><PointCodes data={data}/><Strings title="Description" value={data.description}/><ObjectArrayCards title="Hui-Meeting Points" value={data.points}/><ContentLinkAttributeSections data={data} definitions={definitions} presentationAttributes={presentationAttributes}/></ScrollView>; }
|
||||
|
|
|
|||
|
|
@ -1,7 +1,9 @@
|
|||
import React from "react";
|
||||
import { ScrollView } from "react-native";
|
||||
import type { DetailRendererProps } from "../../types/renderer.types";
|
||||
import { ContentLinkAttributeSections } from "../shared/ContentLinkAttributeSections";
|
||||
import { asString } from "../helpers/value";
|
||||
import { Hero } from "../shared/Hero";
|
||||
import { Hero } from "../shared/Hero"; import { ImageGallery } from "../shared/ImageGallery";
|
||||
import { KeyValueGrid } from "../shared/KeyValueGrid";
|
||||
export function IndexEntryDetailRenderer({content,data}:DetailRendererProps){ return <ScrollView contentContainerStyle={{padding:16,gap:16}}><Hero title={content.title}/><KeyValueGrid rows={Object.entries(data).filter(([,v])=>typeof v==="string"||typeof v==="number").map(([k,v])=>({label:k,value:String(v)}))}/></ScrollView>; }
|
||||
import { SectionCard } from "../shared/SectionCard";
|
||||
export function IndexEntryDetailRenderer({content,data,definitions,presentationAttributes}:DetailRendererProps){ return <ScrollView contentContainerStyle={{paddingHorizontal:18,paddingTop:16,paddingBottom:40,gap:14}}><Hero title={content.title}/><ImageGallery images={[]}/><SectionCard title="Details"><KeyValueGrid rows={Object.entries(data).filter(([,v])=>typeof v==="string"||typeof v==="number").map(([k,v])=>({label:k,value:String(v)}))}/></SectionCard><ContentLinkAttributeSections data={data} definitions={definitions} presentationAttributes={presentationAttributes}/></ScrollView>; }
|
||||
|
|
|
|||
|
|
@ -1,7 +1,8 @@
|
|||
import React from "react";
|
||||
import { ScrollView } from "react-native";
|
||||
import type { DetailRendererProps } from "../../types/renderer.types";
|
||||
import { ContentLinkAttributeSections } from "../shared/ContentLinkAttributeSections";
|
||||
import { asString } from "../helpers/value";
|
||||
import { Hero } from "../shared/Hero";
|
||||
import { DescriptionList, Images, ObjectArrayCards, ObjectArrayTable, ObjectCard, PointCodes, Strings } from "./categoryParts";
|
||||
export function LowerHeSeaDetailRenderer({content,data}:DetailRendererProps){ return <ScrollView contentContainerStyle={{padding:16,gap:16}}><Hero eyebrow={asString(data.code)} title={asString(data.title)||asString(data.name)||content.title}/><PointCodes data={data}/><Strings title="Description" value={data.description}/><ObjectArrayCards title="Lower He-Sea Points" value={data.lower_he_sea_points}/><Images data={data}/></ScrollView>; }
|
||||
export function LowerHeSeaDetailRenderer({content,data,definitions,presentationAttributes}:DetailRendererProps){ return <ScrollView contentContainerStyle={{paddingHorizontal:18,paddingTop:16,paddingBottom:40,gap:14}}><Hero title={asString(data.title)||asString(data.name)||content.title}/><Images data={data}/><PointCodes data={data}/><Strings title="Description" value={data.description}/><ObjectArrayCards title="Lower He-Sea Points" value={data.lower_he_sea_points}/><ContentLinkAttributeSections data={data} definitions={definitions} presentationAttributes={presentationAttributes}/></ScrollView>; }
|
||||
|
|
|
|||
|
|
@ -1,7 +1,8 @@
|
|||
import React from "react";
|
||||
import { ScrollView } from "react-native";
|
||||
import type { DetailRendererProps } from "../../types/renderer.types";
|
||||
import { ContentLinkAttributeSections } from "../shared/ContentLinkAttributeSections";
|
||||
import { asString } from "../helpers/value";
|
||||
import { Hero } from "../shared/Hero";
|
||||
import { DescriptionList, Images, ObjectArrayCards, ObjectArrayTable, ObjectCard, PointCodes, Strings } from "./categoryParts";
|
||||
export function LuoConnectingDetailRenderer({content,data}:DetailRendererProps){ return <ScrollView contentContainerStyle={{padding:16,gap:16}}><Hero eyebrow={asString(data.code)} title={asString(data.title)||asString(data.name)||content.title}/><PointCodes data={data}/><ObjectArrayCards title="Major Luo Point of the Spleen" value={data.major_luo_point_of_the_spleen}/><ObjectArrayCards title="Major Luo Point of the Stomach" value={data.major_luo_point_of_the_stomach}/><ObjectArrayTable title="Interior-Exterior Related Disorders" value={data.treating_disorders_of_their_interiorly_exteriorly_related_channel_or_zangfu}/><ObjectArrayTable title="Regional Disorders" value={data.treating_disorders_in_regions_reached_b_the_luo_connecting_channel}/><ObjectArrayTable title="Psycho-emotional Disorders" value={data.treating_psycho_emotional_disorders}/><Images data={data}/></ScrollView>; }
|
||||
export function LuoConnectingDetailRenderer({content,data,definitions,presentationAttributes}:DetailRendererProps){ return <ScrollView contentContainerStyle={{paddingHorizontal:18,paddingTop:16,paddingBottom:40,gap:14}}><Hero title={asString(data.title)||asString(data.name)||content.title}/><Images data={data}/><PointCodes data={data}/><ObjectArrayCards title="Major Luo Point of the Spleen" value={data.major_luo_point_of_the_spleen}/><ObjectArrayCards title="Major Luo Point of the Stomach" value={data.major_luo_point_of_the_stomach}/><ObjectArrayTable title="Interior-Exterior Related Disorders" value={data.treating_disorders_of_their_interiorly_exteriorly_related_channel_or_zangfu}/><ObjectArrayTable title="Regional Disorders" value={data.treating_disorders_in_regions_reached_b_the_luo_connecting_channel}/><ObjectArrayTable title="Psycho-emotional Disorders" value={data.treating_psycho_emotional_disorders}/><ContentLinkAttributeSections data={data} definitions={definitions} presentationAttributes={presentationAttributes}/></ScrollView>; }
|
||||
|
|
|
|||
|
|
@ -1,6 +1,84 @@
|
|||
import React from "react";
|
||||
import { ScrollView, Text } from "react-native";
|
||||
import { ScrollView } from "react-native";
|
||||
|
||||
import type { DetailRendererProps } from "../../types/renderer.types";
|
||||
import { asRecord, asRecordArray, asString, asStringArray } from "../helpers/value";
|
||||
import { Hero } from "../shared/Hero"; import { SectionCard } from "../shared/SectionCard"; import { BulletList } from "../shared/BulletList"; import { ChipList } from "../shared/ChipList"; import { ObjectSections } from "../shared/ObjectSections"; import { RecordCards } from "../shared/RecordCards";
|
||||
export function MeridianDetailRenderer({content,data}:DetailRendererProps){ return <ScrollView contentContainerStyle={{padding:16,gap:16}}><Hero eyebrow={asString(data.code)} title={asString(data.title)||content.title} subtitle={asString(data.name)}/><SectionCard title="Primary Channel Pathway"><BulletList items={asStringArray(data.primary_channel_pathway)}/></SectionCard><SectionCard title="Secondary Branches"><ObjectSections value={asRecord(data.secondary_branches)}/></SectionCard><SectionCard title="Divergent Channel"><BulletList items={asStringArray(data.divergent_channel)}/></SectionCard><SectionCard title="Luo-Connecting Channel"><BulletList items={asStringArray(data.luo_connecting_channel)}/><ObjectSections value={asRecord(data.luo_connecting_vessel)}/></SectionCard><SectionCard title="Sinew Channel"><BulletList items={asStringArray(data.sinew_channel)}/></SectionCard><SectionCard title="Symptoms"><ObjectSections value={asRecord(data.symptoms)}/></SectionCard><SectionCard title="Meeting Points"><ChipList items={asStringArray(data.meeting_points)}/></SectionCard><SectionCard title="Point Categories"><RecordCards rows={asRecordArray(data.point_categories)}/></SectionCard><SectionCard title="Clinical Manifestations"><RecordCards rows={asRecordArray(data.indications_clinical_manifestations)}/></SectionCard><SectionCard title="Specific Points"><RecordCards rows={asRecordArray(data.specific_points_according_to_functions)}/></SectionCard><SectionCard title="Five-Shu Transporting Points"><RecordCards rows={asRecordArray(data.five_shu_transporting_points)}/></SectionCard></ScrollView>; }
|
||||
import { asRecord, asString, asStringArray } from "../helpers/value";
|
||||
import { ContentLinkAttributeSections } from "../shared/ContentLinkAttributeSections";
|
||||
import { ContentValue } from "../shared/ContentValue";
|
||||
import { Hero } from "../shared/Hero";
|
||||
import { ImageGallery } from "../shared/ImageGallery";
|
||||
import { SectionCard } from "../shared/SectionCard";
|
||||
import { BulletList } from "../shared/BulletList";
|
||||
import { ObjectSections } from "../shared/ObjectSections";
|
||||
|
||||
export function MeridianDetailRenderer({
|
||||
content,
|
||||
data,
|
||||
definitions,
|
||||
presentationAttributes,
|
||||
}: DetailRendererProps) {
|
||||
return (
|
||||
<ScrollView
|
||||
contentContainerStyle={{
|
||||
paddingHorizontal: 18,
|
||||
paddingTop: 16,
|
||||
paddingBottom: 40,
|
||||
gap: 14,
|
||||
}}
|
||||
>
|
||||
<Hero title={asString(data.title) || content.title} subtitle={asString(data.name)} />
|
||||
<ImageGallery images={[]} />
|
||||
|
||||
<SectionCard title="Primary Channel Pathway">
|
||||
<BulletList items={asStringArray(data.primary_channel_pathway)} />
|
||||
</SectionCard>
|
||||
|
||||
<SectionCard title="Secondary Branches">
|
||||
<ObjectSections value={asRecord(data.secondary_branches)} />
|
||||
</SectionCard>
|
||||
|
||||
<SectionCard title="Divergent Channel">
|
||||
<BulletList items={asStringArray(data.divergent_channel)} />
|
||||
</SectionCard>
|
||||
|
||||
<SectionCard title="Luo-Connecting Channel">
|
||||
<BulletList items={asStringArray(data.luo_connecting_channel)} />
|
||||
<ObjectSections value={asRecord(data.luo_connecting_vessel)} />
|
||||
</SectionCard>
|
||||
|
||||
<SectionCard title="Sinew Channel">
|
||||
<BulletList items={asStringArray(data.sinew_channel)} />
|
||||
</SectionCard>
|
||||
|
||||
<SectionCard title="Symptoms">
|
||||
<ObjectSections value={asRecord(data.symptoms)} />
|
||||
</SectionCard>
|
||||
|
||||
<SectionCard title="Meeting Points">
|
||||
<ContentValue value={data.meeting_points} />
|
||||
</SectionCard>
|
||||
|
||||
<SectionCard title="Point Categories">
|
||||
<ObjectSections value={asRecord(data.point_categories)} />
|
||||
</SectionCard>
|
||||
|
||||
<SectionCard title="Clinical Manifestations">
|
||||
<BulletList items={asStringArray(data.indications_clinical_manifestations)} />
|
||||
</SectionCard>
|
||||
|
||||
<SectionCard title="Specific Points">
|
||||
<ObjectSections value={asRecord(data.specific_points_according_to_functions)} />
|
||||
</SectionCard>
|
||||
|
||||
<SectionCard title="Five-Shu Transporting Points">
|
||||
<ObjectSections value={asRecord(data.five_shu_transporting_points)} />
|
||||
</SectionCard>
|
||||
|
||||
<ContentLinkAttributeSections
|
||||
data={data}
|
||||
definitions={definitions}
|
||||
presentationAttributes={presentationAttributes}
|
||||
/>
|
||||
</ScrollView>
|
||||
);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,7 +1,8 @@
|
|||
import React from "react";
|
||||
import { ScrollView } from "react-native";
|
||||
import type { DetailRendererProps } from "../../types/renderer.types";
|
||||
import { ContentLinkAttributeSections } from "../shared/ContentLinkAttributeSections";
|
||||
import { asString } from "../helpers/value";
|
||||
import { Hero } from "../shared/Hero";
|
||||
import { DescriptionList, Images, ObjectArrayCards, ObjectArrayTable, ObjectCard, PointCodes, Strings } from "./categoryParts";
|
||||
export function ReturningYangDetailRenderer({content,data}:DetailRendererProps){ return <ScrollView contentContainerStyle={{padding:16,gap:16}}><Hero eyebrow={asString(data.code)} title={asString(data.title)||asString(data.name)||content.title}/><PointCodes data={data}/><Strings title="Description" value={data.description}/><Strings title="Returning Yang Points" value={data.points}/><Images data={data}/></ScrollView>; }
|
||||
export function ReturningYangDetailRenderer({content,data,definitions,presentationAttributes}:DetailRendererProps){ return <ScrollView contentContainerStyle={{paddingHorizontal:18,paddingTop:16,paddingBottom:40,gap:14}}><Hero title={asString(data.title)||asString(data.name)||content.title}/><Images data={data}/><PointCodes data={data}/><Strings title="Description" value={data.description}/><Strings title="Returning Yang Points" value={data.points}/><ContentLinkAttributeSections data={data} definitions={definitions} presentationAttributes={presentationAttributes}/></ScrollView>; }
|
||||
|
|
|
|||
|
|
@ -1,7 +1,8 @@
|
|||
import React from "react";
|
||||
import { ScrollView } from "react-native";
|
||||
import type { DetailRendererProps } from "../../types/renderer.types";
|
||||
import { ContentLinkAttributeSections } from "../shared/ContentLinkAttributeSections";
|
||||
import { asString } from "../helpers/value";
|
||||
import { Hero } from "../shared/Hero";
|
||||
import { DescriptionList, Images, ObjectArrayCards, ObjectArrayTable, ObjectCard, PointCodes, Strings } from "./categoryParts";
|
||||
export function WindowOfHeavenDetailRenderer({content,data}:DetailRendererProps){ return <ScrollView contentContainerStyle={{padding:16,gap:16}}><Hero eyebrow={asString(data.code)} title={asString(data.title)||asString(data.name)||content.title}/><PointCodes data={data}/><Strings title="Description" value={data.description}/><Strings title="Window of Heaven Points" value={data.window_of_heaven_points}/><ObjectCard title="Clinical Application" value={data.clinical_application}/><Images data={data}/></ScrollView>; }
|
||||
export function WindowOfHeavenDetailRenderer({content,data,definitions,presentationAttributes}:DetailRendererProps){ return <ScrollView contentContainerStyle={{paddingHorizontal:18,paddingTop:16,paddingBottom:40,gap:14}}><Hero title={asString(data.title)||asString(data.name)||content.title}/><Images data={data}/><PointCodes data={data}/><Strings title="Description" value={data.description}/><Strings title="Window of Heaven Points" value={data.window_of_heaven_points}/><ObjectCard title="Clinical Application" value={data.clinical_application}/><ContentLinkAttributeSections data={data} definitions={definitions} presentationAttributes={presentationAttributes}/></ScrollView>; }
|
||||
|
|
|
|||
|
|
@ -1,7 +1,8 @@
|
|||
import React from "react";
|
||||
import { ScrollView } from "react-native";
|
||||
import type { DetailRendererProps } from "../../types/renderer.types";
|
||||
import { ContentLinkAttributeSections } from "../shared/ContentLinkAttributeSections";
|
||||
import { asString } from "../helpers/value";
|
||||
import { Hero } from "../shared/Hero";
|
||||
import { DescriptionList, Images, ObjectArrayCards, ObjectArrayTable, ObjectCard, PointCodes, Strings } from "./categoryParts";
|
||||
export function XiCleftDetailRenderer({content,data}:DetailRendererProps){ return <ScrollView contentContainerStyle={{padding:16,gap:16}}><Hero eyebrow={asString(data.code)} title={asString(data.title)||asString(data.name)||content.title}/><PointCodes data={data}/><ObjectArrayTable title="Xi-Cleft Points of the Twelve Channels" value={data.xi_cleft_points_of_the_twelve_channels}/><ObjectArrayTable title="Xi-Cleft Points of Extraordinary Channels" value={data.xi_cleft_points_of_extraordinary_channels}/><ObjectCard title="Clinical Application" value={data.clinical_application}/><Images data={data}/></ScrollView>; }
|
||||
export function XiCleftDetailRenderer({content,data,definitions,presentationAttributes}:DetailRendererProps){ return <ScrollView contentContainerStyle={{paddingHorizontal:18,paddingTop:16,paddingBottom:40,gap:14}}><Hero title={asString(data.title)||asString(data.name)||content.title}/><Images data={data}/><PointCodes data={data}/><ObjectArrayTable title="Xi-Cleft Points of the Twelve Channels" value={data.xi_cleft_points_of_the_twelve_channels}/><ObjectArrayTable title="Xi-Cleft Points of Extraordinary Channels" value={data.xi_cleft_points_of_extraordinary_channels}/><ObjectCard title="Clinical Application" value={data.clinical_application}/><ContentLinkAttributeSections data={data} definitions={definitions} presentationAttributes={presentationAttributes}/></ScrollView>; }
|
||||
|
|
|
|||
|
|
@ -1,7 +1,8 @@
|
|||
import React from "react";
|
||||
import { ScrollView } from "react-native";
|
||||
import type { DetailRendererProps } from "../../types/renderer.types";
|
||||
import { ContentLinkAttributeSections } from "../shared/ContentLinkAttributeSections";
|
||||
import { asString } from "../helpers/value";
|
||||
import { Hero } from "../shared/Hero";
|
||||
import { DescriptionList, Images, ObjectArrayCards, ObjectArrayTable, ObjectCard, PointCodes, Strings } from "./categoryParts";
|
||||
export function YuanSourceDetailRenderer({content,data}:DetailRendererProps){ return <ScrollView contentContainerStyle={{padding:16,gap:16}}><Hero eyebrow={asString(data.code)} title={asString(data.title)||asString(data.name)||content.title}/><PointCodes data={data}/><ObjectArrayTable title="Source Points" value={data.source_point} columns={["meridian","point"]}/><Strings title="Key Clinical Features" value={data.key_clinical_feature}/><Strings title="Yin vs Yang" value={data.yin_vs_yang}/><Strings title="Functions" value={data.functions}/><Strings title="Diagnostic Utility" value={data.diagnostic_utility}/><Images data={data}/></ScrollView>; }
|
||||
export function YuanSourceDetailRenderer({content,data,definitions,presentationAttributes}:DetailRendererProps){ return <ScrollView contentContainerStyle={{paddingHorizontal:18,paddingTop:16,paddingBottom:40,gap:14}}><Hero title={asString(data.title)||asString(data.name)||content.title}/><Images data={data}/><PointCodes data={data}/><ObjectArrayTable title="Source Points" value={data.source_point} columns={["meridian","point"]}/><Strings title="Key Clinical Features" value={data.key_clinical_feature}/><Strings title="Yin vs Yang" value={data.yin_vs_yang}/><Strings title="Functions" value={data.functions}/><Strings title="Diagnostic Utility" value={data.diagnostic_utility}/><ContentLinkAttributeSections data={data} definitions={definitions} presentationAttributes={presentationAttributes}/></ScrollView>; }
|
||||
|
|
|
|||
|
|
@ -1,26 +1,72 @@
|
|||
import React from "react";
|
||||
import { ContentMediaGallery } from "../../media/ContentMediaGallery";
|
||||
import { useRelationalContentMedia } from "../../media/ContentMediaContext";
|
||||
import { Text } from "react-native";
|
||||
import { StyleSheet, Text } from "react-native";
|
||||
import { asRecord, asRecordArray, asString, asStringArray } from "../helpers/value";
|
||||
import { BulletList } from "../shared/BulletList";
|
||||
import { ChipList } from "../shared/ChipList";
|
||||
import { ImageGallery } from "../shared/ImageGallery";
|
||||
import { ObjectSections } from "../shared/ObjectSections";
|
||||
import { RecordCards } from "../shared/RecordCards";
|
||||
import { RecordTable } from "../shared/RecordTable";
|
||||
import { SectionCard } from "../shared/SectionCard";
|
||||
|
||||
export const PointCodes = ({data}:{data:Record<string,unknown>}) => <SectionCard title="Points"><ChipList items={asStringArray(data.point_codes)}/></SectionCard>;
|
||||
export const DescriptionList = ({data}:{data:Record<string,unknown>}) => { const arr=asStringArray(data.description); const text=asString(data.description); return <SectionCard title="Description">{arr.length?<BulletList items={arr}/>:<Text style={{fontSize:16,lineHeight:24}}>{text}</Text>}</SectionCard>; };
|
||||
export const Images = ({data}:{data:Record<string,unknown>}) => {
|
||||
const relationalMedia = useRelationalContentMedia();
|
||||
if (relationalMedia.length) {
|
||||
return <SectionCard title="Images"><ContentMediaGallery media={relationalMedia}/></SectionCard>;
|
||||
}
|
||||
const rows=asRecordArray(data.images);
|
||||
return rows.length?<SectionCard title="Images"><RecordCards rows={rows}/></SectionCard>:null;
|
||||
export const PointCodes = ({ data }: { data: Record<string, unknown> }) => (
|
||||
<SectionCard title="Points"><ChipList items={asStringArray(data.point_codes)} /></SectionCard>
|
||||
);
|
||||
|
||||
export const DescriptionList = ({ data }: { data: Record<string, unknown> }) => {
|
||||
const arr = asStringArray(data.description);
|
||||
const text = asString(data.description);
|
||||
return (
|
||||
<SectionCard title="Description">
|
||||
{arr.length ? <BulletList items={arr} /> : <Text style={styles.readingText}>{text}</Text>}
|
||||
</SectionCard>
|
||||
);
|
||||
};
|
||||
export const ObjectCard = ({title,value}:{title:string;value:unknown}) => { const obj=asRecord(value); return Object.keys(obj).length?<SectionCard title={title}><ObjectSections value={obj}/></SectionCard>:null; };
|
||||
export const ObjectArrayCards = ({title,value}:{title:string;value:unknown}) => { const rows=asRecordArray(value); return rows.length?<SectionCard title={title}><RecordCards rows={rows}/></SectionCard>:null; };
|
||||
export const ObjectArrayTable = ({title,value,columns}:{title:string;value:unknown;columns?:string[]}) => { const rows=asRecordArray(value); return rows.length?<SectionCard title={title}><RecordTable rows={rows} columns={columns}/></SectionCard>:null; };
|
||||
export const Strings = ({title,value}:{title:string;value:unknown}) => { const arr=asStringArray(value); const txt=asString(value); if(!arr.length&&!txt)return null; return <SectionCard title={title}>{arr.length?<BulletList items={arr}/>:<Text style={{fontSize:16,lineHeight:24}}>{txt}</Text>}</SectionCard>; };
|
||||
|
||||
export const Images = ({ data }: { data: Record<string, unknown> }) => (
|
||||
<ImageGallery images={asRecordArray(data.images)} />
|
||||
);
|
||||
|
||||
export const ObjectCard = ({ title, value }: { title: string; value: unknown }) => {
|
||||
const obj = asRecord(value);
|
||||
return Object.keys(obj).length ? (
|
||||
<SectionCard title={title}><ObjectSections value={obj} /></SectionCard>
|
||||
) : null;
|
||||
};
|
||||
|
||||
export const ObjectArrayCards = ({ title, value }: { title: string; value: unknown }) => {
|
||||
const rows = asRecordArray(value);
|
||||
return rows.length ? (
|
||||
<SectionCard title={title}><RecordCards rows={rows} /></SectionCard>
|
||||
) : null;
|
||||
};
|
||||
|
||||
export const ObjectArrayTable = ({
|
||||
title,
|
||||
value,
|
||||
columns,
|
||||
}: {
|
||||
title: string;
|
||||
value: unknown;
|
||||
columns?: string[];
|
||||
}) => {
|
||||
const rows = asRecordArray(value);
|
||||
return rows.length ? (
|
||||
<SectionCard title={title}><RecordTable rows={rows} columns={columns} /></SectionCard>
|
||||
) : null;
|
||||
};
|
||||
|
||||
export const Strings = ({ title, value }: { title: string; value: unknown }) => {
|
||||
const arr = asStringArray(value);
|
||||
const txt = asString(value);
|
||||
if (!arr.length && !txt) return null;
|
||||
return (
|
||||
<SectionCard title={title}>
|
||||
{arr.length ? <BulletList items={arr} /> : <Text style={styles.readingText}>{txt}</Text>}
|
||||
</SectionCard>
|
||||
);
|
||||
};
|
||||
|
||||
const styles = StyleSheet.create({
|
||||
readingText: { fontSize: 16, lineHeight: 26, color: "#334155" },
|
||||
});
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
import React, { type PropsWithChildren, useState } from "react";
|
||||
import React, { type PropsWithChildren, useMemo, useState } from "react";
|
||||
import {
|
||||
LayoutAnimation,
|
||||
Platform,
|
||||
|
|
@ -8,11 +8,10 @@ import {
|
|||
UIManager,
|
||||
View,
|
||||
} from "react-native";
|
||||
import { Ionicons } from "@expo/vector-icons";
|
||||
import { moderateScale, verticalScale } from "react-native-size-matters";
|
||||
|
||||
import { Colors } from "@/theme/colors";
|
||||
import { Radius } from "@/theme/radius";
|
||||
import { Shadows } from "@/theme/shadows";
|
||||
import { Spacing } from "@/theme/spacing";
|
||||
import { readingToneForTitle } from "./reading-palette";
|
||||
|
||||
if (Platform.OS === "android" && UIManager.setLayoutAnimationEnabledExperimental) {
|
||||
UIManager.setLayoutAnimationEnabledExperimental(true);
|
||||
|
|
@ -29,6 +28,7 @@ export function AccordionSection({
|
|||
children,
|
||||
}: PropsWithChildren<AccordionSectionProps>) {
|
||||
const [expanded, setExpanded] = useState(defaultExpanded);
|
||||
const tone = useMemo(() => readingToneForTitle(title), [title]);
|
||||
|
||||
const toggle = () => {
|
||||
LayoutAnimation.configureNext(LayoutAnimation.Presets.easeInEaseOut);
|
||||
|
|
@ -36,66 +36,75 @@ export function AccordionSection({
|
|||
};
|
||||
|
||||
return (
|
||||
<View style={styles.card}>
|
||||
<View style={[styles.card, { borderColor: tone.border }]}>
|
||||
<Pressable
|
||||
accessibilityRole="button"
|
||||
accessibilityState={{ expanded }}
|
||||
accessibilityLabel={`${expanded ? "Collapse" : "Expand"} ${title}`}
|
||||
onPress={toggle}
|
||||
style={({ pressed }) => [styles.header, pressed && styles.pressed]}
|
||||
style={({ pressed }) => [
|
||||
styles.header,
|
||||
{ backgroundColor: tone.soft },
|
||||
pressed && styles.pressed,
|
||||
]}
|
||||
>
|
||||
<View style={styles.titleRow}>
|
||||
<View style={styles.accent} />
|
||||
<Text style={styles.title}>{title}</Text>
|
||||
</View>
|
||||
|
||||
<View style={[styles.iconCircle, expanded && styles.iconCircleExpanded]}>
|
||||
<Text style={[styles.icon, expanded && styles.iconExpanded]}>
|
||||
{expanded ? "−" : "+"}
|
||||
</Text>
|
||||
<View style={[styles.accent, { backgroundColor: tone.accent }]} />
|
||||
<Text style={[styles.title, { color: tone.title }]}>{title}</Text>
|
||||
<View style={styles.chevron}>
|
||||
<Ionicons
|
||||
name={expanded ? "chevron-up" : "chevron-down"}
|
||||
size={18}
|
||||
color={tone.accent}
|
||||
/>
|
||||
</View>
|
||||
</Pressable>
|
||||
|
||||
{expanded ? (
|
||||
<>
|
||||
<View style={styles.divider} />
|
||||
<View style={styles.body}>{children}</View>
|
||||
</>
|
||||
) : null}
|
||||
{expanded ? <View style={styles.body}>{children}</View> : null}
|
||||
</View>
|
||||
);
|
||||
}
|
||||
|
||||
const styles = StyleSheet.create({
|
||||
card: {
|
||||
borderRadius: Radius.xl,
|
||||
backgroundColor: Colors.background,
|
||||
backgroundColor: "#FFFFFF",
|
||||
borderRadius: moderateScale(18),
|
||||
borderWidth: 1,
|
||||
overflow: "hidden",
|
||||
...Shadows.card,
|
||||
},
|
||||
header: {
|
||||
minHeight: 68,
|
||||
paddingHorizontal: Spacing.md,
|
||||
minHeight: verticalScale(54),
|
||||
paddingHorizontal: moderateScale(14),
|
||||
paddingVertical: verticalScale(12),
|
||||
flexDirection: "row",
|
||||
alignItems: "center",
|
||||
justifyContent: "space-between",
|
||||
gap: Spacing.sm,
|
||||
gap: moderateScale(10),
|
||||
},
|
||||
pressed: { opacity: 0.9 },
|
||||
titleRow: { flex: 1, flexDirection: "row", alignItems: "center", gap: 10 },
|
||||
accent: { width: 4, height: 24, borderRadius: Radius.full, backgroundColor: Colors.primary },
|
||||
title: { flex: 1, fontSize: 18, lineHeight: 24, fontWeight: "800", color: Colors.textPrimary },
|
||||
iconCircle: {
|
||||
width: 34,
|
||||
height: 34,
|
||||
borderRadius: Radius.full,
|
||||
accent: {
|
||||
width: moderateScale(4),
|
||||
alignSelf: "stretch",
|
||||
minHeight: verticalScale(26),
|
||||
borderRadius: moderateScale(999),
|
||||
},
|
||||
pressed: { opacity: 0.74 },
|
||||
title: {
|
||||
flex: 1,
|
||||
fontSize: moderateScale(15),
|
||||
lineHeight: moderateScale(21),
|
||||
fontWeight: "700",
|
||||
letterSpacing: 0.1,
|
||||
},
|
||||
chevron: {
|
||||
width: moderateScale(30),
|
||||
height: moderateScale(30),
|
||||
borderRadius: moderateScale(15),
|
||||
alignItems: "center",
|
||||
justifyContent: "center",
|
||||
backgroundColor: "#F1F5F9",
|
||||
backgroundColor: "#FFFFFFB8",
|
||||
},
|
||||
body: {
|
||||
paddingHorizontal: moderateScale(17),
|
||||
paddingTop: verticalScale(15),
|
||||
paddingBottom: verticalScale(18),
|
||||
gap: verticalScale(12),
|
||||
},
|
||||
iconCircleExpanded: { backgroundColor: "#DBEAFE" },
|
||||
icon: { fontSize: 22, lineHeight: 24, fontWeight: "700", color: Colors.textSecondary },
|
||||
iconExpanded: { color: Colors.primary },
|
||||
divider: { height: StyleSheet.hairlineWidth, marginHorizontal: Spacing.md, backgroundColor: "#E2E8F0" },
|
||||
body: { padding: Spacing.md, gap: 10 },
|
||||
});
|
||||
|
|
|
|||
|
|
@ -1,15 +1,29 @@
|
|||
import React from "react";
|
||||
import { Text, View } from "react-native";
|
||||
import { StyleSheet, Text, View } from "react-native";
|
||||
|
||||
export function BulletList({ items }: { items: string[] }) {
|
||||
if (!items.length) return null;
|
||||
return (
|
||||
<View style={{ gap: 7 }}>
|
||||
<View style={styles.list}>
|
||||
{items.map((item, index) => (
|
||||
<View key={`${index}-${item}`} style={{ flexDirection: "row", gap: 8 }}>
|
||||
<Text>•</Text><Text style={{ flex: 1, fontSize: 16, lineHeight: 23 }}>{item}</Text>
|
||||
<View key={`${index}-${item}`} style={styles.row}>
|
||||
<View style={styles.dot} />
|
||||
<Text style={styles.text}>{item}</Text>
|
||||
</View>
|
||||
))}
|
||||
</View>
|
||||
);
|
||||
}
|
||||
|
||||
const styles = StyleSheet.create({
|
||||
list: { gap: 10 },
|
||||
row: { flexDirection: "row", alignItems: "flex-start", gap: 10 },
|
||||
dot: {
|
||||
width: 6,
|
||||
height: 6,
|
||||
marginTop: 9,
|
||||
borderRadius: 3,
|
||||
backgroundColor: "#5B806D",
|
||||
},
|
||||
text: { flex: 1, fontSize: 16, lineHeight: 25, color: "#334155" },
|
||||
});
|
||||
|
|
|
|||
|
|
@ -1,15 +1,35 @@
|
|||
import React from "react";
|
||||
import { Text, View } from "react-native";
|
||||
import { StyleSheet, Text, View } from "react-native";
|
||||
|
||||
const chipTones = [
|
||||
{ bg: "#EEF7F1", border: "#D5E8DB", text: "#35664E" },
|
||||
{ bg: "#EFF5FA", border: "#D7E5F0", text: "#3C617E" },
|
||||
{ bg: "#FAF4EB", border: "#EEDFC9", text: "#805C31" },
|
||||
];
|
||||
|
||||
export function ChipList({ items }: { items: string[] }) {
|
||||
if (!items.length) return null;
|
||||
return (
|
||||
<View style={{ flexDirection: "row", flexWrap: "wrap", gap: 8 }}>
|
||||
{items.map((item) => (
|
||||
<View key={item} style={{ borderWidth: 1, borderRadius: 999, paddingHorizontal: 10, paddingVertical: 6 }}>
|
||||
<Text style={{ fontSize: 13, fontWeight: "600" }}>{item}</Text>
|
||||
</View>
|
||||
))}
|
||||
<View style={styles.root}>
|
||||
{items.map((item, index) => {
|
||||
const tone = chipTones[index % chipTones.length];
|
||||
return (
|
||||
<View key={item} style={[styles.chip, { backgroundColor: tone.bg, borderColor: tone.border }]}>
|
||||
<Text style={[styles.text, { color: tone.text }]}>{item}</Text>
|
||||
</View>
|
||||
);
|
||||
})}
|
||||
</View>
|
||||
);
|
||||
}
|
||||
|
||||
const styles = StyleSheet.create({
|
||||
root: { flexDirection: "row", flexWrap: "wrap", gap: 8 },
|
||||
chip: {
|
||||
borderWidth: 1,
|
||||
borderRadius: 999,
|
||||
paddingHorizontal: 11,
|
||||
paddingVertical: 7,
|
||||
},
|
||||
text: { fontSize: 13, lineHeight: 18, fontWeight: "600" },
|
||||
});
|
||||
|
|
|
|||
|
|
@ -3,9 +3,13 @@ import {
|
|||
ActivityIndicator,
|
||||
FlatList,
|
||||
RefreshControl,
|
||||
StyleSheet,
|
||||
Text,
|
||||
View,
|
||||
} from "react-native";
|
||||
import { moderateScale, verticalScale } from "react-native-size-matters";
|
||||
|
||||
import { Colors } from "@/theme";
|
||||
import type { CollectionRendererProps } from "../../types/renderer.types";
|
||||
|
||||
export function CollectionScaffold(
|
||||
|
|
@ -20,20 +24,25 @@ export function CollectionScaffold(
|
|||
initialNumToRender={12}
|
||||
maxToRenderPerBatch={12}
|
||||
windowSize={9}
|
||||
style={styles.list}
|
||||
contentContainerStyle={styles.content}
|
||||
ListHeaderComponent={
|
||||
<>
|
||||
{props.header}
|
||||
<View style={{ paddingHorizontal: 16, paddingVertical: 8 }}>
|
||||
<Text accessibilityLiveRegion="polite">{props.total} results</Text>
|
||||
</View>
|
||||
<Text style={styles.resultCount} accessibilityLiveRegion="polite">
|
||||
{props.total} {props.total === 1 ? "result" : "results"}
|
||||
</Text>
|
||||
</>
|
||||
}
|
||||
renderItem={({ item }) =>
|
||||
props.renderItem({
|
||||
item,
|
||||
onPress: () => props.onItemPress(item),
|
||||
})
|
||||
}
|
||||
ItemSeparatorComponent={() => <View style={styles.separator} />}
|
||||
renderItem={({ item }) => (
|
||||
<View style={styles.card}>
|
||||
{props.renderItem({
|
||||
item,
|
||||
onPress: () => props.onItemPress(item),
|
||||
})}
|
||||
</View>
|
||||
)}
|
||||
onEndReached={props.onLoadMore}
|
||||
onEndReachedThreshold={0.5}
|
||||
refreshControl={
|
||||
|
|
@ -41,18 +50,20 @@ export function CollectionScaffold(
|
|||
}
|
||||
ListEmptyComponent={
|
||||
props.isLoading ? (
|
||||
<View style={{ padding: 24, alignItems: "center" }}>
|
||||
<View style={styles.stateCard}>
|
||||
<ActivityIndicator />
|
||||
<Text style={styles.stateText}>Loading content…</Text>
|
||||
</View>
|
||||
) : (
|
||||
<View style={{ padding: 24, alignItems: "center" }}>
|
||||
<Text>No matching content.</Text>
|
||||
<View style={styles.stateCard}>
|
||||
<Text style={styles.emptyTitle}>No content available</Text>
|
||||
<Text style={styles.stateText}>No matching published content was found.</Text>
|
||||
</View>
|
||||
)
|
||||
}
|
||||
ListFooterComponent={
|
||||
props.isFetchingNextPage ? (
|
||||
<View style={{ padding: 16, alignItems: "center" }}>
|
||||
<View style={styles.footerLoader}>
|
||||
<ActivityIndicator />
|
||||
</View>
|
||||
) : null
|
||||
|
|
@ -60,3 +71,59 @@ export function CollectionScaffold(
|
|||
/>
|
||||
);
|
||||
}
|
||||
|
||||
const styles = StyleSheet.create({
|
||||
list: {
|
||||
flex: 1,
|
||||
backgroundColor: "#F6F8F7",
|
||||
},
|
||||
content: {
|
||||
paddingHorizontal: moderateScale(18),
|
||||
paddingTop: verticalScale(16),
|
||||
paddingBottom: verticalScale(32),
|
||||
},
|
||||
resultCount: {
|
||||
fontSize: moderateScale(12),
|
||||
fontWeight: "700",
|
||||
color: Colors.textSecondary,
|
||||
textTransform: "uppercase",
|
||||
letterSpacing: 1,
|
||||
marginBottom: verticalScale(8),
|
||||
marginLeft: moderateScale(4),
|
||||
},
|
||||
card: {
|
||||
backgroundColor: "#FFFFFF",
|
||||
borderRadius: moderateScale(18),
|
||||
borderWidth: 1,
|
||||
borderColor: "#E2EAE5",
|
||||
overflow: "hidden",
|
||||
},
|
||||
separator: {
|
||||
height: verticalScale(12),
|
||||
},
|
||||
stateCard: {
|
||||
alignItems: "center",
|
||||
justifyContent: "center",
|
||||
backgroundColor: "#FFFFFF",
|
||||
borderRadius: moderateScale(18),
|
||||
borderWidth: 1,
|
||||
borderColor: "#E2EAE5",
|
||||
paddingHorizontal: moderateScale(20),
|
||||
paddingVertical: verticalScale(28),
|
||||
gap: verticalScale(8),
|
||||
},
|
||||
emptyTitle: {
|
||||
fontSize: moderateScale(15),
|
||||
fontWeight: "700",
|
||||
color: Colors.textPrimary,
|
||||
},
|
||||
stateText: {
|
||||
fontSize: moderateScale(13),
|
||||
color: Colors.textSecondary,
|
||||
textAlign: "center",
|
||||
},
|
||||
footerLoader: {
|
||||
paddingVertical: verticalScale(18),
|
||||
alignItems: "center",
|
||||
},
|
||||
});
|
||||
|
|
|
|||
|
|
@ -1,6 +1,39 @@
|
|||
import React from "react";
|
||||
import { Text, View } from "react-native";
|
||||
export function ContentCountBadge({ count, label }: { count: number | null; label?: string }) {
|
||||
import { StyleSheet, Text, View } from "react-native";
|
||||
import { moderateScale, verticalScale } from "react-native-size-matters";
|
||||
|
||||
import { Colors } from "@/theme";
|
||||
|
||||
export function ContentCountBadge({
|
||||
count,
|
||||
label,
|
||||
}: {
|
||||
count: number | null;
|
||||
label?: string;
|
||||
}) {
|
||||
if (count === null) return null;
|
||||
return <View style={{ borderWidth:1, borderRadius:999, paddingHorizontal:8, paddingVertical:4 }}><Text style={{ fontSize:12, fontWeight:"600" }}>{count}{label ? ` ${label}` : ""}</Text></View>;
|
||||
|
||||
return (
|
||||
<View style={styles.badge}>
|
||||
<Text style={styles.text}>
|
||||
{count}
|
||||
{label ? ` ${label}` : ""}
|
||||
</Text>
|
||||
</View>
|
||||
);
|
||||
}
|
||||
|
||||
const styles = StyleSheet.create({
|
||||
badge: {
|
||||
backgroundColor: "#F3F4F6",
|
||||
borderRadius: moderateScale(12),
|
||||
paddingHorizontal: moderateScale(9),
|
||||
paddingVertical: verticalScale(5),
|
||||
marginRight: moderateScale(8),
|
||||
},
|
||||
text: {
|
||||
fontSize: moderateScale(11),
|
||||
fontWeight: "700",
|
||||
color: Colors.textSecondary,
|
||||
},
|
||||
});
|
||||
|
|
|
|||
|
|
@ -0,0 +1,82 @@
|
|||
import React, { useMemo } from "react";
|
||||
|
||||
import type { AttributeDefinitionResponse } from "../../types/content.types";
|
||||
import type { TemplateAttributePresentationContract } from "../../types/presentation.types";
|
||||
import {
|
||||
createAttributePresentationMap,
|
||||
getAttributePresentationRule,
|
||||
shouldRenderAttribute,
|
||||
} from "../../utils/attribute-presentation";
|
||||
import { getNavigableContentReferences } from "../../utils/content-reference";
|
||||
import { ContentValue } from "./ContentValue";
|
||||
import { SectionCard } from "./SectionCard";
|
||||
|
||||
interface ContentLinkAttributeSectionsProps {
|
||||
data: Record<string, unknown>;
|
||||
definitions?: readonly AttributeDefinitionResponse[];
|
||||
presentationAttributes?: readonly TemplateAttributePresentationContract[];
|
||||
}
|
||||
|
||||
function containsNavigableReference(value: unknown): boolean {
|
||||
if (getNavigableContentReferences(value).length > 0) return true;
|
||||
if (Array.isArray(value)) return value.some(containsNavigableReference);
|
||||
if (value && typeof value === "object") {
|
||||
return Object.values(value as Record<string, unknown>).some(containsNavigableReference);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
export function ContentLinkAttributeSections({
|
||||
data,
|
||||
definitions = [],
|
||||
presentationAttributes = [],
|
||||
}: ContentLinkAttributeSectionsProps) {
|
||||
const rules = useMemo(
|
||||
() => createAttributePresentationMap(presentationAttributes),
|
||||
[presentationAttributes],
|
||||
);
|
||||
|
||||
const items = useMemo(() => {
|
||||
const roots = [...definitions]
|
||||
.filter((definition) => definition.is_root)
|
||||
.sort((a, b) => a.sort_order - b.sort_order || a.attribute_key.localeCompare(b.attribute_key));
|
||||
|
||||
const orderedKeys = roots.length > 0
|
||||
? roots.map((definition) => definition.attribute_key)
|
||||
: Object.keys(data);
|
||||
|
||||
const seen = new Set<string>();
|
||||
const output: Array<{ key: string; label: string; value: unknown }> = [];
|
||||
|
||||
for (const key of orderedKeys) {
|
||||
if (seen.has(key)) continue;
|
||||
seen.add(key);
|
||||
const value = data[key];
|
||||
if (!containsNavigableReference(value)) continue;
|
||||
|
||||
const rule = getAttributePresentationRule(key, rules);
|
||||
if (!shouldRenderAttribute(value, rule)) continue;
|
||||
|
||||
const definition = roots.find((item) => item.attribute_key === key);
|
||||
output.push({
|
||||
key,
|
||||
label: definition?.label?.trim() || key.replace(/_/g, " "),
|
||||
value,
|
||||
});
|
||||
}
|
||||
|
||||
return output;
|
||||
}, [data, definitions, rules]);
|
||||
|
||||
if (!items.length) return null;
|
||||
|
||||
return (
|
||||
<>
|
||||
{items.map((item) => (
|
||||
<SectionCard key={item.key} title={item.label}>
|
||||
<ContentValue value={item.value} />
|
||||
</SectionCard>
|
||||
))}
|
||||
</>
|
||||
);
|
||||
}
|
||||
|
|
@ -118,8 +118,8 @@ function contentValueKey(value: unknown, index: number): string {
|
|||
const styles = StyleSheet.create({
|
||||
text: {
|
||||
fontSize: 16,
|
||||
lineHeight: 23,
|
||||
color: Colors.textPrimary,
|
||||
lineHeight: 25,
|
||||
color: "#334155",
|
||||
},
|
||||
stack: {
|
||||
gap: Spacing.sm,
|
||||
|
|
|
|||
|
|
@ -1,30 +1,22 @@
|
|||
import React, { type PropsWithChildren, useState } from "react";
|
||||
import { Pressable, SafeAreaView, StyleSheet } from "react-native";
|
||||
import { Pressable, StyleSheet, View } from "react-native";
|
||||
import { SafeAreaView } from "react-native-safe-area-context";
|
||||
import { Ionicons } from "@expo/vector-icons";
|
||||
import { router, useLocalSearchParams } from "expo-router";
|
||||
|
||||
import { Colors } from "@/theme/colors";
|
||||
import { Colors } from "@/theme";
|
||||
import { ContentPageHeader } from "../../components/layout/ContentPageHeader";
|
||||
import { useModuleDisplayName } from "../../hooks/use-module-display-name";
|
||||
|
||||
interface DetailPageShellProps extends PropsWithChildren {
|
||||
/**
|
||||
* Content title is retained for renderer compatibility and accessibility
|
||||
* context. The application header itself always shows the module name.
|
||||
*/
|
||||
title: string;
|
||||
subtitle?: string;
|
||||
}
|
||||
|
||||
export function DetailPageShell({
|
||||
title,
|
||||
children,
|
||||
}: DetailPageShellProps) {
|
||||
export function DetailPageShell({ children }: DetailPageShellProps) {
|
||||
const [isFavorite, setIsFavorite] = useState(false);
|
||||
const { moduleCode } = useLocalSearchParams<{
|
||||
moduleCode?: string;
|
||||
}>();
|
||||
const currentModuleCode =
|
||||
typeof moduleCode === "string" ? moduleCode : "";
|
||||
const { moduleCode } = useLocalSearchParams<{ moduleCode?: string }>();
|
||||
const currentModuleCode = typeof moduleCode === "string" ? moduleCode : "";
|
||||
const moduleDisplay = useModuleDisplayName(currentModuleCode);
|
||||
|
||||
const searchAction = currentModuleCode ? (
|
||||
|
|
@ -33,35 +25,21 @@ export function DetailPageShell({
|
|||
accessibilityLabel={`Search within ${moduleDisplay.name}`}
|
||||
hitSlop={10}
|
||||
onPress={() =>
|
||||
router.push(
|
||||
`/modules/${encodeURIComponent(currentModuleCode)}/search` as never,
|
||||
)
|
||||
router.push(`/modules/${encodeURIComponent(currentModuleCode)}/search` as never)
|
||||
}
|
||||
style={({ pressed }) => [
|
||||
styles.iconButton,
|
||||
pressed && styles.pressed,
|
||||
]}
|
||||
style={({ pressed }) => [styles.iconButton, pressed && styles.pressed]}
|
||||
>
|
||||
<Ionicons
|
||||
name="search"
|
||||
size={22}
|
||||
color={Colors.textPrimary}
|
||||
/>
|
||||
<Ionicons name="search" size={22} color={Colors.primaryDark} />
|
||||
</Pressable>
|
||||
) : null;
|
||||
|
||||
const favoriteAction = (
|
||||
<Pressable
|
||||
accessibilityRole="button"
|
||||
accessibilityLabel={
|
||||
isFavorite ? "Remove from favorites" : "Add to favorites"
|
||||
}
|
||||
accessibilityLabel={isFavorite ? "Remove from favorites" : "Add to favorites"}
|
||||
hitSlop={10}
|
||||
onPress={() => setIsFavorite((value) => !value)}
|
||||
style={({ pressed }) => [
|
||||
styles.iconButton,
|
||||
pressed && styles.pressed,
|
||||
]}
|
||||
style={({ pressed }) => [styles.iconButton, pressed && styles.pressed]}
|
||||
>
|
||||
<Ionicons
|
||||
name={isFavorite ? "heart" : "heart-outline"}
|
||||
|
|
@ -72,21 +50,26 @@ export function DetailPageShell({
|
|||
);
|
||||
|
||||
return (
|
||||
<SafeAreaView style={styles.screen}>
|
||||
<SafeAreaView style={styles.screen} edges={["top", "left", "right"]}>
|
||||
<ContentPageHeader
|
||||
title={moduleDisplay.name}
|
||||
onTitlePress={() =>
|
||||
router.push(moduleDisplay.homeRoute as never)
|
||||
onTitlePress={
|
||||
currentModuleCode
|
||||
? () => router.push(moduleDisplay.homeRoute as never)
|
||||
: undefined
|
||||
}
|
||||
titleAccessibilityLabel={`Open ${moduleDisplay.name} home from ${title}`}
|
||||
titleAccessibilityLabel={
|
||||
currentModuleCode ? `Open ${moduleDisplay.name} home` : moduleDisplay.name
|
||||
}
|
||||
fallbackRoute={moduleDisplay.homeRoute}
|
||||
right={
|
||||
<>
|
||||
<View style={styles.actions}>
|
||||
{searchAction}
|
||||
{favoriteAction}
|
||||
</>
|
||||
</View>
|
||||
}
|
||||
/>
|
||||
{children}
|
||||
<View style={styles.body}>{children}</View>
|
||||
</SafeAreaView>
|
||||
);
|
||||
}
|
||||
|
|
@ -94,12 +77,19 @@ export function DetailPageShell({
|
|||
const styles = StyleSheet.create({
|
||||
screen: {
|
||||
flex: 1,
|
||||
backgroundColor: Colors.surface,
|
||||
backgroundColor: "#F6F8F7",
|
||||
},
|
||||
body: {
|
||||
flex: 1,
|
||||
backgroundColor: "#F6F8F7",
|
||||
},
|
||||
actions: {
|
||||
flexDirection: "row",
|
||||
alignItems: "center",
|
||||
},
|
||||
iconButton: {
|
||||
width: 40,
|
||||
width: 36,
|
||||
height: 40,
|
||||
borderRadius: 20,
|
||||
alignItems: "center",
|
||||
justifyContent: "center",
|
||||
},
|
||||
|
|
|
|||
|
|
@ -1,12 +1,72 @@
|
|||
import React from "react";
|
||||
import { Text, View } from "react-native";
|
||||
import { StyleSheet, Text, View } from "react-native";
|
||||
import { moderateScale, verticalScale } from "react-native-size-matters";
|
||||
|
||||
export function Hero({ eyebrow, title, subtitle }: { eyebrow?: string; title: string; subtitle?: string }) {
|
||||
import { Colors } from "@/theme";
|
||||
|
||||
export function Hero({
|
||||
eyebrow,
|
||||
title,
|
||||
subtitle,
|
||||
meta,
|
||||
}: {
|
||||
eyebrow?: string;
|
||||
title: string;
|
||||
subtitle?: string;
|
||||
meta?: string;
|
||||
}) {
|
||||
return (
|
||||
<View style={{ gap: 6 }}>
|
||||
{eyebrow ? <Text style={{ fontSize: 13, fontWeight: "700" }}>{eyebrow}</Text> : null}
|
||||
<Text style={{ fontSize: 30, fontWeight: "700", lineHeight: 36 }}>{title}</Text>
|
||||
{subtitle ? <Text style={{ fontSize: 16, lineHeight: 23 }}>{subtitle}</Text> : null}
|
||||
<View style={styles.card}>
|
||||
<View style={styles.accent} />
|
||||
<View style={styles.content}>
|
||||
{eyebrow ? <Text style={styles.eyebrow}>{eyebrow}</Text> : null}
|
||||
<Text style={styles.title}>{title}</Text>
|
||||
{subtitle ? <Text style={styles.subtitle}>{subtitle}</Text> : null}
|
||||
{meta ? <Text style={styles.meta}>{meta}</Text> : null}
|
||||
</View>
|
||||
</View>
|
||||
);
|
||||
}
|
||||
|
||||
const styles = StyleSheet.create({
|
||||
card: {
|
||||
flexDirection: "row",
|
||||
backgroundColor: "#F2F8F4",
|
||||
borderRadius: moderateScale(18),
|
||||
borderWidth: 1,
|
||||
borderColor: "#DCEADF",
|
||||
overflow: "hidden",
|
||||
},
|
||||
accent: { width: moderateScale(5), backgroundColor: Colors.primary },
|
||||
content: {
|
||||
flex: 1,
|
||||
paddingHorizontal: moderateScale(18),
|
||||
paddingVertical: verticalScale(18),
|
||||
gap: verticalScale(6),
|
||||
},
|
||||
eyebrow: {
|
||||
fontSize: moderateScale(12),
|
||||
lineHeight: moderateScale(17),
|
||||
fontWeight: "700",
|
||||
color: "#3F7D62",
|
||||
textTransform: "uppercase",
|
||||
letterSpacing: 0.8,
|
||||
},
|
||||
title: {
|
||||
fontSize: moderateScale(24),
|
||||
lineHeight: moderateScale(32),
|
||||
fontWeight: "700",
|
||||
color: "#1F2937",
|
||||
letterSpacing: -0.25,
|
||||
},
|
||||
subtitle: {
|
||||
fontSize: moderateScale(15),
|
||||
lineHeight: moderateScale(23),
|
||||
color: "#53606B",
|
||||
},
|
||||
meta: {
|
||||
fontSize: moderateScale(13),
|
||||
lineHeight: moderateScale(19),
|
||||
color: "#6B7280",
|
||||
},
|
||||
});
|
||||
|
|
|
|||
|
|
@ -1,42 +1,52 @@
|
|||
import React from "react";
|
||||
import { Image, Text, View } from "react-native";
|
||||
import { Image, StyleSheet, Text, View } from "react-native";
|
||||
import { ContentMediaGallery } from "../../media/ContentMediaGallery";
|
||||
import { useRelationalContentMedia } from "../../media/ContentMediaContext";
|
||||
import { asString } from "../helpers/value";
|
||||
|
||||
export function ImageGallery({
|
||||
images,
|
||||
}: {
|
||||
images: Record<string, unknown>[];
|
||||
}) {
|
||||
export function ImageGallery({ images }: { images: Record<string, unknown>[] }) {
|
||||
const relationalMedia = useRelationalContentMedia();
|
||||
|
||||
if (relationalMedia.length > 0) {
|
||||
return <ContentMediaGallery media={relationalMedia} />;
|
||||
return <ContentMediaGallery media={relationalMedia} title="Visual reference" />;
|
||||
}
|
||||
|
||||
const visible = images.filter(
|
||||
(item) => asString(item.image_path).trim().length > 0,
|
||||
);
|
||||
|
||||
const visible = images.filter((item) => asString(item.image_path).trim().length > 0);
|
||||
if (!visible.length) return null;
|
||||
|
||||
return (
|
||||
<View style={{ gap: 12 }}>
|
||||
<View style={styles.root}>
|
||||
{visible.map((item, index) => {
|
||||
const path = asString(item.image_path);
|
||||
const name = asString(item.image_name);
|
||||
return (
|
||||
<View key={`${path}-${index}`} style={{ gap: 6 }}>
|
||||
<Image
|
||||
source={{ uri: path }}
|
||||
resizeMode="contain"
|
||||
style={{ width: "100%", height: 220, borderRadius: 12 }}
|
||||
/>
|
||||
{name ? <Text>{name}</Text> : null}
|
||||
<View key={`${path}-${index}`} style={styles.item}>
|
||||
<View style={styles.imageFrame}>
|
||||
<Image source={{ uri: path }} resizeMode="contain" style={styles.image} />
|
||||
</View>
|
||||
{name ? <Text style={styles.caption}>{name}</Text> : null}
|
||||
</View>
|
||||
);
|
||||
})}
|
||||
</View>
|
||||
);
|
||||
}
|
||||
|
||||
const styles = StyleSheet.create({
|
||||
root: { gap: 14 },
|
||||
item: { gap: 7 },
|
||||
imageFrame: {
|
||||
overflow: "hidden",
|
||||
borderRadius: 18,
|
||||
backgroundColor: "#F4F7F5",
|
||||
borderWidth: 1,
|
||||
borderColor: "#DDE7E1",
|
||||
},
|
||||
image: { width: "100%", height: 270 },
|
||||
caption: {
|
||||
fontSize: 13,
|
||||
lineHeight: 19,
|
||||
color: "#64748B",
|
||||
textAlign: "center",
|
||||
},
|
||||
});
|
||||
|
|
|
|||
|
|
@ -1,17 +1,36 @@
|
|||
import React from "react";
|
||||
import { Text, View } from "react-native";
|
||||
import { StyleSheet, Text, View } from "react-native";
|
||||
|
||||
export function KeyValueGrid({ rows }: { rows: Array<{ label: string; value: string }> }) {
|
||||
const visible = rows.filter((row) => row.value.trim().length > 0);
|
||||
if (!visible.length) return null;
|
||||
return (
|
||||
<View style={{ gap: 10 }}>
|
||||
<View style={styles.list}>
|
||||
{visible.map((row) => (
|
||||
<View key={row.label} style={{ flexDirection: "row", gap: 12 }}>
|
||||
<Text style={{ width: 120, fontWeight: "700" }}>{row.label}</Text>
|
||||
<Text style={{ flex: 1, fontSize: 16 }}>{row.value}</Text>
|
||||
<View key={row.label} style={styles.row}>
|
||||
<Text style={styles.label}>{row.label}</Text>
|
||||
<Text style={styles.value}>{row.value}</Text>
|
||||
</View>
|
||||
))}
|
||||
</View>
|
||||
);
|
||||
}
|
||||
|
||||
const styles = StyleSheet.create({
|
||||
list: { gap: 12 },
|
||||
row: {
|
||||
gap: 5,
|
||||
paddingBottom: 10,
|
||||
borderBottomWidth: StyleSheet.hairlineWidth,
|
||||
borderBottomColor: "#E8ECEF",
|
||||
},
|
||||
label: {
|
||||
fontSize: 12,
|
||||
lineHeight: 17,
|
||||
fontWeight: "700",
|
||||
color: "#597064",
|
||||
textTransform: "uppercase",
|
||||
letterSpacing: 0.4,
|
||||
},
|
||||
value: { fontSize: 16, lineHeight: 25, color: "#334155" },
|
||||
});
|
||||
|
|
|
|||
|
|
@ -1,15 +1,51 @@
|
|||
import React from "react";
|
||||
import { Text, View } from "react-native";
|
||||
import { asStringArray, humanizeKey } from "../helpers/value";
|
||||
import { BulletList } from "./BulletList";
|
||||
import { StyleSheet, Text, View } from "react-native";
|
||||
|
||||
import { humanizeKey } from "../helpers/value";
|
||||
import { ContentValue } from "./ContentValue";
|
||||
|
||||
/**
|
||||
* Render arbitrary JSON objects without flattening or stringifying nested
|
||||
* content references. ContentValue recursively handles arrays, objects and
|
||||
* hydrated content/template references.
|
||||
*/
|
||||
export function ObjectSections({ value }: { value: Record<string, unknown> }) {
|
||||
const entries = Object.entries(value).filter(([,v]) => v !== null && v !== "" && (!Array.isArray(v) || v.length));
|
||||
const entries = Object.entries(value).filter(([, child]) =>
|
||||
isPresent(child),
|
||||
);
|
||||
|
||||
if (!entries.length) return null;
|
||||
return <View style={{ gap:14 }}>{entries.map(([key,val])=>(
|
||||
<View key={key} style={{ gap:6 }}>
|
||||
<Text style={{ fontWeight:"700", fontSize:15 }}>{humanizeKey(key)}</Text>
|
||||
{Array.isArray(val) ? <BulletList items={asStringArray(val)} /> : <Text style={{ fontSize:16, lineHeight:23 }}>{String(val)}</Text>}
|
||||
|
||||
return (
|
||||
<View style={styles.root}>
|
||||
{entries.map(([key, child]) => (
|
||||
<View key={key} style={styles.section}>
|
||||
<Text style={styles.label}>{humanizeKey(key)}</Text>
|
||||
<ContentValue value={child} />
|
||||
</View>
|
||||
))}
|
||||
</View>
|
||||
))}</View>;
|
||||
);
|
||||
}
|
||||
|
||||
function isPresent(value: unknown): boolean {
|
||||
if (value === null || value === undefined || value === "") return false;
|
||||
if (Array.isArray(value)) return value.some(isPresent);
|
||||
if (typeof value === "object") {
|
||||
return Object.values(value as Record<string, unknown>).some(isPresent);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
const styles = StyleSheet.create({
|
||||
root: { gap: 16 },
|
||||
section: { gap: 7 },
|
||||
label: {
|
||||
fontWeight: "700",
|
||||
fontSize: 13,
|
||||
lineHeight: 18,
|
||||
color: "#536F61",
|
||||
textTransform: "uppercase",
|
||||
letterSpacing: 0.35,
|
||||
},
|
||||
});
|
||||
|
|
|
|||
|
|
@ -1,7 +1,18 @@
|
|||
import React from "react";
|
||||
import { Text, View } from "react-native";
|
||||
import { StyleSheet, Text, View } from "react-native";
|
||||
|
||||
export function Paragraphs({ items }: { items: string[] }) {
|
||||
if (!items.length) return null;
|
||||
return <View style={{ gap: 10 }}>{items.map((x,i)=><Text key={`${i}-${x}`} style={{ fontSize:16, lineHeight:24 }}>{x}</Text>)}</View>;
|
||||
return (
|
||||
<View style={styles.list}>
|
||||
{items.map((item, index) => (
|
||||
<Text key={`${index}-${item}`} style={styles.text}>{item}</Text>
|
||||
))}
|
||||
</View>
|
||||
);
|
||||
}
|
||||
|
||||
const styles = StyleSheet.create({
|
||||
list: { gap: 14 },
|
||||
text: { fontSize: 16, lineHeight: 26, color: "#334155" },
|
||||
});
|
||||
|
|
|
|||
|
|
@ -1,15 +1,60 @@
|
|||
import React from "react";
|
||||
import { Text, View } from "react-native";
|
||||
import { StyleSheet, Text, View } from "react-native";
|
||||
import { humanizeKey } from "../helpers/value";
|
||||
import { ContentValue } from "./ContentValue";
|
||||
|
||||
export function RecordCards({ rows, titleKey = "name" }: { rows: Record<string, unknown>[]; titleKey?: string }) {
|
||||
export function RecordCards({
|
||||
rows,
|
||||
titleKey = "name",
|
||||
}: {
|
||||
rows: Record<string, unknown>[];
|
||||
titleKey?: string;
|
||||
}) {
|
||||
if (!rows.length) return null;
|
||||
return <View style={{ gap: 10 }}>{rows.map((row,index)=>(
|
||||
<View key={index} style={{ borderWidth:1, borderRadius:12, padding:12, gap:8 }}>
|
||||
{row[titleKey] ? <Text style={{ fontSize:16, fontWeight:"700" }}>{String(row[titleKey])}</Text> : null}
|
||||
{Object.entries(row).filter(([k])=>k!==titleKey).map(([k,v])=>(
|
||||
<View key={k} style={{ gap:3 }}><Text style={{ fontSize:12, fontWeight:"700" }}>{humanizeKey(k)}</Text><Text style={{ fontSize:15 }}>{Array.isArray(v) ? v.join(", ") : String(v ?? "")}</Text></View>
|
||||
|
||||
return (
|
||||
<View style={styles.list}>
|
||||
{rows.map((row, index) => (
|
||||
<View key={index} style={styles.card}>
|
||||
{typeof row[titleKey] === "string" && String(row[titleKey]).trim() ? (
|
||||
<Text style={styles.title}>{String(row[titleKey])}</Text>
|
||||
) : null}
|
||||
{Object.entries(row).filter(([key]) => key !== titleKey && key !== "code").map(([key, value]) => (
|
||||
<View key={key} style={styles.field}>
|
||||
<Text style={styles.label}>{humanizeKey(key)}</Text>
|
||||
<ContentValue value={value} textStyle={styles.value} />
|
||||
</View>
|
||||
))}
|
||||
</View>
|
||||
))}
|
||||
</View>
|
||||
))}</View>;
|
||||
);
|
||||
}
|
||||
|
||||
const styles = StyleSheet.create({
|
||||
list: { gap: 10 },
|
||||
card: {
|
||||
borderWidth: 1,
|
||||
borderColor: "#E1E8E4",
|
||||
borderRadius: 14,
|
||||
padding: 13,
|
||||
gap: 10,
|
||||
backgroundColor: "#FAFCFB",
|
||||
},
|
||||
title: {
|
||||
fontSize: 16,
|
||||
lineHeight: 22,
|
||||
fontWeight: "700",
|
||||
color: "#294C3B",
|
||||
},
|
||||
field: { gap: 4 },
|
||||
label: {
|
||||
fontSize: 12,
|
||||
lineHeight: 17,
|
||||
fontWeight: "700",
|
||||
color: "#617468",
|
||||
textTransform: "uppercase",
|
||||
letterSpacing: 0.35,
|
||||
},
|
||||
value: { fontSize: 15, lineHeight: 23, color: "#334155" },
|
||||
});
|
||||
|
|
|
|||
|
|
@ -1,21 +1,48 @@
|
|||
import React from "react";
|
||||
import { ScrollView, Text, View } from "react-native";
|
||||
import { humanizeKey } from "../helpers/value";
|
||||
import { ContentValue } from "./ContentValue";
|
||||
import { ContentLink } from "../../components/navigation/ContentLink";
|
||||
import { parseNavigableContentReference } from "../../utils/content-reference";
|
||||
|
||||
export function RecordTable({ rows, columns }: { rows: Record<string, unknown>[]; columns?: string[] }) {
|
||||
if (!rows.length) return null;
|
||||
const cols = columns?.length ? columns : Array.from(new Set(rows.flatMap((row) => Object.keys(row))));
|
||||
return (
|
||||
<ScrollView horizontal showsHorizontalScrollIndicator>
|
||||
<ScrollView horizontal showsHorizontalScrollIndicator={false}>
|
||||
<View>
|
||||
<View style={{ flexDirection: "row", borderBottomWidth: 1 }}>
|
||||
<View style={{ flexDirection: "row", borderBottomWidth: 1, borderBottomColor: "#E5E7EB" }}>
|
||||
{cols.map((col)=><Text key={col} style={{ width: 160, padding: 10, fontWeight: "700" }}>{humanizeKey(col)}</Text>)}
|
||||
</View>
|
||||
{rows.map((row,index)=>(
|
||||
<View key={index} style={{ flexDirection:"row", borderBottomWidth:1 }}>
|
||||
{cols.map((col)=><Text key={col} style={{ width:160, padding:10 }}>{Array.isArray(row[col]) ? (row[col] as unknown[]).join(", ") : String(row[col] ?? "")}</Text>)}
|
||||
</View>
|
||||
))}
|
||||
{rows.map((row,index)=>{
|
||||
const rowReference = parseNavigableContentReference(row);
|
||||
return (
|
||||
<View key={index} style={{ flexDirection:"row", borderBottomWidth:1, borderBottomColor:"#EEF1F3" }}>
|
||||
{cols.map((col)=>{
|
||||
const cell = row[col];
|
||||
const isPointIdentity = ["point", "point_name", "point_code", "name"].includes(col);
|
||||
const cellReference = parseNavigableContentReference(cell) ?? (isPointIdentity ? rowReference : null);
|
||||
return (
|
||||
<View key={col} style={{ width:160, padding:10 }}>
|
||||
{cellReference ? (
|
||||
<ContentLink
|
||||
reference={{
|
||||
...cellReference,
|
||||
label:
|
||||
(typeof cell === "string" && cell.trim()) ||
|
||||
cellReference.label ||
|
||||
undefined,
|
||||
}}
|
||||
/>
|
||||
) : (
|
||||
<ContentValue value={cell} />
|
||||
)}
|
||||
</View>
|
||||
);
|
||||
})}
|
||||
</View>
|
||||
);
|
||||
})}
|
||||
</View>
|
||||
</ScrollView>
|
||||
);
|
||||
|
|
|
|||
|
|
@ -1,11 +1,48 @@
|
|||
import React, { type PropsWithChildren } from "react";
|
||||
import { Text, View } from "react-native";
|
||||
import React, { type PropsWithChildren, isValidElement } from "react";
|
||||
|
||||
import { isEmptyValue } from "../../utils/attribute-presentation";
|
||||
import { AccordionSection } from "./AccordionSection";
|
||||
|
||||
export interface SectionCardProps {
|
||||
title: string;
|
||||
defaultExpanded?: boolean;
|
||||
}
|
||||
|
||||
function hasRenderableContent(node: React.ReactNode): boolean {
|
||||
if (node === null || node === undefined || node === false) return false;
|
||||
if (typeof node === "string") return node.trim().length > 0;
|
||||
if (typeof node === "number" || node === true) return true;
|
||||
if (Array.isArray(node)) return node.some(hasRenderableContent);
|
||||
|
||||
if (isValidElement(node)) {
|
||||
const props = node.props as Record<string, unknown>;
|
||||
|
||||
if (Array.isArray(props.items)) return !isEmptyValue(props.items);
|
||||
if (Array.isArray(props.rows)) {
|
||||
if (props.rows.length === 0) return false;
|
||||
return (props.rows as Array<Record<string, unknown>>).some((row) =>
|
||||
Object.entries(row).some(([key, value]) => key !== "label" && !isEmptyValue(value)),
|
||||
);
|
||||
}
|
||||
if (Object.prototype.hasOwnProperty.call(props, "value")) {
|
||||
return !isEmptyValue(props.value);
|
||||
}
|
||||
return hasRenderableContent(props.children as React.ReactNode);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
export function SectionCard({
|
||||
title,
|
||||
defaultExpanded = true,
|
||||
children,
|
||||
}: PropsWithChildren<SectionCardProps>) {
|
||||
if (!hasRenderableContent(children)) return null;
|
||||
|
||||
export function SectionCard({ title, children }: PropsWithChildren<{ title: string }>) {
|
||||
return (
|
||||
<View style={{ gap: 10, padding: 16, borderWidth: 1, borderRadius: 14 }}>
|
||||
<Text style={{ fontSize: 18, fontWeight: "700" }}>{title}</Text>
|
||||
<AccordionSection title={title} defaultExpanded={defaultExpanded}>
|
||||
{children}
|
||||
</View>
|
||||
</AccordionSection>
|
||||
);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -38,7 +38,6 @@ export function StandardDetailLayout({
|
|||
showsVerticalScrollIndicator={false}
|
||||
>
|
||||
<Hero
|
||||
eyebrow={eyebrow}
|
||||
title={title}
|
||||
subtitle={subtitle}
|
||||
meta={meta}
|
||||
|
|
|
|||
|
|
@ -1,11 +1,9 @@
|
|||
import React from "react";
|
||||
import React, { useMemo } 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/colors";
|
||||
import { Radius } from "@/theme/radius";
|
||||
import { Shadows } from "@/theme/shadows";
|
||||
import { Spacing } from "@/theme/spacing";
|
||||
import { Colors } from "@/theme";
|
||||
|
||||
export interface StandardIndexCardProps {
|
||||
title: string;
|
||||
|
|
@ -15,11 +13,22 @@ export interface StandardIndexCardProps {
|
|||
onPress: () => void;
|
||||
}
|
||||
|
||||
/**
|
||||
* Canonical card for collection/index templates such as CT0002, CT0004,
|
||||
* CT0006 and CT0008. Keeping these templates on one primitive prevents
|
||||
* template-specific styling from drifting across the app.
|
||||
*/
|
||||
const tones = [
|
||||
{ soft: "#F0F7F3", accent: "#3F7D62" },
|
||||
{ soft: "#F1F6FA", accent: "#4E7496" },
|
||||
{ soft: "#FBF6EE", accent: "#A06E35" },
|
||||
{ soft: "#F6F3FA", accent: "#75649B" },
|
||||
];
|
||||
|
||||
function toneFor(value: string) {
|
||||
let hash = 0;
|
||||
for (let i = 0; i < value.length; i += 1) {
|
||||
hash = (hash * 31 + value.charCodeAt(i)) >>> 0;
|
||||
}
|
||||
return tones[hash % tones.length];
|
||||
}
|
||||
|
||||
/** Canonical soothing index row for CT0002 / CT0004 / CT0006 / CT0008. */
|
||||
export function StandardIndexCard({
|
||||
title,
|
||||
subtitle,
|
||||
|
|
@ -29,113 +38,98 @@ export function StandardIndexCard({
|
|||
}: StandardIndexCardProps) {
|
||||
const normalizedTitle = title.trim();
|
||||
const normalizedSubtitle = subtitle?.trim() || null;
|
||||
const tone = useMemo(() => toneFor(normalizedTitle), [normalizedTitle]);
|
||||
|
||||
return (
|
||||
<Pressable
|
||||
accessibilityRole="button"
|
||||
accessibilityLabel={normalizedTitle}
|
||||
onPress={onPress}
|
||||
style={({ pressed }) => [styles.card, pressed && styles.cardPressed]}
|
||||
style={({ pressed }) => [styles.row, pressed && styles.pressed]}
|
||||
>
|
||||
<View style={styles.topRow}>
|
||||
<View style={[styles.accent, { backgroundColor: tone.soft }]}>
|
||||
<View style={[styles.accentDot, { backgroundColor: tone.accent }]} />
|
||||
</View>
|
||||
|
||||
<View style={styles.titleBlock}>
|
||||
<Text numberOfLines={2} style={styles.title}>
|
||||
{normalizedTitle}
|
||||
<View style={styles.titleBlock}>
|
||||
<Text numberOfLines={2} style={styles.title}>
|
||||
{normalizedTitle}
|
||||
</Text>
|
||||
{normalizedSubtitle ? (
|
||||
<Text numberOfLines={2} style={styles.subtitle}>
|
||||
{normalizedSubtitle}
|
||||
</Text>
|
||||
{normalizedSubtitle ? (
|
||||
<Text numberOfLines={1} style={styles.subtitle}>
|
||||
{normalizedSubtitle}
|
||||
) : null}
|
||||
</View>
|
||||
|
||||
{count !== null && count !== undefined ? (
|
||||
<View style={[styles.countBadge, { backgroundColor: tone.soft }]}>
|
||||
<Text style={[styles.countText, { color: tone.accent }]}>{count}</Text>
|
||||
{countLabel ? (
|
||||
<Text numberOfLines={1} style={styles.countLabel}>
|
||||
{countLabel}
|
||||
</Text>
|
||||
) : null}
|
||||
</View>
|
||||
) : null}
|
||||
|
||||
{count !== null && count !== undefined ? (
|
||||
<View style={styles.countBadge}>
|
||||
<Text style={styles.countText}>{count}</Text>
|
||||
{countLabel ? (
|
||||
<Text numberOfLines={1} style={styles.countLabel}>
|
||||
{countLabel}
|
||||
</Text>
|
||||
) : null}
|
||||
</View>
|
||||
) : null}
|
||||
|
||||
<Ionicons name="chevron-forward" size={20} color={Colors.textSecondary} />
|
||||
</View>
|
||||
<Ionicons name="chevron-forward" size={19} color="#94A3B8" />
|
||||
</Pressable>
|
||||
);
|
||||
}
|
||||
|
||||
const styles = StyleSheet.create({
|
||||
card: {
|
||||
marginHorizontal: Spacing.md,
|
||||
marginVertical: 7,
|
||||
padding: Spacing.md,
|
||||
borderRadius: Radius.xl,
|
||||
backgroundColor: Colors.background,
|
||||
...Shadows.card,
|
||||
},
|
||||
cardPressed: {
|
||||
opacity: 0.82,
|
||||
transform: [{ scale: 0.995 }],
|
||||
},
|
||||
topRow: {
|
||||
row: {
|
||||
minHeight: verticalScale(68),
|
||||
flexDirection: "row",
|
||||
alignItems: "center",
|
||||
gap: 12,
|
||||
paddingHorizontal: moderateScale(14),
|
||||
paddingVertical: verticalScale(13),
|
||||
gap: moderateScale(11),
|
||||
},
|
||||
codeBadge: {
|
||||
minWidth: 58,
|
||||
maxWidth: 86,
|
||||
paddingHorizontal: 10,
|
||||
paddingVertical: 8,
|
||||
borderRadius: Radius.lg,
|
||||
pressed: { opacity: 0.72 },
|
||||
accent: {
|
||||
width: moderateScale(38),
|
||||
height: moderateScale(38),
|
||||
borderRadius: moderateScale(19),
|
||||
alignItems: "center",
|
||||
backgroundColor: "#E8F5E9",
|
||||
justifyContent: "center",
|
||||
},
|
||||
codeText: {
|
||||
fontSize: 14,
|
||||
fontWeight: "800",
|
||||
color: Colors.primaryDark,
|
||||
},
|
||||
titleBlock: {
|
||||
flex: 1,
|
||||
gap: 3,
|
||||
accentDot: {
|
||||
width: moderateScale(9),
|
||||
height: moderateScale(9),
|
||||
borderRadius: moderateScale(5),
|
||||
},
|
||||
titleBlock: { flex: 1, gap: verticalScale(3) },
|
||||
title: {
|
||||
fontSize: 17,
|
||||
lineHeight: 22,
|
||||
fontWeight: "800",
|
||||
fontSize: moderateScale(16),
|
||||
lineHeight: moderateScale(22),
|
||||
fontWeight: "700",
|
||||
color: Colors.textPrimary,
|
||||
},
|
||||
subtitle: {
|
||||
fontSize: 13,
|
||||
lineHeight: 18,
|
||||
fontSize: moderateScale(12.5),
|
||||
lineHeight: moderateScale(18),
|
||||
color: Colors.textSecondary,
|
||||
},
|
||||
countBadge: {
|
||||
minWidth: 34,
|
||||
maxWidth: 92,
|
||||
paddingHorizontal: 9,
|
||||
paddingVertical: 6,
|
||||
borderRadius: Radius.full,
|
||||
minWidth: moderateScale(34),
|
||||
maxWidth: moderateScale(82),
|
||||
paddingHorizontal: moderateScale(9),
|
||||
paddingVertical: verticalScale(6),
|
||||
borderRadius: moderateScale(12),
|
||||
alignItems: "center",
|
||||
justifyContent: "center",
|
||||
backgroundColor: Colors.surface,
|
||||
borderWidth: StyleSheet.hairlineWidth,
|
||||
borderColor: Colors.border,
|
||||
},
|
||||
countText: {
|
||||
fontSize: 13,
|
||||
lineHeight: 16,
|
||||
fontSize: moderateScale(13),
|
||||
lineHeight: moderateScale(16),
|
||||
fontWeight: "800",
|
||||
color: Colors.textPrimary,
|
||||
},
|
||||
countLabel: {
|
||||
marginTop: 1,
|
||||
fontSize: 10,
|
||||
lineHeight: 12,
|
||||
fontSize: moderateScale(9.5),
|
||||
lineHeight: moderateScale(12),
|
||||
color: Colors.textSecondary,
|
||||
},
|
||||
});
|
||||
|
|
|
|||
|
|
@ -0,0 +1,28 @@
|
|||
export interface ReadingTone {
|
||||
accent: string;
|
||||
soft: string;
|
||||
border: string;
|
||||
title: string;
|
||||
}
|
||||
|
||||
const tones: readonly ReadingTone[] = [
|
||||
{ accent: "#3F7D62", soft: "#F0F7F3", border: "#D7E9DE", title: "#285A44" },
|
||||
{ accent: "#4E7496", soft: "#F1F6FA", border: "#D9E6F0", title: "#365B78" },
|
||||
{ accent: "#A06E35", soft: "#FBF6EE", border: "#EEE0CC", title: "#7E5529" },
|
||||
{ accent: "#75649B", soft: "#F6F3FA", border: "#E4DDF0", title: "#594978" },
|
||||
{ accent: "#A15D63", soft: "#FBF3F4", border: "#EEDBDE", title: "#7C4248" },
|
||||
];
|
||||
|
||||
export function readingToneForTitle(title: string): ReadingTone {
|
||||
const normalized = title.trim().toLowerCase();
|
||||
|
||||
if (normalized.includes("caution") || normalized.includes("warning")) {
|
||||
return { accent: "#B45353", soft: "#FFF5F5", border: "#F2D7D7", title: "#8D3F3F" };
|
||||
}
|
||||
|
||||
let hash = 0;
|
||||
for (let index = 0; index < normalized.length; index += 1) {
|
||||
hash = (hash * 31 + normalized.charCodeAt(index)) >>> 0;
|
||||
}
|
||||
return tones[hash % tones.length];
|
||||
}
|
||||
|
|
@ -1,18 +1,21 @@
|
|||
import React, { useMemo } from "react";
|
||||
import { Pressable, SafeAreaView, StyleSheet } from "react-native";
|
||||
import React, { useMemo, useState } from "react";
|
||||
import { Pressable, SafeAreaView, StyleSheet, View } from "react-native";
|
||||
import { Ionicons } from "@expo/vector-icons";
|
||||
import { router } from "expo-router";
|
||||
|
||||
import { Colors } from "@/theme";
|
||||
import { ContentPageHeader } from "../components/layout/ContentPageHeader";
|
||||
import { ScreenError } from "../components/ContentScreenState";
|
||||
import { ContractSortModal } from "../components/search/ContractSortModal";
|
||||
import { useContentSearchInfiniteQuery } from "../hooks/use-content-search-infinite-query";
|
||||
import { useModuleDisplayName } from "../hooks/use-module-display-name";
|
||||
import { useTemplateSearchController } from "../hooks/use-template-search-controller";
|
||||
import {
|
||||
resolveCollectionItemRenderer,
|
||||
resolveCollectionRenderer,
|
||||
} from "../renderers/registry";
|
||||
import type { TemplateContractResponse } from "../types/presentation.types";
|
||||
import { buildContentReferenceRoute, getNavigableContentReferences } from "../utils/content-reference";
|
||||
|
||||
export interface CollectionTemplateScreenProps {
|
||||
moduleCode: string;
|
||||
|
|
@ -28,14 +31,22 @@ export function CollectionTemplateScreen({
|
|||
templateCode,
|
||||
contract,
|
||||
onContentPress,
|
||||
onOpenSort,
|
||||
}: CollectionTemplateScreenProps) {
|
||||
const moduleDisplay = useModuleDisplayName(moduleCode);
|
||||
const [sortVisible, setSortVisible] = useState(false);
|
||||
const search = useTemplateSearchController({
|
||||
moduleCode,
|
||||
templateCode,
|
||||
contract,
|
||||
});
|
||||
|
||||
const query = useContentSearchInfiniteQuery({
|
||||
module_code: moduleCode,
|
||||
template_code: templateCode,
|
||||
logic: contract.search.default_logic,
|
||||
filters: [],
|
||||
sort: contract.search.default_sort,
|
||||
logic: search.logic,
|
||||
filters: search.filters,
|
||||
sort: search.sort,
|
||||
page_size: 25,
|
||||
});
|
||||
|
||||
|
|
@ -102,20 +113,51 @@ export function CollectionTemplateScreen({
|
|||
|
||||
const CollectionRenderer = rendererResolution.CollectionRenderer;
|
||||
const ItemRenderer = rendererResolution.ItemRenderer;
|
||||
const searchAction = (
|
||||
<Pressable
|
||||
accessibilityRole="button"
|
||||
accessibilityLabel={`Search within ${moduleDisplay.name}`}
|
||||
hitSlop={10}
|
||||
onPress={() =>
|
||||
router.push(
|
||||
`/modules/${encodeURIComponent(moduleCode)}/search` as never,
|
||||
)
|
||||
}
|
||||
style={({ pressed }) => [styles.iconButton, pressed && styles.pressed]}
|
||||
>
|
||||
<Ionicons name="search" size={22} color={Colors.textPrimary} />
|
||||
</Pressable>
|
||||
const hasSort = contract.search.sort_fields.length > 0;
|
||||
const hasCustomSort =
|
||||
JSON.stringify(search.sort) !== JSON.stringify(contract.search.default_sort);
|
||||
|
||||
const headerActions = (
|
||||
<View style={styles.headerActions}>
|
||||
<Pressable
|
||||
accessibilityRole="button"
|
||||
accessibilityLabel={`Search within ${moduleDisplay.name}`}
|
||||
hitSlop={8}
|
||||
onPress={() =>
|
||||
router.push(
|
||||
`/modules/${encodeURIComponent(moduleCode)}/search` as never,
|
||||
)
|
||||
}
|
||||
style={({ pressed }) => [styles.iconButton, pressed && styles.pressed]}
|
||||
>
|
||||
<Ionicons name="search" size={21} color={Colors.textPrimary} />
|
||||
</Pressable>
|
||||
|
||||
{hasSort ? (
|
||||
<Pressable
|
||||
accessibilityRole="button"
|
||||
accessibilityLabel="Sort content"
|
||||
accessibilityState={{ selected: hasCustomSort }}
|
||||
hitSlop={8}
|
||||
onPress={() => {
|
||||
onOpenSort?.();
|
||||
setSortVisible(true);
|
||||
}}
|
||||
style={({ pressed }) => [
|
||||
styles.iconButton,
|
||||
hasCustomSort && styles.iconButtonActive,
|
||||
pressed && styles.pressed,
|
||||
]}
|
||||
>
|
||||
<Ionicons
|
||||
name="swap-vertical-outline"
|
||||
size={21}
|
||||
color={hasCustomSort ? Colors.primaryDark : Colors.textPrimary}
|
||||
/>
|
||||
{hasCustomSort ? <View style={styles.activeDot} /> : null}
|
||||
</Pressable>
|
||||
) : null}
|
||||
</View>
|
||||
);
|
||||
|
||||
return (
|
||||
|
|
@ -124,7 +166,7 @@ export function CollectionTemplateScreen({
|
|||
title={moduleDisplay.name}
|
||||
onTitlePress={() => router.push(moduleDisplay.homeRoute as never)}
|
||||
titleAccessibilityLabel={`Open ${moduleDisplay.name} home`}
|
||||
right={searchAction}
|
||||
right={headerActions}
|
||||
/>
|
||||
|
||||
<CollectionRenderer
|
||||
|
|
@ -139,11 +181,31 @@ export function CollectionTemplateScreen({
|
|||
void query.fetchNextPage();
|
||||
}
|
||||
}}
|
||||
onItemPress={(item) => onContentPress(item.id)}
|
||||
onItemPress={(item) => {
|
||||
const references = Object.values(item.attributes).flatMap((value) =>
|
||||
getNavigableContentReferences(value),
|
||||
);
|
||||
if (references.length === 1) {
|
||||
router.push(buildContentReferenceRoute(references[0]) as never);
|
||||
return;
|
||||
}
|
||||
onContentPress(item.id);
|
||||
}}
|
||||
renderItem={({ item, onPress }) => (
|
||||
<ItemRenderer item={item} onPress={onPress} />
|
||||
)}
|
||||
/>
|
||||
|
||||
{hasSort ? (
|
||||
<ContractSortModal
|
||||
visible={sortVisible}
|
||||
fields={contract.search.sort_fields}
|
||||
sort={search.sort}
|
||||
defaultSort={contract.search.default_sort}
|
||||
onApply={search.setSort}
|
||||
onClose={() => setSortVisible(false)}
|
||||
/>
|
||||
) : null}
|
||||
</SafeAreaView>
|
||||
);
|
||||
}
|
||||
|
|
@ -151,15 +213,33 @@ export function CollectionTemplateScreen({
|
|||
const styles = StyleSheet.create({
|
||||
screen: {
|
||||
flex: 1,
|
||||
backgroundColor: Colors.surface,
|
||||
backgroundColor: "#F6F8F7",
|
||||
},
|
||||
headerActions: {
|
||||
flexDirection: "row",
|
||||
alignItems: "center",
|
||||
justifyContent: "flex-end",
|
||||
gap: 2,
|
||||
},
|
||||
iconButton: {
|
||||
width: 40,
|
||||
height: 40,
|
||||
borderRadius: 20,
|
||||
width: 38,
|
||||
height: 38,
|
||||
borderRadius: 19,
|
||||
alignItems: "center",
|
||||
justifyContent: "center",
|
||||
},
|
||||
iconButtonActive: {
|
||||
backgroundColor: "#EEF7F1",
|
||||
},
|
||||
activeDot: {
|
||||
position: "absolute",
|
||||
right: 7,
|
||||
top: 7,
|
||||
width: 6,
|
||||
height: 6,
|
||||
borderRadius: 3,
|
||||
backgroundColor: Colors.primary,
|
||||
},
|
||||
pressed: {
|
||||
opacity: 0.65,
|
||||
},
|
||||
|
|
|
|||
|
|
@ -3,6 +3,8 @@ import { ContentMediaProvider } from "../media/ContentMediaContext";
|
|||
import { ScreenError, ScreenLoading } from "../components/ContentScreenState";
|
||||
import { useContentDetailScreen } from "../hooks/use-content-detail-screen";
|
||||
import { resolveDetailRenderer } from "../renderers/registry";
|
||||
import { DetailPageShell } from "../renderers/shared/DetailPageShell";
|
||||
import { applyPresentationContractToData } from "../utils/attribute-presentation";
|
||||
|
||||
export interface ContentDetailScreenProps {
|
||||
moduleCode: string;
|
||||
|
|
@ -81,7 +83,7 @@ function ContentDetailScreenResolved({
|
|||
);
|
||||
}
|
||||
|
||||
if (screen.contractQuery.isError || screen.contentQuery.isError) {
|
||||
if (screen.contractQuery.isError || screen.contentQuery.isError || screen.definitionsQuery.isError) {
|
||||
return (
|
||||
<ScreenError
|
||||
title="Unable to load content"
|
||||
|
|
@ -105,22 +107,36 @@ function ContentDetailScreenResolved({
|
|||
return <ScreenError title="Content unavailable" message="The content detail response was empty." />;
|
||||
}
|
||||
|
||||
const presentationAttributes = screen.contractQuery.data?.presentation.attributes ?? [];
|
||||
const presentedData = applyPresentationContractToData(response.data, presentationAttributes);
|
||||
|
||||
const Renderer = rendererResolution.renderer;
|
||||
const pointName = typeof response.data.point_name === "string" ? response.data.point_name.trim() : "";
|
||||
const name = typeof response.data.name === "string" ? response.data.name.trim() : "";
|
||||
const displayTitle = pointName || name || response.content.title;
|
||||
const alternateNames = [response.data.alt_name_1, response.data.alt_name_2]
|
||||
.filter((value): value is string => typeof value === "string" && value.trim().length > 0)
|
||||
.map((value) => value.trim())
|
||||
.join(" · ");
|
||||
|
||||
return (
|
||||
<ContentMediaProvider media={response.media}>
|
||||
<Renderer
|
||||
moduleCode={moduleCode}
|
||||
templateCode={templateCode}
|
||||
contentId={response.content.id}
|
||||
content={{
|
||||
id: response.content.id,
|
||||
title: response.content.title,
|
||||
slug: response.content.slug,
|
||||
summary: response.content.summary,
|
||||
}}
|
||||
data={response.data}
|
||||
/>
|
||||
</ContentMediaProvider>
|
||||
<DetailPageShell title={displayTitle} subtitle={alternateNames || undefined}>
|
||||
<ContentMediaProvider media={response.media}>
|
||||
<Renderer
|
||||
moduleCode={moduleCode}
|
||||
templateCode={templateCode}
|
||||
contentId={response.content.id}
|
||||
content={{
|
||||
id: response.content.id,
|
||||
title: response.content.title,
|
||||
slug: response.content.slug,
|
||||
summary: response.content.summary,
|
||||
}}
|
||||
data={presentedData}
|
||||
definitions={screen.definitionsQuery.data?.attributes ?? []}
|
||||
presentationAttributes={presentationAttributes}
|
||||
/>
|
||||
</ContentMediaProvider>
|
||||
</DetailPageShell>
|
||||
);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
import React from "react";
|
||||
import { resolveDetailRenderer } from "../renderers/registry";
|
||||
import type { ContentEnvelope } from "../types/renderer.types";
|
||||
export function RendererHost({rendererCode,moduleCode,templateCode,content,data}:{rendererCode:string;moduleCode:string;templateCode:string;content:ContentEnvelope;data:Record<string,unknown>}){ const Renderer=resolveDetailRenderer(rendererCode); return <Renderer moduleCode={moduleCode} templateCode={templateCode} contentId={content.id} content={content} data={data}/>; }
|
||||
export function RendererHost({rendererCode,moduleCode,templateCode,content,data}:{rendererCode:string;moduleCode:string;templateCode:string;content:ContentEnvelope;data:Record<string,unknown>}){ const Renderer=resolveDetailRenderer(rendererCode); return <Renderer moduleCode={moduleCode} templateCode={templateCode} contentId={content.id} content={content} data={data} definitions={[]} presentationAttributes={[]}/>; }
|
||||
|
|
|
|||
|
|
@ -41,6 +41,8 @@ export interface TemplateAttributePresentationContract {
|
|||
visibility: AttributeVisibility;
|
||||
empty_behavior: EmptyBehavior;
|
||||
empty_text?: string | null;
|
||||
/** Client/view-specific display order. Lower values render first. */
|
||||
display_order?: number | null;
|
||||
}
|
||||
|
||||
export interface TemplatePresentationContract {
|
||||
|
|
|
|||
|
|
@ -1,4 +1,6 @@
|
|||
import type React from "react";
|
||||
import type { AttributeDefinitionResponse } from "./content.types";
|
||||
import type { TemplateAttributePresentationContract } from "./presentation.types";
|
||||
|
||||
export interface ContentEnvelope {
|
||||
id: string;
|
||||
|
|
@ -18,6 +20,8 @@ export interface DetailRendererProps {
|
|||
contentId: string;
|
||||
content: ContentEnvelope;
|
||||
data: Record<string, unknown>;
|
||||
definitions: AttributeDefinitionResponse[];
|
||||
presentationAttributes: TemplateAttributePresentationContract[];
|
||||
}
|
||||
|
||||
export interface CollectionItemRendererProps {
|
||||
|
|
|
|||
|
|
@ -15,6 +15,44 @@ export type AttributePresentationMap = ReadonlyMap<
|
|||
TemplateAttributePresentationContract
|
||||
>;
|
||||
|
||||
/** Returns the data-facing key from a canonical contract key. */
|
||||
export function bareAttributeKey(attributeKey: string): string {
|
||||
const normalized = attributeKey.trim();
|
||||
const index = normalized.lastIndexOf(".");
|
||||
return index >= 0 ? normalized.slice(index + 1) : normalized;
|
||||
}
|
||||
|
||||
/**
|
||||
* Resolves a presentation rule for either a canonical key
|
||||
* (`M0001_CT0003.location`) or the reconstructed API key (`location`).
|
||||
*/
|
||||
export function findAttributePresentationRule(
|
||||
attributeKey: string,
|
||||
rules: readonly TemplateAttributePresentationContract[] | null | undefined,
|
||||
): TemplateAttributePresentationContract | undefined {
|
||||
const normalized = attributeKey.trim();
|
||||
if (!normalized) return undefined;
|
||||
const bare = bareAttributeKey(normalized);
|
||||
return (rules ?? []).find((rule) => {
|
||||
const ruleKey = rule.attribute_key.trim();
|
||||
return ruleKey === normalized || bareAttributeKey(ruleKey) === bare;
|
||||
});
|
||||
}
|
||||
|
||||
export function presentationDisplayOrder(
|
||||
rule: TemplateAttributePresentationContract | null | undefined,
|
||||
definitionSortOrder?: number | null,
|
||||
contractIndex?: number,
|
||||
): number {
|
||||
if (typeof rule?.display_order === "number" && Number.isFinite(rule.display_order)) {
|
||||
return rule.display_order;
|
||||
}
|
||||
if (typeof definitionSortOrder === "number" && Number.isFinite(definitionSortOrder)) {
|
||||
return definitionSortOrder;
|
||||
}
|
||||
return 1_000_000 + (contractIndex ?? 0);
|
||||
}
|
||||
|
||||
function isPlainObject(value: unknown): value is Record<string, unknown> {
|
||||
if (value === null || typeof value !== "object") {
|
||||
return false;
|
||||
|
|
@ -111,8 +149,10 @@ export function getAttributePresentationRule(
|
|||
}
|
||||
|
||||
const rule = rules instanceof Map
|
||||
? rules.get(normalizedKey)
|
||||
: (rules ?? []).find((item) => item.attribute_key === normalizedKey);
|
||||
? rules.get(normalizedKey) ?? Array.from(rules.values()).find(
|
||||
(item) => bareAttributeKey(item.attribute_key) === bareAttributeKey(normalizedKey),
|
||||
)
|
||||
: findAttributePresentationRule(normalizedKey, rules);
|
||||
|
||||
return rule ?? {
|
||||
attribute_key: normalizedKey,
|
||||
|
|
@ -157,3 +197,45 @@ export function getEmptyDisplayText(
|
|||
const text = rule.empty_text?.trim();
|
||||
return text ? text : null;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Applies the effective presentation contract before semantic renderers receive
|
||||
* attribute data. This keeps visibility and empty behavior consistent even for
|
||||
* legacy/specialized renderers that read fields directly.
|
||||
*
|
||||
* `code` is presentation-only noise in the mobile reading UI and is removed at
|
||||
* this boundary. Domain-specific values such as `point_code` remain available.
|
||||
*/
|
||||
export function applyPresentationContractToData(
|
||||
data: Record<string, unknown>,
|
||||
attributes: readonly TemplateAttributePresentationContract[] | null | undefined,
|
||||
): Record<string, unknown> {
|
||||
const output: Record<string, unknown> = {};
|
||||
|
||||
for (const [key, value] of Object.entries(data)) {
|
||||
if (key === "code") continue;
|
||||
|
||||
const rule = findAttributePresentationRule(key, attributes);
|
||||
if (rule?.visibility === "hide") continue;
|
||||
|
||||
if (!isEmptyValue(value)) {
|
||||
output[key] = value;
|
||||
continue;
|
||||
}
|
||||
|
||||
if (rule?.empty_behavior !== "show") continue;
|
||||
output[key] = rule.empty_text?.trim() || "—";
|
||||
}
|
||||
|
||||
// Empty-show rules can refer to canonical keys while reconstructed data uses
|
||||
// bare keys. Materialize the bare key so semantic renderers can consume it.
|
||||
for (const rule of attributes ?? []) {
|
||||
const key = bareAttributeKey(rule.attribute_key);
|
||||
if (!key || key === "code" || Object.prototype.hasOwnProperty.call(output, key)) continue;
|
||||
if (rule.visibility === "hide" || rule.empty_behavior !== "show") continue;
|
||||
output[key] = rule.empty_text?.trim() || "—";
|
||||
}
|
||||
|
||||
return output;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -15,6 +15,14 @@ function nonBlankString(value: unknown): string | null {
|
|||
return normalized.length > 0 ? normalized : null;
|
||||
}
|
||||
|
||||
function firstLabel(record: Record<string, unknown>): string | null {
|
||||
for (const key of ["label", "point_name", "name", "point", "title", "point_code", "code"]) {
|
||||
const value = nonBlankString(record[key]);
|
||||
if (value) return value;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
export function parseContentReference(value: unknown): ContentReference | null {
|
||||
const reference = asRecord(value);
|
||||
if (!reference || reference.type !== "content_ref") return null;
|
||||
|
|
@ -26,7 +34,6 @@ export function parseContentReference(value: unknown): ContentReference | null {
|
|||
const templateCode = nonBlankString(target.template_code);
|
||||
const contentId = nonBlankString(target.content_id);
|
||||
|
||||
// source_key is provenance only. A hydrated content_id is mandatory for UI navigation.
|
||||
if (!moduleCode || !templateCode || !contentId) return null;
|
||||
|
||||
const sourceKey = nonBlankString(target.source_key);
|
||||
|
|
@ -66,30 +73,61 @@ export function parseTemplateReference(value: unknown): TemplateReference | null
|
|||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* Accepts both a reference DTO itself and the point/object wrapper shapes used
|
||||
* by content templates, e.g. { point_name, content_link: { type, target } }.
|
||||
*/
|
||||
export function parseNavigableContentReference(value: unknown): NavigableContentReference | null {
|
||||
return parseContentReference(value) ?? parseTemplateReference(value);
|
||||
const direct = parseContentReference(value) ?? parseTemplateReference(value);
|
||||
if (direct) return direct;
|
||||
|
||||
const wrapper = asRecord(value);
|
||||
if (!wrapper) return null;
|
||||
|
||||
for (const key of ["content_link", "link", "reference", "content_ref", "template_ref"]) {
|
||||
const nested = parseContentReference(wrapper[key]) ?? parseTemplateReference(wrapper[key]);
|
||||
if (nested) {
|
||||
const label = nested.label?.trim() || firstLabel(wrapper);
|
||||
return label ? { ...nested, label } : nested;
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Normalizes either a single reference object or a multivalue reference array.
|
||||
* Invalid/unhydrated entries are ignored and original array order is preserved.
|
||||
* Recursively discovers hydrated references in scalar, array and object values.
|
||||
* This is required for point collections where the reference lives inside a
|
||||
* row object rather than being the attribute value itself.
|
||||
*/
|
||||
export function getNavigableContentReferences(value: unknown): NavigableContentReference[] {
|
||||
const values = Array.isArray(value) ? value : [value];
|
||||
const references: NavigableContentReference[] = [];
|
||||
const seen = new Set<string>();
|
||||
|
||||
for (const candidate of values) {
|
||||
const reference = parseNavigableContentReference(candidate);
|
||||
if (reference) references.push(reference);
|
||||
}
|
||||
const visit = (candidate: unknown): void => {
|
||||
const direct = parseNavigableContentReference(candidate);
|
||||
if (direct) {
|
||||
const key = buildContentReferenceRoute(direct);
|
||||
if (!seen.has(key)) {
|
||||
seen.add(key);
|
||||
references.push(direct);
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
if (Array.isArray(candidate)) {
|
||||
candidate.forEach(visit);
|
||||
return;
|
||||
}
|
||||
|
||||
const record = asRecord(candidate);
|
||||
if (record) Object.values(record).forEach(visit);
|
||||
};
|
||||
|
||||
visit(value);
|
||||
return references;
|
||||
}
|
||||
|
||||
/**
|
||||
* Collection-card navigation is only inferred from row data when the row has
|
||||
* exactly one valid target. Multiple targets are intentionally not guessed.
|
||||
*/
|
||||
export function getSingleNavigableContentReference(value: unknown): NavigableContentReference | null {
|
||||
const references = getNavigableContentReferences(value);
|
||||
return references.length === 1 ? references[0] : null;
|
||||
|
|
|
|||
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Loading…
Reference in New Issue