@rebasepro/cms 0.29.1 → 0.29.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (66) hide show
  1. package/dist/collection_editor/serializable_types.d.ts +2 -0
  2. package/dist/collection_editor/ui/collection_editor/CollectionRelationsTab.d.ts +1 -1
  3. package/dist/components/CollectionPanel.js +22 -13
  4. package/dist/components/CollectionPanel.js.map +1 -1
  5. package/dist/components/CollectionTableBinding/internal/popup_field/PopupFormField.d.ts +1 -1
  6. package/dist/components/CollectionTableBinding/internal/popup_field/PopupFormField.js.map +1 -1
  7. package/dist/components/CollectionViewBinding/CollectionCardViewBinding.js.map +1 -1
  8. package/dist/components/CollectionViewBinding/CollectionListViewBinding.js +39 -14
  9. package/dist/components/CollectionViewBinding/CollectionListViewBinding.js.map +1 -1
  10. package/dist/components/CollectionViewBinding/CollectionViewContent.d.ts +11 -0
  11. package/dist/components/CollectionViewBinding/CollectionViewContent.js +19 -2
  12. package/dist/components/CollectionViewBinding/CollectionViewContent.js.map +1 -1
  13. package/dist/components/CollectionViewBinding/EntityCardBinding.d.ts +1 -1
  14. package/dist/components/CollectionViewBinding/EntityCardBinding.js +1 -1
  15. package/dist/components/CollectionViewBinding/EntityCardBinding.js.map +1 -1
  16. package/dist/components/CollectionViewBinding/SlotValue.js.map +1 -1
  17. package/dist/components/CollectionViewBinding/usePreviewSlots.d.ts +19 -1
  18. package/dist/components/CollectionViewBinding/usePreviewSlots.js +18 -7
  19. package/dist/components/CollectionViewBinding/usePreviewSlots.js.map +1 -1
  20. package/dist/components/EntityPreviewBinding.js.map +1 -1
  21. package/dist/components/HomePage/ContentHomePage.js +2 -3
  22. package/dist/components/HomePage/ContentHomePage.js.map +1 -1
  23. package/dist/components/RecordForm.d.ts +25 -4
  24. package/dist/components/RecordForm.js +21 -3
  25. package/dist/components/RecordForm.js.map +1 -1
  26. package/dist/components/RelationSelector.js.map +1 -1
  27. package/dist/components/SelectableTable/filters/FilterFieldBinding.d.ts +13 -1
  28. package/dist/components/SelectableTable/filters/FilterFieldBinding.js +19 -3
  29. package/dist/components/SelectableTable/filters/FilterFieldBinding.js.map +1 -1
  30. package/dist/components/SelectableTable/filters/RelationFilterField.d.ts +1 -1
  31. package/dist/components/SelectableTable/filters/RelationFilterField.js.map +1 -1
  32. package/dist/components/history/EntityHistoryEntry.js.map +1 -1
  33. package/dist/data_import/utils/save_entities.d.ts +10 -2
  34. package/dist/data_import/utils/save_entities.js.map +1 -1
  35. package/dist/editor/markdown.d.ts +10 -0
  36. package/dist/editor/markdown.js.map +1 -1
  37. package/dist/form/PropertyFieldBinding.js +4 -2
  38. package/dist/form/PropertyFieldBinding.js.map +1 -1
  39. package/dist/form/field_bindings/BinaryFieldBinding.js.map +1 -1
  40. package/dist/form/field_bindings/GeopointFieldBinding.js.map +1 -1
  41. package/dist/hooks/useBuildSidePanel.d.ts +10 -0
  42. package/dist/hooks/useBuildSidePanel.js +43 -4
  43. package/dist/hooks/useBuildSidePanel.js.map +1 -1
  44. package/dist/hooks/useResolvedNavigationFrom.d.ts +14 -2
  45. package/dist/hooks/useResolvedNavigationFrom.js.map +1 -1
  46. package/dist/index.d.ts +1 -1
  47. package/dist/index.js +2 -2
  48. package/dist/mcp_view/app_modules.js +4 -2
  49. package/dist/mcp_view/app_modules.js.map +1 -1
  50. package/dist/mcp_view/index.d.ts +1 -1
  51. package/dist/mcp_view/index.js +2 -2
  52. package/dist/mcp_view/index.js.map +1 -1
  53. package/dist/mcp_view/payload.js +7 -2
  54. package/dist/mcp_view/payload.js.map +1 -1
  55. package/dist/mcp_view/screen.js +1 -1
  56. package/dist/mcp_view/screen.js.map +1 -1
  57. package/dist/mcp_view/tool_driver.d.ts +25 -6
  58. package/dist/mcp_view/tool_driver.js +73 -35
  59. package/dist/mcp_view/tool_driver.js.map +1 -1
  60. package/dist/preview/compact_text.d.ts +1 -1
  61. package/dist/preview/compact_text.js.map +1 -1
  62. package/dist/selection/resolve_selection.d.ts +10 -2
  63. package/dist/selection/resolve_selection.js.map +1 -1
  64. package/dist/util/property_utils.d.ts +2 -2
  65. package/dist/util/property_utils.js.map +1 -1
  66. package/package.json +9 -9
@@ -1 +1 @@
1
- {"version":3,"file":"ContentHomePage.js","names":[],"sources":["../../../src/components/HomePage/ContentHomePage.tsx"],"sourcesContent":["import type { HomePageSection, NavigationEntry, NavigationGroupMapping, PluginGenericProps } from \"@rebasepro/cms-types\";\nimport React, { useCallback, useEffect, useMemo, useRef, useState } from \"react\";\nimport Fuse from \"fuse.js\";\nimport { Container, SearchBar } from \"@rebasepro/ui\";\nimport { AnalyticsEvent, studioSchemaToolEnabled } from \"@rebasepro/cms-types\";\nimport { FavouritesView } from \"./FavouritesView\";\nimport { ErrorBoundary } from \"@rebasepro/ui\";\nimport { NavigationGroup } from \"./NavigationGroup\";\nimport {\n NavigationGroupDroppable,\n NewGroupDropZone,\n SortableNavigationCard,\n SortableNavigationGroup,\n useHomePageDnd\n} from \"./HomePageDnD\";\nimport { DndContext, DragOverlay, MeasuringStrategy } from \"@dnd-kit/core\";\nimport { NavigationCardBinding } from \"./NavigationCardBinding\";\nimport { SortableContext, verticalListSortingStrategy } from \"@dnd-kit/sortable\";\nimport { restrictToVerticalAxis, restrictToWindowEdges } from \"@dnd-kit/modifiers\";\nimport { RenameGroupDialog } from \"./RenameGroupDialog\";\nimport { toArray } from \"@rebasepro/utils\";\nimport { useCollapsedGroups, buildCollapsedDefaults, useComponentOverride, useCustomizationController, useTranslation, useSlot, useAdminModeController, useRebaseRegistry } from \"@rebasepro/app\";\nimport { useRestoreScroll } from \"@rebasepro/app\";\n\nimport { SchemaDriftBanner } from \"@rebasepro/app\";\nimport { useBreadcrumbsController } from \"../../hooks/useBreadcrumbsController\";\nimport { useAdminContext } from \"../../hooks/useAdminContext\";\nimport { NavigationLoadingErrorView } from \"../NavigationLoadingErrorView\";\n\nexport const DEFAULT_GROUP_NAME = \"Views\";\nexport const ADMIN_GROUP_NAME = \"Admin\";\n\nexport function ContentHomePage({\n additionalActions,\n additionalChildrenStart,\n additionalChildrenEnd,\n sections,\n hiddenGroups\n}: {\n additionalActions?: React.ReactNode;\n additionalChildrenStart?: React.ReactNode;\n additionalChildrenEnd?: React.ReactNode;\n sections?: HomePageSection[];\n hiddenGroups?: string[];\n}) {\n\n const context = useAdminContext();\n const { navigationStateController } = context;\n const customizationController = useCustomizationController();\n const adminModeController = useAdminModeController();\n const registry = useRebaseRegistry();\n\n const { resolvedSlots } = customizationController;\n const ResolvedCollectionCard = useComponentOverride(\"HomePage.CollectionCard\", NavigationCardBinding);\n const breadcrumbs = useBreadcrumbsController();\n const { t } = useTranslation();\n\n useEffect(() => {\n breadcrumbs.set({ breadcrumbs: [] });\n }, [breadcrumbs.set]);\n\n const {\n allowDragAndDrop = false,\n navigationEntries: unFilteredNavigationEntries = [],\n groups: unFilteredGroupOrder = [],\n onNavigationEntriesUpdate = () => {}\n } = navigationStateController.topLevelNavigation || {};\n\n // Build a set of Studio-only dev view slugs so we can distinguish them from\n // admin custom views added via <RebaseCMS views={...}> or plugins.\n const studioViewSlugs = useMemo(() => {\n const slugs = new Set<string>();\n (registry.studioConfig?.devViews ?? []).forEach(v => slugs.add(v.slug));\n if (studioSchemaToolEnabled(registry)) slugs.add(\"schema\");\n return slugs;\n }, [registry]);\n\n // Studio mode shows Studio dev views + admin entries (Users/Roles).\n // Content mode shows collections, admin custom views, and admin entries — but not Studio dev views.\n const rawNavigationEntries = useMemo(() => {\n if (adminModeController.mode === \"studio\") {\n return unFilteredNavigationEntries.filter(e => (e.type === \"view\" && studioViewSlugs.has(e.slug)) || e.type === \"admin\");\n }\n return unFilteredNavigationEntries.filter(e => e.type !== \"view\" || !studioViewSlugs.has(e.slug));\n }, [unFilteredNavigationEntries, adminModeController.mode, studioViewSlugs]);\n\n const groupOrderFromNavController = useMemo(() => {\n const entryGroups = new Set(rawNavigationEntries.map(e => e.group).filter(Boolean));\n return unFilteredGroupOrder.filter(g => entryGroups.has(g));\n }, [unFilteredGroupOrder, rawNavigationEntries]);\n\n const fuse = useRef<Fuse<NavigationEntry> | null>(null);\n const [filteredUrls, setFilteredUrls] = useState<string[] | null>(null);\n const performingSearch = Boolean(filteredUrls);\n\n // Memoize filtered navigation entries to prevent unnecessary recalculations\n const filteredNavigationEntries = useMemo(() => {\n return filteredUrls\n ? rawNavigationEntries.filter((e) => filteredUrls.includes(e.url))\n : rawNavigationEntries;\n }, [filteredUrls, rawNavigationEntries]);\n\n useEffect(() => {\n fuse.current = new Fuse(rawNavigationEntries, {\n keys: [\"name\", \"description\", \"group\", \"path\"]\n });\n }, [rawNavigationEntries]);\n\n const updateSearch = useCallback((v?: string) => {\n if (!v?.trim()) {\n setFilteredUrls(null);\n return;\n }\n const results = fuse.current?.search(v.trim());\n setFilteredUrls(results ? results.map((x) => x.item.url) : []);\n }, []);\n\n /* ───────────────────────────────────────────────────────────────\n Build groups (all items) + isolate Admin\n ─────────────────────────────────────────────────────────────── */\n const [items, setItems] = useState<\n { name: string; entries: NavigationEntry[] }[]\n >([]);\n const [adminGroupData, setAdminGroupData] = useState<{\n name: string;\n entries: NavigationEntry[];\n } | null>(null);\n\n // Flag to prevent useEffect from overwriting local DnD state\n const isDndDirtyRef = useRef(false);\n const dndDirtyTimeoutRef = useRef<ReturnType<typeof setTimeout> | null>(null);\n\n // Memoize the processed groups to avoid unnecessary recalculations\n const processedGroups = useMemo(() => {\n const src = filteredNavigationEntries;\n const entriesByGroup: Record<string, NavigationEntry[]> = {};\n\n src.forEach((e) => {\n const g =\n e.type === \"admin\"\n ? ADMIN_GROUP_NAME\n : e.group ?? DEFAULT_GROUP_NAME;\n (entriesByGroup[g] ??= []).push(e);\n });\n\n // Check if there are custom additional card components from plugins\n const hasPluginAdditionalCards = customizationController.resolvedSlots.some(s => s.slot === \"home.cards\");\n\n let allProcessed: { name: string; entries: NavigationEntry[] }[];\n\n if (performingSearch) {\n const ordered = [\n ...new Set(src.map((e) => e.group ?? DEFAULT_GROUP_NAME))\n ];\n allProcessed = ordered\n .map((name) => ({\n name,\n entries: entriesByGroup[name] || []\n }))\n .filter((g) => g.entries.length);\n } else {\n allProcessed = groupOrderFromNavController.map((g) => ({\n name: g,\n entries: entriesByGroup[g] || []\n }));\n Object.keys(entriesByGroup).forEach((g) => {\n if (!groupOrderFromNavController.includes(g))\n allProcessed.push({\n name: g,\n entries: entriesByGroup[g]\n });\n });\n\n // Ensure default group exists if there are plugin additional cards but no collections\n if (hasPluginAdditionalCards && !allProcessed.some(g => g.name === DEFAULT_GROUP_NAME)) {\n allProcessed.push({\n name: DEFAULT_GROUP_NAME,\n entries: []\n });\n }\n\n allProcessed = allProcessed.filter(\n (g) =>\n g.entries.length ||\n (g.name === DEFAULT_GROUP_NAME && hasPluginAdditionalCards)\n );\n }\n\n const admin = allProcessed.find((g) => g.name === ADMIN_GROUP_NAME);\n return {\n adminGroupData: admin || null,\n items: allProcessed.filter((g) => g.name !== ADMIN_GROUP_NAME && !hiddenGroups?.includes(g.name))\n };\n }, [filteredNavigationEntries, performingSearch, groupOrderFromNavController, customizationController.resolvedSlots, hiddenGroups]);\n\n // Update state only when processedGroups actually changes\n // Skip update if DnD just made a local change (dirty flag is set)\n useEffect(() => {\n if (isDndDirtyRef.current) {\n // DnD just updated the state, skip this sync\n return;\n }\n setAdminGroupData(processedGroups.adminGroupData);\n setItems(processedGroups.items);\n }, [processedGroups]);\n\n /* ───────────────────────────────────────────────────────────────\n Local update vs. persistence helpers\n ─────────────────────────────────────────────────────────────── */\n const updateItems = (\n updater:\n | { name: string; entries: NavigationEntry[] }[]\n | ((\n prev: { name: string; entries: NavigationEntry[] }[]\n ) => { name: string; entries: NavigationEntry[] }[])\n ) => {\n setItems(updater); // local only\n };\n\n const persistNavigationGroups = (\n latest: { name: string; entries: NavigationEntry[] }[]\n ) => {\n // Set dirty flag to prevent useEffect from overwriting local state\n isDndDirtyRef.current = true;\n\n // Clear any existing timeout\n if (dndDirtyTimeoutRef.current) {\n clearTimeout(dndDirtyTimeoutRef.current);\n }\n\n // Clear dirty flag after a delay to allow navigation to update\n dndDirtyTimeoutRef.current = setTimeout(() => {\n isDndDirtyRef.current = false;\n }, 1000);\n\n // Map ALL groups including \"Views\"\n const draggable: NavigationGroupMapping[] = latest.map((g) => ({\n name: g.name,\n entries: g.entries.map((e) => e.slug)\n }));\n\n const all: NavigationGroupMapping[] = adminGroupData\n ? [\n ...draggable,\n {\n name: adminGroupData.name,\n entries: adminGroupData.entries.map((e) => e.slug)\n }\n ]\n : draggable;\n\n onNavigationEntriesUpdate(all);\n };\n\n // Use custom hook for collapsed groups with localStorage persistence\n const groupNames = useMemo(() => [\n ...items.map(item => item.name),\n ...(adminGroupData ? [adminGroupData.name] : [])\n ], [items, adminGroupData]);\n\n const collapsedDefaults = useMemo(\n () => buildCollapsedDefaults(registry.cmsConfig?.navigationGroupMappings, \"home\"),\n [registry.cmsConfig?.navigationGroupMappings]\n );\n const { isGroupCollapsed, toggleGroupCollapsed } = useCollapsedGroups(groupNames, \"home\", collapsedDefaults);\n\n const {\n sensors,\n collisionDetection,\n onDragStart,\n onDragOver,\n onDragEnd,\n dropAnimation,\n activeItemForOverlay,\n activeGroupData,\n draggingGroupId,\n containers,\n dndKitActiveNode,\n onDragCancel,\n isDraggingCardOnly,\n dialogOpenForGroup,\n setDialogOpenForGroup,\n handleRenameGroup,\n handleDialogClose,\n isHoveringNewGroupDropZone,\n setIsHoveringNewGroupDropZone\n } = useHomePageDnd({\n items,\n setItems: updateItems,\n disabled: !allowDragAndDrop || performingSearch,\n onPersist: persistNavigationGroups,\n onGroupMoved: (g) =>\n context.analyticsController?.onAnalyticsEvent?.(\"home_move_group\", {\n name: g\n }),\n onCardMovedBetweenGroups: (card) =>\n context.analyticsController?.onAnalyticsEvent?.(\"home_move_card\", {\n id: card.id\n }),\n onNewGroupDrop: () =>\n context.analyticsController?.onAnalyticsEvent?.(\n \"home_drop_new_group\"\n )\n });\n\n const {\n containerRef,\n direction\n } = useRestoreScroll();\n\n const dndDisabled = !allowDragAndDrop || performingSearch;\n\n const dndModifiers = dndKitActiveNode?.data.current?.type === \"group\"\n ? [restrictToVerticalAxis, restrictToWindowEdges]\n : [restrictToWindowEdges];\n\n const sectionProps: PluginGenericProps = { context };\n const additionalPluginChildrenStart = useSlot(\"home.children.start\", sectionProps);\n const additionalPluginChildrenEnd = useSlot(\"home.children.end\", sectionProps);\n const additionalPluginActions = useSlot(\"home.actions\", sectionProps);\n\n // Pre-compute home.cards slot contributions (cannot call useSlot inside .map loop)\n const homeCardContributions = useMemo(() => {\n return resolvedSlots\n .filter(s => s.slot === \"home.cards\")\n .sort((a, b) => (a.order ?? 50) - (b.order ?? 50));\n }, [resolvedSlots]);\n\n /* ───────────────────────────────────────────────────────────────\n Render\n ─────────────────────────────────────────────────────────────── */\n return (\n <div ref={containerRef} className=\"py-2 overflow-auto h-full w-full bg-surface-sheet\">\n <Container maxWidth=\"6xl\">\n <div className=\"mb-4 flex flex-col gap-2\">\n <SchemaDriftBanner />\n </div>\n {/* search & actions */}\n <div\n className=\"w-full sticky py-4 transition-all duration-400 ease-in-out top-0 z-10 flex flex-row gap-4\"\n style={{ top: direction === \"down\" ? -84 : 0 }}\n >\n <SearchBar\n onTextSearch={updateSearch}\n placeholder={t(\"search_collections\")}\n autoFocus\n size=\"small\"\n innerClassName=\"w-full\"\n className=\"w-full grow\"\n />\n {additionalActions}\n {additionalPluginActions}\n </div>\n\n {navigationStateController.navigationLoadingError &&\n <div className=\"mb-4\">\n <NavigationLoadingErrorView error={navigationStateController.navigationLoadingError}\n onRetry={navigationStateController.refreshNavigation}/>\n </div>}\n\n <FavouritesView hidden={performingSearch}/>\n\n {additionalChildrenStart}\n {additionalPluginChildrenStart}\n\n {/* ─────── DND context ─────── */}\n <DndContext\n sensors={sensors}\n collisionDetection={collisionDetection}\n measuring={{\n droppable: {\n strategy: MeasuringStrategy.Always,\n frequency: 500\n }\n }}\n onDragStart={onDragStart}\n onDragOver={onDragOver}\n onDragEnd={onDragEnd}\n onDragCancel={onDragCancel}\n modifiers={dndModifiers}\n >\n <SortableContext\n key={containers.join(\",\")}\n items={containers}\n strategy={verticalListSortingStrategy}\n >\n {items.map((groupData, groupIndex) => {\n const groupKey = groupData.name;\n const entriesInGroup = groupData.entries;\n\n const homeCardsProps = {\n group:\n groupKey === DEFAULT_GROUP_NAME\n ? undefined\n : groupKey,\n context\n };\n // Render home.cards contributions inline (no hook call inside loop)\n const additionalCards = homeCardContributions.map((s, i) => (\n <ErrorBoundary key={`home_cards_${groupKey}_${i}`}>\n <s.Component {...homeCardsProps} {...(s.props ?? {})}/>\n </ErrorBoundary>\n ));\n\n if (\n entriesInGroup.length === 0 &&\n (additionalCards.length === 0 || performingSearch)\n )\n return null;\n\n return (\n <SortableNavigationGroup\n key={`group-${groupIndex}`}\n groupName={groupKey}\n disabled={dndDisabled}\n >\n <NavigationGroup\n group={\n groupKey === DEFAULT_GROUP_NAME\n ? undefined\n : groupKey\n }\n minimised={\n draggingGroupId === groupKey &&\n !isDraggingCardOnly\n }\n isPotentialCardDropTarget={\n isDraggingCardOnly\n }\n dndDisabled={dndDisabled}\n onEditGroup={() => {\n if (dndDisabled) return;\n setDialogOpenForGroup(groupKey);\n }}\n collapsed={isGroupCollapsed(groupKey)}\n onToggleCollapsed={() => toggleGroupCollapsed(groupKey)}\n >\n <NavigationGroupDroppable\n id={groupKey}\n itemIds={entriesInGroup.map(\n (e) => e.url\n )}\n isPotentialCardDropTarget={\n isDraggingCardOnly\n }\n >\n <div className=\"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-4 \">\n {entriesInGroup.map(\n (entry) => (\n <SortableNavigationCard\n key={entry.url}\n entry={entry}\n onClick={() => {\n let event: AnalyticsEvent =\n \"unmapped_event\";\n if (\n entry.type ===\n \"collection\"\n )\n event =\n \"home_navigate_to_collection\";\n else if (\n entry.type ===\n \"view\"\n )\n event =\n \"home_navigate_to_view\";\n else if (\n entry.type ===\n \"admin\"\n )\n event =\n \"home_navigate_to_admin_view\";\n\n context.analyticsController?.onAnalyticsEvent?.(\n event,\n {\n path: entry.slug\n }\n );\n }}\n />\n )\n )}\n {!performingSearch &&\n groupKey.toLowerCase() !==\n ADMIN_GROUP_NAME.toLowerCase() &&\n additionalCards}\n </div>\n </NavigationGroupDroppable>\n </NavigationGroup>\n </SortableNavigationGroup>\n );\n })}\n </SortableContext>\n\n <NewGroupDropZone\n disabled={dndDisabled}\n setIsHovering={setIsHoveringNewGroupDropZone}\n />\n\n <DragOverlay adjustScale={false} dropAnimation={dropAnimation}>\n {activeGroupData &&\n draggingGroupId === activeGroupData.name ? (\n <div\n className=\"rounded-lg bg-transparent\"\n style={{\n padding: 0,\n margin: 0\n }}\n >\n <NavigationGroup\n group={\n activeGroupData.name ===\n DEFAULT_GROUP_NAME\n ? undefined\n : activeGroupData.name\n }\n isPreview={false}\n minimised\n />\n </div>\n ) : activeItemForOverlay ? (\n <ResolvedCollectionCard\n {...activeItemForOverlay}\n shrink={isHoveringNewGroupDropZone}\n />\n ) : null}\n </DragOverlay>\n </DndContext>\n\n {!performingSearch && adminGroupData && (\n <NavigationGroup\n group={adminGroupData.name}\n collapsed={isGroupCollapsed(adminGroupData.name)}\n onToggleCollapsed={() => toggleGroupCollapsed(adminGroupData.name)}\n >\n <div className=\"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-4 \">\n {adminGroupData.entries.map((entry) => (\n <ResolvedCollectionCard\n key={entry.url}\n {...entry}\n onClick={() => {\n let event: AnalyticsEvent =\n \"unmapped_event\";\n if (entry.type === \"collection\")\n event =\n \"home_navigate_to_collection\";\n else if (entry.type === \"view\")\n event = \"home_navigate_to_view\";\n else if (entry.type === \"admin\")\n event =\n \"home_navigate_to_admin_view\";\n\n context.analyticsController?.onAnalyticsEvent?.(\n event,\n { path: entry.slug }\n );\n }}\n />\n ))}\n </div>\n </NavigationGroup>\n )}\n\n {sections && sections.map((section) => (\n <NavigationGroup\n key={section.key}\n group={section.title}\n >\n {section.children}\n </NavigationGroup>\n ))}\n\n {additionalPluginChildrenEnd}\n {additionalChildrenEnd}\n </Container>\n\n {dialogOpenForGroup && (\n <RenameGroupDialog\n open\n initialName={dialogOpenForGroup}\n existingGroupNames={items\n .map((g) => g.name)\n .filter((n) => n !== dialogOpenForGroup)}\n onClose={handleDialogClose}\n onRename={(newName) => {\n handleRenameGroup(dialogOpenForGroup, newName);\n }}\n />\n )}\n </div>\n );\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;AA6BA,IAAa,qBAAqB;AAClC,IAAa,mBAAmB;AAEhC,SAAgB,gBAAgB,EAC5B,mBACA,yBACA,uBACA,UACA,gBAOD;CAEC,MAAM,UAAU,gBAAgB;CAChC,MAAM,EAAE,8BAA8B;CACtC,MAAM,0BAA0B,2BAA2B;CAC3D,MAAM,sBAAsB,uBAAuB;CACnD,MAAM,WAAW,kBAAkB;CAEnC,MAAM,EAAE,kBAAkB;CAC1B,MAAM,yBAAyB,qBAAqB,2BAA2B,qBAAqB;CACpG,MAAM,cAAc,yBAAyB;CAC7C,MAAM,EAAE,MAAM,eAAe;CAE7B,gBAAgB;EACZ,YAAY,IAAI,EAAE,aAAa,CAAC,EAAE,CAAC;CACvC,GAAG,CAAC,YAAY,GAAG,CAAC;CAEpB,MAAM,EACF,mBAAmB,OACnB,mBAAmB,8BAA8B,CAAC,GAClD,QAAQ,uBAAuB,CAAC,GAChC,kCAAkC,CAAC,MACnC,0BAA0B,sBAAsB,CAAC;CAIrD,MAAM,kBAAkB,cAAc;EAClC,MAAM,wBAAQ,IAAI,IAAY;EAC9B,CAAC,SAAS,cAAc,YAAY,CAAC,EAAA,CAAG,SAAQ,MAAK,MAAM,IAAI,EAAE,IAAI,CAAC;EACtE,IAAI,wBAAwB,QAAQ,GAAG,MAAM,IAAI,QAAQ;EACzD,OAAO;CACX,GAAG,CAAC,QAAQ,CAAC;CAIb,MAAM,uBAAuB,cAAc;EACvC,IAAI,oBAAoB,SAAS,UAC7B,OAAO,4BAA4B,QAAO,MA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":[],"sources":["../../../src/components/HomePage/ContentHomePage.tsx"],"sourcesContent":["import type { HomePageSection, NavigationEntry, NavigationGroupMapping, PluginGenericProps } from \"@rebasepro/cms-types\";\nimport React, { useCallback, useEffect, useMemo, useRef, useState } from \"react\";\nimport Fuse from \"fuse.js\";\nimport { Container, SearchBar } from \"@rebasepro/ui\";\nimport { AnalyticsEvent, studioSchemaToolEnabled } from \"@rebasepro/cms-types\";\nimport { FavouritesView } from \"./FavouritesView\";\nimport { ErrorBoundary } from \"@rebasepro/ui\";\nimport { NavigationGroup } from \"./NavigationGroup\";\nimport {\n NavigationGroupDroppable,\n NewGroupDropZone,\n SortableNavigationCard,\n SortableNavigationGroup,\n useHomePageDnd\n} from \"./HomePageDnD\";\nimport { DndContext, DragOverlay, MeasuringStrategy } from \"@dnd-kit/core\";\nimport { NavigationCardBinding } from \"./NavigationCardBinding\";\nimport { SortableContext, verticalListSortingStrategy } from \"@dnd-kit/sortable\";\nimport { restrictToVerticalAxis, restrictToWindowEdges } from \"@dnd-kit/modifiers\";\nimport { RenameGroupDialog } from \"./RenameGroupDialog\";\nimport { toArray } from \"@rebasepro/utils\";\nimport { useCollapsedGroups, buildCollapsedDefaults, useComponentOverride, useCustomizationController, useTranslation, useSlot, useAdminModeController, useRebaseRegistry } from \"@rebasepro/app\";\nimport { useRestoreScroll } from \"@rebasepro/app\";\n\nimport { SchemaDriftBanner } from \"@rebasepro/app\";\nimport { useBreadcrumbsController } from \"../../hooks/useBreadcrumbsController\";\nimport { useAdminContext } from \"../../hooks/useAdminContext\";\nimport { NavigationLoadingErrorView } from \"../NavigationLoadingErrorView\";\n\nexport const DEFAULT_GROUP_NAME = \"Views\";\nexport const ADMIN_GROUP_NAME = \"Admin\";\n\nexport function ContentHomePage({\n additionalActions,\n additionalChildrenStart,\n additionalChildrenEnd,\n sections,\n hiddenGroups\n}: {\n additionalActions?: React.ReactNode;\n additionalChildrenStart?: React.ReactNode;\n additionalChildrenEnd?: React.ReactNode;\n sections?: HomePageSection[];\n hiddenGroups?: string[];\n}) {\n\n const context = useAdminContext();\n const { navigationStateController } = context;\n const customizationController = useCustomizationController();\n const adminModeController = useAdminModeController();\n const registry = useRebaseRegistry();\n\n const { resolvedSlots } = customizationController;\n const ResolvedCollectionCard = useComponentOverride(\"HomePage.CollectionCard\", NavigationCardBinding);\n const breadcrumbs = useBreadcrumbsController();\n const { t } = useTranslation();\n\n useEffect(() => {\n breadcrumbs.set({ breadcrumbs: [] });\n }, [breadcrumbs.set]);\n\n const {\n allowDragAndDrop = false,\n navigationEntries: unFilteredNavigationEntries = [],\n groups: unFilteredGroupOrder = [],\n onNavigationEntriesUpdate = () => {}\n } = navigationStateController.topLevelNavigation || {};\n\n // Build a set of Studio-only dev view slugs so we can distinguish them from\n // admin custom views added via <RebaseCMS views={...}> or plugins.\n const studioViewSlugs = useMemo(() => {\n const slugs = new Set<string>();\n (registry.studioConfig?.devViews ?? []).forEach(v => slugs.add(v.slug));\n if (studioSchemaToolEnabled(registry)) slugs.add(\"schema\");\n return slugs;\n }, [registry]);\n\n // Studio mode shows Studio dev views + admin entries (Users/Roles).\n // Content mode shows collections, admin custom views, and admin entries — but not Studio dev views.\n const rawNavigationEntries = useMemo(() => {\n if (adminModeController.mode === \"studio\") {\n return unFilteredNavigationEntries.filter(e => (e.type === \"view\" && studioViewSlugs.has(e.slug)) || e.type === \"admin\");\n }\n return unFilteredNavigationEntries.filter(e => e.type !== \"view\" || !studioViewSlugs.has(e.slug));\n }, [unFilteredNavigationEntries, adminModeController.mode, studioViewSlugs]);\n\n const groupOrderFromNavController = useMemo(() => {\n const entryGroups = new Set(rawNavigationEntries.map(e => e.group).filter(Boolean));\n return unFilteredGroupOrder.filter(g => entryGroups.has(g));\n }, [unFilteredGroupOrder, rawNavigationEntries]);\n\n const fuse = useRef<Fuse<NavigationEntry> | null>(null);\n const [filteredUrls, setFilteredUrls] = useState<string[] | null>(null);\n const performingSearch = Boolean(filteredUrls);\n\n // Memoize filtered navigation entries to prevent unnecessary recalculations\n const filteredNavigationEntries = useMemo(() => {\n return filteredUrls\n ? rawNavigationEntries.filter((e) => filteredUrls.includes(e.url))\n : rawNavigationEntries;\n }, [filteredUrls, rawNavigationEntries]);\n\n useEffect(() => {\n fuse.current = new Fuse(rawNavigationEntries, {\n keys: [\"name\", \"description\", \"group\", \"path\"]\n });\n }, [rawNavigationEntries]);\n\n const updateSearch = useCallback((v?: string) => {\n if (!v?.trim()) {\n setFilteredUrls(null);\n return;\n }\n const results = fuse.current?.search(v.trim());\n setFilteredUrls(results ? results.map((x) => x.item.url) : []);\n }, []);\n\n /* ───────────────────────────────────────────────────────────────\n Build groups (all items) + isolate Admin\n ─────────────────────────────────────────────────────────────── */\n const [items, setItems] = useState<\n { name: string; entries: NavigationEntry[] }[]\n >([]);\n const [adminGroupData, setAdminGroupData] = useState<{\n name: string;\n entries: NavigationEntry[];\n } | null>(null);\n\n // Flag to prevent useEffect from overwriting local DnD state\n const isDndDirtyRef = useRef(false);\n const dndDirtyTimeoutRef = useRef<ReturnType<typeof setTimeout> | null>(null);\n\n // Memoize the processed groups to avoid unnecessary recalculations\n const processedGroups = useMemo(() => {\n const src = filteredNavigationEntries;\n const entriesByGroup: Record<string, NavigationEntry[]> = {};\n\n src.forEach((e) => {\n const g =\n e.type === \"admin\"\n ? ADMIN_GROUP_NAME\n : e.group ?? DEFAULT_GROUP_NAME;\n (entriesByGroup[g] ??= []).push(e);\n });\n\n // Check if there are custom additional card components from plugins\n const hasPluginAdditionalCards = customizationController.resolvedSlots.some(s => s.slot === \"home.cards\");\n\n let allProcessed: { name: string; entries: NavigationEntry[] }[];\n\n if (performingSearch) {\n const ordered = [\n ...new Set(src.map((e) => e.group ?? DEFAULT_GROUP_NAME))\n ];\n allProcessed = ordered\n .map((name) => ({\n name,\n entries: entriesByGroup[name] || []\n }))\n .filter((g) => g.entries.length);\n } else {\n allProcessed = groupOrderFromNavController.map((g) => ({\n name: g,\n entries: entriesByGroup[g] || []\n }));\n Object.keys(entriesByGroup).forEach((g) => {\n if (!groupOrderFromNavController.includes(g))\n allProcessed.push({\n name: g,\n entries: entriesByGroup[g]\n });\n });\n\n // Ensure default group exists if there are plugin additional cards but no collections\n if (hasPluginAdditionalCards && !allProcessed.some(g => g.name === DEFAULT_GROUP_NAME)) {\n allProcessed.push({\n name: DEFAULT_GROUP_NAME,\n entries: []\n });\n }\n\n allProcessed = allProcessed.filter(\n (g) =>\n g.entries.length ||\n (g.name === DEFAULT_GROUP_NAME && hasPluginAdditionalCards)\n );\n }\n\n const admin = allProcessed.find((g) => g.name === ADMIN_GROUP_NAME);\n return {\n adminGroupData: admin || null,\n items: allProcessed.filter((g) => g.name !== ADMIN_GROUP_NAME && !hiddenGroups?.includes(g.name))\n };\n }, [filteredNavigationEntries, performingSearch, groupOrderFromNavController, customizationController.resolvedSlots, hiddenGroups]);\n\n // Update state only when processedGroups actually changes\n // Skip update if DnD just made a local change (dirty flag is set)\n useEffect(() => {\n if (isDndDirtyRef.current) {\n // DnD just updated the state, skip this sync\n return;\n }\n setAdminGroupData(processedGroups.adminGroupData);\n setItems(processedGroups.items);\n }, [processedGroups]);\n\n /* ───────────────────────────────────────────────────────────────\n Local update vs. persistence helpers\n ─────────────────────────────────────────────────────────────── */\n const updateItems = (\n updater:\n | { name: string; entries: NavigationEntry[] }[]\n | ((\n prev: { name: string; entries: NavigationEntry[] }[]\n ) => { name: string; entries: NavigationEntry[] }[])\n ) => {\n setItems(updater); // local only\n };\n\n const persistNavigationGroups = (\n latest: { name: string; entries: NavigationEntry[] }[]\n ) => {\n // Set dirty flag to prevent useEffect from overwriting local state\n isDndDirtyRef.current = true;\n\n // Clear any existing timeout\n if (dndDirtyTimeoutRef.current) {\n clearTimeout(dndDirtyTimeoutRef.current);\n }\n\n // Clear dirty flag after a delay to allow navigation to update\n dndDirtyTimeoutRef.current = setTimeout(() => {\n isDndDirtyRef.current = false;\n }, 1000);\n\n // Map ALL groups including \"Views\"\n const draggable: NavigationGroupMapping[] = latest.map((g) => ({\n name: g.name,\n entries: g.entries.map((e) => e.slug)\n }));\n\n const all: NavigationGroupMapping[] = adminGroupData\n ? [\n ...draggable,\n {\n name: adminGroupData.name,\n entries: adminGroupData.entries.map((e) => e.slug)\n }\n ]\n : draggable;\n\n onNavigationEntriesUpdate(all);\n };\n\n // Use custom hook for collapsed groups with localStorage persistence\n const groupNames = useMemo(() => [\n ...items.map(item => item.name),\n ...(adminGroupData ? [adminGroupData.name] : [])\n ], [items, adminGroupData]);\n\n const collapsedDefaults = useMemo(\n () => buildCollapsedDefaults(registry.cmsConfig?.navigationGroupMappings, \"home\"),\n [registry.cmsConfig?.navigationGroupMappings]\n );\n const { isGroupCollapsed, toggleGroupCollapsed } = useCollapsedGroups(groupNames, \"home\", collapsedDefaults);\n\n const {\n sensors,\n collisionDetection,\n onDragStart,\n onDragOver,\n onDragEnd,\n dropAnimation,\n activeItemForOverlay,\n activeGroupData,\n draggingGroupId,\n containers,\n dndKitActiveNode,\n onDragCancel,\n isDraggingCardOnly,\n dialogOpenForGroup,\n setDialogOpenForGroup,\n handleRenameGroup,\n handleDialogClose,\n isHoveringNewGroupDropZone,\n setIsHoveringNewGroupDropZone\n } = useHomePageDnd({\n items,\n setItems: updateItems,\n disabled: !allowDragAndDrop || performingSearch,\n onPersist: persistNavigationGroups,\n onGroupMoved: (g) =>\n context.analyticsController?.onAnalyticsEvent?.(\"home_move_group\", {\n name: g\n }),\n onCardMovedBetweenGroups: (card) =>\n context.analyticsController?.onAnalyticsEvent?.(\"home_move_card\", {\n id: card.id\n }),\n onNewGroupDrop: () =>\n context.analyticsController?.onAnalyticsEvent?.(\n \"home_drop_new_group\"\n )\n });\n\n const {\n containerRef,\n direction\n } = useRestoreScroll();\n\n const dndDisabled = !allowDragAndDrop || performingSearch;\n\n const dndModifiers = dndKitActiveNode?.data.current?.type === \"group\"\n ? [restrictToVerticalAxis, restrictToWindowEdges]\n : [restrictToWindowEdges];\n\n const sectionProps: PluginGenericProps = { context };\n const additionalPluginChildrenStart = useSlot(\"home.children.start\", sectionProps);\n const additionalPluginChildrenEnd = useSlot(\"home.children.end\", sectionProps);\n const additionalPluginActions = useSlot(\"home.actions\", sectionProps);\n\n // Pre-compute home.cards slot contributions (cannot call useSlot inside .map loop)\n const homeCardContributions = useMemo(() => {\n return resolvedSlots\n .filter(s => s.slot === \"home.cards\")\n .sort((a, b) => (a.order ?? 50) - (b.order ?? 50));\n }, [resolvedSlots]);\n\n /* ───────────────────────────────────────────────────────────────\n Render\n ─────────────────────────────────────────────────────────────── */\n return (\n <div ref={containerRef} className=\"py-2 overflow-auto h-full w-full bg-surface-sheet\">\n <Container maxWidth=\"6xl\">\n <div className=\"mb-4 flex flex-col gap-2\">\n <SchemaDriftBanner />\n </div>\n {/* search & actions */}\n <div\n className=\"w-full sticky py-4 transition-all duration-400 ease-in-out top-0 z-10 flex flex-row gap-4\"\n style={{ top: direction === \"down\" ? -84 : 0 }}\n >\n <SearchBar\n onTextSearch={updateSearch}\n placeholder={t(\"search_collections\")}\n size=\"small\"\n innerClassName=\"w-full\"\n className=\"w-full grow\"\n />\n {Boolean(additionalActions) && additionalActions}\n {Array.isArray(additionalPluginActions) && additionalPluginActions.length > 0 && additionalPluginActions}\n </div>\n\n {navigationStateController.navigationLoadingError &&\n <div className=\"mb-4\">\n <NavigationLoadingErrorView error={navigationStateController.navigationLoadingError}\n onRetry={navigationStateController.refreshNavigation}/>\n </div>}\n\n <FavouritesView hidden={performingSearch}/>\n\n {additionalChildrenStart}\n {additionalPluginChildrenStart}\n\n {/* ─────── DND context ─────── */}\n <DndContext\n sensors={sensors}\n collisionDetection={collisionDetection}\n measuring={{\n droppable: {\n strategy: MeasuringStrategy.Always,\n frequency: 500\n }\n }}\n onDragStart={onDragStart}\n onDragOver={onDragOver}\n onDragEnd={onDragEnd}\n onDragCancel={onDragCancel}\n modifiers={dndModifiers}\n >\n <SortableContext\n key={containers.join(\",\")}\n items={containers}\n strategy={verticalListSortingStrategy}\n >\n {items.map((groupData, groupIndex) => {\n const groupKey = groupData.name;\n const entriesInGroup = groupData.entries;\n\n const homeCardsProps = {\n group:\n groupKey === DEFAULT_GROUP_NAME\n ? undefined\n : groupKey,\n context\n };\n // Render home.cards contributions inline (no hook call inside loop)\n const additionalCards = homeCardContributions.map((s, i) => (\n <ErrorBoundary key={`home_cards_${groupKey}_${i}`}>\n <s.Component {...homeCardsProps} {...(s.props ?? {})}/>\n </ErrorBoundary>\n ));\n\n if (\n entriesInGroup.length === 0 &&\n (additionalCards.length === 0 || performingSearch)\n )\n return null;\n\n return (\n <SortableNavigationGroup\n key={`group-${groupIndex}`}\n groupName={groupKey}\n disabled={dndDisabled}\n >\n <NavigationGroup\n group={\n groupKey === DEFAULT_GROUP_NAME\n ? undefined\n : groupKey\n }\n minimised={\n draggingGroupId === groupKey &&\n !isDraggingCardOnly\n }\n isPotentialCardDropTarget={\n isDraggingCardOnly\n }\n dndDisabled={dndDisabled}\n onEditGroup={() => {\n if (dndDisabled) return;\n setDialogOpenForGroup(groupKey);\n }}\n collapsed={isGroupCollapsed(groupKey)}\n onToggleCollapsed={() => toggleGroupCollapsed(groupKey)}\n >\n <NavigationGroupDroppable\n id={groupKey}\n itemIds={entriesInGroup.map(\n (e) => e.url\n )}\n isPotentialCardDropTarget={\n isDraggingCardOnly\n }\n >\n <div className=\"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-4 \">\n {entriesInGroup.map(\n (entry) => (\n <SortableNavigationCard\n key={entry.url}\n entry={entry}\n onClick={() => {\n let event: AnalyticsEvent =\n \"unmapped_event\";\n if (\n entry.type ===\n \"collection\"\n )\n event =\n \"home_navigate_to_collection\";\n else if (\n entry.type ===\n \"view\"\n )\n event =\n \"home_navigate_to_view\";\n else if (\n entry.type ===\n \"admin\"\n )\n event =\n \"home_navigate_to_admin_view\";\n\n context.analyticsController?.onAnalyticsEvent?.(\n event,\n {\n path: entry.slug\n }\n );\n }}\n />\n )\n )}\n {!performingSearch &&\n groupKey.toLowerCase() !==\n ADMIN_GROUP_NAME.toLowerCase() &&\n additionalCards}\n </div>\n </NavigationGroupDroppable>\n </NavigationGroup>\n </SortableNavigationGroup>\n );\n })}\n </SortableContext>\n\n <NewGroupDropZone\n disabled={dndDisabled}\n setIsHovering={setIsHoveringNewGroupDropZone}\n />\n\n <DragOverlay adjustScale={false} dropAnimation={dropAnimation}>\n {activeGroupData &&\n draggingGroupId === activeGroupData.name ? (\n <div\n className=\"rounded-lg bg-transparent\"\n style={{\n padding: 0,\n margin: 0\n }}\n >\n <NavigationGroup\n group={\n activeGroupData.name ===\n DEFAULT_GROUP_NAME\n ? undefined\n : activeGroupData.name\n }\n isPreview={false}\n minimised\n />\n </div>\n ) : activeItemForOverlay ? (\n <ResolvedCollectionCard\n {...activeItemForOverlay}\n shrink={isHoveringNewGroupDropZone}\n />\n ) : null}\n </DragOverlay>\n </DndContext>\n\n {!performingSearch && adminGroupData && (\n <NavigationGroup\n group={adminGroupData.name}\n collapsed={isGroupCollapsed(adminGroupData.name)}\n onToggleCollapsed={() => toggleGroupCollapsed(adminGroupData.name)}\n >\n <div className=\"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-4 \">\n {adminGroupData.entries.map((entry) => (\n <ResolvedCollectionCard\n key={entry.url}\n {...entry}\n onClick={() => {\n let event: AnalyticsEvent =\n \"unmapped_event\";\n if (entry.type === \"collection\")\n event =\n \"home_navigate_to_collection\";\n else if (entry.type === \"view\")\n event = \"home_navigate_to_view\";\n else if (entry.type === \"admin\")\n event =\n \"home_navigate_to_admin_view\";\n\n context.analyticsController?.onAnalyticsEvent?.(\n event,\n { path: entry.slug }\n );\n }}\n />\n ))}\n </div>\n </NavigationGroup>\n )}\n\n {sections && sections.map((section) => (\n <NavigationGroup\n key={section.key}\n group={section.title}\n >\n {section.children}\n </NavigationGroup>\n ))}\n\n {additionalPluginChildrenEnd}\n {additionalChildrenEnd}\n </Container>\n\n {dialogOpenForGroup && (\n <RenameGroupDialog\n open\n initialName={dialogOpenForGroup}\n existingGroupNames={items\n .map((g) => g.name)\n .filter((n) => n !== dialogOpenForGroup)}\n onClose={handleDialogClose}\n onRename={(newName) => {\n handleRenameGroup(dialogOpenForGroup, newName);\n }}\n />\n )}\n </div>\n );\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;AA6BA,IAAa,qBAAqB;AAClC,IAAa,mBAAmB;AAEhC,SAAgB,gBAAgB,EAC5B,mBACA,yBACA,uBACA,UACA,gBAOD;CAEC,MAAM,UAAU,gBAAgB;CAChC,MAAM,EAAE,8BAA8B;CACtC,MAAM,0BAA0B,2BAA2B;CAC3D,MAAM,sBAAsB,uBAAuB;CACnD,MAAM,WAAW,kBAAkB;CAEnC,MAAM,EAAE,kBAAkB;CAC1B,MAAM,yBAAyB,qBAAqB,2BAA2B,qBAAqB;CACpG,MAAM,cAAc,yBAAyB;CAC7C,MAAM,EAAE,MAAM,eAAe;CAE7B,gBAAgB;EACZ,YAAY,IAAI,EAAE,aAAa,CAAC,EAAE,CAAC;CACvC,GAAG,CAAC,YAAY,GAAG,CAAC;CAEpB,MAAM,EACF,mBAAmB,OACnB,mBAAmB,8BAA8B,CAAC,GAClD,QAAQ,uBAAuB,CAAC,GAChC,kCAAkC,CAAC,MACnC,0BAA0B,sBAAsB,CAAC;CAIrD,MAAM,kBAAkB,cAAc;EAClC,MAAM,wBAAQ,IAAI,IAAY;EAC9B,CAAC,SAAS,cAAc,YAAY,CAAC,EAAA,CAAG,SAAQ,MAAK,MAAM,IAAI,EAAE,IAAI,CAAC;EACtE,IAAI,wBAAwB,QAAQ,GAAG,MAAM,IAAI,QAAQ;EACzD,OAAO;CACX,GAAG,CAAC,QAAQ,CAAC;CAIb,MAAM,uBAAuB,cAAc;EACvC,IAAI,oBAAoB,SAAS,UAC7B,OAAO,4BAA4B,QAAO,MAAM,EAAE,SAAS,UAAU,gBAAgB,IAAI,EAAE,IAAI,KAAM,EAAE,SAAS,OAAO;EAE3H,OAAO,4BAA4B,QAAO,MAAK,EAAE,SAAS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AC,aAAD;OAAa,aAAa;OAAsB;iBAC3C,mBACG,oBAAoB,gBAAgB,OACpC,oBAAC,OAAD;QACI,WAAU;QACV,OAAO;SACH,SAAS;SACT,QAAQ;QACZ;kBAEA,oBAAC,iBAAD;SACI,OACI,gBAAgB,SAAA,UAEV,KAAA,IACA,gBAAgB;SAE1B,WAAW;SACX,WAAA;QACH,CAAA;OACA,CAAA,IACL,uBACA,oBAAC,wBAAD;QACI,GAAI;QACJ,QAAQ;OACX,CAAA,IACD;MACK,CAAA;KACL;;IAEX,CAAC,oBAAoB,kBAClB,oBAAC,iBAAD;KACI,OAAO,eAAe;KACtB,WAAW,iBAAiB,eAAe,IAAI;KAC/C,yBAAyB,qBAAqB,eAAe,IAAI;eAEjE,oBAAC,OAAD;MAAK,WAAU;gBACV,eAAe,QAAQ,KAAK,UACzB,oBAAC,wBAAD;OAEI,GAAI;OACJ,eAAe;QACX,IAAI,QACA;QACJ,IAAI,MAAM,SAAS,cACf,QACI;aACH,IAAI,MAAM,SAAS,QACpB,QAAQ;aACP,IAAI,MAAM,SAAS,SACpB,QACI;QAER,QAAQ,qBAAqB,mBACzB,OACA,EAAE,MAAM,MAAM,KAAK,CACvB;OACJ;MACH,GAnBQ,MAAM,GAmBd,CACJ;KACA,CAAA;IACQ,CAAA;IAGpB,YAAY,SAAS,KAAK,YACvB,oBAAC,iBAAD;KAEI,OAAO,QAAQ;eAEd,QAAQ;IACI,GAJR,QAAQ,GAIA,CACpB;IAEA;IACA;GACM;MAEV,sBACG,oBAAC,mBAAD;GACI,MAAA;GACA,aAAa;GACb,oBAAoB,MACf,KAAK,MAAM,EAAE,IAAI,CAAC,CAClB,QAAQ,MAAM,MAAM,kBAAkB;GAC3C,SAAS;GACT,WAAW,YAAY;IACnB,kBAAkB,oBAAoB,OAAO;GACjD;EACH,CAAA,CAEJ;;AAEb"}
@@ -1,4 +1,5 @@
1
1
  import React from "react";
2
+ import type { Entity } from "@rebasepro/types";
2
3
  import type { AdminCollection } from "@rebasepro/cms-types";
3
4
  import type { EntityFormBindingProps } from "../form/EntityFormBinding.js";
4
5
  import type { OnSavedParams } from "../types/components/EntityFormProps.js";
@@ -115,12 +116,32 @@ export type RecordFormOptions<M extends Record<string, unknown> = Record<string,
115
116
  */
116
117
  export declare function RecordForm<M extends Record<string, unknown> = Record<string, unknown>>(rawProps: RecordFormProps<M>): React.JSX.Element;
117
118
  /**
118
- * @deprecated Renamed {@link RecordForm}, with the same props. It warns once.
119
+ * What {@link EntityFormPanel}'s `onSaved` is called with: {@link OnSavedParams},
120
+ * and the saved record as 0.28 handed it over.
121
+ *
122
+ * @deprecated Use {@link RecordForm}, whose `onSaved` gets {@link OnSavedParams}.
119
123
  * @group Components
120
124
  */
121
- export type EntityFormPanelProps<M extends Record<string, unknown> = Record<string, unknown>> = RecordFormProps<M>;
125
+ export type EntityFormPanelSavedParams = OnSavedParams & {
126
+ /** @deprecated The saved record as an `Entity`: read `row` and `id`. It warns once. */
127
+ entity: Entity<Record<string, unknown>>;
128
+ };
129
+ /**
130
+ * @deprecated Renamed {@link RecordForm}. It also takes 0.28's `entityId`
131
+ * for `id`, and hands `onSaved` the saved record as `entity` beside `row` and
132
+ * `id`. It warns once.
133
+ * @group Components
134
+ */
135
+ export type EntityFormPanelProps<M extends Record<string, unknown> = Record<string, unknown>> = Omit<RecordFormProps<M>, "onSaved"> & {
136
+ /** @deprecated The record to edit is `id`. It warns once. */
137
+ entityId?: string | number;
138
+ /** Called after every successful save, with the saved record. */
139
+ onSaved?: (params: EntityFormPanelSavedParams) => void;
140
+ };
122
141
  /**
123
- * @deprecated Renamed {@link RecordForm}, with the same props. It warns once.
142
+ * @deprecated Renamed {@link RecordForm}. It also takes 0.28's `entityId`
143
+ * for `id`, and hands `onSaved` the saved record as `entity` beside `row` and
144
+ * `id`. It warns once.
124
145
  * @group Components
125
146
  */
126
- export declare function EntityFormPanel<M extends Record<string, unknown> = Record<string, unknown>>(props: RecordFormProps<M>): React.JSX.Element;
147
+ export declare function EntityFormPanel<M extends Record<string, unknown> = Record<string, unknown>>({ entityId, onSaved, ...props }: EntityFormPanelProps<M>): React.JSX.Element;
@@ -184,12 +184,30 @@ function RecordFormInScope({ collection: collectionProp, id: entityId, path: pat
184
184
  });
185
185
  }
186
186
  /**
187
- * @deprecated Renamed {@link RecordForm}, with the same props. It warns once.
187
+ * @deprecated Renamed {@link RecordForm}. It also takes 0.28's `entityId`
188
+ * for `id`, and hands `onSaved` the saved record as `entity` beside `row` and
189
+ * `id`. It warns once.
188
190
  * @group Components
189
191
  */
190
- function EntityFormPanel(props) {
192
+ function EntityFormPanel({ entityId, onSaved, ...props }) {
191
193
  warnDeprecated("EntityFormPanel", "`EntityFormPanel` is now `RecordForm`, with the same props.");
192
- return /* @__PURE__ */ jsx(RecordForm, { ...props });
194
+ if (entityId !== void 0) warnDeprecated("EntityFormPanel.entityId", "`EntityFormPanel`'s `entityId` is `id` now: `<RecordForm id=\"…\"/>`.");
195
+ const onSavedWithEntity = onSaved && ((params) => {
196
+ let entity;
197
+ onSaved({
198
+ ...params,
199
+ get entity() {
200
+ warnDeprecated("EntityFormPanel.onSaved.entity", "`EntityFormPanel`'s `onSaved` hands over the saved record as `row` and `id` now; `entity` is going away.");
201
+ entity ??= entityOfRow(params.row, params.id, params.path, params.collection);
202
+ return entity;
203
+ }
204
+ });
205
+ });
206
+ return /* @__PURE__ */ jsx(RecordForm, {
207
+ ...props,
208
+ id: props.id ?? entityId,
209
+ onSaved: onSavedWithEntity
210
+ });
193
211
  }
194
212
  //#endregion
195
213
  export { EntityFormPanel, RecordForm };
@@ -1 +1 @@
1
- {"version":3,"file":"RecordForm.js","names":[],"sources":["../../src/components/RecordForm.tsx"],"sourcesContent":["import React, { useCallback, useContext, useEffect, useMemo, useRef, useState } from \"react\";\nimport { deepEqual as equal } from \"fast-equals\";\nimport { warnDeprecated } from \"@rebasepro/common\";\nimport type { Entity } from \"@rebasepro/types\";\nimport type { AdminCollection } from \"@rebasepro/cms-types\";\nimport { Alert, Button, CenteredView, CircularProgressCenter } from \"@rebasepro/ui\";\nimport { CollectionScopeProvider, entityOfRow, ErrorView, rowOfEntity, useFetch, usePermissions, useTranslation } from \"@rebasepro/app\";\n\nimport { EntityFormBinding } from \"../form/EntityFormBinding\";\nimport type { EntityFormBindingProps } from \"../form/EntityFormBinding\";\nimport type { OnSavedParams } from \"../types/components/EntityFormProps\";\nimport { useCollectionRegistryController } from \"../hooks/navigation/contexts/CollectionRegistryContext\";\nimport { useNavigationStateController } from \"../hooks/navigation/contexts/NavigationStateContext\";\nimport { CollectionsScopeContext, isRegistered } from \"./CollectionsScopeContext\";\nimport { CollectionsProvider } from \"./CollectionsProvider\";\nimport { PanelNotFound } from \"./PanelNotFound\";\nimport { collectionPropOf, type ScopedRecordPanelProps } from \"./collection_prop\";\n\n/**\n * Props for {@link RecordForm}.\n *\n * @group Components\n */\nexport type RecordFormProps<M extends Record<string, unknown> = Record<string, unknown>> =\n RecordFormOptions<M> & RecordPanelCollection<M>;\n\n/**\n * Which collection a record panel's record belongs to: named, the way\n * {@link CollectionPanel} names it, or handed over as a value.\n *\n * @group Components\n */\nexport type RecordPanelCollection<M extends Record<string, unknown> = Record<string, unknown>> = {\n /**\n * The collection the record belongs to: its name (`\"orders\"`), registered\n * with `<RebaseCMS>` or a {@link CollectionsProvider} above, or the\n * collection as a value — a `defineCollection` config or a resolved\n * collection. Handed over as a value where no CMS navigation is mounted\n * above, the panel brings its own {@link CollectionsProvider} for it.\n */\n collection: AdminCollection<M> | string;\n /**\n * Where the record lives, where that is not the collection's name: a\n * subcollection's full path, `posts/p1/comments`.\n */\n path?: string;\n};\n\n/**\n * The options of an {@link RecordForm}, beside its collection.\n *\n * @group Components\n */\nexport type RecordFormOptions<M extends Record<string, unknown> = Record<string, unknown>> = {\n /**\n * The record to edit. When no record has this id yet, the form creates\n * it under this id — so a record kept at a known key (a settings record,\n * a profile keyed by its user's id) needs no seeding. Omit it to create a\n * new record under an id the data source assigns.\n */\n id?: string | number;\n\n /** Called after every successful save, with the saved record. */\n onSaved?: (params: OnSavedParams) => void;\n\n /**\n * Called when the form asks to be left — after its record is deleted, or\n * by an action that closes it. The form is your page's, so where that\n * leads is yours to say; without it, nothing happens.\n */\n onClose?: () => void;\n\n /** Values a new record starts with — one created without an id, or under an id no record has yet. */\n defaultValues?: Partial<M>;\n\n className?: string;\n\n /**\n * The fields the form shows, in this order; any other property is left\n * out. Sections and the rail keep their grouping, each holding only these\n * fields. The form validates only what it shows, and, creating a record,\n * refuses with an error naming them when a required field it leaves out\n * has no default value and is not filled by the server or the database.\n */\n fields?: string[];\n\n /**\n * A denser form, for a side card or a narrow panel: no rail beside the\n * fields, no record metadata, medium-height controls and tighter padding.\n */\n compact?: boolean;\n\n /**\n * Your own arrangement of the fields, in place of the generated ones:\n * `<FormField name=\"…\"/>`s inside any JSX. Validation covers the fields\n * its `<FormField>`s render, with the same create-time check as\n * {@link fields}. Wins over the collection's `formView.Builder`.\n *\n * ```tsx\n * <RecordForm collection=\"orders\" id={id}>\n * <div className=\"grid grid-cols-2 gap-3\">\n * <FormField name=\"status\"/>\n * <FormField name=\"tracking_number\"/>\n * </div>\n * <FormField name=\"notes\"/>\n * </RecordForm>\n * ```\n */\n children?: React.ReactNode;\n\n /**\n * Collection settings for this form only, applied over the registered\n * collection the way `CollectionPanel` applies its own: a shallow merge,\n * so `properties` given here replaces the collection's whole map.\n */\n collectionOverrides?: Partial<AdminCollection>;\n\n /** Anything else {@link EntityFormBinding} takes. */\n formProps?: Partial<Omit<EntityFormBindingProps<M>, \"path\" | \"collection\" | \"id\" | \"row\" | \"initialStatus\" | \"fields\" | \"layout\" | \"compact\">>;\n};\n\n/**\n * One record's form — loaded by id, saved through `<Rebase>`'s data layer —\n * to drop into a page of your own app.\n *\n * Needs `<Rebase>` and a React Router router above it (any router, any path).\n * Where no CMS navigation is mounted above, it brings its own\n * {@link CollectionsProvider}, so `<RebaseCMS>`, `<RebaseNavigation>` and\n * `<RebaseShell>` are not needed.\n *\n * @example\n * ```tsx\n * <Rebase client={client} authController={authController}>\n * <BrowserRouter>\n * <RecordForm collection={postsCollection} id=\"123\"\n * onSaved={({ id }) => toast(`Saved ${id}`)}/>\n * </BrowserRouter>\n * </Rebase>\n * ```\n *\n * @group Components\n */\nexport function RecordForm<M extends Record<string, unknown> = Record<string, unknown>>(rawProps: RecordFormProps<M>) {\n const inScope = useContext(CollectionsScopeContext);\n const collectionRegistry = useCollectionRegistryController();\n const navigationState = useNavigationStateController();\n const { collection, path } = collectionPropOf<AdminCollection<M>>(rawProps.collection, rawProps.path);\n const props: ScopedRecordPanelProps<RecordFormOptions<M>, M> = { ...rawProps, collection, path };\n const ownCollections = useMemo(() => collection ? [collection] : [], [collection]);\n\n // As `CollectionPanel`: a collection handed over as a value brings its own\n // scope where none is above, or where the one above has settled without\n // it. One named by path is looked up in the scope above.\n const needsOwnScope = collection !== undefined && (!inScope\n || (!navigationState.loading && !isRegistered(collectionRegistry.collections, path)));\n // One form per record: the binding keeps the id and status it mounted\n // with, so a page that hands over another id (a route `/posts/:id` going\n // from p1 to p2) gets a fresh form instead of one that shows p2 and saves\n // into p1. Keyed on the prop, so the id a create assigns keeps the form.\n const recordKey = `${path}/${props.id ?? \"new\"}`;\n // Named by path with no scope above to look it up in: nothing will ever\n // register it, so it is not found rather than loading.\n if (!inScope && collection === undefined) return <PanelNotFound className={props.className}/>;\n if (needsOwnScope) {\n return (\n <CollectionsProvider collections={ownCollections}>\n <RecordFormInScope key={recordKey} {...props}/>\n </CollectionsProvider>\n );\n }\n return <RecordFormInScope key={recordKey} {...props}/>;\n}\n\nfunction RecordFormInScope<M extends Record<string, unknown>>({\n collection: collectionProp,\n id: entityId,\n path: pathProp,\n onSaved,\n onClose,\n defaultValues,\n className,\n fields,\n children,\n compact,\n collectionOverrides,\n formProps\n}: ScopedRecordPanelProps<RecordFormOptions<M>, M>) {\n const { t } = useTranslation();\n const path = pathProp;\n const collectionRegistry = useCollectionRegistryController<Record<string, unknown>, AdminCollection<M>>();\n const navigationState = useNavigationStateController();\n const { canCreate, canEdit } = usePermissions();\n\n // The registry's copy: it carries the plugins' changes and the user's\n // saved overrides.\n // Looked up once per registry: each lookup builds a new object, and the\n // record's subscription is keyed on the collection it was opened with.\n // The overrides are compared by value for the same reason: they are an\n // inline object at most call sites, a new one on every render.\n const overridesRef = useRef(collectionOverrides);\n if (!equal(overridesRef.current, collectionOverrides)) overridesRef.current = collectionOverrides;\n const stableOverrides = overridesRef.current;\n const lookUp = collectionRegistry.initialised || !navigationState.loading;\n const collection = useMemo(() => {\n const registered = lookUp ? collectionRegistry.getCollection(path) : undefined;\n return registered && stableOverrides\n ? { ...registered, ...stableOverrides } as AdminCollection<M>\n : registered;\n }, [lookUp, collectionRegistry, path, stableOverrides]);\n\n const { entity, dataLoading, dataLoadingError } = useFetch<M>({\n path,\n entityId,\n collection: collection ?? collectionProp,\n relations: true,\n useCache: false\n });\n\n // The record as the form last saved it. A record created here has no id\n // to read it back by from the outside, and the form, existing from then\n // on, needs it.\n const [savedEntity, setSavedEntity] = useState<Entity<M> | undefined>(undefined);\n\n // The record as it was last delivered. A live read that stops delivering\n // it — someone deleted it — is not a record that was never there: as in\n // the CMS's own edit view, the form keeps showing it, with what was typed,\n // and says so. Without this the form lost its record mid-edit and threw.\n const [lastSeenEntity, setLastSeenEntity] = useState<Entity<M> | undefined>(undefined);\n useEffect(() => {\n if (entity) setLastSeenEntity(entity);\n }, [entity]);\n // \"Save as new\": the same values, in a form that creates a record. Counted,\n // so that each one is a fresh form.\n const [asNew, setAsNew] = useState<{ values: Partial<M>, n: number, saved?: Entity<M> } | null>(null);\n const typedValues = useRef<Partial<M> | undefined>(undefined);\n const deletedElsewhere = !asNew && entityId !== undefined && !dataLoading && !entity\n && lastSeenEntity !== undefined && String(lastSeenEntity.id) === String(entityId);\n const shownEntity = deletedElsewhere ? lastSeenEntity : (entity ?? savedEntity);\n\n const navigateBack = useCallback(() => onClose?.(), [onClose]);\n const saveAsNew = useCallback(() => {\n const values: Partial<M> = typedValues.current ?? lastSeenEntity?.values ?? {};\n setAsNew(previous => ({ values, n: (previous?.n ?? 0) + 1 }));\n }, [lastSeenEntity]);\n\n if (!collection) {\n if (navigationState.loading) return <CircularProgressCenter/>;\n return <PanelNotFound className={className}/>;\n }\n\n if (asNew) {\n return (\n <CollectionScopeProvider collection={collection}>\n <EntityFormBinding<M>\n {...formProps}\n key={`as-new-${asNew.n}`}\n className={className ?? formProps?.className}\n path={path}\n collection={collection}\n row={asNew.saved ? rowOfEntity(asNew.saved, collection) : undefined}\n initialStatus={\"new\"}\n initialDirtyValues={asNew.values}\n fields={fields}\n layout={children}\n compact={compact}\n disabled={!canCreate(collection, path) || formProps?.disabled}\n onRowChange={(changed) => {\n // The record it created, which it edits from then on.\n const saved = entityOfRow(changed.row, changed.id, path, collection) as Entity<M>;\n setAsNew(current => current && { ...current, saved });\n formProps?.onRowChange?.(changed);\n }}\n onSaved={(params) => {\n formProps?.onSaved?.(params);\n onSaved?.(params);\n }}\n navigateBack={navigateBack}\n />\n </CollectionScopeProvider>\n );\n }\n\n if (entityId !== undefined && dataLoadingError) {\n return <CenteredView className={className}><ErrorView error={dataLoadingError}/></CenteredView>;\n }\n if (entityId !== undefined && !shownEntity && dataLoading) return <CircularProgressCenter/>;\n\n // An id no record has yet is a record to create under that id. The form\n // keeps the status it opened with, so once it creates the record it edits\n // it from then on.\n const creating = shownEntity === undefined;\n // As the CMS's own New button and save actions: a record to create needs\n // canCreate (false while access is simulated), an existing one canEdit.\n const editable = creating ? canCreate(collection, path) : canEdit(collection, path, shownEntity?.values ?? null);\n\n return (\n <CollectionScopeProvider collection={collection}>\n <EntityFormBinding<M>\n {...formProps}\n className={className ?? formProps?.className}\n path={path}\n collection={collection}\n id={entityId}\n row={shownEntity ? rowOfEntity(shownEntity, collection) : undefined}\n initialStatus={creating ? \"new\" : \"existing\"}\n initialDirtyValues={creating ? defaultValues : formProps?.initialDirtyValues}\n fields={fields}\n layout={children}\n compact={compact}\n disabled={!editable || formProps?.disabled}\n onRowChange={(changed) => {\n setSavedEntity(entityOfRow(changed.row, changed.id, path, collection) as Entity<M>);\n formProps?.onRowChange?.(changed);\n }}\n onValuesModified={(modified, values) => {\n typedValues.current = values;\n formProps?.onValuesModified?.(modified, values);\n }}\n onSaved={(params) => {\n formProps?.onSaved?.(params);\n onSaved?.(params);\n }}\n navigateBack={navigateBack}\n >\n {deletedElsewhere &&\n <Alert color={\"warning\"} size={\"small\"} outerClassName={\"w-full mb-4\"}\n action={<Button size={\"small\"} variant={\"text\"} onClick={saveAsNew}>{t(\"save_as_new\")}</Button>}>\n {t(\"entity_deleted_elsewhere\")}\n </Alert>}\n {formProps?.children}\n </EntityFormBinding>\n </CollectionScopeProvider>\n );\n}\n\n/**\n * @deprecated Renamed {@link RecordForm}, with the same props. It warns once.\n * @group Components\n */\nexport type EntityFormPanelProps<M extends Record<string, unknown> = Record<string, unknown>> = RecordFormProps<M>;\n\n/**\n * @deprecated Renamed {@link RecordForm}, with the same props. It warns once.\n * @group Components\n */\nexport function EntityFormPanel<M extends Record<string, unknown> = Record<string, unknown>>(props: RecordFormProps<M>) {\n warnDeprecated(\"EntityFormPanel\", \"`EntityFormPanel` is now `RecordForm`, with the same props.\");\n return <RecordForm<M> {...props}/>;\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA8IA,SAAgB,WAAwE,UAA8B;CAClH,MAAM,UAAU,WAAW,uBAAuB;CAClD,MAAM,qBAAqB,gCAAgC;CAC3D,MAAM,kBAAkB,6BAA6B;CACrD,MAAM,EAAE,YAAY,SAAS,iBAAqC,SAAS,YAAY,SAAS,IAAI;CACpG,MAAM,QAAyD;EAAE,GAAG;EAAU;EAAY;CAAK;CAC/F,MAAM,iBAAiB,cAAc,aAAa,CAAC,UAAU,IAAI,CAAC,GAAG,CAAC,UAAU,CAAC;CAKjF,MAAM,gBAAgB,eAAe,KAAA,MAAc,CAAC,WAC5C,CAAC,gBAAgB,WAAW,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,"file":"RecordForm.js","names":[],"sources":["../../src/components/RecordForm.tsx"],"sourcesContent":["import React, { useCallback, useContext, useEffect, useMemo, useRef, useState } from \"react\";\nimport { deepEqual as equal } from \"fast-equals\";\nimport { warnDeprecated } from \"@rebasepro/common\";\nimport type { Entity } from \"@rebasepro/types\";\nimport type { AdminCollection } from \"@rebasepro/cms-types\";\nimport { Alert, Button, CenteredView, CircularProgressCenter } from \"@rebasepro/ui\";\nimport { CollectionScopeProvider, entityOfRow, ErrorView, rowOfEntity, useFetch, usePermissions, useTranslation } from \"@rebasepro/app\";\n\nimport { EntityFormBinding } from \"../form/EntityFormBinding\";\nimport type { EntityFormBindingProps } from \"../form/EntityFormBinding\";\nimport type { OnSavedParams } from \"../types/components/EntityFormProps\";\nimport { useCollectionRegistryController } from \"../hooks/navigation/contexts/CollectionRegistryContext\";\nimport { useNavigationStateController } from \"../hooks/navigation/contexts/NavigationStateContext\";\nimport { CollectionsScopeContext, isRegistered } from \"./CollectionsScopeContext\";\nimport { CollectionsProvider } from \"./CollectionsProvider\";\nimport { PanelNotFound } from \"./PanelNotFound\";\nimport { collectionPropOf, type ScopedRecordPanelProps } from \"./collection_prop\";\n\n/**\n * Props for {@link RecordForm}.\n *\n * @group Components\n */\nexport type RecordFormProps<M extends Record<string, unknown> = Record<string, unknown>> =\n RecordFormOptions<M> & RecordPanelCollection<M>;\n\n/**\n * Which collection a record panel's record belongs to: named, the way\n * {@link CollectionPanel} names it, or handed over as a value.\n *\n * @group Components\n */\nexport type RecordPanelCollection<M extends Record<string, unknown> = Record<string, unknown>> = {\n /**\n * The collection the record belongs to: its name (`\"orders\"`), registered\n * with `<RebaseCMS>` or a {@link CollectionsProvider} above, or the\n * collection as a value — a `defineCollection` config or a resolved\n * collection. Handed over as a value where no CMS navigation is mounted\n * above, the panel brings its own {@link CollectionsProvider} for it.\n */\n collection: AdminCollection<M> | string;\n /**\n * Where the record lives, where that is not the collection's name: a\n * subcollection's full path, `posts/p1/comments`.\n */\n path?: string;\n};\n\n/**\n * The options of an {@link RecordForm}, beside its collection.\n *\n * @group Components\n */\nexport type RecordFormOptions<M extends Record<string, unknown> = Record<string, unknown>> = {\n /**\n * The record to edit. When no record has this id yet, the form creates\n * it under this id — so a record kept at a known key (a settings record,\n * a profile keyed by its user's id) needs no seeding. Omit it to create a\n * new record under an id the data source assigns.\n */\n id?: string | number;\n\n /** Called after every successful save, with the saved record. */\n onSaved?: (params: OnSavedParams) => void;\n\n /**\n * Called when the form asks to be left — after its record is deleted, or\n * by an action that closes it. The form is your page's, so where that\n * leads is yours to say; without it, nothing happens.\n */\n onClose?: () => void;\n\n /** Values a new record starts with — one created without an id, or under an id no record has yet. */\n defaultValues?: Partial<M>;\n\n className?: string;\n\n /**\n * The fields the form shows, in this order; any other property is left\n * out. Sections and the rail keep their grouping, each holding only these\n * fields. The form validates only what it shows, and, creating a record,\n * refuses with an error naming them when a required field it leaves out\n * has no default value and is not filled by the server or the database.\n */\n fields?: string[];\n\n /**\n * A denser form, for a side card or a narrow panel: no rail beside the\n * fields, no record metadata, medium-height controls and tighter padding.\n */\n compact?: boolean;\n\n /**\n * Your own arrangement of the fields, in place of the generated ones:\n * `<FormField name=\"…\"/>`s inside any JSX. Validation covers the fields\n * its `<FormField>`s render, with the same create-time check as\n * {@link fields}. Wins over the collection's `formView.Builder`.\n *\n * ```tsx\n * <RecordForm collection=\"orders\" id={id}>\n * <div className=\"grid grid-cols-2 gap-3\">\n * <FormField name=\"status\"/>\n * <FormField name=\"tracking_number\"/>\n * </div>\n * <FormField name=\"notes\"/>\n * </RecordForm>\n * ```\n */\n children?: React.ReactNode;\n\n /**\n * Collection settings for this form only, applied over the registered\n * collection the way `CollectionPanel` applies its own: a shallow merge,\n * so `properties` given here replaces the collection's whole map.\n */\n collectionOverrides?: Partial<AdminCollection>;\n\n /** Anything else {@link EntityFormBinding} takes. */\n formProps?: Partial<Omit<EntityFormBindingProps<M>, \"path\" | \"collection\" | \"id\" | \"row\" | \"initialStatus\" | \"fields\" | \"layout\" | \"compact\">>;\n};\n\n/**\n * One record's form — loaded by id, saved through `<Rebase>`'s data layer —\n * to drop into a page of your own app.\n *\n * Needs `<Rebase>` and a React Router router above it (any router, any path).\n * Where no CMS navigation is mounted above, it brings its own\n * {@link CollectionsProvider}, so `<RebaseCMS>`, `<RebaseNavigation>` and\n * `<RebaseShell>` are not needed.\n *\n * @example\n * ```tsx\n * <Rebase client={client} authController={authController}>\n * <BrowserRouter>\n * <RecordForm collection={postsCollection} id=\"123\"\n * onSaved={({ id }) => toast(`Saved ${id}`)}/>\n * </BrowserRouter>\n * </Rebase>\n * ```\n *\n * @group Components\n */\nexport function RecordForm<M extends Record<string, unknown> = Record<string, unknown>>(rawProps: RecordFormProps<M>) {\n const inScope = useContext(CollectionsScopeContext);\n const collectionRegistry = useCollectionRegistryController();\n const navigationState = useNavigationStateController();\n const { collection, path } = collectionPropOf<AdminCollection<M>>(rawProps.collection, rawProps.path);\n const props: ScopedRecordPanelProps<RecordFormOptions<M>, M> = { ...rawProps, collection, path };\n const ownCollections = useMemo(() => collection ? [collection] : [], [collection]);\n\n // As `CollectionPanel`: a collection handed over as a value brings its own\n // scope where none is above, or where the one above has settled without\n // it. One named by path is looked up in the scope above.\n const needsOwnScope = collection !== undefined && (!inScope\n || (!navigationState.loading && !isRegistered(collectionRegistry.collections, path)));\n // One form per record: the binding keeps the id and status it mounted\n // with, so a page that hands over another id (a route `/posts/:id` going\n // from p1 to p2) gets a fresh form instead of one that shows p2 and saves\n // into p1. Keyed on the prop, so the id a create assigns keeps the form.\n const recordKey = `${path}/${props.id ?? \"new\"}`;\n // Named by path with no scope above to look it up in: nothing will ever\n // register it, so it is not found rather than loading.\n if (!inScope && collection === undefined) return <PanelNotFound className={props.className}/>;\n if (needsOwnScope) {\n return (\n <CollectionsProvider collections={ownCollections}>\n <RecordFormInScope key={recordKey} {...props}/>\n </CollectionsProvider>\n );\n }\n return <RecordFormInScope key={recordKey} {...props}/>;\n}\n\nfunction RecordFormInScope<M extends Record<string, unknown>>({\n collection: collectionProp,\n id: entityId,\n path: pathProp,\n onSaved,\n onClose,\n defaultValues,\n className,\n fields,\n children,\n compact,\n collectionOverrides,\n formProps\n}: ScopedRecordPanelProps<RecordFormOptions<M>, M>) {\n const { t } = useTranslation();\n const path = pathProp;\n const collectionRegistry = useCollectionRegistryController<Record<string, unknown>, AdminCollection<M>>();\n const navigationState = useNavigationStateController();\n const { canCreate, canEdit } = usePermissions();\n\n // The registry's copy: it carries the plugins' changes and the user's\n // saved overrides.\n // Looked up once per registry: each lookup builds a new object, and the\n // record's subscription is keyed on the collection it was opened with.\n // The overrides are compared by value for the same reason: they are an\n // inline object at most call sites, a new one on every render.\n const overridesRef = useRef(collectionOverrides);\n if (!equal(overridesRef.current, collectionOverrides)) overridesRef.current = collectionOverrides;\n const stableOverrides = overridesRef.current;\n const lookUp = collectionRegistry.initialised || !navigationState.loading;\n const collection = useMemo(() => {\n const registered = lookUp ? collectionRegistry.getCollection(path) : undefined;\n return registered && stableOverrides\n ? { ...registered, ...stableOverrides } as AdminCollection<M>\n : registered;\n }, [lookUp, collectionRegistry, path, stableOverrides]);\n\n const { entity, dataLoading, dataLoadingError } = useFetch<M>({\n path,\n entityId,\n collection: collection ?? collectionProp,\n relations: true,\n useCache: false\n });\n\n // The record as the form last saved it. A record created here has no id\n // to read it back by from the outside, and the form, existing from then\n // on, needs it.\n const [savedEntity, setSavedEntity] = useState<Entity<M> | undefined>(undefined);\n\n // The record as it was last delivered. A live read that stops delivering\n // it — someone deleted it — is not a record that was never there: as in\n // the CMS's own edit view, the form keeps showing it, with what was typed,\n // and says so. Without this the form lost its record mid-edit and threw.\n const [lastSeenEntity, setLastSeenEntity] = useState<Entity<M> | undefined>(undefined);\n useEffect(() => {\n if (entity) setLastSeenEntity(entity);\n }, [entity]);\n // \"Save as new\": the same values, in a form that creates a record. Counted,\n // so that each one is a fresh form.\n const [asNew, setAsNew] = useState<{ values: Partial<M>, n: number, saved?: Entity<M> } | null>(null);\n const typedValues = useRef<Partial<M> | undefined>(undefined);\n const deletedElsewhere = !asNew && entityId !== undefined && !dataLoading && !entity\n && lastSeenEntity !== undefined && String(lastSeenEntity.id) === String(entityId);\n const shownEntity = deletedElsewhere ? lastSeenEntity : (entity ?? savedEntity);\n\n const navigateBack = useCallback(() => onClose?.(), [onClose]);\n const saveAsNew = useCallback(() => {\n const values: Partial<M> = typedValues.current ?? lastSeenEntity?.values ?? {};\n setAsNew(previous => ({ values, n: (previous?.n ?? 0) + 1 }));\n }, [lastSeenEntity]);\n\n if (!collection) {\n if (navigationState.loading) return <CircularProgressCenter/>;\n return <PanelNotFound className={className}/>;\n }\n\n if (asNew) {\n return (\n <CollectionScopeProvider collection={collection}>\n <EntityFormBinding<M>\n {...formProps}\n key={`as-new-${asNew.n}`}\n className={className ?? formProps?.className}\n path={path}\n collection={collection}\n row={asNew.saved ? rowOfEntity(asNew.saved, collection) : undefined}\n initialStatus={\"new\"}\n initialDirtyValues={asNew.values}\n fields={fields}\n layout={children}\n compact={compact}\n disabled={!canCreate(collection, path) || formProps?.disabled}\n onRowChange={(changed) => {\n // The record it created, which it edits from then on.\n const saved = entityOfRow(changed.row, changed.id, path, collection) as Entity<M>;\n setAsNew(current => current && { ...current, saved });\n formProps?.onRowChange?.(changed);\n }}\n onSaved={(params) => {\n formProps?.onSaved?.(params);\n onSaved?.(params);\n }}\n navigateBack={navigateBack}\n />\n </CollectionScopeProvider>\n );\n }\n\n if (entityId !== undefined && dataLoadingError) {\n return <CenteredView className={className}><ErrorView error={dataLoadingError}/></CenteredView>;\n }\n if (entityId !== undefined && !shownEntity && dataLoading) return <CircularProgressCenter/>;\n\n // An id no record has yet is a record to create under that id. The form\n // keeps the status it opened with, so once it creates the record it edits\n // it from then on.\n const creating = shownEntity === undefined;\n // As the CMS's own New button and save actions: a record to create needs\n // canCreate (false while access is simulated), an existing one canEdit.\n const editable = creating ? canCreate(collection, path) : canEdit(collection, path, shownEntity?.values ?? null);\n\n return (\n <CollectionScopeProvider collection={collection}>\n <EntityFormBinding<M>\n {...formProps}\n className={className ?? formProps?.className}\n path={path}\n collection={collection}\n id={entityId}\n row={shownEntity ? rowOfEntity(shownEntity, collection) : undefined}\n initialStatus={creating ? \"new\" : \"existing\"}\n initialDirtyValues={creating ? defaultValues : formProps?.initialDirtyValues}\n fields={fields}\n layout={children}\n compact={compact}\n disabled={!editable || formProps?.disabled}\n onRowChange={(changed) => {\n setSavedEntity(entityOfRow(changed.row, changed.id, path, collection) as Entity<M>);\n formProps?.onRowChange?.(changed);\n }}\n onValuesModified={(modified, values) => {\n typedValues.current = values;\n formProps?.onValuesModified?.(modified, values);\n }}\n onSaved={(params) => {\n formProps?.onSaved?.(params);\n onSaved?.(params);\n }}\n navigateBack={navigateBack}\n >\n {deletedElsewhere &&\n <Alert color={\"warning\"} size={\"small\"} outerClassName={\"w-full mb-4\"}\n action={<Button size={\"small\"} variant={\"text\"} onClick={saveAsNew}>{t(\"save_as_new\")}</Button>}>\n {t(\"entity_deleted_elsewhere\")}\n </Alert>}\n {formProps?.children}\n </EntityFormBinding>\n </CollectionScopeProvider>\n );\n}\n\n/**\n * What {@link EntityFormPanel}'s `onSaved` is called with: {@link OnSavedParams},\n * and the saved record as 0.28 handed it over.\n *\n * @deprecated Use {@link RecordForm}, whose `onSaved` gets {@link OnSavedParams}.\n * @group Components\n */\nexport type EntityFormPanelSavedParams = OnSavedParams & {\n /** @deprecated The saved record as an `Entity`: read `row` and `id`. It warns once. */\n entity: Entity<Record<string, unknown>>;\n};\n\n/**\n * @deprecated Renamed {@link RecordForm}. It also takes 0.28's `entityId`\n * for `id`, and hands `onSaved` the saved record as `entity` beside `row` and\n * `id`. It warns once.\n * @group Components\n */\nexport type EntityFormPanelProps<M extends Record<string, unknown> = Record<string, unknown>> =\n Omit<RecordFormProps<M>, \"onSaved\"> & {\n /** @deprecated The record to edit is `id`. It warns once. */\n entityId?: string | number;\n /** Called after every successful save, with the saved record. */\n onSaved?: (params: EntityFormPanelSavedParams) => void;\n };\n\n/**\n * @deprecated Renamed {@link RecordForm}. It also takes 0.28's `entityId`\n * for `id`, and hands `onSaved` the saved record as `entity` beside `row` and\n * `id`. It warns once.\n * @group Components\n */\nexport function EntityFormPanel<M extends Record<string, unknown> = Record<string, unknown>>({\n entityId,\n onSaved,\n ...props\n}: EntityFormPanelProps<M>) {\n warnDeprecated(\"EntityFormPanel\", \"`EntityFormPanel` is now `RecordForm`, with the same props.\");\n if (entityId !== undefined) {\n warnDeprecated(\"EntityFormPanel.entityId\", \"`EntityFormPanel`'s `entityId` is `id` now: `<RecordForm id=\\\"…\\\"/>`.\");\n }\n const onSavedWithEntity = onSaved && ((params: OnSavedParams) => {\n let entity: Entity<Record<string, unknown>> | undefined;\n onSaved({\n ...params,\n get entity() {\n warnDeprecated(\"EntityFormPanel.onSaved.entity\", \"`EntityFormPanel`'s `onSaved` hands over the saved record as `row` and `id` now; `entity` is going away.\");\n entity ??= entityOfRow(params.row, params.id, params.path, params.collection);\n return entity;\n }\n });\n });\n return <RecordForm<M> {...props} id={props.id ?? entityId} onSaved={onSavedWithEntity}/>;\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA8IA,SAAgB,WAAwE,UAA8B;CAClH,MAAM,UAAU,WAAW,uBAAuB;CAClD,MAAM,qBAAqB,gCAAgC;CAC3D,MAAM,kBAAkB,6BAA6B;CACrD,MAAM,EAAE,YAAY,SAAS,iBAAqC,SAAS,YAAY,SAAS,IAAI;CACpG,MAAM,QAAyD;EAAE,GAAG;EAAU;EAAY;CAAK;CAC/F,MAAM,iBAAiB,cAAc,aAAa,CAAC,UAAU,IAAI,CAAC,GAAG,CAAC,UAAU,CAAC;CAKjF,MAAM,gBAAgB,eAAe,KAAA,MAAc,CAAC,WAC5C,CAAC,gBAAgB,WAAW,CAAC,aAAa,mBAAmB,aAAa,IAAI;CAKtF,MAAM,YAAY,GAAG,KAAK,GAAG,MAAM,MAAM;CAGzC,IAAI,CAAC,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