diff --git a/.gitignore b/.gitignore index 4b00baf..72b51c6 100644 --- a/.gitignore +++ b/.gitignore @@ -36,6 +36,7 @@ yarn-error.* # typescript *.tsbuildinfo +versions example # generated native folders diff --git a/src/features/content/CollectionTemplateScreen.tsx b/src/features/content/CollectionTemplateScreen.tsx deleted file mode 100644 index 4f17ee9..0000000 --- a/src/features/content/CollectionTemplateScreen.tsx +++ /dev/null @@ -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("and"); - const [moduleFilters, setModuleFilters] = useState([]); - const [moduleSearchAttributes, setModuleSearchAttributes] = useState([]); - const [moduleSort, setModuleSort] = useState([]); - - 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 ; - if (moduleContractQuery.isError) return void moduleContractQuery.refetch()} />; - if (moduleSearchActive && moduleQueryResult.isError) return void moduleQueryResult.refetch()} />; - if (!moduleSearchActive && templateQuery.isError) return 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 - - - setFilterBuilderVisible(true)} onSearchAttributes={() => setSearchAttributesVisible(true)} onSort={() => { if (onOpenSort) onOpenSort(); else setSortVisible(true); }} /> - setModuleFilters((current) => current.filter((_, itemIndex) => itemIndex !== index))} onClear={() => setModuleFilters([])} /> - {moduleQuery !== debouncedModuleQuery ? Searching… : null} - - {moduleSearchActive ? void moduleQueryResult.refetch()} onLoadMore={() => { if (moduleQueryResult.hasNextPage && !moduleQueryResult.isFetchingNextPage) void moduleQueryResult.fetchNextPage(); }} onItemPress={onModuleSearchItemPress} /> : void templateQuery.refetch()} onLoadMore={() => { if (templateQuery.hasNextPage && !templateQuery.isFetchingNextPage) void templateQuery.fetchNextPage(); }} onItemPress={onItemPress} renderItem={({item,onPress}) => } />} - - {hasFilters ? setFilterBuilderVisible(false)} onAdd={(criterion) => setModuleFilters((current) => [...current, criterion])} /> : null} - {hasSearchAttributes ? setSearchAttributesVisible(false)} onApply={setModuleSearchAttributes} /> : null} - {hasSort && !onOpenSort ? setSortVisible(false)} onApply={moduleSearchActive ? setModuleSort : templateSearch.setSort} /> : null} - ; -} - -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}}); diff --git a/src/features/content/TemplateScreen.tsx b/src/features/content/TemplateScreen.tsx deleted file mode 100644 index aca3dc1..0000000 --- a/src/features/content/TemplateScreen.tsx +++ /dev/null @@ -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 ; - } - - return ( - 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 ; - - if (contractQuery.isError) { - return ( - void contractQuery.refetch()} - /> - ); - } - - const contract = contractQuery.data; - if (!contract) return ; - - if (contract.template_code !== templateCode) { - return ; - } - - if (contract.module_code && contract.module_code !== moduleCode) { - return ; - } - - if (contract.presentation.mode === "single") { - return ; - } - - if (contract.presentation.mode === "collection") { - return ( - { - 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 ; -} diff --git a/src/features/content/attribute-presentation.ts b/src/features/content/attribute-presentation.ts index a6a4ecf..572ba5b 100644 --- a/src/features/content/attribute-presentation.ts +++ b/src/features/content/attribute-presentation.ts @@ -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 { 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, + attributes: readonly TemplateAttributePresentationContract[] | null | undefined, +): Record { + const output: Record = {}; + + 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; +} diff --git a/src/features/content/components/layout/ContentPageHeader.tsx b/src/features/content/components/layout/ContentPageHeader.tsx index cbbcba1..5ac1995 100644 --- a/src/features/content/components/layout/ContentPageHeader.tsx +++ b/src/features/content/components/layout/ContentPageHeader.tsx @@ -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 = ( - - {title} - + + + {title} + + {subtitle ? ( + + {subtitle} + + ) : null} + ); return ( @@ -76,31 +85,31 @@ export function ContentPageHeader({ {titleContent} )} - - {right} - + {right} ); } 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, + }, }); diff --git a/src/features/content/components/m0001/category.tsx b/src/features/content/components/m0001/category.tsx index 5153b27..c310571 100644 --- a/src/features/content/components/m0001/category.tsx +++ b/src/features/content/components/m0001/category.tsx @@ -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;title:string})=>; +export const CategoryHero=({data,title}:{data:Record;title:string})=>; export const SourcePointTable=({data}:{data:Record})=>; export const ClinicalFeatureList=({data}:{data:Record})=>; export const YinYangSection=({data}:{data:Record})=>; diff --git a/src/features/content/components/m0001/eov.tsx b/src/features/content/components/m0001/eov.tsx index 40194f1..ed63188 100644 --- a/src/features/content/components/m0001/eov.tsx +++ b/src/features/content/components/m0001/eov.tsx @@ -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;title:string})=>; +export const VesselHero=({data,title}:{data:Record;title:string})=>; export const PointRelationsGrid=({data}:{data:Record})=>; export const AreasOfEffectChips=({data}:{data:Record})=>; export const FunctionsList=({data}:{data:Record})=>; diff --git a/src/features/content/components/m0001/meridian.tsx b/src/features/content/components/m0001/meridian.tsx index 92f0179..0d2e656 100644 --- a/src/features/content/components/m0001/meridian.tsx +++ b/src/features/content/components/m0001/meridian.tsx @@ -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;title:string})=>; -export const PrimaryChannelPathway=({data}:{data:Record})=>; -export const SecondaryBranches=({data}:{data:Record})=>; -export const DivergentChannel=({data}:{data:Record})=>; -export const LuoChannel=({data}:{data:Record})=>; -export const SinewChannel=({data}:{data:Record})=>; -export const SymptomsSections=({data}:{data:Record})=>; -export const MeetingPoints=({data}:{data:Record})=>; -export const PointCategoriesGrid=({data}:{data:Record})=>; -export const ClinicalManifestations=({data}:{data:Record})=>; -export const SpecificPoints=({data}:{data:Record})=>; -export const FiveShuTable=({data}:{data:Record})=>; + +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; + title: string; +}) => ; + +export const PrimaryChannelPathway = ({ data }: { data: Record }) => ( + + + +); + +export const SecondaryBranches = ({ data }: { data: Record }) => ( + + + +); + +export const DivergentChannel = ({ data }: { data: Record }) => ( + + + +); + +export const LuoChannel = ({ data }: { data: Record }) => ( + + + + +); + +export const SinewChannel = ({ data }: { data: Record }) => ( + + + +); + +export const SymptomsSections = ({ data }: { data: Record }) => ( + + + +); + +export const MeetingPoints = ({ data }: { data: Record }) => ( + + + +); + +export const PointCategoriesGrid = ({ data }: { data: Record }) => ( + + + +); + +export const ClinicalManifestations = ({ data }: { data: Record }) => ( + + + +); + +export const SpecificPoints = ({ data }: { data: Record }) => ( + + + +); + +export const FiveShuTable = ({ data }: { data: Record }) => ( + + + +); diff --git a/src/features/content/components/m0001/point.tsx b/src/features/content/components/m0001/point.tsx index 40afb1c..cfc69ef 100644 --- a/src/features/content/components/m0001/point.tsx +++ b/src/features/content/components/m0001/point.tsx @@ -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;title:string})=>; +export const PointHero=({data,title}:{data:Record;title:string})=>; export const AlternativeNames=({data}:{data:Record})=>; export const PointTypeChips=({data}:{data:Record})=>; export const ChannelSection=({data}:{data:Record})=>asString(data.channel)?{asString(data.channel)}:null; diff --git a/src/features/content/hooks/use-content-detail-screen.ts b/src/features/content/hooks/use-content-detail-screen.ts index 0b8c124..712b4cd 100644 --- a/src/features/content/hooks/use-content-detail-screen.ts +++ b/src/features/content/hooks/use-content-detail-screen.ts @@ -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()]); }, }; } diff --git a/src/features/content/media/ContentMediaGallery.tsx b/src/features/content/media/ContentMediaGallery.tsx index ee3fc61..8c5bb42 100644 --- a/src/features/content/media/ContentMediaGallery.tsx +++ b/src/features/content/media/ContentMediaGallery.tsx @@ -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, diff --git a/src/features/content/renderers/GenericDetailRenderer.tsx b/src/features/content/renderers/GenericDetailRenderer.tsx index fc6c243..789cc1f 100644 --- a/src/features/content/renderers/GenericDetailRenderer.tsx +++ b/src/features/content/renderers/GenericDetailRenderer.tsx @@ -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 {content.title}{Object.entries(data).map(([key,value])=>{key}{JSON.stringify(value,null,2)})}; + return ( + + + + {Object.entries(data) + .filter(([key]) => key !== "code") + .map(([key, value]) => ( + + + + ))} + + ); } diff --git a/src/features/content/renderers/acupuncture/AcuPointCardRenderer.tsx b/src/features/content/renderers/acupuncture/AcuPointCardRenderer.tsx index 6edc7b2..60ea581 100644 --- a/src/features/content/renderers/acupuncture/AcuPointCardRenderer.tsx +++ b/src/features/content/renderers/acupuncture/AcuPointCardRenderer.tsx @@ -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 {code}{item.title}{meridian?{meridian}:null}; + return {item.title}{meridian?{meridian}:null}; } diff --git a/src/features/content/renderers/acupuncture/AcuPointDetailRenderer.tsx b/src/features/content/renderers/acupuncture/AcuPointDetailRenderer.tsx index 73bc7c6..0eed0eb 100644 --- a/src/features/content/renderers/acupuncture/AcuPointDetailRenderer.tsx +++ b/src/features/content/renderers/acupuncture/AcuPointDetailRenderer.tsx @@ -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})=>{title}{children}; 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 {pointCode}{content.title}{location?
{location}
:null}{indications.length?
{indications.map((x,i)=>• {String(x)})}
:null}
; + return {content.title}{location?
{location}
:null}{indications.length?
{indications.map((x,i)=>• {String(x)})}
:null}
; } diff --git a/src/features/content/renderers/collections/EovRenderers.tsx b/src/features/content/renderers/collections/EovRenderers.tsx index 3e331c8..92c41e1 100644 --- a/src/features/content/renderers/collections/EovRenderers.tsx +++ b/src/features/content/renderers/collections/EovRenderers.tsx @@ -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 ; } -export function EovCollectionRenderer(props:CollectionRendererProps){ return ; } -export function EovIndexCardRenderer({item,onPress}:CollectionItemRendererProps){ const a=item.attributes; return {asString(a.name)||item.title}{asString(a.code)}; } -export function EovCardRenderer({item,onPress}:CollectionItemRendererProps){ const a=item.attributes; return {asString(a.name)||item.title}Master: {asString(a.master_point)} · Paired: {asString(a.paired_meridian)}; } + +export function EovIndexCollectionRenderer(props: CollectionRendererProps) { + return ; +} +export function EovCollectionRenderer(props: CollectionRendererProps) { + return ; +} +export function EovIndexCardRenderer({ item, onPress }: CollectionItemRendererProps) { + const a = item.attributes; + return ( + + ); +} +export function EovCardRenderer({ item, onPress }: CollectionItemRendererProps) { + const a = item.attributes; + return ( + + + {asString(a.name) || item.title} + + Master: {asString(a.master_point)} · Paired: {asString(a.paired_meridian)} + + + ); +} diff --git a/src/features/content/renderers/collections/MeridianRenderers.tsx b/src/features/content/renderers/collections/MeridianRenderers.tsx index f8e0d93..b5c3cc6 100644 --- a/src/features/content/renderers/collections/MeridianRenderers.tsx +++ b/src/features/content/renderers/collections/MeridianRenderers.tsx @@ -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 ; } -export function MeridianCollectionRenderer(props:CollectionRendererProps){ return ; } -export function MeridianIndexCardRenderer({item,onPress}:CollectionItemRendererProps){ const a=item.attributes; return {asString(a.name)||item.title}{asString(a.code)}; } -export function MeridianCardRenderer({item,onPress}:CollectionItemRendererProps){ const a=item.attributes; return {asString(a.title)||item.title}{asString(a.name)}{asStringArray(a.point_codes).length} referenced points; } + +export function MeridianIndexCollectionRenderer(props: CollectionRendererProps) { + return ; +} +export function MeridianCollectionRenderer(props: CollectionRendererProps) { + return ; +} +export function MeridianIndexCardRenderer({ item, onPress }: CollectionItemRendererProps) { + const a = item.attributes; + return ( + + ); +} +export function MeridianCardRenderer({ item, onPress }: CollectionItemRendererProps) { + const a = item.attributes; + return ( + + + {asString(a.title) || item.title} + {asString(a.name)} + {asStringArray(a.point_codes).length} referenced points + + + ); +} diff --git a/src/features/content/renderers/collections/ModuleCatalogRenderers.tsx b/src/features/content/renderers/collections/ModuleCatalogRenderers.tsx index 1130705..fd57368 100644 --- a/src/features/content/renderers/collections/ModuleCatalogRenderers.tsx +++ b/src/features/content/renderers/collections/ModuleCatalogRenderers.tsx @@ -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 ; } -export function ModuleCatalogCardRenderer({item,onPress}:CollectionItemRendererProps){ const a=item.attributes; return {asString(a.name)||item.title}{asString(a.content_label)}›; } +import type { + CollectionItemRendererProps, + CollectionRendererProps, +} from "../../types/renderer.types"; + +export function ModuleCatalogCollectionRenderer(props: CollectionRendererProps) { + return ; +} + +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 ( + [styles.row, pressed && styles.pressed]} + > + + + + + + {title} + + {label} + + + + + + + ); +} + +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, + }, +}); diff --git a/src/features/content/renderers/collections/PointCategoryRenderers.tsx b/src/features/content/renderers/collections/PointCategoryRenderers.tsx index ec882c8..3f50995 100644 --- a/src/features/content/renderers/collections/PointCategoryRenderers.tsx +++ b/src/features/content/renderers/collections/PointCategoryRenderers.tsx @@ -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 ; } -export function PointCategoryIndexCardRenderer({item,onPress}:CollectionItemRendererProps){ const a=item.attributes; return {asString(a.name)||item.title}›; } + +export function PointCategoryIndexCollectionRenderer(props: CollectionRendererProps) { + return ; +} +export function PointCategoryIndexCardRenderer({ item, onPress }: CollectionItemRendererProps) { + const a = item.attributes; + return ( + + ); +} diff --git a/src/features/content/renderers/collections/PointRenderers.tsx b/src/features/content/renderers/collections/PointRenderers.tsx index 2c0f174..396e849 100644 --- a/src/features/content/renderers/collections/PointRenderers.tsx +++ b/src/features/content/renderers/collections/PointRenderers.tsx @@ -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 ; } -export function AcuPointCollectionRenderer(props:CollectionRendererProps){ return ; } -export function AcuPointIndexCardRenderer({item,onPress}:CollectionItemRendererProps){ const a=item.attributes; return {asString(a.code)||item.title}{asString(a.alt_name_1)}{asString(a.alt_name_2)}; } -export function AcuPointCardRenderer({item,onPress}:CollectionItemRendererProps){ const a=item.attributes; return {asString(a.code)}{item.title}{asString(a.channel)}; } + +export function AcuPointIndexCollectionRenderer(props: CollectionRendererProps) { + return ; +} +export function AcuPointCollectionRenderer(props: CollectionRendererProps) { + return ; +} +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 ( + + ); +} +export function AcuPointCardRenderer({ item, onPress }: CollectionItemRendererProps) { + const a = item.attributes; + return ( + + + + {asString(a.point_name) || asString(a.name) || item.title} + + {asString(a.channel)} + + + + ); +} diff --git a/src/features/content/renderers/details/AcuPointDetailRenderer.tsx b/src/features/content/renderers/details/AcuPointDetailRenderer.tsx index 7f8fb4d..8fd1595 100644 --- a/src/features/content/renderers/details/AcuPointDetailRenderer.tsx +++ b/src/features/content/renderers/details/AcuPointDetailRenderer.tsx @@ -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 {asString(data.channel)}{asString(data.location)}{asString(data.location_note)?{asString(data.location_note)}:null}{asString(data.caution)?{asString(data.caution)}:null}; } +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(); + + 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 ; + } + + if ((key === "indications" || key === "actions") && isStringArray(value)) { + return ; + } + + if ((key === "channel" || key === "location" || key === "location_note") && typeof value === "string") { + return ( + + {value} + + ); + } + + if (key === "caution" && typeof value === "string") { + return ( + + {value} + + ); + } + + if (key === "regional_anatomy" && value !== null && typeof value === "object" && !Array.isArray(value)) { + return ; + } + + if (key === "methods" && hasRenderableMethodValues(value)) { + const methods = asRecord(value); + return ( + + ); + } + + // Specialized-field fallback: any unexpected runtime shape is still + // rendered through the generic reference-aware value renderer. + return ; + }; + + return ( + + + + + + {orderedAttributes.map((attribute) => ( + + {renderAttributeValue(attribute.key, attribute.value, attribute.emptyText)} + + ))} + + ); +} diff --git a/src/features/content/renderers/details/BackShuDetailRenderer.tsx b/src/features/content/renderers/details/BackShuDetailRenderer.tsx index 18ff1f9..001c0d3 100644 --- a/src/features/content/renderers/details/BackShuDetailRenderer.tsx +++ b/src/features/content/renderers/details/BackShuDetailRenderer.tsx @@ -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 ; } +export function BackShuDetailRenderer({content,data,definitions,presentationAttributes}:DetailRendererProps){ return ; } diff --git a/src/features/content/renderers/details/ConfluentPointsDetailRenderer.tsx b/src/features/content/renderers/details/ConfluentPointsDetailRenderer.tsx index f530639..204463e 100644 --- a/src/features/content/renderers/details/ConfluentPointsDetailRenderer.tsx +++ b/src/features/content/renderers/details/ConfluentPointsDetailRenderer.tsx @@ -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 ; } +export function ConfluentPointsDetailRenderer({content,data,definitions,presentationAttributes}:DetailRendererProps){ return ; } diff --git a/src/features/content/renderers/details/EntryExitPointsDetailRenderer.tsx b/src/features/content/renderers/details/EntryExitPointsDetailRenderer.tsx index 51581c3..c392fbb 100644 --- a/src/features/content/renderers/details/EntryExitPointsDetailRenderer.tsx +++ b/src/features/content/renderers/details/EntryExitPointsDetailRenderer.tsx @@ -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 ; } +export function EntryExitPointsDetailRenderer({content,data,definitions,presentationAttributes}:DetailRendererProps){ return ; } diff --git a/src/features/content/renderers/details/EovDetailRenderer.tsx b/src/features/content/renderers/details/EovDetailRenderer.tsx index 597129d..4f64963 100644 --- a/src/features/content/renderers/details/EovDetailRenderer.tsx +++ b/src/features/content/renderers/details/EovDetailRenderer.tsx @@ -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 {asString(data.pathway)}; } +export function EovDetailRenderer({content,data,definitions,presentationAttributes}:DetailRendererProps){ return {asString(data.pathway)}; } diff --git a/src/features/content/renderers/details/FiveShuDetailRenderer.tsx b/src/features/content/renderers/details/FiveShuDetailRenderer.tsx index 0297e31..1feee23 100644 --- a/src/features/content/renderers/details/FiveShuDetailRenderer.tsx +++ b/src/features/content/renderers/details/FiveShuDetailRenderer.tsx @@ -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 ; } +export function FiveShuDetailRenderer({content,data,definitions,presentationAttributes}:DetailRendererProps){ return ; } diff --git a/src/features/content/renderers/details/FourSeasDetailRenderer.tsx b/src/features/content/renderers/details/FourSeasDetailRenderer.tsx index f9800f8..d13ba5c 100644 --- a/src/features/content/renderers/details/FourSeasDetailRenderer.tsx +++ b/src/features/content/renderers/details/FourSeasDetailRenderer.tsx @@ -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 ; } +export function FourSeasDetailRenderer({content,data,definitions,presentationAttributes}:DetailRendererProps){ return ; } diff --git a/src/features/content/renderers/details/FrontMuDetailRenderer.tsx b/src/features/content/renderers/details/FrontMuDetailRenderer.tsx index 200a0bd..9fe7fd0 100644 --- a/src/features/content/renderers/details/FrontMuDetailRenderer.tsx +++ b/src/features/content/renderers/details/FrontMuDetailRenderer.tsx @@ -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 ; } +export function FrontMuDetailRenderer({content,data,definitions,presentationAttributes}:DetailRendererProps){ return ; } diff --git a/src/features/content/renderers/details/GaoWuCommandDetailRenderer.tsx b/src/features/content/renderers/details/GaoWuCommandDetailRenderer.tsx index 39ad466..742656c 100644 --- a/src/features/content/renderers/details/GaoWuCommandDetailRenderer.tsx +++ b/src/features/content/renderers/details/GaoWuCommandDetailRenderer.tsx @@ -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 ; } +export function GaoWuCommandDetailRenderer({content,data,definitions,presentationAttributes}:DetailRendererProps){ return ; } diff --git a/src/features/content/renderers/details/GhostPointsDetailRenderer.tsx b/src/features/content/renderers/details/GhostPointsDetailRenderer.tsx index f4a9092..b56a327 100644 --- a/src/features/content/renderers/details/GhostPointsDetailRenderer.tsx +++ b/src/features/content/renderers/details/GhostPointsDetailRenderer.tsx @@ -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 ; } +export function GhostPointsDetailRenderer({content,data,definitions,presentationAttributes}:DetailRendererProps){ return ; } diff --git a/src/features/content/renderers/details/HoraryPointsDetailRenderer.tsx b/src/features/content/renderers/details/HoraryPointsDetailRenderer.tsx index a1ab370..6612df7 100644 --- a/src/features/content/renderers/details/HoraryPointsDetailRenderer.tsx +++ b/src/features/content/renderers/details/HoraryPointsDetailRenderer.tsx @@ -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 ; } +export function HoraryPointsDetailRenderer({content,data,definitions,presentationAttributes}:DetailRendererProps){ return ; } diff --git a/src/features/content/renderers/details/HuiMeetingDetailRenderer.tsx b/src/features/content/renderers/details/HuiMeetingDetailRenderer.tsx index c5614ec..8982efc 100644 --- a/src/features/content/renderers/details/HuiMeetingDetailRenderer.tsx +++ b/src/features/content/renderers/details/HuiMeetingDetailRenderer.tsx @@ -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 ; } +export function HuiMeetingDetailRenderer({content,data,definitions,presentationAttributes}:DetailRendererProps){ return ; } diff --git a/src/features/content/renderers/details/IndexEntryDetailRenderer.tsx b/src/features/content/renderers/details/IndexEntryDetailRenderer.tsx index 45bd2b3..85ed188 100644 --- a/src/features/content/renderers/details/IndexEntryDetailRenderer.tsx +++ b/src/features/content/renderers/details/IndexEntryDetailRenderer.tsx @@ -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 typeof v==="string"||typeof v==="number").map(([k,v])=>({label:k,value:String(v)}))}/>; } +import { SectionCard } from "../shared/SectionCard"; +export function IndexEntryDetailRenderer({content,data,definitions,presentationAttributes}:DetailRendererProps){ return typeof v==="string"||typeof v==="number").map(([k,v])=>({label:k,value:String(v)}))}/>; } diff --git a/src/features/content/renderers/details/LowerHeSeaDetailRenderer.tsx b/src/features/content/renderers/details/LowerHeSeaDetailRenderer.tsx index c51f84b..e41644d 100644 --- a/src/features/content/renderers/details/LowerHeSeaDetailRenderer.tsx +++ b/src/features/content/renderers/details/LowerHeSeaDetailRenderer.tsx @@ -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 ; } +export function LowerHeSeaDetailRenderer({content,data,definitions,presentationAttributes}:DetailRendererProps){ return ; } diff --git a/src/features/content/renderers/details/LuoConnectingDetailRenderer.tsx b/src/features/content/renderers/details/LuoConnectingDetailRenderer.tsx index 8ce53c0..131c323 100644 --- a/src/features/content/renderers/details/LuoConnectingDetailRenderer.tsx +++ b/src/features/content/renderers/details/LuoConnectingDetailRenderer.tsx @@ -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 ; } +export function LuoConnectingDetailRenderer({content,data,definitions,presentationAttributes}:DetailRendererProps){ return ; } diff --git a/src/features/content/renderers/details/MeridianDetailRenderer.tsx b/src/features/content/renderers/details/MeridianDetailRenderer.tsx index bf9be48..eea9063 100644 --- a/src/features/content/renderers/details/MeridianDetailRenderer.tsx +++ b/src/features/content/renderers/details/MeridianDetailRenderer.tsx @@ -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 ; } +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 ( + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + ); +} diff --git a/src/features/content/renderers/details/ReturningYangDetailRenderer.tsx b/src/features/content/renderers/details/ReturningYangDetailRenderer.tsx index b2e629d..b7c8023 100644 --- a/src/features/content/renderers/details/ReturningYangDetailRenderer.tsx +++ b/src/features/content/renderers/details/ReturningYangDetailRenderer.tsx @@ -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 ; } +export function ReturningYangDetailRenderer({content,data,definitions,presentationAttributes}:DetailRendererProps){ return ; } diff --git a/src/features/content/renderers/details/WindowOfHeavenDetailRenderer.tsx b/src/features/content/renderers/details/WindowOfHeavenDetailRenderer.tsx index 6f1458b..6c7e76d 100644 --- a/src/features/content/renderers/details/WindowOfHeavenDetailRenderer.tsx +++ b/src/features/content/renderers/details/WindowOfHeavenDetailRenderer.tsx @@ -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 ; } +export function WindowOfHeavenDetailRenderer({content,data,definitions,presentationAttributes}:DetailRendererProps){ return ; } diff --git a/src/features/content/renderers/details/XiCleftDetailRenderer.tsx b/src/features/content/renderers/details/XiCleftDetailRenderer.tsx index b396127..9d7da6b 100644 --- a/src/features/content/renderers/details/XiCleftDetailRenderer.tsx +++ b/src/features/content/renderers/details/XiCleftDetailRenderer.tsx @@ -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 ; } +export function XiCleftDetailRenderer({content,data,definitions,presentationAttributes}:DetailRendererProps){ return ; } diff --git a/src/features/content/renderers/details/YuanSourceDetailRenderer.tsx b/src/features/content/renderers/details/YuanSourceDetailRenderer.tsx index 43d40ca..7e53deb 100644 --- a/src/features/content/renderers/details/YuanSourceDetailRenderer.tsx +++ b/src/features/content/renderers/details/YuanSourceDetailRenderer.tsx @@ -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 ; } +export function YuanSourceDetailRenderer({content,data,definitions,presentationAttributes}:DetailRendererProps){ return ; } diff --git a/src/features/content/renderers/details/categoryParts.tsx b/src/features/content/renderers/details/categoryParts.tsx index 7542d61..986a045 100644 --- a/src/features/content/renderers/details/categoryParts.tsx +++ b/src/features/content/renderers/details/categoryParts.tsx @@ -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}) => ; -export const DescriptionList = ({data}:{data:Record}) => { const arr=asStringArray(data.description); const text=asString(data.description); return {arr.length?:{text}}; }; -export const Images = ({data}:{data:Record}) => { - const relationalMedia = useRelationalContentMedia(); - if (relationalMedia.length) { - return ; - } - const rows=asRecordArray(data.images); - return rows.length?:null; +export const PointCodes = ({ data }: { data: Record }) => ( + +); + +export const DescriptionList = ({ data }: { data: Record }) => { + const arr = asStringArray(data.description); + const text = asString(data.description); + return ( + + {arr.length ? : {text}} + + ); }; -export const ObjectCard = ({title,value}:{title:string;value:unknown}) => { const obj=asRecord(value); return Object.keys(obj).length?:null; }; -export const ObjectArrayCards = ({title,value}:{title:string;value:unknown}) => { const rows=asRecordArray(value); return rows.length?:null; }; -export const ObjectArrayTable = ({title,value,columns}:{title:string;value:unknown;columns?:string[]}) => { const rows=asRecordArray(value); return rows.length?: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 {arr.length?:{txt}}; }; + +export const Images = ({ data }: { data: Record }) => ( + +); + +export const ObjectCard = ({ title, value }: { title: string; value: unknown }) => { + const obj = asRecord(value); + return Object.keys(obj).length ? ( + + ) : null; +}; + +export const ObjectArrayCards = ({ title, value }: { title: string; value: unknown }) => { + const rows = asRecordArray(value); + return rows.length ? ( + + ) : null; +}; + +export const ObjectArrayTable = ({ + title, + value, + columns, +}: { + title: string; + value: unknown; + columns?: string[]; +}) => { + const rows = asRecordArray(value); + return rows.length ? ( + + ) : 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 ( + + {arr.length ? : {txt}} + + ); +}; + +const styles = StyleSheet.create({ + readingText: { fontSize: 16, lineHeight: 26, color: "#334155" }, +}); diff --git a/src/features/content/renderers/shared/AccordionSection.tsx b/src/features/content/renderers/shared/AccordionSection.tsx index 83b1b09..2ccd98d 100644 --- a/src/features/content/renderers/shared/AccordionSection.tsx +++ b/src/features/content/renderers/shared/AccordionSection.tsx @@ -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) { 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 ( - + [styles.header, pressed && styles.pressed]} + style={({ pressed }) => [ + styles.header, + { backgroundColor: tone.soft }, + pressed && styles.pressed, + ]} > - - - {title} - - - - - {expanded ? "−" : "+"} - + + {title} + + - {expanded ? ( - <> - - {children} - - ) : null} + {expanded ? {children} : null} ); } 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 }, }); diff --git a/src/features/content/renderers/shared/BulletList.tsx b/src/features/content/renderers/shared/BulletList.tsx index a5e404a..8e318bc 100644 --- a/src/features/content/renderers/shared/BulletList.tsx +++ b/src/features/content/renderers/shared/BulletList.tsx @@ -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 ( - + {items.map((item, index) => ( - - •{item} + + + {item} ))} ); } + +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" }, +}); diff --git a/src/features/content/renderers/shared/ChipList.tsx b/src/features/content/renderers/shared/ChipList.tsx index 2503661..9251fbb 100644 --- a/src/features/content/renderers/shared/ChipList.tsx +++ b/src/features/content/renderers/shared/ChipList.tsx @@ -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 ( - - {items.map((item) => ( - - {item} - - ))} + + {items.map((item, index) => { + const tone = chipTones[index % chipTones.length]; + return ( + + {item} + + ); + })} ); } + +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" }, +}); diff --git a/src/features/content/renderers/shared/CollectionScaffold.tsx b/src/features/content/renderers/shared/CollectionScaffold.tsx index 678fd29..465a0e8 100644 --- a/src/features/content/renderers/shared/CollectionScaffold.tsx +++ b/src/features/content/renderers/shared/CollectionScaffold.tsx @@ -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} - - {props.total} results - + + {props.total} {props.total === 1 ? "result" : "results"} + } - renderItem={({ item }) => - props.renderItem({ - item, - onPress: () => props.onItemPress(item), - }) - } + ItemSeparatorComponent={() => } + renderItem={({ item }) => ( + + {props.renderItem({ + item, + onPress: () => props.onItemPress(item), + })} + + )} onEndReached={props.onLoadMore} onEndReachedThreshold={0.5} refreshControl={ @@ -41,18 +50,20 @@ export function CollectionScaffold( } ListEmptyComponent={ props.isLoading ? ( - + + Loading content… ) : ( - - No matching content. + + No content available + No matching published content was found. ) } ListFooterComponent={ props.isFetchingNextPage ? ( - + ) : 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", + }, +}); diff --git a/src/features/content/renderers/shared/ContentCountBadge.tsx b/src/features/content/renderers/shared/ContentCountBadge.tsx index 1cdf200..7a05a58 100644 --- a/src/features/content/renderers/shared/ContentCountBadge.tsx +++ b/src/features/content/renderers/shared/ContentCountBadge.tsx @@ -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 {count}{label ? ` ${label}` : ""}; + + return ( + + + {count} + {label ? ` ${label}` : ""} + + + ); } + +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, + }, +}); diff --git a/src/features/content/renderers/shared/ContentLinkAttributeSections.tsx b/src/features/content/renderers/shared/ContentLinkAttributeSections.tsx new file mode 100644 index 0000000..08f5577 --- /dev/null +++ b/src/features/content/renderers/shared/ContentLinkAttributeSections.tsx @@ -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; + 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).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(); + 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) => ( + + + + ))} + + ); +} diff --git a/src/features/content/renderers/shared/ContentValue.tsx b/src/features/content/renderers/shared/ContentValue.tsx index 166e303..76cb9cf 100644 --- a/src/features/content/renderers/shared/ContentValue.tsx +++ b/src/features/content/renderers/shared/ContentValue.tsx @@ -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, diff --git a/src/features/content/renderers/shared/DetailPageShell.tsx b/src/features/content/renderers/shared/DetailPageShell.tsx index 71559e2..bb58a9a 100644 --- a/src/features/content/renderers/shared/DetailPageShell.tsx +++ b/src/features/content/renderers/shared/DetailPageShell.tsx @@ -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]} > - + ) : null; const favoriteAction = ( setIsFavorite((value) => !value)} - style={({ pressed }) => [ - styles.iconButton, - pressed && styles.pressed, - ]} + style={({ pressed }) => [styles.iconButton, pressed && styles.pressed]} > + - 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={ - <> + {searchAction} {favoriteAction} - + } /> - {children} + {children} ); } @@ -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", }, diff --git a/src/features/content/renderers/shared/Hero.tsx b/src/features/content/renderers/shared/Hero.tsx index c359865..332a2e3 100644 --- a/src/features/content/renderers/shared/Hero.tsx +++ b/src/features/content/renderers/shared/Hero.tsx @@ -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 ( - - {eyebrow ? {eyebrow} : null} - {title} - {subtitle ? {subtitle} : null} + + + + {eyebrow ? {eyebrow} : null} + {title} + {subtitle ? {subtitle} : null} + {meta ? {meta} : null} + ); } + +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", + }, +}); diff --git a/src/features/content/renderers/shared/ImageGallery.tsx b/src/features/content/renderers/shared/ImageGallery.tsx index 951476e..337fa79 100644 --- a/src/features/content/renderers/shared/ImageGallery.tsx +++ b/src/features/content/renderers/shared/ImageGallery.tsx @@ -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[]; -}) { +export function ImageGallery({ images }: { images: Record[] }) { const relationalMedia = useRelationalContentMedia(); if (relationalMedia.length > 0) { - return ; + return ; } - 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 ( - + {visible.map((item, index) => { const path = asString(item.image_path); const name = asString(item.image_name); return ( - - - {name ? {name} : null} + + + + + {name ? {name} : null} ); })} ); } + +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", + }, +}); diff --git a/src/features/content/renderers/shared/KeyValueGrid.tsx b/src/features/content/renderers/shared/KeyValueGrid.tsx index 3e4155c..274ee88 100644 --- a/src/features/content/renderers/shared/KeyValueGrid.tsx +++ b/src/features/content/renderers/shared/KeyValueGrid.tsx @@ -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 ( - + {visible.map((row) => ( - - {row.label} - {row.value} + + {row.label} + {row.value} ))} ); } + +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" }, +}); diff --git a/src/features/content/renderers/shared/ObjectSections.tsx b/src/features/content/renderers/shared/ObjectSections.tsx index 5d15f33..906dad8 100644 --- a/src/features/content/renderers/shared/ObjectSections.tsx +++ b/src/features/content/renderers/shared/ObjectSections.tsx @@ -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 }) { - 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 {entries.map(([key,val])=>( - - {humanizeKey(key)} - {Array.isArray(val) ? : {String(val)}} + + return ( + + {entries.map(([key, child]) => ( + + {humanizeKey(key)} + + + ))} - ))}; + ); } + +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).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, + }, +}); diff --git a/src/features/content/renderers/shared/Paragraphs.tsx b/src/features/content/renderers/shared/Paragraphs.tsx index fe2060b..a0aa484 100644 --- a/src/features/content/renderers/shared/Paragraphs.tsx +++ b/src/features/content/renderers/shared/Paragraphs.tsx @@ -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 {items.map((x,i)=>{x})}; + return ( + + {items.map((item, index) => ( + {item} + ))} + + ); } + +const styles = StyleSheet.create({ + list: { gap: 14 }, + text: { fontSize: 16, lineHeight: 26, color: "#334155" }, +}); diff --git a/src/features/content/renderers/shared/RecordCards.tsx b/src/features/content/renderers/shared/RecordCards.tsx index e79b629..ee52c03 100644 --- a/src/features/content/renderers/shared/RecordCards.tsx +++ b/src/features/content/renderers/shared/RecordCards.tsx @@ -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[]; titleKey?: string }) { +export function RecordCards({ + rows, + titleKey = "name", +}: { + rows: Record[]; + titleKey?: string; +}) { if (!rows.length) return null; - return {rows.map((row,index)=>( - - {row[titleKey] ? {String(row[titleKey])} : null} - {Object.entries(row).filter(([k])=>k!==titleKey).map(([k,v])=>( - {humanizeKey(k)}{Array.isArray(v) ? v.join(", ") : String(v ?? "")} + + return ( + + {rows.map((row, index) => ( + + {typeof row[titleKey] === "string" && String(row[titleKey]).trim() ? ( + {String(row[titleKey])} + ) : null} + {Object.entries(row).filter(([key]) => key !== titleKey && key !== "code").map(([key, value]) => ( + + {humanizeKey(key)} + + + ))} + ))} - ))}; + ); } + +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" }, +}); diff --git a/src/features/content/renderers/shared/RecordTable.tsx b/src/features/content/renderers/shared/RecordTable.tsx index 20152eb..55adf74 100644 --- a/src/features/content/renderers/shared/RecordTable.tsx +++ b/src/features/content/renderers/shared/RecordTable.tsx @@ -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[]; columns?: string[] }) { if (!rows.length) return null; const cols = columns?.length ? columns : Array.from(new Set(rows.flatMap((row) => Object.keys(row)))); return ( - + - + {cols.map((col)=>{humanizeKey(col)})} - {rows.map((row,index)=>( - - {cols.map((col)=>{Array.isArray(row[col]) ? (row[col] as unknown[]).join(", ") : String(row[col] ?? "")})} - - ))} + {rows.map((row,index)=>{ + const rowReference = parseNavigableContentReference(row); + return ( + + {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 ( + + {cellReference ? ( + + ) : ( + + )} + + ); + })} + + ); + })} ); diff --git a/src/features/content/renderers/shared/SectionCard.tsx b/src/features/content/renderers/shared/SectionCard.tsx index 9e498bb..2288449 100644 --- a/src/features/content/renderers/shared/SectionCard.tsx +++ b/src/features/content/renderers/shared/SectionCard.tsx @@ -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; + + 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>).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) { + if (!hasRenderableContent(children)) return null; -export function SectionCard({ title, children }: PropsWithChildren<{ title: string }>) { return ( - - {title} + {children} - + ); } diff --git a/src/features/content/renderers/shared/StandardDetailLayout.tsx b/src/features/content/renderers/shared/StandardDetailLayout.tsx index 54ab9d4..b440f02 100644 --- a/src/features/content/renderers/shared/StandardDetailLayout.tsx +++ b/src/features/content/renderers/shared/StandardDetailLayout.tsx @@ -38,7 +38,6 @@ export function StandardDetailLayout({ showsVerticalScrollIndicator={false} > 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 ( [styles.card, pressed && styles.cardPressed]} + style={({ pressed }) => [styles.row, pressed && styles.pressed]} > - + + + - - - {normalizedTitle} + + + {normalizedTitle} + + {normalizedSubtitle ? ( + + {normalizedSubtitle} - {normalizedSubtitle ? ( - - {normalizedSubtitle} + ) : null} + + + {count !== null && count !== undefined ? ( + + {count} + {countLabel ? ( + + {countLabel} ) : null} + ) : null} - {count !== null && count !== undefined ? ( - - {count} - {countLabel ? ( - - {countLabel} - - ) : null} - - ) : null} - - - + ); } 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, }, }); diff --git a/src/features/content/renderers/shared/reading-palette.ts b/src/features/content/renderers/shared/reading-palette.ts new file mode 100644 index 0000000..c581dea --- /dev/null +++ b/src/features/content/renderers/shared/reading-palette.ts @@ -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]; +} diff --git a/src/features/content/screens/CollectionTemplateScreen.tsx b/src/features/content/screens/CollectionTemplateScreen.tsx index a7cce93..5ee8539 100644 --- a/src/features/content/screens/CollectionTemplateScreen.tsx +++ b/src/features/content/screens/CollectionTemplateScreen.tsx @@ -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 = ( - - router.push( - `/modules/${encodeURIComponent(moduleCode)}/search` as never, - ) - } - style={({ pressed }) => [styles.iconButton, pressed && styles.pressed]} - > - - + const hasSort = contract.search.sort_fields.length > 0; + const hasCustomSort = + JSON.stringify(search.sort) !== JSON.stringify(contract.search.default_sort); + + const headerActions = ( + + + router.push( + `/modules/${encodeURIComponent(moduleCode)}/search` as never, + ) + } + style={({ pressed }) => [styles.iconButton, pressed && styles.pressed]} + > + + + + {hasSort ? ( + { + onOpenSort?.(); + setSortVisible(true); + }} + style={({ pressed }) => [ + styles.iconButton, + hasCustomSort && styles.iconButtonActive, + pressed && styles.pressed, + ]} + > + + {hasCustomSort ? : null} + + ) : null} + ); 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} /> 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 }) => ( )} /> + + {hasSort ? ( + setSortVisible(false)} + /> + ) : null} ); } @@ -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, }, diff --git a/src/features/content/screens/ContentDetailScreen.tsx b/src/features/content/screens/ContentDetailScreen.tsx index 8f46486..99eb703 100644 --- a/src/features/content/screens/ContentDetailScreen.tsx +++ b/src/features/content/screens/ContentDetailScreen.tsx @@ -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 ( ; } + 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 ( - - - + + + + + ); } diff --git a/src/features/content/screens/RendererHost.tsx b/src/features/content/screens/RendererHost.tsx index 70ad9b5..24aa794 100644 --- a/src/features/content/screens/RendererHost.tsx +++ b/src/features/content/screens/RendererHost.tsx @@ -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}){ const Renderer=resolveDetailRenderer(rendererCode); return ; } +export function RendererHost({rendererCode,moduleCode,templateCode,content,data}:{rendererCode:string;moduleCode:string;templateCode:string;content:ContentEnvelope;data:Record}){ const Renderer=resolveDetailRenderer(rendererCode); return ; } diff --git a/src/features/content/types/presentation.types.ts b/src/features/content/types/presentation.types.ts index c68e648..b6cd5cd 100644 --- a/src/features/content/types/presentation.types.ts +++ b/src/features/content/types/presentation.types.ts @@ -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 { diff --git a/src/features/content/types/renderer.types.ts b/src/features/content/types/renderer.types.ts index b5b6b97..47aa0d9 100644 --- a/src/features/content/types/renderer.types.ts +++ b/src/features/content/types/renderer.types.ts @@ -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; + definitions: AttributeDefinitionResponse[]; + presentationAttributes: TemplateAttributePresentationContract[]; } export interface CollectionItemRendererProps { diff --git a/src/features/content/utils/attribute-presentation.ts b/src/features/content/utils/attribute-presentation.ts index a6a4ecf..572ba5b 100644 --- a/src/features/content/utils/attribute-presentation.ts +++ b/src/features/content/utils/attribute-presentation.ts @@ -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 { 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, + attributes: readonly TemplateAttributePresentationContract[] | null | undefined, +): Record { + const output: Record = {}; + + 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; +} diff --git a/src/features/content/utils/content-reference.ts b/src/features/content/utils/content-reference.ts index 44ab018..312375e 100644 --- a/src/features/content/utils/content-reference.ts +++ b/src/features/content/utils/content-reference.ts @@ -15,6 +15,14 @@ function nonBlankString(value: unknown): string | null { return normalized.length > 0 ? normalized : null; } +function firstLabel(record: Record): 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(); - 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; diff --git a/versions/src-v0.1.zip b/versions/src-v0.1.zip new file mode 100644 index 0000000..95a0f56 Binary files /dev/null and b/versions/src-v0.1.zip differ diff --git a/versions/src-v0.11.zip b/versions/src-v0.11.zip new file mode 100644 index 0000000..7b39c39 Binary files /dev/null and b/versions/src-v0.11.zip differ diff --git a/versions/src-v0.12.zip b/versions/src-v0.12.zip new file mode 100644 index 0000000..19ab929 Binary files /dev/null and b/versions/src-v0.12.zip differ diff --git a/versions/src-v0.13.zip b/versions/src-v0.13.zip new file mode 100644 index 0000000..a89a925 Binary files /dev/null and b/versions/src-v0.13.zip differ diff --git a/versions/src-v0.2.zip b/versions/src-v0.2.zip new file mode 100644 index 0000000..f44e6ec Binary files /dev/null and b/versions/src-v0.2.zip differ diff --git a/versions/src-v0.3.zip b/versions/src-v0.3.zip new file mode 100644 index 0000000..2e2268d Binary files /dev/null and b/versions/src-v0.3.zip differ diff --git a/versions/src-v0.4.zip b/versions/src-v0.4.zip new file mode 100644 index 0000000..2a7c836 Binary files /dev/null and b/versions/src-v0.4.zip differ diff --git a/versions/src-v0.5.zip b/versions/src-v0.5.zip new file mode 100644 index 0000000..80d4963 Binary files /dev/null and b/versions/src-v0.5.zip differ diff --git a/versions/src-v0.6.zip b/versions/src-v0.6.zip new file mode 100644 index 0000000..003db0a Binary files /dev/null and b/versions/src-v0.6.zip differ diff --git a/versions/src-v0.7.zip b/versions/src-v0.7.zip new file mode 100644 index 0000000..6687b26 Binary files /dev/null and b/versions/src-v0.7.zip differ diff --git a/versions/src-v08.zip b/versions/src-v08.zip new file mode 100644 index 0000000..388c902 Binary files /dev/null and b/versions/src-v08.zip differ diff --git a/versions/src-v09.zip b/versions/src-v09.zip new file mode 100644 index 0000000..d39997e Binary files /dev/null and b/versions/src-v09.zip differ diff --git a/versions/src-v10.zip b/versions/src-v10.zip new file mode 100644 index 0000000..ee5582e Binary files /dev/null and b/versions/src-v10.zip differ