@rebasepro/cms 0.26.0 → 0.28.0

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 (67) hide show
  1. package/dist/collection_editor/serializable_utils.js +5 -2
  2. package/dist/collection_editor/serializable_utils.js.map +1 -1
  3. package/dist/collection_editor/ui/collection_editor/EnumForm.d.ts +17 -0
  4. package/dist/collection_editor/ui/collection_editor/EnumForm.js +31 -17
  5. package/dist/collection_editor/ui/collection_editor/EnumForm.js.map +1 -1
  6. package/dist/collection_editor/ui/collection_editor/properties/EnumPropertyField.js +6 -5
  7. package/dist/collection_editor/ui/collection_editor/properties/EnumPropertyField.js.map +1 -1
  8. package/dist/components/CollectionTableBinding/internal/popup_field/PopupFormField.js +3 -2
  9. package/dist/components/CollectionTableBinding/internal/popup_field/PopupFormField.js.map +1 -1
  10. package/dist/components/CollectionViewBinding/CollectionListViewBinding.js +32 -16
  11. package/dist/components/CollectionViewBinding/CollectionListViewBinding.js.map +1 -1
  12. package/dist/components/DefaultDrawer.js +3 -2
  13. package/dist/components/DefaultDrawer.js.map +1 -1
  14. package/dist/components/DetailViewBinding.js +4 -3
  15. package/dist/components/DetailViewBinding.js.map +1 -1
  16. package/dist/components/EditViewBinding.js +23 -5
  17. package/dist/components/EditViewBinding.js.map +1 -1
  18. package/dist/components/EntityPreviewBinding.js +1 -0
  19. package/dist/components/EntityPreviewBinding.js.map +1 -1
  20. package/dist/components/HomePage/ContentHomePage.js +3 -2
  21. package/dist/components/HomePage/ContentHomePage.js.map +1 -1
  22. package/dist/components/SelectableTable/filters/StringNumberFilterField.js +3 -3
  23. package/dist/components/SelectableTable/filters/StringNumberFilterField.js.map +1 -1
  24. package/dist/components/SidePanelBinding.js +7 -6
  25. package/dist/components/SidePanelBinding.js.map +1 -1
  26. package/dist/components/app/Scaffold.js +16 -1
  27. package/dist/components/app/Scaffold.js.map +1 -1
  28. package/dist/components/history/EntityHistoryView.js +2 -1
  29. package/dist/components/history/EntityHistoryView.js.map +1 -1
  30. package/dist/data_export/export/export.js +3 -3
  31. package/dist/data_export/export/export.js.map +1 -1
  32. package/dist/data_import/import/ImportCollectionAction.js +10 -12
  33. package/dist/data_import/import/ImportCollectionAction.js.map +1 -1
  34. package/dist/data_import/utils/id_column.d.ts +19 -0
  35. package/dist/data_import/utils/id_column.js +19 -1
  36. package/dist/data_import/utils/id_column.js.map +1 -1
  37. package/dist/data_import/utils/transforms.js +24 -7
  38. package/dist/data_import/utils/transforms.js.map +1 -1
  39. package/dist/form/EntityForm.d.ts +1 -1
  40. package/dist/form/EntityForm.js +14 -4
  41. package/dist/form/EntityForm.js.map +1 -1
  42. package/dist/form/EntityFormBinding.js +12 -8
  43. package/dist/form/EntityFormBinding.js.map +1 -1
  44. package/dist/form/components/FieldBlock.js +2 -1
  45. package/dist/form/components/FieldBlock.js.map +1 -1
  46. package/dist/form/field_bindings/KeyValueFieldBinding.js +3 -1
  47. package/dist/form/field_bindings/KeyValueFieldBinding.js.map +1 -1
  48. package/dist/form/field_bindings/ReadOnlyFieldBinding.js +0 -2
  49. package/dist/form/field_bindings/ReadOnlyFieldBinding.js.map +1 -1
  50. package/dist/form/field_bindings/TextFieldBinding.js +3 -2
  51. package/dist/form/field_bindings/TextFieldBinding.js.map +1 -1
  52. package/dist/form/validation.js +12 -1
  53. package/dist/form/validation.js.map +1 -1
  54. package/dist/hooks/navigation/url_segments.d.ts +33 -0
  55. package/dist/hooks/navigation/url_segments.js +56 -0
  56. package/dist/hooks/navigation/url_segments.js.map +1 -0
  57. package/dist/hooks/navigation/useBuildUrlController.js +4 -2
  58. package/dist/hooks/navigation/useBuildUrlController.js.map +1 -1
  59. package/dist/hooks/useBuildSidePanel.js +6 -5
  60. package/dist/hooks/useBuildSidePanel.js.map +1 -1
  61. package/dist/hooks/useHistory.js +4 -3
  62. package/dist/hooks/useHistory.js.map +1 -1
  63. package/dist/routes/RebaseRoute.js +20 -30
  64. package/dist/routes/RebaseRoute.js.map +1 -1
  65. package/dist/util/navigation_utils.js +4 -3
  66. package/dist/util/navigation_utils.js.map +1 -1
  67. 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 } 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 (registry.studioConfig && registry.cmsConfig?.collectionEditor) slugs.add(\"schema\");\n return slugs;\n }, [registry.studioConfig, registry.cmsConfig?.collectionEditor]);\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,SAAS,gBAAgB,SAAS,WAAW,kBAAkB,MAAM,IAAI,QAAQ;EACrF,OAAO;CACX,GAAG,CAAC,SAAS,cAAc,SAAS,WAAW,gBAAgB,CAAC;CAIhE,MAAM,uBAAuB,cAAc;EACvC,IAAI,oBAAoB,SAAS,UAC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 {"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,MAAM,EAAE,SAAS,UAAU,gBAAgB,IAAI,EAAE,IAAI,KAAM,EAAE,SAAS,OAAO;EAE3H,OAAO,4BAA4B,QAAO,MAAK,EAAE,SAAS,UAAU,CAAC,gBAA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ACI,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"}
@@ -113,7 +113,7 @@ function StringNumberFilterField({ name, value, setValue, type, isArray, enumVal
113
113
  disabled: isNullOperation,
114
114
  placeholder: isNullOperation ? "null" : void 0,
115
115
  onChange: (evt) => {
116
- const val = type === "number" ? parseFloat(evt.target.value) : evt.target.value;
116
+ const val = evt.target.value === "" ? void 0 : type === "number" ? parseFloat(evt.target.value) : evt.target.value;
117
117
  updateFilter(operation, val);
118
118
  },
119
119
  endAdornment: internalValue !== void 0 && internalValue != null && /* @__PURE__ */ jsx(IconButton, {
@@ -129,7 +129,7 @@ function StringNumberFilterField({ name, value, setValue, type, isArray, enumVal
129
129
  disabled: isNullOperation,
130
130
  value: hasSingleValue ? String(internalValue) : "",
131
131
  onValueChange: (value) => {
132
- if (value !== "") updateFilter(operation, type === "number" ? parseInt(value) : value);
132
+ if (value !== "") updateFilter(operation, type === "number" ? parseFloat(value) : value);
133
133
  },
134
134
  endAdornment: hasSingleValue && /* @__PURE__ */ jsx(IconButton, {
135
135
  "aria-label": t("clear"),
@@ -160,7 +160,7 @@ function StringNumberFilterField({ name, value, setValue, type, isArray, enumVal
160
160
  value: Array.isArray(internalValue) ? internalValue.map((e) => String(e)) : [],
161
161
  disabled: isNullOperation,
162
162
  onValueChange: (value) => {
163
- updateFilter(operation, type === "number" ? (value ?? []).map((v) => parseInt(v)) : value);
163
+ updateFilter(operation, type === "number" ? (value ?? []).map((v) => parseFloat(v)) : value);
164
164
  },
165
165
  children: enumValues.map((enumConfig) => /* @__PURE__ */ jsx(MultiSelectItem, {
166
166
  value: String(enumConfig.id),
@@ -1 +1 @@
1
- {"version":3,"file":"StringNumberFilterField.js","names":[],"sources":["../../../../src/components/SelectableTable/filters/StringNumberFilterField.tsx"],"sourcesContent":["import React, { useState } from \"react\";\nimport { EnumValuesChip } from \"../../../preview\";\nimport {\n IconButton,\n MultiSelect,\n MultiSelectItem,\n Select,\n SelectItem,\n TextField,\n VirtualTableWhereFilterOp,\n XIcon\n} from \"@rebasepro/ui\";\nimport { EnumValueConfig } from \"@rebasepro/types\";\nimport { useTranslation } from \"@rebasepro/app\";\n\ninterface StringNumberFilterFieldProps {\n name: string,\n type: \"string\" | \"number\";\n value?: [op: VirtualTableWhereFilterOp, fieldValue: unknown];\n setValue: (value?: [op: VirtualTableWhereFilterOp, newValue: unknown]) => void;\n isArray?: boolean;\n enumValues?: EnumValueConfig[];\n title?: string;\n /**\n * Restrict the offered operators (already resolved against engine\n * capabilities and property config). When omitted, all operators this\n * field can render are offered.\n */\n operators?: readonly VirtualTableWhereFilterOp[];\n}\n\nconst operationLabels = {\n \"==\": \"==\",\n \"!=\": \"!=\",\n \">\": \">\",\n \"<\": \"<\",\n \">=\": \">=\",\n \"<=\": \"<=\",\n in: \"In\",\n \"not-in\": \"Not in\",\n \"array-contains\": \"Contains\",\n \"array-contains-any\": \"Any\",\n \"ilike\": \"Contains\",\n \"not-ilike\": \"Not contains\",\n \"is-null\": \"Is null\",\n \"is-not-null\": \"Is not null\"\n};\n\nconst multipleSelectOperations = [\"array-contains-any\", \"in\", \"not-in\"];\n\n/** Operators that match a substring, wrapped in SQL wildcards (`%value%`). */\nconst containsOperations = [\"ilike\", \"not-ilike\"];\n\n/** Strip the surrounding `%` wildcards a contains-filter adds, for display. */\nfunction unwrapContains(value: unknown): string {\n if (typeof value !== \"string\") return \"\";\n return value.replace(/^%/, \"\").replace(/%$/, \"\");\n}\n\nexport function StringNumberFilterField({\n name,\n value,\n setValue,\n type,\n isArray,\n enumValues,\n title,\n operators\n }: StringNumberFilterFieldProps) {\n const { t } = useTranslation();\n\n let possibleOperations: (keyof typeof operationLabels)[] = isArray\n ? [\"array-contains\"]\n : [\"==\", \"!=\", \">\", \"<\", \">=\", \"<=\", \"is-null\", \"is-not-null\"];\n\n // Case-insensitive substring matching is only meaningful for free-text\n // string columns (not numbers, arrays, or enums).\n if (!isArray && !enumValues && type === \"string\") {\n possibleOperations.push(\"ilike\", \"not-ilike\");\n }\n\n if (enumValues) {\n if (isArray) {\n possibleOperations.push(\"array-contains-any\");\n } else {\n possibleOperations.push(\"in\", \"not-in\");\n }\n }\n\n if (operators) {\n possibleOperations = possibleOperations.filter(op => (operators as readonly string[]).includes(op));\n }\n\n const [fieldOperation, fieldValue] = value || [possibleOperations[0], undefined];\n // Read back both the canonical null operators and the legacy `[\"==\", null]` /\n // `[\"!=\", null]` form saved by older filter presets.\n const [operation, setOperation] = useState<VirtualTableWhereFilterOp>(\n fieldOperation === \"==\" && fieldValue === null ? \"is-null\"\n : fieldOperation === \"!=\" && fieldValue === null ? \"is-not-null\"\n : fieldOperation\n );\n const [internalValue, setInternalValue] = useState<string | number | string[] | number[] | null | undefined>(\n containsOperations.includes(fieldOperation) ? unwrapContains(fieldValue) : (fieldValue as string | number | string[] | number[] | null | undefined)\n );\n\n const isNullOperation = operation === \"is-null\" || operation === \"is-not-null\";\n\n // A single picked value, `0` included: a truthiness check dropped a zero\n // id's clear button and rendered a stray \"0\" where it should have been.\n const hasSingleValue = internalValue !== undefined && internalValue !== null && !Array.isArray(internalValue);\n\n // All renderable operators were filtered out (engine/property narrowing).\n if (possibleOperations.length === 0) return null;\n\n function updateFilter(op: VirtualTableWhereFilterOp, val: string | number | string[] | number[] | null | undefined) {\n // Null-testing operators ignore their value.\n if (op === \"is-null\" || op === \"is-not-null\") {\n setOperation(op);\n setInternalValue(null);\n setValue([op, null]);\n return;\n }\n\n // Substring matching: keep the raw text in the field, emit it wrapped\n // in SQL wildcards so the backend runs `column ILIKE '%value%'`.\n if (op === \"ilike\" || op === \"not-ilike\") {\n const raw = typeof val === \"string\" ? val : \"\";\n setOperation(op);\n setInternalValue(raw);\n if (raw.length > 0) {\n setValue([op, `%${raw}%`]);\n } else {\n setValue(undefined);\n }\n return;\n }\n\n let newValue = val;\n const prevOpIsArray = multipleSelectOperations.includes(operation);\n const newOpIsArray = multipleSelectOperations.includes(op);\n if (prevOpIsArray !== newOpIsArray) {\n if (newOpIsArray) {\n if (typeof val === \"string\") newValue = [val];\n else if (typeof val === \"number\") newValue = [val];\n else newValue = [];\n } else {\n newValue = undefined;\n }\n }\n\n if (typeof newValue === \"number\" && isNaN(newValue))\n newValue = undefined;\n\n setOperation(op);\n setInternalValue(newValue);\n\n const hasNewValue = newValue !== null && Array.isArray(newValue)\n ? newValue.length > 0\n : newValue !== undefined;\n if (op && hasNewValue) {\n setValue(\n [op, newValue]\n );\n } else {\n setValue(\n undefined\n );\n }\n }\n\n const multiple = multipleSelectOperations.includes(operation);\n\n return (\n\n <div className=\"flex w-full\">\n <div className={\"w-[100px]\"}>\n <Select value={operation}\n size={\"medium\"}\n fullWidth={true}\n position={\"item-aligned\"}\n onValueChange={(value) => {\n updateFilter(value as VirtualTableWhereFilterOp, internalValue);\n }}\n renderValue={(op) => operationLabels[op as keyof typeof operationLabels]}>\n {possibleOperations.map((op) => (\n <SelectItem key={op} value={op}>\n {operationLabels[op]}\n </SelectItem>\n ))}\n </Select>\n </div>\n\n <div className=\"grow ml-2 flex flex-col gap-2\">\n\n {!enumValues && <TextField\n size={\"medium\"}\n aria-label={`${title ?? name} filter value`}\n type={type === \"number\" ? \"number\" : undefined}\n value={internalValue !== undefined && internalValue != null ? String(internalValue) : \"\"}\n disabled={isNullOperation}\n placeholder={isNullOperation ? \"null\" : undefined}\n onChange={(evt) => {\n const val = type === \"number\"\n ? parseFloat(evt.target.value)\n : evt.target.value;\n updateFilter(operation, val);\n }}\n endAdornment={internalValue !== undefined && internalValue != null && <IconButton aria-label={t(\"clear\")}\n onClick={(e) => updateFilter(operation, undefined)}>\n <XIcon/>\n </IconButton>}\n />}\n\n {enumValues && !multiple &&\n <Select\n size={\"medium\"}\n position={\"item-aligned\"}\n fullWidth={true}\n disabled={isNullOperation}\n // As a string whatever the enum's type: a number enum\n // holds the picked id as a number, which the select\n // read as no value at all and showed blank.\n value={hasSingleValue ? String(internalValue) : \"\"}\n onValueChange={(value) => {\n if (value !== \"\")\n updateFilter(operation, type === \"number\" ? parseInt(value as string) : value as string)\n }}\n endAdornment={hasSingleValue && <IconButton aria-label={t(\"clear\")}\n onClick={(e) => updateFilter(operation, undefined)}>\n <XIcon/>\n </IconButton>}\n renderValue={(enumKey) => {\n if (enumKey === null)\n return t(\"filter_for_null_values\");\n if (enumKey === undefined)\n return null;\n\n return <EnumValuesChip\n key={`select_value_${name}_${enumKey}`}\n enumKey={enumKey}\n enumValues={enumValues}\n size={\"small\"}/>;\n }}>\n {enumValues.map((enumConfig) => (\n <SelectItem key={`select_item_${name}_${enumConfig.id}`}\n value={String(enumConfig.id)}\n textValue={enumConfig.label}>\n <EnumValuesChip\n enumKey={String(enumConfig.id)}\n enumValues={enumValues}\n size={\"small\"}/>\n </SelectItem>\n ))}\n </Select>\n }\n\n {enumValues && multiple &&\n <MultiSelect\n size={\"medium\"}\n value={Array.isArray(internalValue) ? internalValue.map(e => String(e)) : []}\n disabled={isNullOperation}\n onValueChange={(value) => {\n updateFilter(operation, type === \"number\" ? (value ?? []).map(v => parseInt(v)) : value)\n }}\n >\n {enumValues.map((enumConfig) => (\n <MultiSelectItem key={`select_value_${name}_${enumConfig.id}`}\n value={String(enumConfig.id)}>\n <EnumValuesChip\n enumKey={String(enumConfig.id)}\n enumValues={enumValues}\n size={\"small\"}/>\n </MultiSelectItem>\n ))}\n </MultiSelect>\n }\n\n </div>\n\n </div>\n );\n\n}\n"],"mappings":";;;;;;AA+BA,IAAM,kBAAkB;CACpB,MAAM;CACN,MAAM;CACN,KAAK;CACL,KAAK;CACL,MAAM;CACN,MAAM;CACN,IAAI;CACJ,UAAU;CACV,kBAAkB;CAClB,sBAAsB;CACtB,SAAS;CACT,aAAa;CACb,WAAW;CACX,eAAe;AACnB;AAEA,IAAM,2BAA2B;CAAC;CAAsB;CAAM;AAAQ;;AAGtE,IAAM,qBAAqB,CAAC,SAAS,WAAW;;AAGhD,SAAS,eAAe,OAAwB;CAC5C,IAAI,OAAO,UAAU,UAAU,OAAO;CACtC,OAAO,MAAM,QAAQ,MAAM,EAAE,CAAC,CAAC,QAAQ,MAAM,EAAE;AACnD;AAEA,SAAgB,wBAAwB,EACI,MACA,OACA,UACA,MACA,SACA,YACA,OACA,aAC6B;CACrE,MAAM,EAAE,MAAM,eAAe;CAE7B,IAAI,qBAAuD,UACrD,CAAC,gBAAgB,IACjB;EAAC;EAAM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AAO,WAAW,EAAE;OACjB;OACZ,MAAM;MAAS,CAAA;KACN,GANK,gBAAgB,KAAK,GAAG,WAAW,IAMxC,CACpB;IACQ,CAAA;GAGhB;IAEJ;;AAGb"}
1
+ {"version":3,"file":"StringNumberFilterField.js","names":[],"sources":["../../../../src/components/SelectableTable/filters/StringNumberFilterField.tsx"],"sourcesContent":["import React, { useState } from \"react\";\nimport { EnumValuesChip } from \"../../../preview\";\nimport {\n IconButton,\n MultiSelect,\n MultiSelectItem,\n Select,\n SelectItem,\n TextField,\n VirtualTableWhereFilterOp,\n XIcon\n} from \"@rebasepro/ui\";\nimport { EnumValueConfig } from \"@rebasepro/types\";\nimport { useTranslation } from \"@rebasepro/app\";\n\ninterface StringNumberFilterFieldProps {\n name: string,\n type: \"string\" | \"number\";\n value?: [op: VirtualTableWhereFilterOp, fieldValue: unknown];\n setValue: (value?: [op: VirtualTableWhereFilterOp, newValue: unknown]) => void;\n isArray?: boolean;\n enumValues?: EnumValueConfig[];\n title?: string;\n /**\n * Restrict the offered operators (already resolved against engine\n * capabilities and property config). When omitted, all operators this\n * field can render are offered.\n */\n operators?: readonly VirtualTableWhereFilterOp[];\n}\n\nconst operationLabels = {\n \"==\": \"==\",\n \"!=\": \"!=\",\n \">\": \">\",\n \"<\": \"<\",\n \">=\": \">=\",\n \"<=\": \"<=\",\n in: \"In\",\n \"not-in\": \"Not in\",\n \"array-contains\": \"Contains\",\n \"array-contains-any\": \"Any\",\n \"ilike\": \"Contains\",\n \"not-ilike\": \"Not contains\",\n \"is-null\": \"Is null\",\n \"is-not-null\": \"Is not null\"\n};\n\nconst multipleSelectOperations = [\"array-contains-any\", \"in\", \"not-in\"];\n\n/** Operators that match a substring, wrapped in SQL wildcards (`%value%`). */\nconst containsOperations = [\"ilike\", \"not-ilike\"];\n\n/** Strip the surrounding `%` wildcards a contains-filter adds, for display. */\nfunction unwrapContains(value: unknown): string {\n if (typeof value !== \"string\") return \"\";\n return value.replace(/^%/, \"\").replace(/%$/, \"\");\n}\n\nexport function StringNumberFilterField({\n name,\n value,\n setValue,\n type,\n isArray,\n enumValues,\n title,\n operators\n }: StringNumberFilterFieldProps) {\n const { t } = useTranslation();\n\n let possibleOperations: (keyof typeof operationLabels)[] = isArray\n ? [\"array-contains\"]\n : [\"==\", \"!=\", \">\", \"<\", \">=\", \"<=\", \"is-null\", \"is-not-null\"];\n\n // Case-insensitive substring matching is only meaningful for free-text\n // string columns (not numbers, arrays, or enums).\n if (!isArray && !enumValues && type === \"string\") {\n possibleOperations.push(\"ilike\", \"not-ilike\");\n }\n\n if (enumValues) {\n if (isArray) {\n possibleOperations.push(\"array-contains-any\");\n } else {\n possibleOperations.push(\"in\", \"not-in\");\n }\n }\n\n if (operators) {\n possibleOperations = possibleOperations.filter(op => (operators as readonly string[]).includes(op));\n }\n\n const [fieldOperation, fieldValue] = value || [possibleOperations[0], undefined];\n // Read back both the canonical null operators and the legacy `[\"==\", null]` /\n // `[\"!=\", null]` form saved by older filter presets.\n const [operation, setOperation] = useState<VirtualTableWhereFilterOp>(\n fieldOperation === \"==\" && fieldValue === null ? \"is-null\"\n : fieldOperation === \"!=\" && fieldValue === null ? \"is-not-null\"\n : fieldOperation\n );\n const [internalValue, setInternalValue] = useState<string | number | string[] | number[] | null | undefined>(\n containsOperations.includes(fieldOperation) ? unwrapContains(fieldValue) : (fieldValue as string | number | string[] | number[] | null | undefined)\n );\n\n const isNullOperation = operation === \"is-null\" || operation === \"is-not-null\";\n\n // A single picked value, `0` included: a truthiness check dropped a zero\n // id's clear button and rendered a stray \"0\" where it should have been.\n const hasSingleValue = internalValue !== undefined && internalValue !== null && !Array.isArray(internalValue);\n\n // All renderable operators were filtered out (engine/property narrowing).\n if (possibleOperations.length === 0) return null;\n\n function updateFilter(op: VirtualTableWhereFilterOp, val: string | number | string[] | number[] | null | undefined) {\n // Null-testing operators ignore their value.\n if (op === \"is-null\" || op === \"is-not-null\") {\n setOperation(op);\n setInternalValue(null);\n setValue([op, null]);\n return;\n }\n\n // Substring matching: keep the raw text in the field, emit it wrapped\n // in SQL wildcards so the backend runs `column ILIKE '%value%'`.\n if (op === \"ilike\" || op === \"not-ilike\") {\n const raw = typeof val === \"string\" ? val : \"\";\n setOperation(op);\n setInternalValue(raw);\n if (raw.length > 0) {\n setValue([op, `%${raw}%`]);\n } else {\n setValue(undefined);\n }\n return;\n }\n\n let newValue = val;\n const prevOpIsArray = multipleSelectOperations.includes(operation);\n const newOpIsArray = multipleSelectOperations.includes(op);\n if (prevOpIsArray !== newOpIsArray) {\n if (newOpIsArray) {\n if (typeof val === \"string\") newValue = [val];\n else if (typeof val === \"number\") newValue = [val];\n else newValue = [];\n } else {\n newValue = undefined;\n }\n }\n\n if (typeof newValue === \"number\" && isNaN(newValue))\n newValue = undefined;\n\n setOperation(op);\n setInternalValue(newValue);\n\n const hasNewValue = newValue !== null && Array.isArray(newValue)\n ? newValue.length > 0\n : newValue !== undefined;\n if (op && hasNewValue) {\n setValue(\n [op, newValue]\n );\n } else {\n setValue(\n undefined\n );\n }\n }\n\n const multiple = multipleSelectOperations.includes(operation);\n\n return (\n\n <div className=\"flex w-full\">\n <div className={\"w-[100px]\"}>\n <Select value={operation}\n size={\"medium\"}\n fullWidth={true}\n position={\"item-aligned\"}\n onValueChange={(value) => {\n updateFilter(value as VirtualTableWhereFilterOp, internalValue);\n }}\n renderValue={(op) => operationLabels[op as keyof typeof operationLabels]}>\n {possibleOperations.map((op) => (\n <SelectItem key={op} value={op}>\n {operationLabels[op]}\n </SelectItem>\n ))}\n </Select>\n </div>\n\n <div className=\"grow ml-2 flex flex-col gap-2\">\n\n {!enumValues && <TextField\n size={\"medium\"}\n aria-label={`${title ?? name} filter value`}\n type={type === \"number\" ? \"number\" : undefined}\n value={internalValue !== undefined && internalValue != null ? String(internalValue) : \"\"}\n disabled={isNullOperation}\n placeholder={isNullOperation ? \"null\" : undefined}\n onChange={(evt) => {\n // Text typed and deleted again is no filter, not a\n // filter for the empty string.\n const val = evt.target.value === \"\"\n ? undefined\n : type === \"number\"\n ? parseFloat(evt.target.value)\n : evt.target.value;\n updateFilter(operation, val);\n }}\n endAdornment={internalValue !== undefined && internalValue != null && <IconButton aria-label={t(\"clear\")}\n onClick={(e) => updateFilter(operation, undefined)}>\n <XIcon/>\n </IconButton>}\n />}\n\n {enumValues && !multiple &&\n <Select\n size={\"medium\"}\n position={\"item-aligned\"}\n fullWidth={true}\n disabled={isNullOperation}\n // As a string whatever the enum's type: a number enum\n // holds the picked id as a number, which the select\n // read as no value at all and showed blank.\n value={hasSingleValue ? String(internalValue) : \"\"}\n onValueChange={(value) => {\n if (value !== \"\")\n updateFilter(operation, type === \"number\" ? parseFloat(value as string) : value as string)\n }}\n endAdornment={hasSingleValue && <IconButton aria-label={t(\"clear\")}\n onClick={(e) => updateFilter(operation, undefined)}>\n <XIcon/>\n </IconButton>}\n renderValue={(enumKey) => {\n if (enumKey === null)\n return t(\"filter_for_null_values\");\n if (enumKey === undefined)\n return null;\n\n return <EnumValuesChip\n key={`select_value_${name}_${enumKey}`}\n enumKey={enumKey}\n enumValues={enumValues}\n size={\"small\"}/>;\n }}>\n {enumValues.map((enumConfig) => (\n <SelectItem key={`select_item_${name}_${enumConfig.id}`}\n value={String(enumConfig.id)}\n textValue={enumConfig.label}>\n <EnumValuesChip\n enumKey={String(enumConfig.id)}\n enumValues={enumValues}\n size={\"small\"}/>\n </SelectItem>\n ))}\n </Select>\n }\n\n {enumValues && multiple &&\n <MultiSelect\n size={\"medium\"}\n value={Array.isArray(internalValue) ? internalValue.map(e => String(e)) : []}\n disabled={isNullOperation}\n onValueChange={(value) => {\n updateFilter(operation, type === \"number\" ? (value ?? []).map(v => parseFloat(v)) : value)\n }}\n >\n {enumValues.map((enumConfig) => (\n <MultiSelectItem key={`select_value_${name}_${enumConfig.id}`}\n value={String(enumConfig.id)}>\n <EnumValuesChip\n enumKey={String(enumConfig.id)}\n enumValues={enumValues}\n size={\"small\"}/>\n </MultiSelectItem>\n ))}\n </MultiSelect>\n }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;OAEM;OACG;OACZ,MAAM;MAAS,GAHV,gBAAgB,KAAK,GAAG,SAGd;KACvB;eACC,WAAW,KAAK,eACb,oBAAC,YAAD;MACY,OAAO,OAAO,WAAW,EAAE;MAC3B,WAAW,WAAW;gBAC9B,oBAAC,gBAAD;OACI,SAAS,OAAO,WAAW,EAAE;OACjB;OACZ,MAAM;MAAS,CAAA;KACX,GAPK,eAAe,KAAK,GAAG,WAAW,IAOvC,CACf;IACG,CAAA;IAGX,cAAc,YACX,oBAAC,aAAD;KACI,MAAM;KACN,OAAO,MAAM,QAAQ,aAAa,IAAI,cAAc,KAAI,MAAK,OAAO,CAAC,CAAC,IAAI,CAAC;KAC3E,UAAU;KACV,gBAAgB,UAAU;MACtB,aAAa,WAAW,SAAS,YAAY,SAAS,CAAC,EAAA,CAAG,KAAI,MAAK,WAAW,CAAC,CAAC,IAAI,KAAK;KAC7F;eAEC,WAAW,KAAK,eACb,oBAAC,iBAAD;MACiB,OAAO,OAAO,WAAW,EAAE;gBACxC,oBAAC,gBAAD;OACI,SAAS,OAAO,WAAW,EAAE;OACjB;OACZ,MAAM;MAAS,CAAA;KACN,GANK,gBAAgB,KAAK,GAAG,WAAW,IAMxC,CACpB;IACQ,CAAA;GAGhB;IAEJ;;AAGb"}
@@ -7,6 +7,7 @@ import { DetailViewBinding } from "./DetailViewBinding.js";
7
7
  import { useCallback, useEffect, useMemo, useRef, useState } from "react";
8
8
  import { Fragment, jsx, jsxs } from "react/jsx-runtime";
9
9
  import { ErrorBoundary, IconButton, Maximize2Icon, XIcon } from "@rebasepro/ui";
10
+ import { hasEntityId } from "@rebasepro/common";
10
11
  import { resolveDefaultSelectedView, useComponentOverride, useTranslation } from "@rebasepro/app";
11
12
  import { useNavigate } from "react-router";
12
13
  //#region src/components/SidePanelBinding.tsx
@@ -94,12 +95,12 @@ function SidePanelBinding(props) {
94
95
  const isDialogMode = collection?.openEntityMode === "dialog";
95
96
  const [editInDialog, setEditInDialog] = useState(false);
96
97
  const showEditInPanel = isDialogMode ? editInDialog : selectedTab === "edit";
97
- const isDetailMode = collection?.defaultEntityAction === "view" && !showEditInPanel && Boolean(entityId);
98
+ const isDetailMode = collection?.defaultEntityAction === "view" && !showEditInPanel && hasEntityId(entityId);
98
99
  useEffect(() => {
99
100
  setEditInDialog(false);
100
101
  }, [entityId]);
101
102
  const openEditView = useCallback(() => {
102
- if (isDialogMode || !entityId) {
103
+ if (isDialogMode || !hasEntityId(entityId)) {
103
104
  setEditInDialog(true);
104
105
  return;
105
106
  }
@@ -118,7 +119,7 @@ function SidePanelBinding(props) {
118
119
  sidePanelController
119
120
  ]);
120
121
  const closeEditView = useCallback(() => {
121
- if (isDialogMode || !entityId) {
122
+ if (isDialogMode || !hasEntityId(entityId)) {
122
123
  setEditInDialog(false);
123
124
  return;
124
125
  }
@@ -143,7 +144,7 @@ function SidePanelBinding(props) {
143
144
  useEffect(() => {
144
145
  if (hasCorrectedDefaultView.current) return;
145
146
  if (selectedTab) return;
146
- if (!entityId || !collection?.defaultSelectedView) return;
147
+ if (!hasEntityId(entityId) || !collection?.defaultSelectedView) return;
147
148
  const effectiveDefault = resolveDefaultSelectedView(collection.defaultSelectedView, {
148
149
  status: "existing",
149
150
  entityId
@@ -223,7 +224,7 @@ function SidePanelBinding(props) {
223
224
  className: "self-center",
224
225
  size: "small",
225
226
  onClick: () => {
226
- if (entityId) {
227
+ if (hasEntityId(entityId)) {
227
228
  const fullScreenUrl = urlController.buildUrlCollectionPath(`${path}/${entityId}`);
228
229
  navigate(fullScreenUrl, { state: null });
229
230
  }
@@ -258,7 +259,7 @@ function SidePanelBinding(props) {
258
259
  carryEdit?.();
259
260
  setBlocked(false);
260
261
  setBlockedNavigationMessage(void 0);
261
- if (entityId) {
262
+ if (hasEntityId(entityId)) {
262
263
  const fullScreenUrl = urlController.buildUrlCollectionPath(`${path}/${entityId}`);
263
264
  navigate(fullScreenUrl, { state: null });
264
265
  } else {
@@ -1 +1 @@
1
- {"version":3,"file":"SidePanelBinding.js","names":[],"sources":["../../src/components/SidePanelBinding.tsx"],"sourcesContent":["\nimport type { SidePanelBindingProps, AdminCollection } from \"@rebasepro/cms-types\";\nimport React, { useCallback, useEffect, useMemo, useRef, useState } from \"react\";\n\nimport type { OnUpdateParams } from \"../types/components/EntityFormProps\";\nimport { ErrorBoundary } from \"@rebasepro/ui\";\nimport { IconButton, Maximize2Icon, XIcon } from \"@rebasepro/ui\";\nimport { EditViewBinding } from \"./EditViewBinding\";\nimport { DetailViewBinding } from \"./DetailViewBinding\";\nimport { useSideDialogContext } from \"./SideDialogs\";\nimport { useNavigate } from \"react-router\";\nimport { useComponentOverride, useTranslation } from \"@rebasepro/app\";\nimport { useCollectionRegistryController } from \"../hooks/navigation/contexts/CollectionRegistryContext\";\nimport { useSidePanel } from \"../hooks/useSidePanel\";\nimport { useUrlController } from \"../hooks/navigation/contexts/UrlContext\";\nimport { resolveDefaultSelectedView } from \"@rebasepro/app\";\n\n/**\n * This is the component in charge of rendering the side dialog used\n * for editing entities. Use the {@link useSidePanel} to open\n * and control the dialogs.\n * This component needs a parent {@link Rebase}\n * {@link useSidePanel}\n * @group Components\n */\nexport function SidePanelBinding(props: SidePanelBindingProps) {\n const { t } = useTranslation();\n\n const {\n allowFullScreen = true,\n path,\n entityId,\n selectedTab,\n formProps\n } = props;\n\n const ResolvedDetailView = useComponentOverride(\"DetailView\", DetailViewBinding);\n\n const {\n blocked,\n setBlocked,\n setBlockedNavigationMessage,\n close\n } = useSideDialogContext();\n\n const navigate = useNavigate();\n\n const sidePanelController = useSidePanel();\n const collectionRegistryController = useCollectionRegistryController();\n const sideDialogsController = useSideDialogContext();\n const urlController = useUrlController();\n\n /**\n * The X in the identity bar.\n *\n * Unforced, so it stops at the same unsaved-changes prompt that Escape and\n * a click outside already do. It used to clear `blocked` and force the\n * close, which made the one control actually labelled \"close\" the only way\n * out of the panel that dropped an edit without asking.\n *\n * `props.onClose` is not called here: the panel carries the same callback\n * (see `propsToSidePanel`) and {@link SideDialogs} fires it once the panel\n * really closes — which is after the prompt, not before it.\n */\n const onClose = () => {\n close();\n }\n\n /**\n * Closing because the record was just saved, which is the one case that has\n * to force. `blocked` is driven by an effect on the form's dirty flag and is\n * still true for a tick after a save; prompting about unsaved changes here\n * would be asking about values that are already on the server.\n */\n const closeAfterSave = () => {\n setBlocked(false);\n close(true);\n }\n\n /**\n * The panel's response to a save, and the one place it decides where the\n * panel goes next.\n *\n * Exactly **one** panel navigation is raised here. These branches used to\n * run independently — a `replace` onto the saved record's address *and* a\n * close — and because the last navigation is the one that survives, which\n * of them the user got was settled by statement order rather than by\n * intent. Closing wins by construction now: moving a panel to a new address\n * it is about to leave is work whose only effect is to fight the close.\n *\n * `props.onUpdate` runs last for the same reason. It belongs to whoever\n * opened the panel and it is free to navigate — the reference picker's\n * selects the record and closes the picker — so the opener's intent should\n * be the final word, not something this panel overwrites on its way out.\n */\n const onUpdate = (params: OnUpdateParams) => {\n setEditInDialog(false);\n\n // Either \"save and close\" was clicked, or the opener asked for it when\n // it opened the panel.\n const closeRequested = sideDialogsController.pendingClose || props.closeOnSave;\n\n if (closeRequested) {\n sideDialogsController.setPendingClose(false);\n closeAfterSave();\n } else if (params.status !== \"existing\") {\n // A newly created entity replaces the panel with its own address,\n // which already leaves the edit view behind.\n sidePanelController.replace({\n path: params.path,\n entityId: params.entityId,\n selectedTab: params.selectedTab,\n updateUrl: collection?.openEntityMode !== \"dialog\",\n collection: params.collection\n });\n } else {\n closeEditView();\n }\n\n props.onUpdate?.(params);\n }\n\n const parentCollectionSlugs = useMemo(() => {\n return collectionRegistryController.getParentCollectionSlugs(path);\n }, [collectionRegistryController, path]);\n\n const parentEntityIds = useMemo(() => {\n return collectionRegistryController.getParentEntityIds(path);\n }, [collectionRegistryController, path]);\n\n const collection = collectionRegistryController.getCollection(path) ?? props.collection;\n\n // Dialog mode deliberately stays out of the URL, so it is the only case that\n // needs local edit state. Everywhere else `edit` is a path segment, which\n // keeps refresh and the back button working the same way they do in split.\n const isDialogMode = collection?.openEntityMode === \"dialog\";\n const [editInDialog, setEditInDialog] = useState(false);\n const showEditInPanel = isDialogMode ? editInDialog : selectedTab === \"edit\";\n const isDetailMode = collection?.defaultEntityAction === \"view\" && !showEditInPanel && Boolean(entityId);\n\n // Reset edit mode when switching entities\n useEffect(() => {\n setEditInDialog(false);\n }, [entityId]);\n\n const openEditView = useCallback(() => {\n if (isDialogMode || !entityId) {\n setEditInDialog(true);\n return;\n }\n sidePanelController.replace({\n path,\n entityId,\n selectedTab: \"edit\",\n updateUrl: true,\n collection\n });\n }, [isDialogMode, entityId, path, collection, sidePanelController]);\n\n const closeEditView = useCallback(() => {\n if (isDialogMode || !entityId) {\n setEditInDialog(false);\n return;\n }\n sidePanelController.replace({\n path,\n entityId,\n selectedTab: undefined,\n updateUrl: true,\n collection\n });\n }, [isDialogMode, entityId, path, collection, sidePanelController]);\n\n // One-time correction: when the side panel opens without the correct\n // selectedTab but the resolved collection (from the registry) has a\n // defaultSelectedView, update the panel width and URL to match.\n // This handles cases where defaultSelectedView is set via the collection\n // editor / Studio and is not available on the collection object the\n // caller passed to sidePanelController.open().\n const hasCorrectedDefaultView = useRef(false);\n useEffect(() => {\n hasCorrectedDefaultView.current = false;\n }, [entityId]);\n useEffect(() => {\n if (hasCorrectedDefaultView.current) return;\n if (selectedTab) return; // Already has a tab — no correction needed\n if (!entityId || !collection?.defaultSelectedView) return;\n\n const effectiveDefault = resolveDefaultSelectedView(\n collection.defaultSelectedView,\n { status: \"existing\",\nentityId }\n );\n if (effectiveDefault && effectiveDefault !== \"edit\") {\n hasCorrectedDefaultView.current = true;\n sidePanelController.replace({\n path,\n entityId,\n selectedTab: effectiveDefault,\n updateUrl: collection.openEntityMode !== \"dialog\",\n collection\n });\n }\n }, [selectedTab, entityId, collection, path, sidePanelController]);\n\n // Note: beforeunload is handled by useUnsavedChangesDialog in SideDialogView,\n // which listens to the same `blocked` state via SideDialogContext.\n\n const onValuesModified = useCallback((modified: boolean) => {\n setBlockedNavigationMessage(modified\n ? <> You have unsaved changes in this <b>{collection?.singularName ?? collection?.name}</b>.</>\n : undefined)\n setBlocked(modified);\n }, [collection?.name, setBlocked, setBlockedNavigationMessage]);\n\n if (!props || !collection) {\n return <div className={\"w-full\"}/>;\n }\n\n const closeButton = (\n <IconButton aria-label={t(\"close\")}\n className=\"self-center\"\n size={\"small\"}\n onClick={onClose}>\n <XIcon/>\n </IconButton>\n );\n\n /**\n * Where the panel's own two controls sit, which is not the same question in\n * the two layouts that have them.\n *\n * A **side panel** slides in over the list from the right, and its leading\n * edge is the seam between the two. Close belongs on that seam — it points\n * back at the thing still visible behind it — and it is where the eye\n * already is, because the breadcrumb starts there.\n *\n * A **dialog** has no seam and nothing behind it to point at. It is a box\n * centred on a dimmed screen, and every box like it on every platform is\n * dismissed from its top-right corner. Close was sitting at the far left\n * of the bar, a full dialog's width from the expand button it belongs\n * beside, in the one corner that means \"back\" in a layout with no back.\n *\n * So in a dialog the two travel together at the trailing edge, expand then\n * close: the window controls, after the record's actions and its overflow\n * menu, in the corner a dialog is closed from.\n */\n const barActionsStart = isDialogMode ? undefined : closeButton;\n\n const windowControls = (expandButton: React.ReactNode) => (\n <div className=\"flex gap-1 items-center\">\n {expandButton}\n {isDialogMode && closeButton}\n </div>\n );\n\n return (\n <>\n <ErrorBoundary>\n {isDetailMode\n ? <ResolvedDetailView\n path={path}\n layout={collection?.openEntityMode === \"dialog\" ? \"dialog\" : \"side_panel\"}\n collection={collection as AdminCollection}\n entityId={entityId!}\n parentCollectionSlugs={parentCollectionSlugs}\n parentEntityIds={parentEntityIds}\n onEditClick={openEditView}\n barActionsStart={barActionsStart}\n barActions={() => windowControls(\n allowFullScreen && <IconButton aria-label={t(\"full_screen\")}\n className=\"self-center\"\n size={\"small\"}\n onClick={() => {\n if (entityId) {\n const fullScreenUrl = urlController.buildUrlCollectionPath(`${path}/${entityId}`);\n navigate(fullScreenUrl, { state: null });\n }\n }}>\n <Maximize2Icon/>\n </IconButton>\n )}\n onTabChange={({\n entityId: tabEntityId,\n selectedTab,\n collection: paramCollection\n }) => {\n if (collection?.openEntityMode === \"dialog\" || paramCollection?.openEntityMode === \"dialog\") {\n return;\n }\n if (tabEntityId) {\n sidePanelController.replace({\n path,\n entityId: tabEntityId,\n selectedTab,\n updateUrl: true,\n collection: paramCollection ?? collection\n });\n }\n }}\n />\n : <EditViewBinding\n {...props}\n layout={collection?.openEntityMode === \"dialog\" ? \"dialog\" : \"side_panel\"}\n collection={collection as AdminCollection}\n parentCollectionSlugs={parentCollectionSlugs} parentEntityIds={parentEntityIds}\n onValuesModified={onValuesModified}\n onSaved={onUpdate}\n navigateBack={closeEditView}\n barActionsStart={barActionsStart}\n barActions={({ carryEdit }) => windowControls(\n allowFullScreen && <IconButton aria-label={t(\"full_screen\")}\n className=\"self-center\"\n size={\"small\"}\n onClick={() => {\n // The form's own handoff, rather than a second\n // copy of the rules for it here: only an edit in\n // progress is worth carrying (a clean record\n // stashed anyway arrived announcing unsaved\n // changes to someone who had only looked at it),\n // and only the fields that were edited (carrying\n // the whole record marked every field touched).\n carryEdit?.();\n setBlocked(false);\n setBlockedNavigationMessage(undefined);\n if (entityId) {\n const fullScreenUrl = urlController.buildUrlCollectionPath(`${path}/${entityId}`);\n navigate(fullScreenUrl, { state: null });\n } else {\n const fullScreenUrl = urlController.buildUrlCollectionPath(path);\n navigate(fullScreenUrl + \"#new\", { state: null });\n }\n }}>\n <Maximize2Icon/>\n </IconButton>\n )}\n onTabChange={({\n entityId: tabEntityId,\n selectedTab,\n collection: paramCollection\n }) => {\n if (collection?.openEntityMode === \"dialog\" || paramCollection?.openEntityMode === \"dialog\") {\n return;\n }\n if (tabEntityId) {\n sidePanelController.replace({\n path,\n entityId: tabEntityId,\n selectedTab,\n updateUrl: true,\n collection: paramCollection ?? collection\n });\n }\n }}\n formProps={formProps}\n />\n }\n </ErrorBoundary>\n\n </>\n );\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAyBA,SAAgB,iBAAiB,OA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a;GACtD,WAAU;GACV,MAAM;GACN,eAAe;IAQX,YAAY;IACZ,WAAW,KAAK;IAChB,4BAA4B,KAAA,CAAS;IACrC,IAAI,UAAU;KACV,MAAM,gBAAgB,cAAc,uBAAuB,GAAG,KAAK,GAAG,UAAU;KAChF,SAAS,eAAe,EAAE,OAAO,KAAK,CAAC;IAC3C,OAAO;KACH,MAAM,gBAAgB,cAAc,uBAAuB,IAAI;KAC/D,SAAS,gBAAgB,QAAQ,EAAE,OAAO,KAAK,CAAC;IACpD;GACJ;aACA,oBAAC,eAAD,CAAe,CAAA;EACP,CAAA,CAChB;EACA,cAAc,EACV,UAAU,aACV,aACA,YAAY,sBACV;GACF,IAAI,YAAY,mBAAmB,YAAY,iBAAiB,mBAAmB,UAC/E;GAEJ,IAAI,aACA,oBAAoB,QAAQ;IACxB;IACA,UAAU;IACV;IACA,WAAW;IACX,YAAY,mBAAmB;GACnC,CAAC;EAET;EACW;CACd,CAAA,EAEM,CAAA,EAEjB,CAAA;AAEV"}
1
+ {"version":3,"file":"SidePanelBinding.js","names":[],"sources":["../../src/components/SidePanelBinding.tsx"],"sourcesContent":["\nimport type { SidePanelBindingProps, AdminCollection } from \"@rebasepro/cms-types\";\nimport { hasEntityId } from \"@rebasepro/common\";\nimport React, { useCallback, useEffect, useMemo, useRef, useState } from \"react\";\n\nimport type { OnUpdateParams } from \"../types/components/EntityFormProps\";\nimport { ErrorBoundary } from \"@rebasepro/ui\";\nimport { IconButton, Maximize2Icon, XIcon } from \"@rebasepro/ui\";\nimport { EditViewBinding } from \"./EditViewBinding\";\nimport { DetailViewBinding } from \"./DetailViewBinding\";\nimport { useSideDialogContext } from \"./SideDialogs\";\nimport { useNavigate } from \"react-router\";\nimport { useComponentOverride, useTranslation } from \"@rebasepro/app\";\nimport { useCollectionRegistryController } from \"../hooks/navigation/contexts/CollectionRegistryContext\";\nimport { useSidePanel } from \"../hooks/useSidePanel\";\nimport { useUrlController } from \"../hooks/navigation/contexts/UrlContext\";\nimport { resolveDefaultSelectedView } from \"@rebasepro/app\";\n\n/**\n * This is the component in charge of rendering the side dialog used\n * for editing entities. Use the {@link useSidePanel} to open\n * and control the dialogs.\n * This component needs a parent {@link Rebase}\n * {@link useSidePanel}\n * @group Components\n */\nexport function SidePanelBinding(props: SidePanelBindingProps) {\n const { t } = useTranslation();\n\n const {\n allowFullScreen = true,\n path,\n entityId,\n selectedTab,\n formProps\n } = props;\n\n const ResolvedDetailView = useComponentOverride(\"DetailView\", DetailViewBinding);\n\n const {\n blocked,\n setBlocked,\n setBlockedNavigationMessage,\n close\n } = useSideDialogContext();\n\n const navigate = useNavigate();\n\n const sidePanelController = useSidePanel();\n const collectionRegistryController = useCollectionRegistryController();\n const sideDialogsController = useSideDialogContext();\n const urlController = useUrlController();\n\n /**\n * The X in the identity bar.\n *\n * Unforced, so it stops at the same unsaved-changes prompt that Escape and\n * a click outside already do. It used to clear `blocked` and force the\n * close, which made the one control actually labelled \"close\" the only way\n * out of the panel that dropped an edit without asking.\n *\n * `props.onClose` is not called here: the panel carries the same callback\n * (see `propsToSidePanel`) and {@link SideDialogs} fires it once the panel\n * really closes — which is after the prompt, not before it.\n */\n const onClose = () => {\n close();\n }\n\n /**\n * Closing because the record was just saved, which is the one case that has\n * to force. `blocked` is driven by an effect on the form's dirty flag and is\n * still true for a tick after a save; prompting about unsaved changes here\n * would be asking about values that are already on the server.\n */\n const closeAfterSave = () => {\n setBlocked(false);\n close(true);\n }\n\n /**\n * The panel's response to a save, and the one place it decides where the\n * panel goes next.\n *\n * Exactly **one** panel navigation is raised here. These branches used to\n * run independently — a `replace` onto the saved record's address *and* a\n * close — and because the last navigation is the one that survives, which\n * of them the user got was settled by statement order rather than by\n * intent. Closing wins by construction now: moving a panel to a new address\n * it is about to leave is work whose only effect is to fight the close.\n *\n * `props.onUpdate` runs last for the same reason. It belongs to whoever\n * opened the panel and it is free to navigate — the reference picker's\n * selects the record and closes the picker — so the opener's intent should\n * be the final word, not something this panel overwrites on its way out.\n */\n const onUpdate = (params: OnUpdateParams) => {\n setEditInDialog(false);\n\n // Either \"save and close\" was clicked, or the opener asked for it when\n // it opened the panel.\n const closeRequested = sideDialogsController.pendingClose || props.closeOnSave;\n\n if (closeRequested) {\n sideDialogsController.setPendingClose(false);\n closeAfterSave();\n } else if (params.status !== \"existing\") {\n // A newly created entity replaces the panel with its own address,\n // which already leaves the edit view behind.\n sidePanelController.replace({\n path: params.path,\n entityId: params.entityId,\n selectedTab: params.selectedTab,\n updateUrl: collection?.openEntityMode !== \"dialog\",\n collection: params.collection\n });\n } else {\n closeEditView();\n }\n\n props.onUpdate?.(params);\n }\n\n const parentCollectionSlugs = useMemo(() => {\n return collectionRegistryController.getParentCollectionSlugs(path);\n }, [collectionRegistryController, path]);\n\n const parentEntityIds = useMemo(() => {\n return collectionRegistryController.getParentEntityIds(path);\n }, [collectionRegistryController, path]);\n\n const collection = collectionRegistryController.getCollection(path) ?? props.collection;\n\n // Dialog mode deliberately stays out of the URL, so it is the only case that\n // needs local edit state. Everywhere else `edit` is a path segment, which\n // keeps refresh and the back button working the same way they do in split.\n const isDialogMode = collection?.openEntityMode === \"dialog\";\n const [editInDialog, setEditInDialog] = useState(false);\n const showEditInPanel = isDialogMode ? editInDialog : selectedTab === \"edit\";\n const isDetailMode = collection?.defaultEntityAction === \"view\" && !showEditInPanel && hasEntityId(entityId);\n\n // Reset edit mode when switching entities\n useEffect(() => {\n setEditInDialog(false);\n }, [entityId]);\n\n const openEditView = useCallback(() => {\n if (isDialogMode || !hasEntityId(entityId)) {\n setEditInDialog(true);\n return;\n }\n sidePanelController.replace({\n path,\n entityId,\n selectedTab: \"edit\",\n updateUrl: true,\n collection\n });\n }, [isDialogMode, entityId, path, collection, sidePanelController]);\n\n const closeEditView = useCallback(() => {\n if (isDialogMode || !hasEntityId(entityId)) {\n setEditInDialog(false);\n return;\n }\n sidePanelController.replace({\n path,\n entityId,\n selectedTab: undefined,\n updateUrl: true,\n collection\n });\n }, [isDialogMode, entityId, path, collection, sidePanelController]);\n\n // One-time correction: when the side panel opens without the correct\n // selectedTab but the resolved collection (from the registry) has a\n // defaultSelectedView, update the panel width and URL to match.\n // This handles cases where defaultSelectedView is set via the collection\n // editor / Studio and is not available on the collection object the\n // caller passed to sidePanelController.open().\n const hasCorrectedDefaultView = useRef(false);\n useEffect(() => {\n hasCorrectedDefaultView.current = false;\n }, [entityId]);\n useEffect(() => {\n if (hasCorrectedDefaultView.current) return;\n if (selectedTab) return; // Already has a tab — no correction needed\n if (!hasEntityId(entityId) || !collection?.defaultSelectedView) return;\n\n const effectiveDefault = resolveDefaultSelectedView(\n collection.defaultSelectedView,\n { status: \"existing\",\nentityId }\n );\n if (effectiveDefault && effectiveDefault !== \"edit\") {\n hasCorrectedDefaultView.current = true;\n sidePanelController.replace({\n path,\n entityId,\n selectedTab: effectiveDefault,\n updateUrl: collection.openEntityMode !== \"dialog\",\n collection\n });\n }\n }, [selectedTab, entityId, collection, path, sidePanelController]);\n\n // Note: beforeunload is handled by useUnsavedChangesDialog in SideDialogView,\n // which listens to the same `blocked` state via SideDialogContext.\n\n const onValuesModified = useCallback((modified: boolean) => {\n setBlockedNavigationMessage(modified\n ? <> You have unsaved changes in this <b>{collection?.singularName ?? collection?.name}</b>.</>\n : undefined)\n setBlocked(modified);\n }, [collection?.name, setBlocked, setBlockedNavigationMessage]);\n\n if (!props || !collection) {\n return <div className={\"w-full\"}/>;\n }\n\n const closeButton = (\n <IconButton aria-label={t(\"close\")}\n className=\"self-center\"\n size={\"small\"}\n onClick={onClose}>\n <XIcon/>\n </IconButton>\n );\n\n /**\n * Where the panel's own two controls sit, which is not the same question in\n * the two layouts that have them.\n *\n * A **side panel** slides in over the list from the right, and its leading\n * edge is the seam between the two. Close belongs on that seam — it points\n * back at the thing still visible behind it — and it is where the eye\n * already is, because the breadcrumb starts there.\n *\n * A **dialog** has no seam and nothing behind it to point at. It is a box\n * centred on a dimmed screen, and every box like it on every platform is\n * dismissed from its top-right corner. Close was sitting at the far left\n * of the bar, a full dialog's width from the expand button it belongs\n * beside, in the one corner that means \"back\" in a layout with no back.\n *\n * So in a dialog the two travel together at the trailing edge, expand then\n * close: the window controls, after the record's actions and its overflow\n * menu, in the corner a dialog is closed from.\n */\n const barActionsStart = isDialogMode ? undefined : closeButton;\n\n const windowControls = (expandButton: React.ReactNode) => (\n <div className=\"flex gap-1 items-center\">\n {expandButton}\n {isDialogMode && closeButton}\n </div>\n );\n\n return (\n <>\n <ErrorBoundary>\n {isDetailMode\n ? <ResolvedDetailView\n path={path}\n layout={collection?.openEntityMode === \"dialog\" ? \"dialog\" : \"side_panel\"}\n collection={collection as AdminCollection}\n entityId={entityId!}\n parentCollectionSlugs={parentCollectionSlugs}\n parentEntityIds={parentEntityIds}\n onEditClick={openEditView}\n barActionsStart={barActionsStart}\n barActions={() => windowControls(\n allowFullScreen && <IconButton aria-label={t(\"full_screen\")}\n className=\"self-center\"\n size={\"small\"}\n onClick={() => {\n if (hasEntityId(entityId)) {\n const fullScreenUrl = urlController.buildUrlCollectionPath(`${path}/${entityId}`);\n navigate(fullScreenUrl, { state: null });\n }\n }}>\n <Maximize2Icon/>\n </IconButton>\n )}\n onTabChange={({\n entityId: tabEntityId,\n selectedTab,\n collection: paramCollection\n }) => {\n if (collection?.openEntityMode === \"dialog\" || paramCollection?.openEntityMode === \"dialog\") {\n return;\n }\n if (tabEntityId) {\n sidePanelController.replace({\n path,\n entityId: tabEntityId,\n selectedTab,\n updateUrl: true,\n collection: paramCollection ?? collection\n });\n }\n }}\n />\n : <EditViewBinding\n {...props}\n layout={collection?.openEntityMode === \"dialog\" ? \"dialog\" : \"side_panel\"}\n collection={collection as AdminCollection}\n parentCollectionSlugs={parentCollectionSlugs} parentEntityIds={parentEntityIds}\n onValuesModified={onValuesModified}\n onSaved={onUpdate}\n navigateBack={closeEditView}\n barActionsStart={barActionsStart}\n barActions={({ carryEdit }) => windowControls(\n allowFullScreen && <IconButton aria-label={t(\"full_screen\")}\n className=\"self-center\"\n size={\"small\"}\n onClick={() => {\n // The form's own handoff, rather than a second\n // copy of the rules for it here: only an edit in\n // progress is worth carrying (a clean record\n // stashed anyway arrived announcing unsaved\n // changes to someone who had only looked at it),\n // and only the fields that were edited (carrying\n // the whole record marked every field touched).\n carryEdit?.();\n setBlocked(false);\n setBlockedNavigationMessage(undefined);\n if (hasEntityId(entityId)) {\n const fullScreenUrl = urlController.buildUrlCollectionPath(`${path}/${entityId}`);\n navigate(fullScreenUrl, { state: null });\n } else {\n const fullScreenUrl = urlController.buildUrlCollectionPath(path);\n navigate(fullScreenUrl + \"#new\", { state: null });\n }\n }}>\n <Maximize2Icon/>\n </IconButton>\n )}\n onTabChange={({\n entityId: tabEntityId,\n selectedTab,\n collection: paramCollection\n }) => {\n if (collection?.openEntityMode === \"dialog\" || paramCollection?.openEntityMode === \"dialog\") {\n return;\n }\n if (tabEntityId) {\n sidePanelController.replace({\n path,\n entityId: tabEntityId,\n selectedTab,\n updateUrl: true,\n collection: paramCollection ?? collection\n });\n }\n }}\n formProps={formProps}\n />\n }\n </ErrorBoundary>\n\n </>\n );\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;AA0BA,SAAgB,iBAAiB,OAA8B;CAC3D,MAAM,EAAE,MAAM,eAAe;CAE7B,MAAM,EACF,kBAAkB,MAClB,MACA,UACA,aACA,cACA;CAEJ,MAAM,qBAAqB,qBAAqB,cAAc,iBAAiB;CAE/E,MAAM,EACF,SACA,YACA,6BACA,UACA,qBAAqB;CAEzB,MAAM,WAAW,YAAY;CAE7B,MAAM,sBAAsB,aAAa;CACzC,MAAM,+BAA+B,gCAAgC;CACrE,MAAM,wBAAwB,qBAAqB;CACnD,MAAM,gBAAgB,iBAAiB;;;;;;;;;;;;;CAcvC,MAAM,gBAAgB;EAClB,MAAM;CACV;;;;;;;CAQA,MAAM,uBAAuB;EACzB,WAAW,KAAK;EAChB,MAAM,IAAI;CACd;;;;;;;;;;;;;;;;;CAkBA,MAAM,YAAY,WAA2B;EACzC,gBAAg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Y,mBAAmB,YAAY,iBAAiB,mBAAmB,UAC/E;GAEJ,IAAI,aACA,oBAAoB,QAAQ;IACxB;IACA,UAAU;IACV;IACA,WAAW;IACX,YAAY,mBAAmB;GACnC,CAAC;EAET;EACW;CACd,CAAA,EAEM,CAAA,EAEjB,CAAA;AAEV"}
@@ -111,6 +111,7 @@ var Scaffold = React.memo(function Scaffold(props) {
111
111
  const computedDrawerOpen = drawerOpen;
112
112
  const computedDrawerHovered = Boolean(largeLayout && onHover);
113
113
  const hasAppBar = Boolean(appBarChildren.length > 0);
114
+ const menuButtonRow = Boolean(includeDrawer) && !largeLayout && !hasAppBar;
114
115
  const appContextValue = useMemo(() => ({
115
116
  hasDrawer: Boolean(includeDrawer),
116
117
  drawerOpen: computedDrawerOpen,
@@ -150,12 +151,14 @@ var Scaffold = React.memo(function Scaffold(props) {
150
151
  open: drawerOpen,
151
152
  hovered: onHover,
152
153
  setDrawerOpen,
154
+ floatingMenuButton: !menuButtonRow,
153
155
  children: includeDrawer && drawerChildren
154
156
  }),
155
157
  /* @__PURE__ */ jsxs("main", {
156
158
  className: "flex flex-col grow overflow-auto",
157
159
  children: [
158
160
  hasAppBar && /* @__PURE__ */ jsx(DrawerHeader, {}),
161
+ menuButtonRow && /* @__PURE__ */ jsx(MenuButtonRow, { onOpen: handleDrawerOpen }),
159
162
  /* @__PURE__ */ jsx(ConnectionLostBanner, { className: cls("px-2 pt-1", {
160
163
  "lg:pt-0 lg:pb-2": padding,
161
164
  "lg:pt-2": !hasAppBar && padding
@@ -181,6 +184,18 @@ var Scaffold = React.memo(function Scaffold(props) {
181
184
  var DrawerHeader = () => {
182
185
  return /* @__PURE__ */ jsx("div", { className: "flex flex-col min-h-14" });
183
186
  };
187
+ /** The small-layout menu button, in the flow above the sheet. */
188
+ function MenuButtonRow({ onOpen }) {
189
+ const { t } = useTranslation();
190
+ return /* @__PURE__ */ jsx("div", {
191
+ className: "flex items-center shrink-0 px-2 sm:px-4 pt-1",
192
+ children: /* @__PURE__ */ jsx(IconButton, {
193
+ "aria-label": t("open_menu"),
194
+ onClick: onOpen,
195
+ children: /* @__PURE__ */ jsx(MenuIcon, {})
196
+ })
197
+ });
198
+ }
184
199
  function DrawerWrapper(props) {
185
200
  const layoutWidth = !props.displayed ? 0 : props.open ? 280 : 72;
186
201
  const visualWidth = !props.displayed ? 0 : props.open || props.hovered ? 280 : 72;
@@ -199,7 +214,7 @@ function DrawerWrapper(props) {
199
214
  });
200
215
  if (!useLargeLayout()) {
201
216
  if (!props.displayed) return null;
202
- return /* @__PURE__ */ jsxs(Fragment, { children: [/* @__PURE__ */ jsx(IconButton, {
217
+ return /* @__PURE__ */ jsxs(Fragment, { children: [props.floatingMenuButton && /* @__PURE__ */ jsx(IconButton, {
203
218
  "aria-label": t("open_menu"),
204
219
  onClick: () => props.setDrawerOpen(true),
205
220
  className: "absolute sm:top-2 sm:left-4 top-1 left-2",