@rebasepro/cms 0.33.2 → 0.34.1

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 (61) hide show
  1. package/dist/collection_editor/ui/collection_editor/CollectionEditorDialog.js +1 -1
  2. package/dist/collection_editor/ui/collection_editor/DisplaySettingsForm.js +1 -1
  3. package/dist/collection_editor/ui/collection_editor/GeneralSettingsForm.js +1 -1
  4. package/dist/collection_editor/ui/collection_editor/KanbanConfigSection.js +1 -1
  5. package/dist/components/BrandLogo.d.ts +16 -0
  6. package/dist/components/BrandLogo.js +34 -0
  7. package/dist/components/BrandLogo.js.map +1 -0
  8. package/dist/components/CollectionViewBinding/BoardCardBinding.js +3 -3
  9. package/dist/components/CollectionViewBinding/BoardCardBinding.js.map +1 -1
  10. package/dist/components/CollectionViewBinding/CollectionListViewBinding.js +2 -2
  11. package/dist/components/CollectionViewBinding/CollectionListViewBinding.js.map +1 -1
  12. package/dist/components/CollectionViewBinding/CollectionViewActions.js +1 -6
  13. package/dist/components/CollectionViewBinding/CollectionViewActions.js.map +1 -1
  14. package/dist/components/CollectionViewBinding/EntityCardBinding.js +3 -3
  15. package/dist/components/CollectionViewBinding/EntityCardBinding.js.map +1 -1
  16. package/dist/components/CollectionViewBinding/SlotValue.js +2 -2
  17. package/dist/components/CollectionViewBinding/SlotValue.js.map +1 -1
  18. package/dist/components/DefaultAppBar.d.ts +3 -1
  19. package/dist/components/DefaultAppBar.js +11 -6
  20. package/dist/components/DefaultAppBar.js.map +1 -1
  21. package/dist/components/DefaultDrawer.d.ts +5 -2
  22. package/dist/components/DefaultDrawer.js +9 -6
  23. package/dist/components/DefaultDrawer.js.map +1 -1
  24. package/dist/components/EntityIdentityBar.js +1 -1
  25. package/dist/components/EntityIdentityBar.js.map +1 -1
  26. package/dist/components/PropertyKeyHint.js +1 -1
  27. package/dist/components/PropertyKeyHint.js.map +1 -1
  28. package/dist/components/RebaseAuthGate.d.ts +5 -1
  29. package/dist/components/RebaseAuthGate.js +6 -2
  30. package/dist/components/RebaseAuthGate.js.map +1 -1
  31. package/dist/components/RebaseLayout.d.ts +2 -0
  32. package/dist/components/RebaseLayout.js +4 -2
  33. package/dist/components/RebaseLayout.js.map +1 -1
  34. package/dist/components/RebaseNavigation.js +7 -14
  35. package/dist/components/RebaseNavigation.js.map +1 -1
  36. package/dist/components/RebaseShell.d.ts +6 -1
  37. package/dist/components/RebaseShell.js +21 -16
  38. package/dist/components/RebaseShell.js.map +1 -1
  39. package/dist/components/RelationSelector.js +1 -1
  40. package/dist/components/RelationSelector.js.map +1 -1
  41. package/dist/components/app/Drawer.d.ts +2 -1
  42. package/dist/components/app/Drawer.js +2 -1
  43. package/dist/components/app/Drawer.js.map +1 -1
  44. package/dist/components/app/Scaffold.d.ts +5 -0
  45. package/dist/components/app/Scaffold.js +5 -3
  46. package/dist/components/app/Scaffold.js.map +1 -1
  47. package/dist/components/app/useApp.d.ts +1 -0
  48. package/dist/components/app/useApp.js.map +1 -1
  49. package/dist/editor/components/SlashCommandMenu.js +1 -1
  50. package/dist/editor/components/SlashCommandMenu.js.map +1 -1
  51. package/dist/editor/selectors/link-selector.js +1 -1
  52. package/dist/editor/selectors/link-selector.js.map +1 -1
  53. package/dist/editor/selectors/text-buttons.js +1 -1
  54. package/dist/editor/selectors/text-buttons.js.map +1 -1
  55. package/dist/form/field_bindings/VectorFieldBinding.js +1 -1
  56. package/dist/form/field_bindings/VectorFieldBinding.js.map +1 -1
  57. package/dist/hooks/navigation/compose_collections.d.ts +3 -2
  58. package/dist/hooks/navigation/compose_collections.js +27 -3
  59. package/dist/hooks/navigation/compose_collections.js.map +1 -1
  60. package/dist/index.js +17 -17
  61. package/package.json +9 -9
@@ -1 +1 @@
1
- {"version":3,"file":"EntityIdentityBar.js","names":[],"sources":["../../src/components/EntityIdentityBar.tsx"],"sourcesContent":["import type { AdminCollection } from \"@rebasepro/cms-types\";\nimport type { EntityStatus } from \"@rebasepro/types\";\nimport React, { useLayoutEffect, useRef, useState } from \"react\";\nimport { flushSync } from \"react-dom\";\nimport { Link } from \"react-router\";\nimport { useTranslation } from \"@rebasepro/app\";\nimport {\n Button,\n CheckIcon,\n CircularProgress,\n ChevronDownIcon,\n cls,\n CodeIcon,\n CopyIcon,\n ExternalLinkIcon,\n HistoryIcon,\n IconButton,\n iconSize,\n LoadingButton,\n ArrowLeftIcon,\n Menu,\n MenuItem,\n MoreVerticalIcon,\n Separator,\n Tooltip,\n Typography,\n XIcon\n} from \"@rebasepro/ui\";\nimport type { PlacedEntityActions } from \"../util/entity_actions\";\nimport { fitInlineActions, type InlineActionsFit } from \"../util/fit_inline_actions\";\nimport { ActionMenuLabel } from \"./common/ActionMenuLabel\";\n\n/**\n * One of the record's own actions, resolved and ready to run — what the bar\n * needs to draw it as a button or as a menu item.\n */\nexport interface RecordActionItem {\n key: string;\n name: string;\n icon?: React.ReactNode;\n enabled: boolean;\n /** Why it is disabled, when it is and its action says. */\n disabledReason?: string;\n /**\n * Runs the action, reporting its own failure. Returns a promise only when\n * the action is asynchronous, which is what keeps a button's spinner up.\n */\n run: () => Promise<void> | undefined;\n}\n\nexport interface EntityIdentityBarProps {\n /** Plural collection name, shown as the breadcrumb ahead of the title. */\n collection: AdminCollection;\n /**\n * Where the breadcrumb points. Without it the collection name is inert text\n * that still reads as a breadcrumb — worse than no breadcrumb at all, and\n * the only way back once a layout drops its back arrow.\n *\n * Left unset by the overlays (side panel, dialog), where the collection is\n * already underneath and navigating would dismiss the record instead.\n */\n collectionUrl?: string;\n /** Resolved record title, already guarded against showing a field default. */\n title: string;\n entityId?: string | number;\n status: EntityStatus;\n\n dirty: boolean;\n saving: boolean;\n /** Undefined hides the Save button — read-only views, or a custom form. */\n onSave?: () => void;\n onDiscard?: () => void;\n saveDisabled?: boolean;\n hasErrors?: boolean;\n\n /**\n * Save and dismiss, for the side panel and the dialog where the dominant\n * action is \"done with this record\" rather than \"keep editing\".\n */\n onSaveAndClose?: () => void;\n\n /**\n * Where {@link onSaveAndClose} is offered.\n *\n * `\"button\"` — its own filled button, and Save demotes to text. For the\n * overlays, where you opened the record to do one thing to it and closing is\n * the dominant intent.\n *\n * `\"menu\"` — a `▾` welded to the Save button. For the split, where the list\n * is right there and `j`/`k` walk from record to record: there, saving and\n * *staying* is the common case, so it keeps the filled button and dismissing\n * is one step further in. The gesture still exists, so muscle memory carried\n * over from the side panel finds it.\n */\n saveAndClosePlacement?: \"button\" | \"menu\";\n\n /**\n * Dismiss this record, from the ✕ at the bar's trailing edge.\n *\n * Fenced off from Save by a separator: it is chrome, not the last item in\n * the action row. The panel that supplies it decides what dismissing means —\n * in the split it is a navigation, which the layout's unsaved-changes\n * blocker already guards, so the ✕ cannot drop an edit without asking.\n */\n onClose?: () => void;\n\n onBack?: () => void;\n onInspect?: () => void;\n /** Opens the inspector straight on its history tab. */\n onViewHistory?: () => void;\n\n /**\n * Where this record appears on the live site, from `entityLinkBuilder`.\n *\n * Here rather than above the record, where it used to be a single unlabelled\n * icon alone on its own right-aligned row — the only thing between the bar\n * and the first field, and the only control in the view that did not say\n * what it was. It is a thing you do *to* a record, so it belongs with the\n * others.\n */\n externalLink?: string;\n\n /**\n * Actions performed *on* the record — copy, delete, whatever the collection\n * adds — already placed: `inline` ones are buttons ahead of Save, folding\n * into the overflow menu when the bar runs short of room, and the rest are\n * menu groups. They live here rather than in a footer, which is what let\n * the footer go away entirely.\n */\n recordActions?: PlacedEntityActions<RecordActionItem>;\n\n /**\n * The read-only view's Edit: its main button, drawn where Save stands on\n * the edit view — after the record's own buttons, ahead of the menu.\n */\n primaryAction?: React.ReactNode;\n\n /** Plugin-contributed actions, rendered inline before Save. */\n pluginActions?: React.ReactNode;\n\n /** Close / full-screen buttons supplied by the panel that owns this view. */\n trailing?: React.ReactNode;\n\n /**\n * Controls the owning panel puts at the bar's leading edge, ahead of the\n * breadcrumb — where the side panel's close button lives.\n */\n leading?: React.ReactNode;\n}\n\n/**\n * The persistent header of an entity view: who this record is, and what you can\n * do to it.\n *\n * The title and the id used to live inside the scrolling form, above 72px of\n * empty space — 219px of chrome that carried nothing and scrolled away the\n * moment you touched the wheel, leaving no indication of which record you were\n * editing. They live here instead, and the left half of a bar that was\n * previously empty now does the work.\n */\nexport function EntityIdentityBar({\n collection,\n collectionUrl,\n title,\n entityId,\n status,\n dirty,\n saving,\n onSave,\n onDiscard,\n saveDisabled,\n hasErrors,\n onSaveAndClose,\n saveAndClosePlacement = \"button\",\n onClose,\n onBack,\n onInspect,\n onViewHistory,\n externalLink,\n recordActions,\n primaryAction,\n pluginActions,\n trailing,\n leading\n}: EntityIdentityBarProps) {\n\n const { t } = useTranslation();\n\n const inline = recordActions?.inline ?? NO_ACTIONS;\n const inlineRef = useRef<HTMLDivElement>(null);\n const labelledRef = useRef<HTMLDivElement>(null);\n const compactRef = useRef<HTMLDivElement>(null);\n const fit = useInlineActionsFit(inlineRef, labelledRef, compactRef, inline);\n\n // What did not fit leads the menu, ahead of the actions that were always\n // there: it is what the developer ranked highest.\n const ownActions = [...inline.slice(fit.count), ...(recordActions?.own ?? NO_ACTIONS)];\n const genericActions = recordActions?.generic ?? NO_ACTIONS;\n const destructiveActions = recordActions?.destructive ?? NO_ACTIONS;\n const hasUtilities = genericActions.length > 0 || Boolean(externalLink) || Boolean(onViewHistory) || Boolean(onInspect);\n const menuGroups = [ownActions.length > 0, hasUtilities, destructiveActions.length > 0];\n const hasMenu = menuGroups.some(Boolean);\n // A rule between two groups that are both there, never at an edge.\n const ruleBefore = (group: number) => menuGroups[group] && menuGroups.slice(0, group).some(Boolean);\n\n return (\n <div className={cls(\n // No line under it: the bar and the tab strip below are one band on\n // the sheet, and the strip already carries the edge the folder tab\n // sits on. Regions meet with a step, not a rule.\n \"h-[52px] shrink-0 flex items-center gap-2 pl-1.5 pr-2\",\n \"bg-surface-sheet\"\n )}>\n {leading}\n\n {onBack && (\n <Tooltip title={t(\"back\")}>\n <IconButton size={\"small\"} onClick={onBack} aria-label={t(\"back\")}>\n <ArrowLeftIcon size={iconSize.smallest}/>\n </IconButton>\n </Tooltip>\n )}\n\n {collectionUrl\n ? <Link to={collectionUrl}\n className={\"visited:text-inherit dark:visited:text-inherit hidden sm:block\"}>\n <Typography variant={\"caption\"}\n className={cls(\n \"text-text-disabled dark:text-text-disabled-dark whitespace-nowrap\",\n \"hover:text-text-primary dark:hover:text-text-primary-dark transition-colors\"\n )}>\n {collection.name}&nbsp;/\n </Typography>\n </Link>\n : <Typography variant={\"caption\"}\n className={\"text-text-disabled dark:text-text-disabled-dark whitespace-nowrap hidden sm:block\"}>\n {collection.name}&nbsp;/\n </Typography>}\n\n <span className={cls(\n \"font-headers font-semibold text-[15px] tracking-tight truncate min-w-0\",\n // The title takes the room it needs and the actions get what is\n // left, so a long one would fold every action away. Capped, it\n // truncates first — only where there are actions to make room for.\n inline.length > 0 && \"max-w-[40%]\"\n )}\n title={title}>\n {title}\n </span>\n\n {entityId !== undefined && <IdChip value={String(entityId)}/>}\n\n {/* The bar's free space, and the actions that fit in it. Always\n rendered: it is the spacer, and the observer measures it. */}\n <div ref={inlineRef}\n className={\"flex-1 min-w-0 flex items-center justify-end gap-1\"}>\n {inline.slice(0, fit.count).map(action =>\n <RecordActionButton key={action.key} action={action} compact={fit.compact}/>)}\n {inline.length > 0 && (\n // Every action in both of its forms, laid out at its natural\n // width and never seen, so a fit can be decided without\n // first drawing the bar wrong. A zero-size clipping box: it\n // takes no room and cannot widen anything it sits in.\n <div aria-hidden={true}\n className={\"absolute w-0 h-0 overflow-hidden invisible pointer-events-none\"}>\n <div ref={labelledRef} className={\"flex w-max\"}>\n {inline.map(action =>\n <RecordActionButton key={action.key} action={action} compact={false}/>)}\n </div>\n <div ref={compactRef} className={\"flex w-max\"}>\n {inline.map(action =>\n <RecordActionButton key={action.key} action={action} compact={true}/>)}\n </div>\n </div>\n )}\n </div>\n\n {pluginActions}\n\n <EntitySaveActions status={status}\n dirty={dirty}\n saving={saving}\n onSave={onSave}\n onDiscard={onDiscard}\n saveDisabled={saveDisabled}\n hasErrors={hasErrors}\n onSaveAndClose={onSaveAndClose}\n saveAndClosePlacement={saveAndClosePlacement}/>\n\n {primaryAction}\n\n {hasMenu && (\n <Menu align={\"end\"}\n trigger={\n <IconButton size={\"small\"} aria-label={t(\"more_actions\") ?? \"More actions\"}>\n <MoreVerticalIcon size={iconSize.smallest}/>\n </IconButton>\n }>\n {/* The collection's own operations first — the reason\n someone opened this record — then the ones every record\n has, then Delete, last and apart. */}\n {ownActions.map(action => <RecordActionMenuItem key={action.key} action={action}/>)}\n {ruleBefore(1) && <Separator orientation={\"horizontal\"}/>}\n {genericActions.map(action => <RecordActionMenuItem key={action.key} action={action}/>)}\n {externalLink && (\n <MenuItem onClick={() => window.open(externalLink, \"_blank\", \"noopener,noreferrer\")}>\n <ExternalLinkIcon size={iconSize.smallest}/>\n {t(\"open_in_live_site\") ?? \"Open in the live site\"}\n </MenuItem>\n )}\n {onViewHistory && (\n <MenuItem onClick={onViewHistory}>\n <HistoryIcon size={iconSize.smallest}/>\n {t(\"record_history\") ?? \"History\"}\n </MenuItem>\n )}\n {onInspect && (\n <MenuItem onClick={onInspect}>\n <CodeIcon size={iconSize.smallest}/>\n {t(\"inspect_record\") ?? \"Inspect record\"}\n </MenuItem>\n )}\n {ruleBefore(2) && <Separator orientation={\"horizontal\"}/>}\n {destructiveActions.map(action => <RecordActionMenuItem key={action.key} action={action}/>)}\n </Menu>\n )}\n\n {trailing}\n\n {/* Last, and set apart by space rather than a rule. A ✕ flush against\n Save reads as the next item in the action row, and the two\n adjacent controls are then \"commit this edit\" and \"abandon it\";\n the vertical separator that used to fence it off was the one\n line on the bar, and a line marks an object, not a gap. */}\n {onClose && (\n <Tooltip title={`${t(\"close\")} · Esc`}>\n <IconButton size={\"small\"} onClick={onClose} aria-label={t(\"close\")} className={\"ml-2\"}>\n <XIcon size={iconSize.smallest}/>\n </IconButton>\n </Tooltip>\n )}\n </div>\n );\n}\n\nconst NO_ACTIONS: RecordActionItem[] = [];\n\n/** `gap-1`, between the inline actions. */\nconst INLINE_ACTIONS_GAP = 4;\n\n/**\n * Which of the inline actions fit in the bar's free space, and whether they\n * keep their labels — decided from the measuring copies before the bar is\n * painted, and again whenever the space or the buttons change size: a resize,\n * Discard appearing beside Save, a web font arriving, a language switch.\n */\nfunction useInlineActionsFit(\n containerRef: React.RefObject<HTMLDivElement | null>,\n labelledRef: React.RefObject<HTMLDivElement | null>,\n compactRef: React.RefObject<HTMLDivElement | null>,\n actions: RecordActionItem[]\n): InlineActionsFit {\n\n const [fit, setFit] = useState<InlineActionsFit>({ count: actions.length, compact: false });\n const actionKeys = actions.map(action => action.key).join(\"\\u0000\");\n\n useLayoutEffect(() => {\n const container = containerRef.current;\n const labelled = labelledRef.current;\n const compact = compactRef.current;\n if (!container || !labelled || !compact) {\n setFit(previous => previous.count === 0 && !previous.compact ? previous : { count: 0, compact: false });\n return;\n }\n const widths = (row: HTMLElement) =>\n Array.from(row.children).map(child => child.getBoundingClientRect().width);\n const measure = () => {\n const next = fitInlineActions(container.clientWidth, widths(labelled), widths(compact), INLINE_ACTIONS_GAP);\n setFit(previous => previous.count === next.count && previous.compact === next.compact ? previous : next);\n };\n measure();\n if (typeof ResizeObserver === \"undefined\") return;\n // Synchronously: the observer reports after layout and before paint,\n // and an ordinary update would render after that paint — one frame\n // with the old buttons drawn over the title whenever Discard appeared.\n const observer = new ResizeObserver(() => flushSync(measure));\n observer.observe(container);\n observer.observe(labelled);\n observer.observe(compact);\n return () => observer.disconnect();\n }, [containerRef, labelledRef, compactRef, actionKeys]);\n\n return fit;\n}\n\n/**\n * An action promoted out of the menu: a text button with its icon, as the\n * collection toolbar draws Filter and Sort, or the icon alone with its name in\n * a tooltip where the bar is short of room. It shows a spinner while the work\n * it started is running, and cannot be pressed twice meanwhile. Disabled, its\n * tooltip says why, where the action gives a reason.\n */\nfunction RecordActionButton({ action, compact }: { action: RecordActionItem, compact: boolean }) {\n\n const [running, setRunning] = useState(false);\n const reason = action.enabled ? undefined : action.disabledReason;\n\n const onClick = () => {\n const pending = action.run();\n if (!pending) return;\n setRunning(true);\n pending.finally(() => setRunning(false));\n };\n\n if (compact && action.icon) {\n return (\n <Tooltip title={reason ? `${action.name}: ${reason}` : action.name}>\n <IconButton size={\"small\"}\n aria-label={action.name}\n disabled={!action.enabled || running}\n onClick={onClick}>\n {running ? <CircularProgress size={\"smallest\"}/> : action.icon}\n </IconButton>\n </Tooltip>\n );\n }\n\n // The tooltip's wrapper takes the hover: a disabled button receives no\n // pointer events of its own, so the button lets them through to it.\n return (\n <Tooltip title={reason}>\n <LoadingButton variant={\"text\"}\n size={\"small\"}\n startIcon={action.icon}\n loading={running}\n disabled={!action.enabled}\n className={reason ? \"pointer-events-none\" : undefined}\n onClick={onClick}>\n {action.name}\n </LoadingButton>\n </Tooltip>\n );\n}\n\nfunction RecordActionMenuItem({ action }: { action: RecordActionItem }) {\n return (\n <MenuItem disabled={!action.enabled} onClick={() => void action.run()}>\n {action.icon}\n <ActionMenuLabel name={action.name} disabledReason={action.enabled ? undefined : action.disabledReason}/>\n </MenuItem>\n );\n}\n\nexport type EntitySaveActionsProps = Pick<EntityIdentityBarProps,\n \"status\" | \"dirty\" | \"saving\" | \"onSave\" | \"onDiscard\" | \"saveDisabled\" | \"hasErrors\"\n | \"onSaveAndClose\" | \"saveAndClosePlacement\">;\n\n/**\n * Save, \"save and close\", Discard, and the words saying where the edit stands.\n *\n * Its own component because it has two homes. On a page and in the side panel\n * it sits in the identity bar, where it stays in view while the form scrolls. In\n * the dialog it sits in a footer under the form: a dialog is read top to bottom\n * and finished at the bottom, where every other dialog in the app keeps its\n * buttons, and the bar at its top is left to say what the record is.\n */\nexport function EntitySaveActions({\n status,\n dirty,\n saving,\n onSave,\n onDiscard,\n saveDisabled,\n hasErrors,\n onSaveAndClose,\n saveAndClosePlacement = \"button\"\n}: EntitySaveActionsProps) {\n\n const { t } = useTranslation();\n\n const saveLabel = status === \"existing\"\n ? t(\"save\")\n : status === \"copy\" ? t(\"create_copy\") : t(\"create\");\n const closeLabel = status === \"existing\"\n ? t(\"save_and_close\")\n : status === \"copy\" ? t(\"create_copy_and_close\") : t(\"create_and_close\");\n\n // The two shapes \"save and close\" takes, so the Save button next to it knows\n // whether it is still the primary action.\n const saveAndCloseButton = Boolean(onSaveAndClose) && saveAndClosePlacement === \"button\";\n const saveAndCloseMenu = Boolean(onSaveAndClose) && saveAndClosePlacement === \"menu\";\n\n const saveTooltip = hasErrors\n ? (t(\"fix_errors_before_saving\") ?? \"Fix highlighted errors before saving\")\n : undefined;\n\n return <>\n {/* Only where there is something to save. The read-only detail\n view has no Save button, and reporting \"Saved\" there implies an\n editing session the user never started. */}\n {onSave && <SaveState dirty={dirty} saving={saving} status={status} t={t}/>}\n\n {onDiscard && dirty && !saving && (\n <Button variant={\"text\"} size={\"small\"} onClick={onDiscard}>\n {status === \"existing\" ? t(\"discard\") : t(\"clear\")}\n </Button>\n )}\n\n {onSave && (\n // `rounded-lg overflow-hidden`: the two halves of the split\n // button are square inside and the group carries the radius, so\n // there is one control with a seam rather than two buttons that\n // happen to touch. Their borders match their own fill, so the\n // seam has to be drawn — see the `▾` half for where and in what.\n <div className={\"flex items-stretch rounded-lg overflow-hidden\"}>\n <Tooltip title={saveTooltip}>\n <LoadingButton\n // Where a separate close button carries it, closing\n // is the dominant intent and takes the filled\n // treatment. Under the `▾` the record is staying\n // open, so Save keeps it.\n variant={saveAndCloseButton ? \"text\" : \"filled\"}\n color={\"primary\"}\n size={\"small\"}\n loading={saving && !saveAndCloseButton}\n disabled={saveDisabled}\n onClick={onSave}\n className={saveAndCloseMenu ? \"rounded-none\" : undefined}>\n {saveLabel}\n </LoadingButton>\n </Tooltip>\n\n {saveAndCloseMenu && <>\n <Menu align={\"end\"}\n trigger={\n <Button variant={\"filled\"}\n color={\"primary\"}\n size={\"small\"}\n disabled={saveDisabled}\n aria-label={closeLabel}\n // The seam is this half's own left border,\n // tinted from `currentColor` — the ink the\n // label is drawn in — so it holds on any\n // button colour and dims with the control\n // rather than needing a case per state. It\n // was a `bg-white/25` span between the\n // halves: a bright hairline scratched over a\n // saturated blue, and, being a sibling of\n // the buttons rather than part of one, it\n // stayed at full strength while `disabled`\n // dropped both halves to `opacity-40` — a\n // rule brighter than the button it bisected.\n // Inline because it has to beat the\n // variant's `border-<color>` on one edge.\n style={{ borderLeftColor: \"color-mix(in oklab, currentColor 15%, transparent)\" }}\n className={\"rounded-none px-1.5\"}>\n <ChevronDownIcon size={iconSize.smallest}/>\n </Button>\n }>\n <MenuItem onClick={onSaveAndClose}>\n <CheckIcon size={iconSize.smallest}/>\n {closeLabel}\n </MenuItem>\n </Menu>\n </>}\n </div>\n )}\n\n {saveAndCloseButton && (\n <LoadingButton variant={\"filled\"}\n color={\"primary\"}\n size={\"small\"}\n loading={saving}\n disabled={saveDisabled}\n onClick={onSaveAndClose}>\n {closeLabel}\n </LoadingButton>\n )}\n </>;\n}\n\n/**\n * The words the unlabelled floating circle never said.\n *\n * That indicator was a ✓ / pencil / spinner chip stuck to the top-right of the\n * scroll area in an `h-0 overflow-visible` container, so it drifted across\n * field values as you scrolled — and it duplicated what the Save button was\n * already able to tell you.\n */\nfunction SaveState({\n dirty,\n saving,\n status,\n t\n}: {\n dirty: boolean;\n saving: boolean;\n status: EntityStatus;\n t: (key: string) => string;\n}) {\n if (saving) {\n return <StateText>{t(\"saving\")}</StateText>;\n }\n if (dirty) {\n return <StateText>{t(\"unsaved_changes_title\")}</StateText>;\n }\n if (status === \"existing\") {\n return <StateText>{t(\"entity_saved\") ?? \"Saved\"}</StateText>;\n }\n return null;\n}\n\nfunction StateText({ children }: { children: React.ReactNode }) {\n return (\n <span className={\"text-xs text-text-disabled dark:text-text-disabled-dark whitespace-nowrap hidden md:inline\"}>\n {children}\n </span>\n );\n}\n\n/**\n * The id, as a chip you can copy rather than a full-width alert holding a UUID.\n */\nfunction IdChip({ value }: { value: string }) {\n\n const { t } = useTranslation();\n const [copied, setCopied] = useState(false);\n\n const truncated = value.length > 14\n ? `${value.slice(0, 8)}…${value.slice(-4)}`\n : value;\n\n const copy = () => {\n navigator.clipboard?.writeText(value).then(() => {\n setCopied(true);\n setTimeout(() => setCopied(false), 1600);\n }, () => undefined);\n };\n\n return (\n <Tooltip title={copied ? t(\"copied\") : value}>\n <button type={\"button\"}\n onClick={copy}\n aria-label={`${t(\"copy_id\")} ${value}`}\n className={cls(\n // `whitespace-nowrap`: the middle of the id is elided with a\n // `…`, and a line break is allowed after one. In the dialog,\n // where the bar is narrow and every button is on it, the\n // chip broke across two lines inside a 52px row.\n \"hidden md:inline-flex items-center gap-1.5 shrink-0 whitespace-nowrap px-2 py-0.5 rounded-md\",\n \"font-mono text-[11px] text-text-secondary dark:text-text-secondary-dark\",\n \"bg-surface-field\",\n \"hover:bg-surface-field-hover transition-colors\"\n )}>\n {truncated}\n {copied ? <CheckIcon size={iconSize.smallest}/> : <CopyIcon size={iconSize.smallest}/>}\n </button>\n </Tooltip>\n );\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;AAgKA,SAAgB,kBAAkB,EAC9B,YACA,eACA,OACA,UACA,QACA,OACA,QACA,QACA,WACA,cACA,WACA,gBACA,wBAAwB,UACxB,SACA,QACA,WACA,eACA,cACA,eACA,eACA,eACA,UACA,WACuB;CAEvB,MAAM,EAAE,MAAM,eAAe;CAE7B,MAAM,SAAS,eAAe,UAAU;CACxC,MAAM,YAAY,OAAuB,IAAI;CAC7C,MAAM,cAAc,OAAuB,IAAI;CAC/C,MAAM,aAAa,OAAuB,IAAI;CAC9C,MAAM,MAAM,oBAAoB,WAAW,aAAa,YAAY,MAAM;CAI1E,MAAM,aAAa,CAAC,GAAG,OAAO,MAAM,IAAI,KAAK,GAAG,GAAI,eAAe,OAAO,UAAW;CACrF,MAAM,iBAAiB,eAAe,WAAW;CACjD,MAAM,qBAAqB,eAAe,eAAe;CACzD,MAAM,eAAe,eAAe,SAAS,KAAK,QAAQ,YAAY,KAAK,QAAQ,aAAa,KAAK,QAAQ,SAAS;CACtH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V,SAAS;aACR;EACU,CAAA;CAErB,EAAA,CAAA;AACN;;;;;;;;;AAUA,SAAS,UAAU,EACf,OACA,QACA,QACA,KAMD;CACC,IAAI,QACA,OAAO,oBAAC,WAAD,EAAA,UAAY,EAAE,QAAQ,EAAa,CAAA;CAE9C,IAAI,OACA,OAAO,oBAAC,WAAD,EAAA,UAAY,EAAE,uBAAuB,EAAa,CAAA;CAE7D,IAAI,WAAW,YACX,OAAO,oBAAC,WAAD,EAAA,UAAY,EAAE,cAAc,KAAK,QAAmB,CAAA;CAE/D,OAAO;AACX;AAEA,SAAS,UAAU,EAAE,YAA2C;CAC5D,OACI,oBAAC,QAAD;EAAM,WAAW;EACZ;CACC,CAAA;AAEd;;;;AAKA,SAAS,OAAO,EAAE,SAA4B;CAE1C,MAAM,EAAE,MAAM,eAAe;CAC7B,MAAM,CAAC,QAAQ,aAAa,SAAS,KAAK;CAE1C,MAAM,YAAY,MAAM,SAAS,KAC3B,GAAG,MAAM,MAAM,GAAG,CAAC,EAAE,GAAG,MAAM,MAAM,EAAE,MACtC;CAEN,MAAM,aAAa;EACf,UAAU,WAAW,UAAU,KAAK,CAAC,CAAC,WAAW;GAC7C,UAAU,IAAI;GACd,iBAAiB,UAAU,KAAK,GAAG,IAAI;EAC3C,SAAS,KAAA,CAAS;CACtB;CAEA,OACI,oBAAC,SAAD;EAAS,OAAO,SAAS,EAAE,QAAQ,IAAI;YACnC,qBAAC,UAAD;GAAQ,MAAM;GACV,SAAS;GACT,cAAY,GAAG,EAAE,SAAS,EAAE,GAAG;GAC/B,WAAW,IAKP,gGACA,2EACA,oBACA,gDACJ;aAZJ,CAaK,WACA,SAAS,oBAAC,WAAD,EAAW,MAAM,SAAS,SAAU,CAAA,IAAI,oBAAC,UAAD,EAAU,MAAM,SAAS,SAAU,CAAA,CACjF;;CACH,CAAA;AAEjB"}
1
+ {"version":3,"file":"EntityIdentityBar.js","names":[],"sources":["../../src/components/EntityIdentityBar.tsx"],"sourcesContent":["import type { AdminCollection } from \"@rebasepro/cms-types\";\nimport type { EntityStatus } from \"@rebasepro/types\";\nimport React, { useLayoutEffect, useRef, useState } from \"react\";\nimport { flushSync } from \"react-dom\";\nimport { Link } from \"react-router\";\nimport { useTranslation } from \"@rebasepro/app\";\nimport {\n Button,\n CheckIcon,\n CircularProgress,\n ChevronDownIcon,\n cls,\n CodeIcon,\n CopyIcon,\n ExternalLinkIcon,\n HistoryIcon,\n IconButton,\n iconSize,\n LoadingButton,\n ArrowLeftIcon,\n Menu,\n MenuItem,\n MoreVerticalIcon,\n Separator,\n Tooltip,\n Typography,\n XIcon\n} from \"@rebasepro/ui\";\nimport type { PlacedEntityActions } from \"../util/entity_actions\";\nimport { fitInlineActions, type InlineActionsFit } from \"../util/fit_inline_actions\";\nimport { ActionMenuLabel } from \"./common/ActionMenuLabel\";\n\n/**\n * One of the record's own actions, resolved and ready to run — what the bar\n * needs to draw it as a button or as a menu item.\n */\nexport interface RecordActionItem {\n key: string;\n name: string;\n icon?: React.ReactNode;\n enabled: boolean;\n /** Why it is disabled, when it is and its action says. */\n disabledReason?: string;\n /**\n * Runs the action, reporting its own failure. Returns a promise only when\n * the action is asynchronous, which is what keeps a button's spinner up.\n */\n run: () => Promise<void> | undefined;\n}\n\nexport interface EntityIdentityBarProps {\n /** Plural collection name, shown as the breadcrumb ahead of the title. */\n collection: AdminCollection;\n /**\n * Where the breadcrumb points. Without it the collection name is inert text\n * that still reads as a breadcrumb — worse than no breadcrumb at all, and\n * the only way back once a layout drops its back arrow.\n *\n * Left unset by the overlays (side panel, dialog), where the collection is\n * already underneath and navigating would dismiss the record instead.\n */\n collectionUrl?: string;\n /** Resolved record title, already guarded against showing a field default. */\n title: string;\n entityId?: string | number;\n status: EntityStatus;\n\n dirty: boolean;\n saving: boolean;\n /** Undefined hides the Save button — read-only views, or a custom form. */\n onSave?: () => void;\n onDiscard?: () => void;\n saveDisabled?: boolean;\n hasErrors?: boolean;\n\n /**\n * Save and dismiss, for the side panel and the dialog where the dominant\n * action is \"done with this record\" rather than \"keep editing\".\n */\n onSaveAndClose?: () => void;\n\n /**\n * Where {@link onSaveAndClose} is offered.\n *\n * `\"button\"` — its own filled button, and Save demotes to text. For the\n * overlays, where you opened the record to do one thing to it and closing is\n * the dominant intent.\n *\n * `\"menu\"` — a `▾` welded to the Save button. For the split, where the list\n * is right there and `j`/`k` walk from record to record: there, saving and\n * *staying* is the common case, so it keeps the filled button and dismissing\n * is one step further in. The gesture still exists, so muscle memory carried\n * over from the side panel finds it.\n */\n saveAndClosePlacement?: \"button\" | \"menu\";\n\n /**\n * Dismiss this record, from the ✕ at the bar's trailing edge.\n *\n * Fenced off from Save by a separator: it is chrome, not the last item in\n * the action row. The panel that supplies it decides what dismissing means —\n * in the split it is a navigation, which the layout's unsaved-changes\n * blocker already guards, so the ✕ cannot drop an edit without asking.\n */\n onClose?: () => void;\n\n onBack?: () => void;\n onInspect?: () => void;\n /** Opens the inspector straight on its history tab. */\n onViewHistory?: () => void;\n\n /**\n * Where this record appears on the live site, from `entityLinkBuilder`.\n *\n * Here rather than above the record, where it used to be a single unlabelled\n * icon alone on its own right-aligned row — the only thing between the bar\n * and the first field, and the only control in the view that did not say\n * what it was. It is a thing you do *to* a record, so it belongs with the\n * others.\n */\n externalLink?: string;\n\n /**\n * Actions performed *on* the record — copy, delete, whatever the collection\n * adds — already placed: `inline` ones are buttons ahead of Save, folding\n * into the overflow menu when the bar runs short of room, and the rest are\n * menu groups. They live here rather than in a footer, which is what let\n * the footer go away entirely.\n */\n recordActions?: PlacedEntityActions<RecordActionItem>;\n\n /**\n * The read-only view's Edit: its main button, drawn where Save stands on\n * the edit view — after the record's own buttons, ahead of the menu.\n */\n primaryAction?: React.ReactNode;\n\n /** Plugin-contributed actions, rendered inline before Save. */\n pluginActions?: React.ReactNode;\n\n /** Close / full-screen buttons supplied by the panel that owns this view. */\n trailing?: React.ReactNode;\n\n /**\n * Controls the owning panel puts at the bar's leading edge, ahead of the\n * breadcrumb — where the side panel's close button lives.\n */\n leading?: React.ReactNode;\n}\n\n/**\n * The persistent header of an entity view: who this record is, and what you can\n * do to it.\n *\n * The title and the id used to live inside the scrolling form, above 72px of\n * empty space — 219px of chrome that carried nothing and scrolled away the\n * moment you touched the wheel, leaving no indication of which record you were\n * editing. They live here instead, and the left half of a bar that was\n * previously empty now does the work.\n */\nexport function EntityIdentityBar({\n collection,\n collectionUrl,\n title,\n entityId,\n status,\n dirty,\n saving,\n onSave,\n onDiscard,\n saveDisabled,\n hasErrors,\n onSaveAndClose,\n saveAndClosePlacement = \"button\",\n onClose,\n onBack,\n onInspect,\n onViewHistory,\n externalLink,\n recordActions,\n primaryAction,\n pluginActions,\n trailing,\n leading\n}: EntityIdentityBarProps) {\n\n const { t } = useTranslation();\n\n const inline = recordActions?.inline ?? NO_ACTIONS;\n const inlineRef = useRef<HTMLDivElement>(null);\n const labelledRef = useRef<HTMLDivElement>(null);\n const compactRef = useRef<HTMLDivElement>(null);\n const fit = useInlineActionsFit(inlineRef, labelledRef, compactRef, inline);\n\n // What did not fit leads the menu, ahead of the actions that were always\n // there: it is what the developer ranked highest.\n const ownActions = [...inline.slice(fit.count), ...(recordActions?.own ?? NO_ACTIONS)];\n const genericActions = recordActions?.generic ?? NO_ACTIONS;\n const destructiveActions = recordActions?.destructive ?? NO_ACTIONS;\n const hasUtilities = genericActions.length > 0 || Boolean(externalLink) || Boolean(onViewHistory) || Boolean(onInspect);\n const menuGroups = [ownActions.length > 0, hasUtilities, destructiveActions.length > 0];\n const hasMenu = menuGroups.some(Boolean);\n // A rule between two groups that are both there, never at an edge.\n const ruleBefore = (group: number) => menuGroups[group] && menuGroups.slice(0, group).some(Boolean);\n\n return (\n <div className={cls(\n // No line under it: the bar and the tab strip below are one band on\n // the sheet, and the strip already carries the edge the folder tab\n // sits on. Regions meet with a step, not a rule.\n \"h-[52px] shrink-0 flex items-center gap-2 pl-1.5 pr-2\",\n \"bg-surface-sheet\"\n )}>\n {leading}\n\n {onBack && (\n <Tooltip title={t(\"back\")}>\n <IconButton size={\"small\"} onClick={onBack} aria-label={t(\"back\")}>\n <ArrowLeftIcon size={iconSize.smallest}/>\n </IconButton>\n </Tooltip>\n )}\n\n {collectionUrl\n ? <Link to={collectionUrl}\n className={\"visited:text-inherit dark:visited:text-inherit hidden sm:block\"}>\n <Typography variant={\"caption\"}\n className={cls(\n \"text-text-disabled dark:text-text-disabled-dark whitespace-nowrap\",\n \"hover:text-text-primary dark:hover:text-text-primary-dark transition-colors\"\n )}>\n {collection.name}&nbsp;/\n </Typography>\n </Link>\n : <Typography variant={\"caption\"}\n className={\"text-text-disabled dark:text-text-disabled-dark whitespace-nowrap hidden sm:block\"}>\n {collection.name}&nbsp;/\n </Typography>}\n\n <span className={cls(\n \"font-headers font-semibold text-[15px] tracking-tight truncate min-w-0\",\n // The title takes the room it needs and the actions get what is\n // left, so a long one would fold every action away. Capped, it\n // truncates first — only where there are actions to make room for.\n inline.length > 0 && \"max-w-[40%]\"\n )}\n title={title}>\n {title}\n </span>\n\n {entityId !== undefined && <IdChip value={String(entityId)}/>}\n\n {/* The bar's free space, and the actions that fit in it. Always\n rendered: it is the spacer, and the observer measures it. */}\n <div ref={inlineRef}\n className={\"flex-1 min-w-0 flex items-center justify-end gap-1\"}>\n {inline.slice(0, fit.count).map(action =>\n <RecordActionButton key={action.key} action={action} compact={fit.compact}/>)}\n {inline.length > 0 && (\n // Every action in both of its forms, laid out at its natural\n // width and never seen, so a fit can be decided without\n // first drawing the bar wrong. A zero-size clipping box: it\n // takes no room and cannot widen anything it sits in.\n <div aria-hidden={true}\n className={\"absolute w-0 h-0 overflow-hidden invisible pointer-events-none\"}>\n <div ref={labelledRef} className={\"flex w-max\"}>\n {inline.map(action =>\n <RecordActionButton key={action.key} action={action} compact={false}/>)}\n </div>\n <div ref={compactRef} className={\"flex w-max\"}>\n {inline.map(action =>\n <RecordActionButton key={action.key} action={action} compact={true}/>)}\n </div>\n </div>\n )}\n </div>\n\n {pluginActions}\n\n <EntitySaveActions status={status}\n dirty={dirty}\n saving={saving}\n onSave={onSave}\n onDiscard={onDiscard}\n saveDisabled={saveDisabled}\n hasErrors={hasErrors}\n onSaveAndClose={onSaveAndClose}\n saveAndClosePlacement={saveAndClosePlacement}/>\n\n {primaryAction}\n\n {hasMenu && (\n <Menu align={\"end\"}\n trigger={\n <IconButton size={\"small\"} aria-label={t(\"more_actions\") ?? \"More actions\"}>\n <MoreVerticalIcon size={iconSize.smallest}/>\n </IconButton>\n }>\n {/* The collection's own operations first — the reason\n someone opened this record — then the ones every record\n has, then Delete, last and apart. */}\n {ownActions.map(action => <RecordActionMenuItem key={action.key} action={action}/>)}\n {ruleBefore(1) && <Separator orientation={\"horizontal\"}/>}\n {genericActions.map(action => <RecordActionMenuItem key={action.key} action={action}/>)}\n {externalLink && (\n <MenuItem onClick={() => window.open(externalLink, \"_blank\", \"noopener,noreferrer\")}>\n <ExternalLinkIcon size={iconSize.smallest}/>\n {t(\"open_in_live_site\") ?? \"Open in the live site\"}\n </MenuItem>\n )}\n {onViewHistory && (\n <MenuItem onClick={onViewHistory}>\n <HistoryIcon size={iconSize.smallest}/>\n {t(\"record_history\") ?? \"History\"}\n </MenuItem>\n )}\n {onInspect && (\n <MenuItem onClick={onInspect}>\n <CodeIcon size={iconSize.smallest}/>\n {t(\"inspect_record\") ?? \"Inspect record\"}\n </MenuItem>\n )}\n {ruleBefore(2) && <Separator orientation={\"horizontal\"}/>}\n {destructiveActions.map(action => <RecordActionMenuItem key={action.key} action={action}/>)}\n </Menu>\n )}\n\n {trailing}\n\n {/* Last, and set apart by space rather than a rule. A ✕ flush against\n Save reads as the next item in the action row, and the two\n adjacent controls are then \"commit this edit\" and \"abandon it\";\n the vertical separator that used to fence it off was the one\n line on the bar, and a line marks an object, not a gap. */}\n {onClose && (\n <Tooltip title={`${t(\"close\")} · Esc`}>\n <IconButton size={\"small\"} onClick={onClose} aria-label={t(\"close\")} className={\"ml-2\"}>\n <XIcon size={iconSize.smallest}/>\n </IconButton>\n </Tooltip>\n )}\n </div>\n );\n}\n\nconst NO_ACTIONS: RecordActionItem[] = [];\n\n/** `gap-1`, between the inline actions. */\nconst INLINE_ACTIONS_GAP = 4;\n\n/**\n * Which of the inline actions fit in the bar's free space, and whether they\n * keep their labels — decided from the measuring copies before the bar is\n * painted, and again whenever the space or the buttons change size: a resize,\n * Discard appearing beside Save, a web font arriving, a language switch.\n */\nfunction useInlineActionsFit(\n containerRef: React.RefObject<HTMLDivElement | null>,\n labelledRef: React.RefObject<HTMLDivElement | null>,\n compactRef: React.RefObject<HTMLDivElement | null>,\n actions: RecordActionItem[]\n): InlineActionsFit {\n\n const [fit, setFit] = useState<InlineActionsFit>({ count: actions.length, compact: false });\n const actionKeys = actions.map(action => action.key).join(\"\\u0000\");\n\n useLayoutEffect(() => {\n const container = containerRef.current;\n const labelled = labelledRef.current;\n const compact = compactRef.current;\n if (!container || !labelled || !compact) {\n setFit(previous => previous.count === 0 && !previous.compact ? previous : { count: 0, compact: false });\n return;\n }\n const widths = (row: HTMLElement) =>\n Array.from(row.children).map(child => child.getBoundingClientRect().width);\n const measure = () => {\n const next = fitInlineActions(container.clientWidth, widths(labelled), widths(compact), INLINE_ACTIONS_GAP);\n setFit(previous => previous.count === next.count && previous.compact === next.compact ? previous : next);\n };\n measure();\n if (typeof ResizeObserver === \"undefined\") return;\n // Synchronously: the observer reports after layout and before paint,\n // and an ordinary update would render after that paint — one frame\n // with the old buttons drawn over the title whenever Discard appeared.\n const observer = new ResizeObserver(() => flushSync(measure));\n observer.observe(container);\n observer.observe(labelled);\n observer.observe(compact);\n return () => observer.disconnect();\n }, [containerRef, labelledRef, compactRef, actionKeys]);\n\n return fit;\n}\n\n/**\n * An action promoted out of the menu: a text button with its icon, as the\n * collection toolbar draws Filter and Sort, or the icon alone with its name in\n * a tooltip where the bar is short of room. It shows a spinner while the work\n * it started is running, and cannot be pressed twice meanwhile. Disabled, its\n * tooltip says why, where the action gives a reason.\n */\nfunction RecordActionButton({ action, compact }: { action: RecordActionItem, compact: boolean }) {\n\n const [running, setRunning] = useState(false);\n const reason = action.enabled ? undefined : action.disabledReason;\n\n const onClick = () => {\n const pending = action.run();\n if (!pending) return;\n setRunning(true);\n pending.finally(() => setRunning(false));\n };\n\n if (compact && action.icon) {\n return (\n <Tooltip title={reason ? `${action.name}: ${reason}` : action.name}>\n <IconButton size={\"small\"}\n aria-label={action.name}\n disabled={!action.enabled || running}\n onClick={onClick}>\n {running ? <CircularProgress size={\"smallest\"}/> : action.icon}\n </IconButton>\n </Tooltip>\n );\n }\n\n // The tooltip's wrapper takes the hover: a disabled button receives no\n // pointer events of its own, so the button lets them through to it.\n return (\n <Tooltip title={reason}>\n <LoadingButton variant={\"text\"}\n size={\"small\"}\n startIcon={action.icon}\n loading={running}\n disabled={!action.enabled}\n className={reason ? \"pointer-events-none\" : undefined}\n onClick={onClick}>\n {action.name}\n </LoadingButton>\n </Tooltip>\n );\n}\n\nfunction RecordActionMenuItem({ action }: { action: RecordActionItem }) {\n return (\n <MenuItem disabled={!action.enabled} onClick={() => void action.run()}>\n {action.icon}\n <ActionMenuLabel name={action.name} disabledReason={action.enabled ? undefined : action.disabledReason}/>\n </MenuItem>\n );\n}\n\nexport type EntitySaveActionsProps = Pick<EntityIdentityBarProps,\n \"status\" | \"dirty\" | \"saving\" | \"onSave\" | \"onDiscard\" | \"saveDisabled\" | \"hasErrors\"\n | \"onSaveAndClose\" | \"saveAndClosePlacement\">;\n\n/**\n * Save, \"save and close\", Discard, and the words saying where the edit stands.\n *\n * Its own component because it has two homes. On a page and in the side panel\n * it sits in the identity bar, where it stays in view while the form scrolls. In\n * the dialog it sits in a footer under the form: a dialog is read top to bottom\n * and finished at the bottom, where every other dialog in the app keeps its\n * buttons, and the bar at its top is left to say what the record is.\n */\nexport function EntitySaveActions({\n status,\n dirty,\n saving,\n onSave,\n onDiscard,\n saveDisabled,\n hasErrors,\n onSaveAndClose,\n saveAndClosePlacement = \"button\"\n}: EntitySaveActionsProps) {\n\n const { t } = useTranslation();\n\n const saveLabel = status === \"existing\"\n ? t(\"save\")\n : status === \"copy\" ? t(\"create_copy\") : t(\"create\");\n const closeLabel = status === \"existing\"\n ? t(\"save_and_close\")\n : status === \"copy\" ? t(\"create_copy_and_close\") : t(\"create_and_close\");\n\n // The two shapes \"save and close\" takes, so the Save button next to it knows\n // whether it is still the primary action.\n const saveAndCloseButton = Boolean(onSaveAndClose) && saveAndClosePlacement === \"button\";\n const saveAndCloseMenu = Boolean(onSaveAndClose) && saveAndClosePlacement === \"menu\";\n\n const saveTooltip = hasErrors\n ? (t(\"fix_errors_before_saving\") ?? \"Fix highlighted errors before saving\")\n : undefined;\n\n return <>\n {/* Only where there is something to save. The read-only detail\n view has no Save button, and reporting \"Saved\" there implies an\n editing session the user never started. */}\n {onSave && <SaveState dirty={dirty} saving={saving} status={status} t={t}/>}\n\n {onDiscard && dirty && !saving && (\n <Button variant={\"text\"} size={\"small\"} onClick={onDiscard}>\n {status === \"existing\" ? t(\"discard\") : t(\"clear\")}\n </Button>\n )}\n\n {onSave && (\n // `rounded-lg overflow-hidden`: the two halves of the split\n // button are square inside and the group carries the radius, so\n // there is one control with a seam rather than two buttons that\n // happen to touch. Their borders match their own fill, so the\n // seam has to be drawn — see the `▾` half for where and in what.\n <div className={\"flex items-stretch rounded-lg overflow-hidden\"}>\n <Tooltip title={saveTooltip}>\n <LoadingButton\n // Where a separate close button carries it, closing\n // is the dominant intent and takes the filled\n // treatment. Under the `▾` the record is staying\n // open, so Save keeps it.\n variant={saveAndCloseButton ? \"text\" : \"filled\"}\n color={\"primary\"}\n size={\"small\"}\n loading={saving && !saveAndCloseButton}\n disabled={saveDisabled}\n onClick={onSave}\n className={saveAndCloseMenu ? \"rounded-none\" : undefined}>\n {saveLabel}\n </LoadingButton>\n </Tooltip>\n\n {saveAndCloseMenu && <>\n <Menu align={\"end\"}\n trigger={\n <Button variant={\"filled\"}\n color={\"primary\"}\n size={\"small\"}\n disabled={saveDisabled}\n aria-label={closeLabel}\n // The seam is this half's own left border,\n // tinted from `currentColor` — the ink the\n // label is drawn in — so it holds on any\n // button colour and dims with the control\n // rather than needing a case per state. It\n // was a `bg-white/25` span between the\n // halves: a bright hairline scratched over a\n // saturated blue, and, being a sibling of\n // the buttons rather than part of one, it\n // stayed at full strength while `disabled`\n // dropped both halves to `opacity-40` — a\n // rule brighter than the button it bisected.\n // Inline because it has to beat the\n // variant's `border-<color>` on one edge.\n style={{ borderLeftColor: \"color-mix(in oklab, currentColor 15%, transparent)\" }}\n className={\"rounded-none px-1.5\"}>\n <ChevronDownIcon size={iconSize.smallest}/>\n </Button>\n }>\n <MenuItem onClick={onSaveAndClose}>\n <CheckIcon size={iconSize.smallest}/>\n {closeLabel}\n </MenuItem>\n </Menu>\n </>}\n </div>\n )}\n\n {saveAndCloseButton && (\n <LoadingButton variant={\"filled\"}\n color={\"primary\"}\n size={\"small\"}\n loading={saving}\n disabled={saveDisabled}\n onClick={onSaveAndClose}>\n {closeLabel}\n </LoadingButton>\n )}\n </>;\n}\n\n/**\n * The words the unlabelled floating circle never said.\n *\n * That indicator was a ✓ / pencil / spinner chip stuck to the top-right of the\n * scroll area in an `h-0 overflow-visible` container, so it drifted across\n * field values as you scrolled — and it duplicated what the Save button was\n * already able to tell you.\n */\nfunction SaveState({\n dirty,\n saving,\n status,\n t\n}: {\n dirty: boolean;\n saving: boolean;\n status: EntityStatus;\n t: (key: string) => string;\n}) {\n if (saving) {\n return <StateText>{t(\"saving\")}</StateText>;\n }\n if (dirty) {\n return <StateText>{t(\"unsaved_changes_title\")}</StateText>;\n }\n if (status === \"existing\") {\n return <StateText>{t(\"entity_saved\") ?? \"Saved\"}</StateText>;\n }\n return null;\n}\n\nfunction StateText({ children }: { children: React.ReactNode }) {\n return (\n <span className={\"text-xs text-text-disabled dark:text-text-disabled-dark whitespace-nowrap hidden md:inline\"}>\n {children}\n </span>\n );\n}\n\n/**\n * The id, as a chip you can copy rather than a full-width alert holding a UUID.\n */\nfunction IdChip({ value }: { value: string }) {\n\n const { t } = useTranslation();\n const [copied, setCopied] = useState(false);\n\n const truncated = value.length > 14\n ? `${value.slice(0, 8)}…${value.slice(-4)}`\n : value;\n\n const copy = () => {\n navigator.clipboard?.writeText(value).then(() => {\n setCopied(true);\n setTimeout(() => setCopied(false), 1600);\n }, () => undefined);\n };\n\n return (\n <Tooltip title={copied ? t(\"copied\") : value}>\n <button type={\"button\"}\n onClick={copy}\n aria-label={`${t(\"copy_id\")} ${value}`}\n className={cls(\n // `whitespace-nowrap`: the middle of the id is elided with a\n // `…`, and a line break is allowed after one. In the dialog,\n // where the bar is narrow and every button is on it, the\n // chip broke across two lines inside a 52px row.\n \"hidden md:inline-flex items-center gap-1.5 shrink-0 whitespace-nowrap px-2 py-0.5 rounded-md\",\n \"font-mono text-xs text-text-secondary dark:text-text-secondary-dark\",\n \"bg-surface-field\",\n \"hover:bg-surface-field-hover transition-colors\"\n )}>\n {truncated}\n {copied ? <CheckIcon size={iconSize.smallest}/> : <CopyIcon size={iconSize.smallest}/>}\n </button>\n </Tooltip>\n );\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;AAgKA,SAAgB,kBAAkB,EAC9B,YACA,eACA,OACA,UACA,QACA,OACA,QACA,QACA,WACA,cACA,WACA,gBACA,wBAAwB,UACxB,SACA,QACA,WACA,eACA,cACA,eACA,eACA,eACA,UACA,WACuB;CAEvB,MAAM,EAAE,MAAM,eAAe;CAE7B,MAAM,SAAS,eAAe,UAAU;CACxC,MAAM,YAAY,OAAuB,IAAI;CAC7C,MAAM,cAAc,OAAuB,IAAI;CAC/C,MAAM,aAAa,OAAuB,IAAI;CAC9C,MAAM,MAAM,oBAAoB,WAAW,aAAa,YAAY,MAAM;CAI1E,MAAM,aAAa,CAAC,GAAG,OAAO,MAAM,IAAI,KAAK,GAAG,GAAI,eAAe,OAAO,UAAW;CACrF,MAAM,iBAAiB,eAAe,WAAW;CACjD,MAAM,qBAAqB,eAAe,eAAe;CACzD,MAAM,eAAe,eAAe,SAAS,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ertyKeyHint({ propertyKey, className }) {
39
39
  tabIndex: -1,
40
40
  onClick: copy,
41
41
  "aria-label": `${t("copy")} ${propertyKey}`,
42
- className: cls("inline-flex items-center gap-1 min-w-0 shrink-[999] px-1 -my-0.5 rounded-md", "font-mono text-[11px] font-normal leading-tight", "text-text-disabled dark:text-text-disabled-dark", "hover:text-text-secondary dark:hover:text-text-secondary-dark hover:bg-surface-hover", "opacity-0 transition-opacity duration-150 group-hover/label:opacity-100 group-hover/label:delay-500", className),
42
+ className: cls("inline-flex items-center gap-1 min-w-0 shrink-[999] px-1 -my-0.5 rounded-md", "font-mono text-xs font-normal leading-tight", "text-text-disabled dark:text-text-disabled-dark", "hover:text-text-secondary dark:hover:text-text-secondary-dark hover:bg-surface-hover", "opacity-0 transition-opacity duration-150 group-hover/label:opacity-100 group-hover/label:delay-500", className),
43
43
  children: [/* @__PURE__ */ jsx("span", {
44
44
  className: "truncate",
45
45
  children: propertyKey
@@ -1 +1 @@
1
- {"version":3,"file":"PropertyKeyHint.js","names":[],"sources":["../../src/components/PropertyKeyHint.tsx"],"sourcesContent":["import React, { useState } from \"react\";\nimport { useTranslation } from \"@rebasepro/app\";\nimport { CheckIcon, cls, CopyIcon } from \"@rebasepro/ui\";\n\n/**\n * A property's key, shown beside its label while the label is hovered, and\n * copied when clicked.\n *\n * Inline, in the label row's own empty space, rather than a tooltip. The tooltip\n * this replaces wrapped the field's control as well as its label, so it opened\n * the moment a field took focus and sat on top of the label of the very field\n * being filled in. Closing again on blur, it was also what threw Tab out of the\n * dialog (see `useRestoreInterruptedFocus` in `@rebasepro/ui`). A key a\n * developer copies now and then is not worth a layer over the form.\n *\n * Revealed by hovering the nearest `group/label` ancestor, after a pause, so a\n * pointer crossing the form does not flicker keys on and off; hidden again at\n * once. Out of the tab order: a stop per field would double the keystrokes it\n * takes to get through a form, for something only the pointer needs.\n *\n * Gives up its width before the label does (`shrink-[999]`), so a long field\n * name in a narrow column is never truncated to make room for a key that is not\n * even showing.\n */\nexport function PropertyKeyHint({\n propertyKey,\n className\n}: {\n propertyKey: string;\n className?: string;\n}) {\n\n const { t } = useTranslation();\n const [copied, setCopied] = useState(false);\n\n const copy = (event: React.MouseEvent) => {\n // Labels sit inside things that act on a click — an expandable\n // panel's header, above all. Copying a key must not also toggle it.\n event.preventDefault();\n event.stopPropagation();\n navigator.clipboard?.writeText(propertyKey).then(() => {\n setCopied(true);\n setTimeout(() => setCopied(false), 1600);\n }, () => undefined);\n };\n\n return (\n <button type={\"button\"}\n tabIndex={-1}\n onClick={copy}\n aria-label={`${t(\"copy\")} ${propertyKey}`}\n className={cls(\n \"inline-flex items-center gap-1 min-w-0 shrink-[999] px-1 -my-0.5 rounded-md\",\n \"font-mono text-[11px] font-normal leading-tight\",\n \"text-text-disabled dark:text-text-disabled-dark\",\n \"hover:text-text-secondary dark:hover:text-text-secondary-dark hover:bg-surface-hover\",\n \"opacity-0 transition-opacity duration-150 group-hover/label:opacity-100 group-hover/label:delay-500\",\n className\n )}>\n <span className={\"truncate\"}>{propertyKey}</span>\n {copied\n ? <CheckIcon size={11} className={\"shrink-0\"}/>\n : <CopyIcon size={11} className={\"shrink-0\"}/>}\n </button>\n );\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;AAwBA,SAAgB,gBAAgB,EAC5B,aACA,aAID;CAEC,MAAM,EAAE,MAAM,eAAe;CAC7B,MAAM,CAAC,QAAQ,aAAa,SAAS,KAAK;CAE1C,MAAM,QAAQ,UAA4B;EAGtC,MAAM,eAAe;EACrB,MAAM,gBAAgB;EACtB,UAAU,WAAW,UAAU,WAAW,CAAC,CAAC,WAAW;GACnD,UAAU,IAAI;GACd,iBAAiB,UAAU,KAAK,GAAG,IAAI;EAC3C,SAAS,KAAA,CAAS;CACtB;CAEA,OACI,qBAAC,UAAD;EAAQ,MAAM;EACV,UAAU;EACV,SAAS;EACT,cAAY,GAAG,EAAE,MAAM,EAAE,GAAG;EAC5B,WAAW,IACP,+EACA,mDACA,mDACA,wFACA,uGACA,SACJ;YAXJ,CAYI,oBAAC,QAAD;GAAM,WAAW;aAAa;EAAkB,CAAA,GAC/C,SACK,oBAAC,WAAD;GAAW,MAAM;GAAI,WAAW;EAAY,CAAA,IAC5C,oBAAC,UAAD;GAAU,MAAM;GAAI,WAAW;EAAY,CAAA,CAC7C;;AAEhB"}
1
+ {"version":3,"file":"PropertyKeyHint.js","names":[],"sources":["../../src/components/PropertyKeyHint.tsx"],"sourcesContent":["import React, { useState } from \"react\";\nimport { useTranslation } from \"@rebasepro/app\";\nimport { CheckIcon, cls, CopyIcon } from \"@rebasepro/ui\";\n\n/**\n * A property's key, shown beside its label while the label is hovered, and\n * copied when clicked.\n *\n * Inline, in the label row's own empty space, rather than a tooltip. The tooltip\n * this replaces wrapped the field's control as well as its label, so it opened\n * the moment a field took focus and sat on top of the label of the very field\n * being filled in. Closing again on blur, it was also what threw Tab out of the\n * dialog (see `useRestoreInterruptedFocus` in `@rebasepro/ui`). A key a\n * developer copies now and then is not worth a layer over the form.\n *\n * Revealed by hovering the nearest `group/label` ancestor, after a pause, so a\n * pointer crossing the form does not flicker keys on and off; hidden again at\n * once. Out of the tab order: a stop per field would double the keystrokes it\n * takes to get through a form, for something only the pointer needs.\n *\n * Gives up its width before the label does (`shrink-[999]`), so a long field\n * name in a narrow column is never truncated to make room for a key that is not\n * even showing.\n */\nexport function PropertyKeyHint({\n propertyKey,\n className\n}: {\n propertyKey: string;\n className?: string;\n}) {\n\n const { t } = useTranslation();\n const [copied, setCopied] = useState(false);\n\n const copy = (event: React.MouseEvent) => {\n // Labels sit inside things that act on a click — an expandable\n // panel's header, above all. Copying a key must not also toggle it.\n event.preventDefault();\n event.stopPropagation();\n navigator.clipboard?.writeText(propertyKey).then(() => {\n setCopied(true);\n setTimeout(() => setCopied(false), 1600);\n }, () => undefined);\n };\n\n return (\n <button type={\"button\"}\n tabIndex={-1}\n onClick={copy}\n aria-label={`${t(\"copy\")} ${propertyKey}`}\n className={cls(\n \"inline-flex items-center gap-1 min-w-0 shrink-[999] px-1 -my-0.5 rounded-md\",\n \"font-mono text-xs font-normal leading-tight\",\n \"text-text-disabled dark:text-text-disabled-dark\",\n \"hover:text-text-secondary dark:hover:text-text-secondary-dark hover:bg-surface-hover\",\n \"opacity-0 transition-opacity duration-150 group-hover/label:opacity-100 group-hover/label:delay-500\",\n className\n )}>\n <span className={\"truncate\"}>{propertyKey}</span>\n {copied\n ? <CheckIcon size={11} className={\"shrink-0\"}/>\n : <CopyIcon size={11} className={\"shrink-0\"}/>}\n </button>\n );\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;AAwBA,SAAgB,gBAAgB,EAC5B,aACA,aAID;CAEC,MAAM,EAAE,MAAM,eAAe;CAC7B,MAAM,CAAC,QAAQ,aAAa,SAAS,KAAK;CAE1C,MAAM,QAAQ,UAA4B;EAGtC,MAAM,eAAe;EACrB,MAAM,gBAAgB;EACtB,UAAU,WAAW,UAAU,WAAW,CAAC,CAAC,WAAW;GACnD,UAAU,IAAI;GACd,iBAAiB,UAAU,KAAK,GAAG,IAAI;EAC3C,SAAS,KAAA,CAAS;CACtB;CAEA,OACI,qBAAC,UAAD;EAAQ,MAAM;EACV,UAAU;EACV,SAAS;EACT,cAAY,GAAG,EAAE,MAAM,EAAE,GAAG;EAC5B,WAAW,IACP,+EACA,+CACA,mDACA,wFACA,uGACA,SACJ;YAXJ,CAYI,oBAAC,QAAD;GAAM,WAAW;aAAa;EAAkB,CAAA,GAC/C,SACK,oBAAC,WAAD;GAAW,MAAM;GAAI,WAAW;EAAY,CAAA,IAC5C,oBAAC,UAAD;GAAU,MAAM;GAAI,WAAW;EAAY,CAAA,CAC7C;;AAEhB"}
@@ -16,6 +16,10 @@ import React from "react";
16
16
  * </RebaseAuthGate>
17
17
  * ```
18
18
  */
19
- export declare function RebaseAuthGate({ children }: {
19
+ export declare function RebaseAuthGate({ children, logo, logoDark }: {
20
20
  children: React.ReactNode;
21
+ /** The logo the built-in sign-in screen shows. `<RebaseShell logo>` passes its own. */
22
+ logo?: string;
23
+ /** The sign-in screen's logo in the dark theme. Falls back to `logo`. */
24
+ logoDark?: string;
21
25
  }): React.JSX.Element;
@@ -20,14 +20,18 @@ import { LoginView, readEmailLinkAction, useAuthController, useComponentOverride
20
20
  * </RebaseAuthGate>
21
21
  * ```
22
22
  */
23
- function RebaseAuthGate({ children }) {
23
+ function RebaseAuthGate({ children, logo, logoDark }) {
24
24
  const registry = useRebaseRegistry();
25
25
  const authController = useAuthController();
26
26
  const ResolvedLoginView = useComponentOverride("Auth.LoginView", LoginView);
27
27
  if (authController?.initialLoading) return /* @__PURE__ */ jsx(CircularProgressCenter, { size: "large" });
28
28
  const openedLink = typeof window !== "undefined" ? readEmailLinkAction(window.location)?.kind : void 0;
29
29
  const linkOpensOverSession = openedLink === "verify-email" || openedLink === "confirm-email-change" || openedLink === "magic-link";
30
- if (!authController?.user || linkOpensOverSession) return /* @__PURE__ */ jsx(Fragment, { children: registry.authConfig?.loginView ?? /* @__PURE__ */ jsx(ResolvedLoginView, { authController }) });
30
+ if (!authController?.user || linkOpensOverSession) return /* @__PURE__ */ jsx(Fragment, { children: registry.authConfig?.loginView ?? /* @__PURE__ */ jsx(ResolvedLoginView, {
31
+ authController,
32
+ logo,
33
+ logoDark
34
+ }) });
31
35
  return /* @__PURE__ */ jsx(Fragment, { children });
32
36
  }
33
37
  //#endregion
@@ -1 +1 @@
1
- {"version":3,"file":"RebaseAuthGate.js","names":[],"sources":["../../src/components/RebaseAuthGate.tsx"],"sourcesContent":["import React from \"react\";\nimport {\n useRebaseRegistry,\n useAuthController,\n useComponentOverride\n} from \"@rebasepro/app\";\nimport { CircularProgressCenter } from \"@rebasepro/ui\";\nimport { LoginView, readEmailLinkAction } from \"@rebasepro/app\";\nimport type { AuthControllerExtended } from \"@rebasepro/cms-types\";\n\n/**\n * Auth gate component that handles the authentication flow.\n *\n * - Shows a loading spinner while `authController.initialLoading` is true.\n * - Shows the login view when no user is authenticated.\n * - Renders `children` when a user is authenticated.\n *\n * **Independently usable**: Use this alone when you want auth gating\n * without the full admin layout or navigation.\n *\n * @example\n * ```tsx\n * <RebaseAuthGate>\n * <MyCustomApp />\n * </RebaseAuthGate>\n * ```\n */\nexport function RebaseAuthGate({ children }: { children: React.ReactNode }) {\n const registry = useRebaseRegistry();\n const authController = useAuthController();\n // `<RebaseAuth loginView>` is an element and wins; `\"Auth.LoginView\"` in\n // `<Rebase components>` replaces or wraps the built-in screen.\n const ResolvedLoginView = useComponentOverride(\"Auth.LoginView\", LoginView);\n\n if (authController?.initialLoading) {\n return <CircularProgressCenter size={\"large\"}/>;\n }\n\n // A verification link opened while signed in is verified by the session\n // itself — which keeps everything on the account — on the screen that\n // knows the link, and an address-change link is usually followed in the\n // tab that asked for the change. A magic link opened while signed in is\n // sent on to the app by that screen, without being spent. Left to the\n // app's router each was a page that does not exist.\n const openedLink = typeof window !== \"undefined\" ? readEmailLinkAction(window.location)?.kind : undefined;\n const linkOpensOverSession = openedLink === \"verify-email\"\n || openedLink === \"confirm-email-change\"\n || openedLink === \"magic-link\";\n\n if (!authController?.user || linkOpensOverSession) {\n const ActiveLoginView = registry.authConfig?.loginView ?? (\n <ResolvedLoginView authController={authController as AuthControllerExtended}/>\n );\n return <>{ActiveLoginView}</>;\n }\n\n return <>{children}</>;\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;AA2BA,SAAgB,eAAe,EAAE,YAA2C;CACxE,MAAM,WAAW,kBAAkB;CACnC,MAAM,iBAAiB,kBAAkB;CAGzC,MAAM,oBAAoB,qBAAqB,kBAAkB,SAAS;CAE1E,IAAI,gBAAgB,gBAChB,OAAO,oBAAC,wBAAD,EAAwB,MAAM,QAAS,CAAA;CASlD,MAAM,aAAa,OAAO,WAAW,cAAc,oBAAoB,OAAO,QAAQ,CAAC,EAAE,OAAO,KAAA;CAChG,MAAM,uBAAuB,eAAe,kBACrC,eAAe,0BACf,eAAe;CAEtB,IAAI,CAAC,gBAAgB,QAAQ,sBAIzB,OAAO,oBAAA,UAAA,EAAA,UAHiB,SAAS,YAAY,aACzC,oBAAC,mBAAD,EAAmC,eAA0C,CAAA,EAErD,CAAA;CAGhC,OAAO,oBAAA,UAAA,EAAG,SAAW,CAAA;AACzB"}
1
+ {"version":3,"file":"RebaseAuthGate.js","names":[],"sources":["../../src/components/RebaseAuthGate.tsx"],"sourcesContent":["import React from \"react\";\nimport {\n useRebaseRegistry,\n useAuthController,\n useComponentOverride\n} from \"@rebasepro/app\";\nimport { CircularProgressCenter } from \"@rebasepro/ui\";\nimport { LoginView, readEmailLinkAction } from \"@rebasepro/app\";\nimport type { AuthControllerExtended } from \"@rebasepro/cms-types\";\n\n/**\n * Auth gate component that handles the authentication flow.\n *\n * - Shows a loading spinner while `authController.initialLoading` is true.\n * - Shows the login view when no user is authenticated.\n * - Renders `children` when a user is authenticated.\n *\n * **Independently usable**: Use this alone when you want auth gating\n * without the full admin layout or navigation.\n *\n * @example\n * ```tsx\n * <RebaseAuthGate>\n * <MyCustomApp />\n * </RebaseAuthGate>\n * ```\n */\nexport function RebaseAuthGate({\n children,\n logo,\n logoDark\n}: {\n children: React.ReactNode;\n /** The logo the built-in sign-in screen shows. `<RebaseShell logo>` passes its own. */\n logo?: string;\n /** The sign-in screen's logo in the dark theme. Falls back to `logo`. */\n logoDark?: string;\n}) {\n const registry = useRebaseRegistry();\n const authController = useAuthController();\n // `<RebaseAuth loginView>` is an element and wins; `\"Auth.LoginView\"` in\n // `<Rebase components>` replaces or wraps the built-in screen.\n const ResolvedLoginView = useComponentOverride(\"Auth.LoginView\", LoginView);\n\n if (authController?.initialLoading) {\n return <CircularProgressCenter size={\"large\"}/>;\n }\n\n // A verification link opened while signed in is verified by the session\n // itself — which keeps everything on the account — on the screen that\n // knows the link, and an address-change link is usually followed in the\n // tab that asked for the change. A magic link opened while signed in is\n // sent on to the app by that screen, without being spent. Left to the\n // app's router each was a page that does not exist.\n const openedLink = typeof window !== \"undefined\" ? readEmailLinkAction(window.location)?.kind : undefined;\n const linkOpensOverSession = openedLink === \"verify-email\"\n || openedLink === \"confirm-email-change\"\n || openedLink === \"magic-link\";\n\n if (!authController?.user || linkOpensOverSession) {\n const ActiveLoginView = registry.authConfig?.loginView ?? (\n <ResolvedLoginView authController={authController as AuthControllerExtended}\n logo={logo}\n logoDark={logoDark}/>\n );\n return <>{ActiveLoginView}</>;\n }\n\n return <>{children}</>;\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;AA2BA,SAAgB,eAAe,EAC3B,UACA,MACA,YAOD;CACC,MAAM,WAAW,kBAAkB;CACnC,MAAM,iBAAiB,kBAAkB;CAGzC,MAAM,oBAAoB,qBAAqB,kBAAkB,SAAS;CAE1E,IAAI,gBAAgB,gBAChB,OAAO,oBAAC,wBAAD,EAAwB,MAAM,QAAS,CAAA;CASlD,MAAM,aAAa,OAAO,WAAW,cAAc,oBAAoB,OAAO,QAAQ,CAAC,EAAE,OAAO,KAAA;CAChG,MAAM,uBAAuB,eAAe,kBACrC,eAAe,0BACf,eAAe;CAEtB,IAAI,CAAC,gBAAgB,QAAQ,sBAMzB,OAAO,oBAAA,UAAA,EAAA,UALiB,SAAS,YAAY,aACzC,oBAAC,mBAAD;EAAmC;EACzB;EACI;CAAU,CAAA,EAEA,CAAA;CAGhC,OAAO,oBAAA,UAAA,EAAG,SAAW,CAAA;AACzB"}
@@ -16,6 +16,8 @@ export interface RebaseLayoutProps {
16
16
  defaultDrawerOpen?: boolean;
17
17
  /** Path to the logo shown in the drawer and top bar. Falls back to the Rebase mark. */
18
18
  logo?: string;
19
+ /** The logo for the dark theme, when `logo` would not read on a dark background. Falls back to `logo`. */
20
+ logoDark?: string;
19
21
  /** Dev views passed to AdminModeSyncer (resolved from RebaseNavigation). */
20
22
  devViews?: AppView[];
21
23
  }
@@ -34,13 +34,14 @@ import { Outlet } from "react-router";
34
34
  * ```
35
35
  */
36
36
  function RebaseLayout(props) {
37
- const { title = "Rebase", appBar, drawer, autoOpenDrawer = true, defaultDrawerOpen = false, logo, devViews = [] } = props;
37
+ const { title = "Rebase", appBar, drawer, autoOpenDrawer = true, defaultDrawerOpen = false, logo, logoDark, devViews = [] } = props;
38
38
  const adminModeController = useAdminModeController();
39
39
  const ResolvedDrawer = useComponentOverride("Shell.Drawer", Drawer);
40
40
  const ResolvedAppBar = useComponentOverride("Shell.AppBar", DefaultAppBar);
41
41
  const ActiveAppBar = appBar ?? (ResolvedAppBar !== DefaultAppBar ? /* @__PURE__ */ jsx(ResolvedAppBar, {
42
42
  title,
43
- logo
43
+ logo,
44
+ logoDark
44
45
  }) : null);
45
46
  const ActiveDrawer = drawer ?? /* @__PURE__ */ jsx(ResolvedDrawer, {
46
47
  title,
@@ -50,6 +51,7 @@ function RebaseLayout(props) {
50
51
  autoOpenDrawer,
51
52
  defaultDrawerOpen,
52
53
  logo,
54
+ logoDark,
53
55
  children: [
54
56
  /* @__PURE__ */ jsx(AdminModeSyncer, { devViews }),
55
57
  ActiveAppBar,
@@ -1 +1 @@
1
- {"version":3,"file":"RebaseLayout.js","names":[],"sources":["../../src/components/RebaseLayout.tsx"],"sourcesContent":["import React from \"react\";\nimport { Outlet } from \"react-router\";\nimport {\n useAdminModeController,\n useComponentOverride,\n useRebaseRegistry\n} from \"@rebasepro/app\";\n\nimport { Scaffold } from \"./app/Scaffold\";\nimport { Drawer } from \"./app/Drawer\";\nimport { DefaultAppBar } from \"./DefaultAppBar\";\nimport { SideDialogs } from \"./SideDialogs\";\nimport { AdminModeSyncer } from \"./AdminModeSyncer\";\nimport type { AppView } from \"@rebasepro/cms-types\";\n\nexport interface RebaseLayoutProps {\n /** Title shown in the drawer. */\n title?: string;\n /**\n * Top bar. Only rendered if provided — pass `<AppBar/>` for the default\n * one — or when `<Rebase components>` overrides `\"Shell.AppBar\"`.\n */\n appBar?: React.ReactNode;\n /** Custom Drawer to override the default. */\n drawer?: React.ReactNode;\n /** Expand the drawer while the pointer is over it. On by default; pass `false` to opt out. Not a load-time default — that is `defaultDrawerOpen`. */\n autoOpenDrawer?: boolean;\n /** Start with the drawer expanded instead of collapsed to icons. Ignored on small layouts. */\n defaultDrawerOpen?: boolean;\n /** Path to the logo shown in the drawer and top bar. Falls back to the Rebase mark. */\n logo?: string;\n /** Dev views passed to AdminModeSyncer (resolved from RebaseNavigation). */\n devViews?: AppView[];\n}\n\n/**\n * Layout layer — provides the Scaffold, Drawer, and SideDialogs.\n *\n * Wraps the route outlet with the standard Rebase admin layout.\n * Override the drawer via props; pass `appBar` to add a top bar (there is\n * none by default — the drawer owns navigation and user actions).\n *\n * **Independently usable**: Use this when you want the Rebase layout\n * without its default route definitions.\n *\n * It takes no children: the routed view arrives through react-router's\n * `<Outlet/>`. This example used to pass `<Route>` elements, which is neither\n * what the component renders nor something `RebaseLayoutProps` accepts — a\n * reader following it wrote a type error whose message was about `children`,\n * not about routes.\n *\n * Hand it to `<RebaseRouteDefs layout>`, which renders the routes inside it:\n *\n * @example\n * ```tsx\n * <RebaseRouteDefs layout={<RebaseLayout title=\"My Admin\" appBar={<AppBar/>}/>}>\n * <Route path=\"/custom\" element={<CustomView/>}/>\n * </RebaseRouteDefs>\n * ```\n */\nexport function RebaseLayout(props: RebaseLayoutProps) {\n const {\n title = \"Rebase\",\n appBar,\n drawer,\n autoOpenDrawer = true,\n defaultDrawerOpen = false,\n logo,\n devViews = []\n } = props;\n\n const adminModeController = useAdminModeController();\n const ResolvedDrawer = useComponentOverride(\"Shell.Drawer\", Drawer);\n const ResolvedAppBar = useComponentOverride(\"Shell.AppBar\", DefaultAppBar);\n\n // There is no top bar by default, so an override of it is also the ask\n // for one: a replacement renders on its own, and a wrapper is handed the\n // default bar as `OriginalComponent`. An `appBar` element still wins, the\n // way a `drawer` element wins over a `\"Shell.Drawer\"` override.\n const ActiveAppBar = appBar ?? (ResolvedAppBar !== DefaultAppBar\n ? <ResolvedAppBar title={title} logo={logo}/>\n : null);\n\n const ActiveDrawer = drawer ?? (\n <ResolvedDrawer\n title={title}\n logoDestination={adminModeController.mode === \"studio\" ? \"/s\" : \"/\"}\n />\n );\n\n return (\n <Scaffold autoOpenDrawer={autoOpenDrawer} defaultDrawerOpen={defaultDrawerOpen} logo={logo}>\n <AdminModeSyncer devViews={devViews}/>\n {ActiveAppBar}\n {ActiveDrawer}\n <Outlet/>\n <SideDialogs/>\n </Scaffold>\n );\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA4DA,SAAgB,aAAa,OAA0B;CACnD,MAAM,EACF,QAAQ,UACR,QACA,QACA,iBAAiB,MACjB,oBAAoB,OACpB,MACA,WAAW,CAAC,MACZ;CAEJ,MAAM,sBAAsB,uBAAuB;CACnD,MAAM,iBAAiB,qBAAqB,gBAAgB,MAAM;CAClE,MAAM,iBAAiB,qBAAqB,gBAAgB,aAAa;CAMzE,MAAM,eAAe,WAAW,mBAAmB,gBAC7C,oBAAC,gBAAD;EAAuB;EAAa;CAAM,CAAA,IAC1C;CAEN,MAAM,eAAe,UACjB,oBAAC,gBAAD;EACW;EACP,iBAAiB,oBAAoB,SAAS,WAAW,OAAO;CACnE,CAAA;CAGL,OACI,qBAAC,UAAD;EAA0B;EAAmC;EAAyB;YAAtF;GACI,oBAAC,iBAAD,EAA2B,SAAU,CAAA;GACpC;GACA;GACD,oBAAC,QAAD,CAAQ,CAAA;GACR,oBAAC,aAAD,CAAa,CAAA;EACP;;AAElB"}
1
+ {"version":3,"file":"RebaseLayout.js","names":[],"sources":["../../src/components/RebaseLayout.tsx"],"sourcesContent":["import React from \"react\";\nimport { Outlet } from \"react-router\";\nimport {\n useAdminModeController,\n useComponentOverride,\n useRebaseRegistry\n} from \"@rebasepro/app\";\n\nimport { Scaffold } from \"./app/Scaffold\";\nimport { Drawer } from \"./app/Drawer\";\nimport { DefaultAppBar } from \"./DefaultAppBar\";\nimport { SideDialogs } from \"./SideDialogs\";\nimport { AdminModeSyncer } from \"./AdminModeSyncer\";\nimport type { AppView } from \"@rebasepro/cms-types\";\n\nexport interface RebaseLayoutProps {\n /** Title shown in the drawer. */\n title?: string;\n /**\n * Top bar. Only rendered if provided — pass `<AppBar/>` for the default\n * one — or when `<Rebase components>` overrides `\"Shell.AppBar\"`.\n */\n appBar?: React.ReactNode;\n /** Custom Drawer to override the default. */\n drawer?: React.ReactNode;\n /** Expand the drawer while the pointer is over it. On by default; pass `false` to opt out. Not a load-time default — that is `defaultDrawerOpen`. */\n autoOpenDrawer?: boolean;\n /** Start with the drawer expanded instead of collapsed to icons. Ignored on small layouts. */\n defaultDrawerOpen?: boolean;\n /** Path to the logo shown in the drawer and top bar. Falls back to the Rebase mark. */\n logo?: string;\n /** The logo for the dark theme, when `logo` would not read on a dark background. Falls back to `logo`. */\n logoDark?: string;\n /** Dev views passed to AdminModeSyncer (resolved from RebaseNavigation). */\n devViews?: AppView[];\n}\n\n/**\n * Layout layer — provides the Scaffold, Drawer, and SideDialogs.\n *\n * Wraps the route outlet with the standard Rebase admin layout.\n * Override the drawer via props; pass `appBar` to add a top bar (there is\n * none by default — the drawer owns navigation and user actions).\n *\n * **Independently usable**: Use this when you want the Rebase layout\n * without its default route definitions.\n *\n * It takes no children: the routed view arrives through react-router's\n * `<Outlet/>`. This example used to pass `<Route>` elements, which is neither\n * what the component renders nor something `RebaseLayoutProps` accepts — a\n * reader following it wrote a type error whose message was about `children`,\n * not about routes.\n *\n * Hand it to `<RebaseRouteDefs layout>`, which renders the routes inside it:\n *\n * @example\n * ```tsx\n * <RebaseRouteDefs layout={<RebaseLayout title=\"My Admin\" appBar={<AppBar/>}/>}>\n * <Route path=\"/custom\" element={<CustomView/>}/>\n * </RebaseRouteDefs>\n * ```\n */\nexport function RebaseLayout(props: RebaseLayoutProps) {\n const {\n title = \"Rebase\",\n appBar,\n drawer,\n autoOpenDrawer = true,\n defaultDrawerOpen = false,\n logo,\n logoDark,\n devViews = []\n } = props;\n\n const adminModeController = useAdminModeController();\n const ResolvedDrawer = useComponentOverride(\"Shell.Drawer\", Drawer);\n const ResolvedAppBar = useComponentOverride(\"Shell.AppBar\", DefaultAppBar);\n\n // There is no top bar by default, so an override of it is also the ask\n // for one: a replacement renders on its own, and a wrapper is handed the\n // default bar as `OriginalComponent`. An `appBar` element still wins, the\n // way a `drawer` element wins over a `\"Shell.Drawer\"` override.\n const ActiveAppBar = appBar ?? (ResolvedAppBar !== DefaultAppBar\n ? <ResolvedAppBar title={title} logo={logo} logoDark={logoDark}/>\n : null);\n\n const ActiveDrawer = drawer ?? (\n <ResolvedDrawer\n title={title}\n logoDestination={adminModeController.mode === \"studio\" ? \"/s\" : \"/\"}\n />\n );\n\n return (\n <Scaffold autoOpenDrawer={autoOpenDrawer} defaultDrawerOpen={defaultDrawerOpen} logo={logo} logoDark={logoDark}>\n <AdminModeSyncer devViews={devViews}/>\n {ActiveAppBar}\n {ActiveDrawer}\n <Outlet/>\n <SideDialogs/>\n </Scaffold>\n );\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA8DA,SAAgB,aAAa,OAA0B;CACnD,MAAM,EACF,QAAQ,UACR,QACA,QACA,iBAAiB,MACjB,oBAAoB,OACpB,MACA,UACA,WAAW,CAAC,MACZ;CAEJ,MAAM,sBAAsB,uBAAuB;CACnD,MAAM,iBAAiB,qBAAqB,gBAAgB,MAAM;CAClE,MAAM,iBAAiB,qBAAqB,gBAAgB,aAAa;CAMzE,MAAM,eAAe,WAAW,mBAAmB,gBAC7C,oBAAC,gBAAD;EAAuB;EAAa;EAAgB;CAAU,CAAA,IAC9D;CAEN,MAAM,eAAe,UACjB,oBAAC,gBAAD;EACW;EACP,iBAAiB,oBAAoB,SAAS,WAAW,OAAO;CACnE,CAAA;CAGL,OACI,qBAAC,UAAD;EAA0B;EAAmC;EAAyB;EAAgB;YAAtG;GACI,oBAAC,iBAAD,EAA2B,SAAU,CAAA;GACpC;GACA;GACD,oBAAC,QAAD,CAAQ,CAAA;GACR,oBAAC,aAAD,CAAa,CAAA;EACP;;AAElB"}
@@ -7,17 +7,17 @@ import { callerHoldsScope, reportsScopes } from "../util/caller_scopes.js";
7
7
  import { useBuildNavigationStateController } from "../hooks/navigation/useBuildNavigationStateController.js";
8
8
  import { useBuildUrlController } from "../hooks/navigation/useBuildUrlController.js";
9
9
  import { withUserLayer } from "../hooks/navigation/ui_preferences.js";
10
- import { ConfigControllerProvider } from "../collection_editor/ConfigControllerProvider.js";
11
10
  import { SidePanelProvider } from "./SidePanelProvider.js";
12
11
  import { composeCollectionsInput } from "../hooks/navigation/compose_collections_input.js";
13
12
  import { usePanelTables } from "../hooks/navigation/usePanelTables.js";
14
13
  import { CollectionsScopeContext } from "./CollectionsScopeContext.js";
15
14
  import { useLocalCollectionsConfigController } from "../collection_editor/useLocalCollectionsConfigController.js";
15
+ import { ConfigControllerProvider } from "../collection_editor/ConfigControllerProvider.js";
16
16
  import { useCollectionsConfigController } from "../collection_editor/useCollectionsConfigController.js";
17
17
  import { Suspense, useCallback, useContext, useEffect, useMemo, useRef, useState } from "react";
18
18
  import { jsx, jsxs } from "react/jsx-runtime";
19
19
  import { CircularProgressCenter, lazyChunk } from "@rebasepro/ui";
20
- import { buildRoutedRebaseData } from "@rebasepro/cms-types";
20
+ import { buildRoutedRebaseData, studioSchemaToolEnabled } from "@rebasepro/cms-types";
21
21
  import { CollectionResolverRegistrationContext, CustomizationControllerContext, RebaseDataContext, StudioBridgeRegistryProvider, UserConfigurationPersistenceContext, useAdminModeController, useAuthController, useBridgeRegistration, useCustomizationController, useData, useDataSources, useRebaseClient, useRebaseContext, useRebaseEmbedHost, useRebaseRegistry, useTranslation, useUiPreferences, useUserConfigurationPersistence } from "@rebasepro/app";
22
22
  import { RebaseApiError } from "@rebasepro/types";
23
23
  import { resolveDataSource } from "@rebasepro/common";
@@ -146,19 +146,13 @@ function RebaseNavigation({ children }) {
146
146
  tables: servedTables,
147
147
  presentation: { save: uiPreferences.controller.saveWorkspace }
148
148
  } : { readOnly: true });
149
+ const { t } = useTranslation();
149
150
  const schemaView = useMemo(() => {
150
- if (!collectionEditorEnabled) return void 0;
151
- const studioTools = registry.studioConfig?.tools ?? [
152
- "sql",
153
- "js",
154
- "rls",
155
- "schema",
156
- "storage"
157
- ];
158
- if (!registry.studioConfig || !studioTools.includes("schema")) return void 0;
151
+ if (!studioSchemaToolEnabled(registry)) return void 0;
159
152
  return {
160
153
  slug: "schema",
161
- name: "Edit collections",
154
+ name: t("studio_tool_schema"),
155
+ description: t("studio_tool_schema_description"),
162
156
  group: "Database",
163
157
  icon: "LayoutList",
164
158
  nestedRoutes: true,
@@ -167,7 +161,7 @@ function RebaseNavigation({ children }) {
167
161
  children: /* @__PURE__ */ jsx(CollectionsStudioViewFromContext, {})
168
162
  })
169
163
  };
170
- }, [collectionEditorEnabled, registry.studioConfig]);
164
+ }, [registry, t]);
171
165
  const devViews = useMemo(() => {
172
166
  const base = registry.studioConfig?.devViews ?? [];
173
167
  if (schemaView) return [...base, schemaView];
@@ -195,7 +189,6 @@ function RebaseNavigation({ children }) {
195
189
  urlController,
196
190
  adminMode: adminModeController?.mode
197
191
  });
198
- const { t } = useTranslation();
199
192
  const tablesError = descriptors.status === "error" ? descriptors.error : void 0;
200
193
  const reloadTables = descriptors.reload;
201
194
  const tablesInUse = registry.cmsConfig !== null && !descriptors.unavailable;
@@ -1 +1 @@
1
- {"version":3,"file":"RebaseNavigation.js","names":[],"sources":["../../src/components/RebaseNavigation.tsx"],"sourcesContent":["import React, { useMemo, useRef, useEffect, useCallback, useContext, useState, Suspense } from \"react\";\nimport {\n useRebaseRegistry,\n useRebaseContext,\n useAuthController,\n useCustomizationController,\n useAdminModeController,\n useUserConfigurationPersistence,\n useRebaseClient,\n useData,\n useDataSources,\n CollectionResolverRegistrationContext,\n StudioBridgeRegistryProvider,\n useBridgeRegistration,\n CustomizationControllerContext,\n RebaseDataContext,\n UserConfigurationPersistenceContext,\n useRebaseEmbedHost,\n useTranslation,\n useUiPreferences\n} from \"@rebasepro/app\";\nimport { resolveDataSource } from \"@rebasepro/common\";\nimport { buildRoutedRebaseData } from \"@rebasepro/cms-types\";\nimport { CircularProgressCenter, lazyChunk } from \"@rebasepro/ui\";\n\nimport type { AppView, CollectionCustomView, CollectionEditorOptions, EntityCustomView, EntityAction, RebasePlugin, AdminCollection, TableCustomization } from \"@rebasepro/cms-types\";\nimport { RebaseApiError } from \"@rebasepro/types\";\nimport type { UrlController, NavigationStateController, CollectionRegistryController } from \"@rebasepro/cms-types\";\n\nconst EMPTY_PLUGINS: RebasePlugin[] = [];\nconst NO_COLLECTIONS: AdminCollection[] = [];\nconst NO_CUSTOMIZATIONS: readonly TableCustomization[] = [];\nconst NO_EXTERNAL_COLLECTIONS: readonly AdminCollection[] = [];\n\nimport { useBuildNavigationStateController } from \"../hooks/navigation/useBuildNavigationStateController\";\nimport { useBuildUrlController } from \"../hooks/navigation/useBuildUrlController\";\nimport { useBuildCollectionRegistryController } from \"../hooks/navigation/useBuildCollectionRegistryController\";\nimport { composeCollectionsInput } from \"../hooks/navigation/compose_collections_input\";\nimport { withUserLayer } from \"../hooks/navigation/ui_preferences\";\nimport { usePanelTables } from \"../hooks/navigation/usePanelTables\";\n\nimport { CollectionRegistryContext } from \"../hooks/navigation/contexts/CollectionRegistryContext\";\nimport { UrlContext } from \"../hooks/navigation/contexts/UrlContext\";\nimport { NavigationStateContext } from \"../hooks/navigation/contexts/NavigationStateContext\";\n\nimport { SidePanelProvider } from \"./SidePanelProvider\";\nimport { CollectionsScopeContext } from \"./CollectionsScopeContext\";\nimport { prefetchRecordViews } from \"./lazy_record_views\";\n\n// Collection editor internals — used when collectionEditor is enabled\nimport { useLocalCollectionsConfigController } from \"../collection_editor/useLocalCollectionsConfigController\";\nimport { ConfigControllerProvider } from \"../collection_editor/ConfigControllerProvider\";\nimport { useCollectionsConfigController } from \"../collection_editor/useCollectionsConfigController\";\nimport { callerHoldsScope, reportsScopes } from \"../util/caller_scopes\";\n\n// Lazy-load the schema view — only fetched when studio schema tool is active\nconst CollectionsStudioView = lazyChunk(() =>\n import(\"../collection_editor/ui/collection_editor/RouterCollectionsStudioView\")\n .then(m => ({ default: m.RouterCollectionsStudioView }))\n);\n\nexport interface RebaseNavigationProps {\n children: React.ReactNode;\n}\n\n/**\n * Navigation layer — builds and provides all admin navigation controllers:\n * collection registry, URL controller, navigation state, side entity,\n * and the self-assembling Studio bridge.\n *\n * Also handles the collection editor config controller when enabled.\n *\n * **Independently usable**: Use this when you need admin navigation\n * (entity tables, side panels) in a custom layout.\n *\n * @example\n * ```tsx\n * <RebaseNavigation>\n * <MyCustomLayout>\n * <CollectionViewBinding ... />\n * </MyCustomLayout>\n * </RebaseNavigation>\n * ```\n */\nexport function RebaseNavigation({ children }: RebaseNavigationProps) {\n const registry = useRebaseRegistry();\n // Mounted behind the auth gate: someone is signed in, so the collection\n // table and record views are about to be wanted. Fetch them while idle.\n useEffect(() => prefetchRecordViews(), []);\n const context = useRebaseContext();\n const adminModeController = useAdminModeController();\n // The store the rest of the panel reads. Built one level up, by\n // `<Rebase>`, so the registry here and the collection views below merge\n // from the same cache — a second instance built here would keep its own.\n const browserUserConfigPersistence = useUserConfigurationPersistence();\n\n // ── Collection Editor resolution ──────────────────────────────────\n // The collection editor is ALWAYS enabled when Studio is registered.\n // The `collectionEditor` admin config is for fine-tuning (readOnly, auth, etc.),\n // not for opting-in. When omitted, the editor defaults to enabled\n // (read-only in production).\n const collectionEditorConfig = registry.cmsConfig?.collectionEditor;\n const collectionEditorEnabled = Boolean(collectionEditorConfig) || Boolean(registry.studioConfig);\n const collectionEditorOptions: CollectionEditorOptions | undefined = useMemo(() => {\n if (collectionEditorConfig === true || !collectionEditorConfig) return {};\n return collectionEditorConfig;\n }, [collectionEditorConfig]);\n\n // ── The collections: served tables and external ones ──────────────\n // Every table the server serves the signed-in user (or the ones handed\n // to <RebaseCMS tables>), projected and customized, beside the\n // collections whose rows live elsewhere (Firestore). Only with a\n // <RebaseCMS> registered: a Studio alone shows no collections.\n const tableCustomizations = registry.cmsConfig?.tableCustomizations ?? NO_CUSTOMIZATIONS;\n const externalCollections = registry.cmsConfig?.externalCollections ?? NO_EXTERNAL_COLLECTIONS;\n const descriptors = usePanelTables(registry.cmsConfig?.tables, registry.cmsConfig !== null);\n const servedTables = descriptors.tables;\n // In an embedding (an MCP App view) the panel asks the server for no\n // preferences: the embedding received them with the screen, and they are\n // folded here exactly as the panel's own — the server's `ui-config.json`\n // where the app passes no `uiConfig` of its own.\n const embeddedPreferences = useRebaseEmbedHost()?.uiPreferences;\n const uiConfig = registry.cmsConfig?.uiConfig ?? embeddedPreferences?.file;\n\n // ── UI preferences: the workspace's, and the signed-in user's own ──\n // How each table is presented, as the collection editor saved it for\n // everybody and as the views remember it for this user. The user's live\n // on the server when it keeps them, in the browser otherwise; everything\n // below reads them through the persistence provided here.\n const preferencesClient = useRebaseClient();\n const preferencesAuth = useAuthController();\n const inEmbedding = useRebaseEmbedHost() !== undefined;\n const uiPreferences = useUiPreferences({\n transport: preferencesClient,\n getAuthToken: preferencesAuth?.getAuthToken,\n authKey: preferencesAuth?.user?.uid ?? null,\n enabled: registry.cmsConfig !== null && Boolean(preferencesAuth?.user) && !inEmbedding,\n local: browserUserConfigPersistence\n });\n const embeddedUser = embeddedPreferences?.user;\n const userConfigPersistence = useMemo(\n () => embeddedUser && uiPreferences.userPersistence\n ? withUserLayer(uiPreferences.userPersistence, embeddedUser)\n : uiPreferences.userPersistence,\n [embeddedUser, uiPreferences.userPersistence]);\n const workspacePreferences = embeddedPreferences?.workspace ?? uiPreferences.controller.workspace;\n\n // What the composition last produced, for the collection editor, which\n // lists and edits the collections the panel shows.\n const [composedCollections, setComposedCollections] = useState<AdminCollection[]>(NO_COLLECTIONS);\n\n // In an embedding (an MCP App view, `embed_host.ts`), the collections are\n // the app's own — custom fields, previews, views and actions included —\n // narrowed to what the person may see and do there.\n const narrow = useRebaseEmbedHost()?.narrowCollections;\n\n // ── Build the navigation controllers ──────────────────────────────\n const collectionsBuilder = useMemo(() => {\n const composed = composeCollectionsInput({\n tables: servedTables,\n tableCustomizations,\n externalCollections,\n uiConfig,\n workspacePreferences\n });\n return async (params: Parameters<typeof composed>[0]) => {\n const collections = await composed(params);\n setComposedCollections(collections);\n return narrow ? narrow(collections) : collections;\n };\n }, [servedTables, tableCustomizations, externalCollections, uiConfig, workspacePreferences, narrow]);\n\n const dataSources = useDataSources();\n const collectionRegistryController = useBuildCollectionRegistryController({ userConfigPersistence, dataSources: dataSources.registry });\n\n // ── Multi-data-source routing ─────────────────────────────────────\n // Combine the default data source (server transport) with the registered\n // direct/custom sources from <Rebase> and route each collection by its\n // resolved data-source key, looked up by path against the collection\n // registry. A stable resolver ref keeps the routed data instance\n // referentially stable across registry rebuilds, so data-effect\n // dependencies don't thrash.\n const defaultData = useData();\n const getCollectionRef = useRef(collectionRegistryController.getCollection);\n getCollectionRef.current = collectionRegistryController.getCollection;\n\n // Hand the data layer a way to read this registry. It was built by <Rebase>,\n // above us, and needs a collection's primary keys to give its rows an\n // address — rows themselves carry only columns.\n //\n // Registered during render, not in an effect: the views that fetch rows are\n // below us, and their effects run before ours, so an effect here would bind\n // after the first page had already been converted. The call only assigns a\n // ref, so repeating it per render is free.\n //\n // With it goes where each collection is stored: a direct driver has to be\n // handed the `path` a Firestore collection declares, not its slug.\n const registerCollectionResolver = useContext(CollectionResolverRegistrationContext);\n const resolveCollection = useCallback(\n (slug: string) => getCollectionRef.current(slug),\n []);\n registerCollectionResolver(resolveCollection, collectionRegistryController.resolveDataPath);\n const routedData = useMemo(() => buildRoutedRebaseData({\n defaultData,\n sources: dataSources.sources,\n resolveKey: (slugOrPath) => resolveDataSource(getCollectionRef.current(slugOrPath), dataSources.registry).key\n }), [defaultData, dataSources]);\n\n // Normalize the configured mount prefix to a leading-slash, no-trailing-slash\n // form (e.g. \"admin\" or \"/admin/\" -> \"/admin\"); empty/\"/\" stays \"/\".\n const basePath = useMemo(() => {\n const raw = registry.cmsConfig?.basePath;\n if (!raw || raw === \"/\") return \"/\";\n const trimmed = raw.replace(/^\\/+/, \"\").replace(/\\/+$/, \"\");\n return trimmed ? `/${trimmed}` : \"/\";\n }, [registry.cmsConfig?.basePath]);\n\n const builtUrlController = useBuildUrlController({\n basePath,\n baseCollectionPath: \"/c\",\n collectionRegistryController\n });\n // In an embedding (an MCP App view) no route draws a record's page: a\n // record opens over the screen, as it does under a CollectionsProvider.\n const embedded = useRebaseEmbedHost() !== undefined;\n const urlController = useMemo<UrlController>(() => embedded ? {\n ...builtUrlController,\n isUrlCollectionPath: () => false,\n routesMounted: false\n } : builtUrlController, [builtUrlController, embedded]);\n\n // ── Build config controller internally when collection editor is enabled ──\n const rebaseClient = useRebaseClient();\n const authController = useAuthController();\n\n // ── Dev-only data-source sanity check ─────────────────────────────\n // Warn about data sources declared with a direct/custom transport that\n // have no client-side driver — these silently fall back to the default\n // (server) source, a common source of misrouting. Unambiguous: it never\n // false-positives on server-mediated sources (which intentionally have\n // no client driver).\n useEffect(() => {\n if (process.env.NODE_ENV === \"production\") return;\n const { registry, sources } = dataSources;\n const missing = Object.values(registry)\n .filter((d) => (d.transport === \"direct\" || d.transport === \"custom\") && !sources[d.key])\n .map((d) => d.key);\n if (missing.length > 0) {\n console.warn(\n `[Rebase] These data source(s) declare a direct/custom transport but have no client-side driver and will fall back to the default data source: ${missing.map(k => `\"${k}\"`).join(\", \")}. ` +\n `Provide a \\`driver\\` for them in \\`dataSources\\` on <Rebase>.`\n );\n }\n }, [dataSources]);\n\n // `readOnly` is left undefined unless the developer set it: the controller\n // asks the backend whether its schema editor will accept a write, which is\n // the only process that knows. Deciding it here from `process.env.NODE_ENV`\n // — the *frontend bundle's* build mode — is what made the editor offer\n // itself against production backends, `baas` projects and servers without\n // `ts-morph`, and turned every save into a bare 404.\n //\n // Both of its status routes require `schema:read`. Asked by someone\n // without it, each answers 403 on every page load. So when the controller\n // reports scopes, it is not asked until they include that one. A\n // controller that does not report them leaves the backend to answer.\n const internalConfigController = useLocalCollectionsConfigController(\n rebaseClient,\n composedCollections,\n collectionEditorEnabled ? {\n readOnly: collectionEditorOptions?.readOnly,\n getAuthToken: collectionEditorOptions?.getAuthToken ?? authController?.getAuthToken,\n authKey: authController?.user?.uid ?? null,\n mayReadSchema: reportsScopes(authController)\n ? callerHoldsScope(authController, \"schema:read\")\n : undefined,\n tables: servedTables,\n presentation: { save: uiPreferences.controller.saveWorkspace }\n } : { readOnly: true }\n );\n\n // ── Auto-inject schema view into Studio devViews ──────────────────\n const schemaView: AppView | undefined = useMemo(() => {\n if (!collectionEditorEnabled) return undefined;\n // Only inject when Studio is registered and includes \"schema\" tool (or all tools)\n const studioTools = registry.studioConfig?.tools ?? [\"sql\", \"js\", \"rls\", \"schema\", \"storage\"];\n if (!registry.studioConfig || !studioTools.includes(\"schema\")) return undefined;\n return {\n slug: \"schema\",\n name: \"Edit collections\",\n group: \"Database\",\n icon: \"LayoutList\",\n nestedRoutes: true,\n // Reads the controller from context at render time rather than\n // capturing it here. A view is a React *element*, and the\n // navigation state controller resolves the view list once and holds\n // on to the elements it resolved — so a controller passed as a prop\n // is frozen at whatever it was on the first render, forever. That\n // hid every later change: the editor stayed writable after the\n // backend said it was read-only, and the collection list never\n // refreshed. Everything else in the editor already reads this from\n // `ConfigControllerProvider`, which wraps this subtree.\n view: (\n <Suspense fallback={<CircularProgressCenter/>}>\n <CollectionsStudioViewFromContext/>\n </Suspense>\n )\n };\n }, [collectionEditorEnabled, registry.studioConfig]);\n\n const devViews = useMemo(() => {\n const base = registry.studioConfig?.devViews ?? [];\n if (schemaView) return [...base, schemaView];\n return base;\n }, [registry.studioConfig?.devViews, schemaView]);\n\n // Merge admin-registered views with Studio dev views.\n // Order: admin views (developer's primary content) → Studio dev views (tooling).\n // Plugin views are merged later inside resolveAppViews.\n const cmsViews = registry.cmsConfig?.views;\n const mergedViews = useMemo(() => {\n if (!cmsViews) return devViews;\n if (Array.isArray(cmsViews) && cmsViews.length === 0) return devViews;\n // When cmsViews is a builder function, wrap it to append devViews after resolution\n if (typeof cmsViews === \"function\") {\n return async (params: Parameters<typeof cmsViews>[0]) => {\n const resolved = await cmsViews(params) ?? [];\n return [...resolved, ...devViews];\n };\n }\n return [...cmsViews, ...devViews];\n }, [cmsViews, devViews]);\n\n const parentCustomizationController = useCustomizationController();\n\n const builtNavigationStateController = useBuildNavigationStateController({\n plugins: parentCustomizationController.plugins ?? EMPTY_PLUGINS,\n collections: collectionsBuilder,\n // Until the tables arrive, no route that needs a collection renders:\n // they show the loading state, not \"collection not found\", and a deep\n // link resolves once the collections built from them are registered.\n collectionsPending: descriptors.status === \"loading\",\n views: mergedViews,\n navigationGroupMappings: registry.cmsConfig?.navigationGroupMappings,\n authController: context.authController!,\n // The collection and view builders get the rows the server sends.\n data: context.data,\n collectionRegistryController,\n urlController,\n adminMode: adminModeController?.mode\n });\n\n // A failure to load the tables is the navigation's loading error: the home\n // page and a route to a collection that could not be built say what failed\n // and offer to retry. A session the server no longer accepts is the\n // client's to renew, and it signs out when it cannot — so the error says to\n // sign in again.\n //\n // Refreshing the navigation asks for the tables again too: it is what the\n // collection editor calls after it changed the schema, and with an `ETag`\n // an unchanged schema costs a 304.\n const { t } = useTranslation();\n const tablesError = descriptors.status === \"error\" ? descriptors.error : undefined;\n const reloadTables = descriptors.reload;\n const tablesInUse = registry.cmsConfig !== null && !descriptors.unavailable;\n const navigationStateController = useMemo<NavigationStateController>(() => {\n if (!tablesInUse) return builtNavigationStateController;\n const signedOut = tablesError instanceof RebaseApiError && tablesError.status === 401;\n const error = tablesError\n ? new Error(signedOut\n ? t(\"tables_load_signed_out\")\n : t(\"tables_load_failed\", { message: tablesError.message }), { cause: tablesError })\n : undefined;\n return {\n ...builtNavigationStateController,\n navigationLoadingError: builtNavigationStateController.navigationLoadingError ?? error,\n refreshNavigation: () => {\n reloadTables();\n builtNavigationStateController.refreshNavigation();\n }\n };\n }, [builtNavigationStateController, tablesInUse, tablesError, reloadTables, t]);\n\n // ── Merge admin-registered entityViews/entityActions into the customization controller ──\n // The <Rebase> component builds the customizationController from its own props,\n // but entity views passed to <RebaseCMS> are stored in the registry and not\n // automatically merged. We re-provide an enriched controller here so that\n // downstream consumers (EditViewBinding, side panels, etc.) can resolve\n // string-keyed entity views like \"blog_preview\".\n const enrichedCustomizationController = useMemo(() => {\n const cmsEntityViews = (registry.cmsConfig?.entityViews ?? []) as EntityCustomView[];\n const cmsEntityActions = (registry.cmsConfig?.entityActions ?? []) as EntityAction[];\n // Collection view modes ride the same channel, for the same reason:\n // `admin.customViews: [\"map\"]` has to find the component somewhere.\n const cmsCollectionViews = (registry.cmsConfig?.collectionViews ?? []) as CollectionCustomView[];\n if (cmsEntityViews.length === 0 && cmsEntityActions.length === 0 && cmsCollectionViews.length === 0) {\n return parentCustomizationController;\n }\n return {\n ...parentCustomizationController,\n entityViews: [\n ...(parentCustomizationController.entityViews ?? []),\n ...cmsEntityViews.filter(v => !(parentCustomizationController.entityViews ?? []).some(ev => ev.key === v.key))\n ],\n entityActions: [\n ...(parentCustomizationController.entityActions ?? []),\n ...cmsEntityActions.filter(a => !(parentCustomizationController.entityActions ?? []).some(ea => ea.key === a.key))\n ],\n collectionViews: [\n ...(parentCustomizationController.collectionViews ?? []),\n ...cmsCollectionViews.filter(v => !(parentCustomizationController.collectionViews ?? []).some(cv => cv.key === v.key))\n ]\n };\n }, [parentCustomizationController, registry.cmsConfig?.entityViews, registry.cmsConfig?.entityActions, registry.cmsConfig?.collectionViews]);\n\n // ── Inner content with all context providers ──────────────────────\n // Re-provide RebaseDataContext with the routed data so that every admin\n // consumer (list/entity views, references, board, import/export, and\n // `context.data`) is routed to the correct driver by collection path.\n const navigationContent = (\n <UserConfigurationPersistenceContext.Provider value={userConfigPersistence}>\n <CollectionsScopeContext.Provider value={true}>\n <RebaseDataContext.Provider value={routedData}>\n <CustomizationControllerContext.Provider value={enrichedCustomizationController}>\n <StudioBridgeRegistryProvider>\n <CollectionRegistryContext.Provider value={collectionRegistryController}>\n <UrlContext.Provider value={urlController}>\n <NavigationStateContext.Provider value={navigationStateController}>\n <SidePanelProvider>\n <BridgeAutoRegistrar\n collectionRegistryController={collectionRegistryController}\n urlController={urlController}\n navigationStateController={navigationStateController}\n canWriteToCodebase={!internalConfigController.readOnly}\n />\n {children}\n </SidePanelProvider>\n </NavigationStateContext.Provider>\n </UrlContext.Provider>\n </CollectionRegistryContext.Provider>\n </StudioBridgeRegistryProvider>\n </CustomizationControllerContext.Provider>\n </RebaseDataContext.Provider>\n </CollectionsScopeContext.Provider>\n </UserConfigurationPersistenceContext.Provider>\n );\n\n // ── Wrap with ConfigControllerProvider when collection editor is enabled ──\n if (collectionEditorEnabled) {\n return (\n <ConfigControllerProvider\n collectionConfigController={internalConfigController}\n pathSuggestions={collectionEditorOptions?.pathSuggestions}\n >\n {navigationContent}\n </ConfigControllerProvider>\n );\n }\n\n return navigationContent;\n}\n\n/**\n * The injected \"Edit collections\" view, bound to the live config controller.\n *\n * Exists so the element stored in the navigation state does not close over a\n * controller instance — see the comment at its construction site.\n */\nfunction CollectionsStudioViewFromContext() {\n const configController = useCollectionsConfigController();\n return <CollectionsStudioView configController={configController}/>;\n}\n\n/**\n * Internal component that auto-registers admin controllers into the\n * self-assembling Studio bridge. Must be rendered inside both the\n * navigation contexts and the StudioBridgeRegistryProvider.\n */\nfunction BridgeAutoRegistrar({\n collectionRegistryController,\n urlController,\n navigationStateController,\n canWriteToCodebase\n}: {\n collectionRegistryController: CollectionRegistryController;\n urlController: UrlController;\n navigationStateController: NavigationStateController;\n canWriteToCodebase: boolean;\n}) {\n useBridgeRegistration(\"collectionRegistry\", collectionRegistryController);\n useBridgeRegistration(\"urlController\", urlController);\n useBridgeRegistration(\"navigationState\", navigationStateController);\n\n // Studio tools that would write into the project's collection source — the\n // RLS editor's policy save for a mapped table, its \"Import to codebase\" —\n // ask the bridge whether that write can land. The default is `true`, which\n // is what an admin panel sitting next to its own `collectionsDir` assumes;\n // it is wrong for exactly the same backends that make the collection editor\n // read-only, so the two now answer from one source.\n const capabilities = useMemo(() => ({ codebase: canWriteToCodebase }), [canWriteToCodebase]);\n useBridgeRegistration(\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AW;EAAe,SAAS,WAAW;CAAe,CAAC;CAM3I,MAAM,oBACF,oBAAC,oCAAoC,UAArC;EAA8C,OAAO;YACrD,oBAAC,wBAAwB,UAAzB;GAAkC,OAAO;aACzC,oBAAC,kBAAkB,UAAnB;IAA4B,OAAO;cACnC,oBAAC,+BAA+B,UAAhC;KAAyC,OAAO;eAChD,oBAAC,8BAAD,EAAA,UACI,oBAAC,0BAA0B,UAA3B;MAAoC,OAAO;gBACvC,oBAAC,WAAW,UAAZ;OAAqB,OAAO;iBACxB,oBAAC,uBAAuB,UAAxB;QAAiC,OAAO;kBACpC,qBAAC,mBAAD,EAAA,UAAA,CACI,oBAAC,qBAAD;SACkC;SACf;SACY;SAC3B,oBAAoB,CAAC,yBAAyB;QACjD,CAAA,GACA,QACc,EAAA,CAAA;OACU,CAAA;MAChB,CAAA;KACW,CAAA,EACV,CAAA;IACW,CAAA;GACb,CAAA;EACM,CAAA;CACY,CAAA;CAIlD,IAAI,yBACA,OACI,oBAAC,0BAAD;EACI,4BAA4B;EAC5B,iBAAiB,yBAAyB;YAEzC;CACqB,CAAA;CAIlC,OAAO;AACX;;;;;;;AAQA,SAAS,mCAAmC;CAExC,OAAO,oBAAC,uBAAD,EAAyC,kBADvB,+BACuB,EAAkB,CAAA;AACtE;;;;;;AAOA,SAAS,oBAAoB,EACzB,8BACA,eACA,2BACA,sBAMD;CACC,sBAAsB,sBAAsB,4BAA4B;CACxE,sBAAsB,iBAAiB,aAAa;CACpD,sBAAsB,mBAAmB,yBAAyB;CASlE,sBAAsB,gBADD,eAAe,EAAE,UAAU,mBAAmB,IAAI,CAAC,kBAAkB,CACpD,CAAY;CAClD,OAAO;AACX"}
1
+ {"version":3,"file":"RebaseNavigation.js","names":[],"sources":["../../src/components/RebaseNavigation.tsx"],"sourcesContent":["import React, { useMemo, useRef, useEffect, useCallback, useContext, useState, Suspense } from \"react\";\nimport {\n useRebaseRegistry,\n useRebaseContext,\n useAuthController,\n useCustomizationController,\n useAdminModeController,\n useUserConfigurationPersistence,\n useRebaseClient,\n useData,\n useDataSources,\n CollectionResolverRegistrationContext,\n StudioBridgeRegistryProvider,\n useBridgeRegistration,\n CustomizationControllerContext,\n RebaseDataContext,\n UserConfigurationPersistenceContext,\n useRebaseEmbedHost,\n useTranslation,\n useUiPreferences\n} from \"@rebasepro/app\";\nimport { resolveDataSource } from \"@rebasepro/common\";\nimport { buildRoutedRebaseData, studioSchemaToolEnabled } from \"@rebasepro/cms-types\";\nimport { CircularProgressCenter, lazyChunk } from \"@rebasepro/ui\";\n\nimport type { AppView, CollectionCustomView, CollectionEditorOptions, EntityCustomView, EntityAction, RebasePlugin, AdminCollection, TableCustomization } from \"@rebasepro/cms-types\";\nimport { RebaseApiError } from \"@rebasepro/types\";\nimport type { UrlController, NavigationStateController, CollectionRegistryController } from \"@rebasepro/cms-types\";\n\nconst EMPTY_PLUGINS: RebasePlugin[] = [];\nconst NO_COLLECTIONS: AdminCollection[] = [];\nconst NO_CUSTOMIZATIONS: readonly TableCustomization[] = [];\nconst NO_EXTERNAL_COLLECTIONS: readonly AdminCollection[] = [];\n\nimport { useBuildNavigationStateController } from \"../hooks/navigation/useBuildNavigationStateController\";\nimport { useBuildUrlController } from \"../hooks/navigation/useBuildUrlController\";\nimport { useBuildCollectionRegistryController } from \"../hooks/navigation/useBuildCollectionRegistryController\";\nimport { composeCollectionsInput } from \"../hooks/navigation/compose_collections_input\";\nimport { withUserLayer } from \"../hooks/navigation/ui_preferences\";\nimport { usePanelTables } from \"../hooks/navigation/usePanelTables\";\n\nimport { CollectionRegistryContext } from \"../hooks/navigation/contexts/CollectionRegistryContext\";\nimport { UrlContext } from \"../hooks/navigation/contexts/UrlContext\";\nimport { NavigationStateContext } from \"../hooks/navigation/contexts/NavigationStateContext\";\n\nimport { SidePanelProvider } from \"./SidePanelProvider\";\nimport { CollectionsScopeContext } from \"./CollectionsScopeContext\";\nimport { prefetchRecordViews } from \"./lazy_record_views\";\n\n// Collection editor internals — used when collectionEditor is enabled\nimport { useLocalCollectionsConfigController } from \"../collection_editor/useLocalCollectionsConfigController\";\nimport { ConfigControllerProvider } from \"../collection_editor/ConfigControllerProvider\";\nimport { useCollectionsConfigController } from \"../collection_editor/useCollectionsConfigController\";\nimport { callerHoldsScope, reportsScopes } from \"../util/caller_scopes\";\n\n// Lazy-load the schema view — only fetched when studio schema tool is active\nconst CollectionsStudioView = lazyChunk(() =>\n import(\"../collection_editor/ui/collection_editor/RouterCollectionsStudioView\")\n .then(m => ({ default: m.RouterCollectionsStudioView }))\n);\n\nexport interface RebaseNavigationProps {\n children: React.ReactNode;\n}\n\n/**\n * Navigation layer — builds and provides all admin navigation controllers:\n * collection registry, URL controller, navigation state, side entity,\n * and the self-assembling Studio bridge.\n *\n * Also handles the collection editor config controller when enabled.\n *\n * **Independently usable**: Use this when you need admin navigation\n * (entity tables, side panels) in a custom layout.\n *\n * @example\n * ```tsx\n * <RebaseNavigation>\n * <MyCustomLayout>\n * <CollectionViewBinding ... />\n * </MyCustomLayout>\n * </RebaseNavigation>\n * ```\n */\nexport function RebaseNavigation({ children }: RebaseNavigationProps) {\n const registry = useRebaseRegistry();\n // Mounted behind the auth gate: someone is signed in, so the collection\n // table and record views are about to be wanted. Fetch them while idle.\n useEffect(() => prefetchRecordViews(), []);\n const context = useRebaseContext();\n const adminModeController = useAdminModeController();\n // The store the rest of the panel reads. Built one level up, by\n // `<Rebase>`, so the registry here and the collection views below merge\n // from the same cache — a second instance built here would keep its own.\n const browserUserConfigPersistence = useUserConfigurationPersistence();\n\n // ── Collection Editor resolution ──────────────────────────────────\n // The collection editor is ALWAYS enabled when Studio is registered.\n // The `collectionEditor` admin config is for fine-tuning (readOnly, auth, etc.),\n // not for opting-in. When omitted, the editor defaults to enabled\n // (read-only in production).\n const collectionEditorConfig = registry.cmsConfig?.collectionEditor;\n const collectionEditorEnabled = Boolean(collectionEditorConfig) || Boolean(registry.studioConfig);\n const collectionEditorOptions: CollectionEditorOptions | undefined = useMemo(() => {\n if (collectionEditorConfig === true || !collectionEditorConfig) return {};\n return collectionEditorConfig;\n }, [collectionEditorConfig]);\n\n // ── The collections: served tables and external ones ──────────────\n // Every table the server serves the signed-in user (or the ones handed\n // to <RebaseCMS tables>), projected and customized, beside the\n // collections whose rows live elsewhere (Firestore). Only with a\n // <RebaseCMS> registered: a Studio alone shows no collections.\n const tableCustomizations = registry.cmsConfig?.tableCustomizations ?? NO_CUSTOMIZATIONS;\n const externalCollections = registry.cmsConfig?.externalCollections ?? NO_EXTERNAL_COLLECTIONS;\n const descriptors = usePanelTables(registry.cmsConfig?.tables, registry.cmsConfig !== null);\n const servedTables = descriptors.tables;\n // In an embedding (an MCP App view) the panel asks the server for no\n // preferences: the embedding received them with the screen, and they are\n // folded here exactly as the panel's own — the server's `ui-config.json`\n // where the app passes no `uiConfig` of its own.\n const embeddedPreferences = useRebaseEmbedHost()?.uiPreferences;\n const uiConfig = registry.cmsConfig?.uiConfig ?? embeddedPreferences?.file;\n\n // ── UI preferences: the workspace's, and the signed-in user's own ──\n // How each table is presented, as the collection editor saved it for\n // everybody and as the views remember it for this user. The user's live\n // on the server when it keeps them, in the browser otherwise; everything\n // below reads them through the persistence provided here.\n const preferencesClient = useRebaseClient();\n const preferencesAuth = useAuthController();\n const inEmbedding = useRebaseEmbedHost() !== undefined;\n const uiPreferences = useUiPreferences({\n transport: preferencesClient,\n getAuthToken: preferencesAuth?.getAuthToken,\n authKey: preferencesAuth?.user?.uid ?? null,\n enabled: registry.cmsConfig !== null && Boolean(preferencesAuth?.user) && !inEmbedding,\n local: browserUserConfigPersistence\n });\n const embeddedUser = embeddedPreferences?.user;\n const userConfigPersistence = useMemo(\n () => embeddedUser && uiPreferences.userPersistence\n ? withUserLayer(uiPreferences.userPersistence, embeddedUser)\n : uiPreferences.userPersistence,\n [embeddedUser, uiPreferences.userPersistence]);\n const workspacePreferences = embeddedPreferences?.workspace ?? uiPreferences.controller.workspace;\n\n // What the composition last produced, for the collection editor, which\n // lists and edits the collections the panel shows.\n const [composedCollections, setComposedCollections] = useState<AdminCollection[]>(NO_COLLECTIONS);\n\n // In an embedding (an MCP App view, `embed_host.ts`), the collections are\n // the app's own — custom fields, previews, views and actions included —\n // narrowed to what the person may see and do there.\n const narrow = useRebaseEmbedHost()?.narrowCollections;\n\n // ── Build the navigation controllers ──────────────────────────────\n const collectionsBuilder = useMemo(() => {\n const composed = composeCollectionsInput({\n tables: servedTables,\n tableCustomizations,\n externalCollections,\n uiConfig,\n workspacePreferences\n });\n return async (params: Parameters<typeof composed>[0]) => {\n const collections = await composed(params);\n setComposedCollections(collections);\n return narrow ? narrow(collections) : collections;\n };\n }, [servedTables, tableCustomizations, externalCollections, uiConfig, workspacePreferences, narrow]);\n\n const dataSources = useDataSources();\n const collectionRegistryController = useBuildCollectionRegistryController({ userConfigPersistence, dataSources: dataSources.registry });\n\n // ── Multi-data-source routing ─────────────────────────────────────\n // Combine the default data source (server transport) with the registered\n // direct/custom sources from <Rebase> and route each collection by its\n // resolved data-source key, looked up by path against the collection\n // registry. A stable resolver ref keeps the routed data instance\n // referentially stable across registry rebuilds, so data-effect\n // dependencies don't thrash.\n const defaultData = useData();\n const getCollectionRef = useRef(collectionRegistryController.getCollection);\n getCollectionRef.current = collectionRegistryController.getCollection;\n\n // Hand the data layer a way to read this registry. It was built by <Rebase>,\n // above us, and needs a collection's primary keys to give its rows an\n // address — rows themselves carry only columns.\n //\n // Registered during render, not in an effect: the views that fetch rows are\n // below us, and their effects run before ours, so an effect here would bind\n // after the first page had already been converted. The call only assigns a\n // ref, so repeating it per render is free.\n //\n // With it goes where each collection is stored: a direct driver has to be\n // handed the `path` a Firestore collection declares, not its slug.\n const registerCollectionResolver = useContext(CollectionResolverRegistrationContext);\n const resolveCollection = useCallback(\n (slug: string) => getCollectionRef.current(slug),\n []);\n registerCollectionResolver(resolveCollection, collectionRegistryController.resolveDataPath);\n const routedData = useMemo(() => buildRoutedRebaseData({\n defaultData,\n sources: dataSources.sources,\n resolveKey: (slugOrPath) => resolveDataSource(getCollectionRef.current(slugOrPath), dataSources.registry).key\n }), [defaultData, dataSources]);\n\n // Normalize the configured mount prefix to a leading-slash, no-trailing-slash\n // form (e.g. \"admin\" or \"/admin/\" -> \"/admin\"); empty/\"/\" stays \"/\".\n const basePath = useMemo(() => {\n const raw = registry.cmsConfig?.basePath;\n if (!raw || raw === \"/\") return \"/\";\n const trimmed = raw.replace(/^\\/+/, \"\").replace(/\\/+$/, \"\");\n return trimmed ? `/${trimmed}` : \"/\";\n }, [registry.cmsConfig?.basePath]);\n\n const builtUrlController = useBuildUrlController({\n basePath,\n baseCollectionPath: \"/c\",\n collectionRegistryController\n });\n // In an embedding (an MCP App view) no route draws a record's page: a\n // record opens over the screen, as it does under a CollectionsProvider.\n const embedded = useRebaseEmbedHost() !== undefined;\n const urlController = useMemo<UrlController>(() => embedded ? {\n ...builtUrlController,\n isUrlCollectionPath: () => false,\n routesMounted: false\n } : builtUrlController, [builtUrlController, embedded]);\n\n // ── Build config controller internally when collection editor is enabled ──\n const rebaseClient = useRebaseClient();\n const authController = useAuthController();\n\n // ── Dev-only data-source sanity check ─────────────────────────────\n // Warn about data sources declared with a direct/custom transport that\n // have no client-side driver — these silently fall back to the default\n // (server) source, a common source of misrouting. Unambiguous: it never\n // false-positives on server-mediated sources (which intentionally have\n // no client driver).\n useEffect(() => {\n if (process.env.NODE_ENV === \"production\") return;\n const { registry, sources } = dataSources;\n const missing = Object.values(registry)\n .filter((d) => (d.transport === \"direct\" || d.transport === \"custom\") && !sources[d.key])\n .map((d) => d.key);\n if (missing.length > 0) {\n console.warn(\n `[Rebase] These data source(s) declare a direct/custom transport but have no client-side driver and will fall back to the default data source: ${missing.map(k => `\"${k}\"`).join(\", \")}. ` +\n `Provide a \\`driver\\` for them in \\`dataSources\\` on <Rebase>.`\n );\n }\n }, [dataSources]);\n\n // `readOnly` is left undefined unless the developer set it: the controller\n // asks the backend whether its schema editor will accept a write, which is\n // the only process that knows. Deciding it here from `process.env.NODE_ENV`\n // — the *frontend bundle's* build mode — is what made the editor offer\n // itself against production backends, `baas` projects and servers without\n // `ts-morph`, and turned every save into a bare 404.\n //\n // Both of its status routes require `schema:read`. Asked by someone\n // without it, each answers 403 on every page load. So when the controller\n // reports scopes, it is not asked until they include that one. A\n // controller that does not report them leaves the backend to answer.\n const internalConfigController = useLocalCollectionsConfigController(\n rebaseClient,\n composedCollections,\n collectionEditorEnabled ? {\n readOnly: collectionEditorOptions?.readOnly,\n getAuthToken: collectionEditorOptions?.getAuthToken ?? authController?.getAuthToken,\n authKey: authController?.user?.uid ?? null,\n mayReadSchema: reportsScopes(authController)\n ? callerHoldsScope(authController, \"schema:read\")\n : undefined,\n tables: servedTables,\n presentation: { save: uiPreferences.controller.saveWorkspace }\n } : { readOnly: true }\n );\n\n const { t } = useTranslation();\n\n // ── Auto-inject schema view into Studio devViews ──────────────────\n const schemaView: AppView | undefined = useMemo(() => {\n // One rule, shared with the drawer and both home pages: they sort a\n // view into the Studio by asking the same question, so a route\n // injected here on any other terms shows up in CMS mode.\n if (!studioSchemaToolEnabled(registry)) return undefined;\n return {\n slug: \"schema\",\n // The name and description the Studio home page's card carries:\n // the drawer said \"Edit collections\" for what the card beside\n // it called \"Collections\".\n name: t(\"studio_tool_schema\"),\n description: t(\"studio_tool_schema_description\"),\n group: \"Database\",\n icon: \"LayoutList\",\n nestedRoutes: true,\n // Reads the controller from context at render time rather than\n // capturing it here. A view is a React *element*, and the\n // navigation state controller resolves the view list once and holds\n // on to the elements it resolved — so a controller passed as a prop\n // is frozen at whatever it was on the first render, forever. That\n // hid every later change: the editor stayed writable after the\n // backend said it was read-only, and the collection list never\n // refreshed. Everything else in the editor already reads this from\n // `ConfigControllerProvider`, which wraps this subtree.\n view: (\n <Suspense fallback={<CircularProgressCenter/>}>\n <CollectionsStudioViewFromContext/>\n </Suspense>\n )\n };\n }, [registry, t]);\n\n const devViews = useMemo(() => {\n const base = registry.studioConfig?.devViews ?? [];\n if (schemaView) return [...base, schemaView];\n return base;\n }, [registry.studioConfig?.devViews, schemaView]);\n\n // Merge admin-registered views with Studio dev views.\n // Order: admin views (developer's primary content) → Studio dev views (tooling).\n // Plugin views are merged later inside resolveAppViews.\n const cmsViews = registry.cmsConfig?.views;\n const mergedViews = useMemo(() => {\n if (!cmsViews) return devViews;\n if (Array.isArray(cmsViews) && cmsViews.length === 0) return devViews;\n // When cmsViews is a builder function, wrap it to append devViews after resolution\n if (typeof cmsViews === \"function\") {\n return async (params: Parameters<typeof cmsViews>[0]) => {\n const resolved = await cmsViews(params) ?? [];\n return [...resolved, ...devViews];\n };\n }\n return [...cmsViews, ...devViews];\n }, [cmsViews, devViews]);\n\n const parentCustomizationController = useCustomizationController();\n\n const builtNavigationStateController = useBuildNavigationStateController({\n plugins: parentCustomizationController.plugins ?? EMPTY_PLUGINS,\n collections: collectionsBuilder,\n // Until the tables arrive, no route that needs a collection renders:\n // they show the loading state, not \"collection not found\", and a deep\n // link resolves once the collections built from them are registered.\n collectionsPending: descriptors.status === \"loading\",\n views: mergedViews,\n navigationGroupMappings: registry.cmsConfig?.navigationGroupMappings,\n authController: context.authController!,\n // The collection and view builders get the rows the server sends.\n data: context.data,\n collectionRegistryController,\n urlController,\n adminMode: adminModeController?.mode\n });\n\n // A failure to load the tables is the navigation's loading error: the home\n // page and a route to a collection that could not be built say what failed\n // and offer to retry. A session the server no longer accepts is the\n // client's to renew, and it signs out when it cannot — so the error says to\n // sign in again.\n //\n // Refreshing the navigation asks for the tables again too: it is what the\n // collection editor calls after it changed the schema, and with an `ETag`\n // an unchanged schema costs a 304.\n const tablesError = descriptors.status === \"error\" ? descriptors.error : undefined;\n const reloadTables = descriptors.reload;\n const tablesInUse = registry.cmsConfig !== null && !descriptors.unavailable;\n const navigationStateController = useMemo<NavigationStateController>(() => {\n if (!tablesInUse) return builtNavigationStateController;\n const signedOut = tablesError instanceof RebaseApiError && tablesError.status === 401;\n const error = tablesError\n ? new Error(signedOut\n ? t(\"tables_load_signed_out\")\n : t(\"tables_load_failed\", { message: tablesError.message }), { cause: tablesError })\n : undefined;\n return {\n ...builtNavigationStateController,\n navigationLoadingError: builtNavigationStateController.navigationLoadingError ?? error,\n refreshNavigation: () => {\n reloadTables();\n builtNavigationStateController.refreshNavigation();\n }\n };\n }, [builtNavigationStateController, tablesInUse, tablesError, reloadTables, t]);\n\n // ── Merge admin-registered entityViews/entityActions into the customization controller ──\n // The <Rebase> component builds the customizationController from its own props,\n // but entity views passed to <RebaseCMS> are stored in the registry and not\n // automatically merged. We re-provide an enriched controller here so that\n // downstream consumers (EditViewBinding, side panels, etc.) can resolve\n // string-keyed entity views like \"blog_preview\".\n const enrichedCustomizationController = useMemo(() => {\n const cmsEntityViews = (registry.cmsConfig?.entityViews ?? []) as EntityCustomView[];\n const cmsEntityActions = (registry.cmsConfig?.entityActions ?? []) as EntityAction[];\n // Collection view modes ride the same channel, for the same reason:\n // `admin.customViews: [\"map\"]` has to find the component somewhere.\n const cmsCollectionViews = (registry.cmsConfig?.collectionViews ?? []) as CollectionCustomView[];\n if (cmsEntityViews.length === 0 && cmsEntityActions.length === 0 && cmsCollectionViews.length === 0) {\n return parentCustomizationController;\n }\n return {\n ...parentCustomizationController,\n entityViews: [\n ...(parentCustomizationController.entityViews ?? []),\n ...cmsEntityViews.filter(v => !(parentCustomizationController.entityViews ?? []).some(ev => ev.key === v.key))\n ],\n entityActions: [\n ...(parentCustomizationController.entityActions ?? []),\n ...cmsEntityActions.filter(a => !(parentCustomizationController.entityActions ?? []).some(ea => ea.key === a.key))\n ],\n collectionViews: [\n ...(parentCustomizationController.collectionViews ?? []),\n ...cmsCollectionViews.filter(v => !(parentCustomizationController.collectionViews ?? []).some(cv => cv.key === v.key))\n ]\n };\n }, [parentCustomizationController, registry.cmsConfig?.entityViews, registry.cmsConfig?.entityActions, registry.cmsConfig?.collectionViews]);\n\n // ── Inner content with all context providers ──────────────────────\n // Re-provide RebaseDataContext with the routed data so that every admin\n // consumer (list/entity views, references, board, import/export, and\n // `context.data`) is routed to the correct driver by collection path.\n const navigationContent = (\n <UserConfigurationPersistenceContext.Provider value={userConfigPersistence}>\n <CollectionsScopeContext.Provider value={true}>\n <RebaseDataContext.Provider value={routedData}>\n <CustomizationControllerContext.Provider value={enrichedCustomizationController}>\n <StudioBridgeRegistryProvider>\n <CollectionRegistryContext.Provider value={collectionRegistryController}>\n <UrlContext.Provider value={urlController}>\n <NavigationStateContext.Provider value={navigationStateController}>\n <SidePanelProvider>\n <BridgeAutoRegistrar\n collectionRegistryController={collectionRegistryController}\n urlController={urlController}\n navigationStateController={navigationStateController}\n canWriteToCodebase={!internalConfigController.readOnly}\n />\n {children}\n </SidePanelProvider>\n </NavigationStateContext.Provider>\n </UrlContext.Provider>\n </CollectionRegistryContext.Provider>\n </StudioBridgeRegistryProvider>\n </CustomizationControllerContext.Provider>\n </RebaseDataContext.Provider>\n </CollectionsScopeContext.Provider>\n </UserConfigurationPersistenceContext.Provider>\n );\n\n // ── Wrap with ConfigControllerProvider when collection editor is enabled ──\n if (collectionEditorEnabled) {\n return (\n <ConfigControllerProvider\n collectionConfigController={internalConfigController}\n pathSuggestions={collectionEditorOptions?.pathSuggestions}\n >\n {navigationContent}\n </ConfigControllerProvider>\n );\n }\n\n return navigationContent;\n}\n\n/**\n * The injected \"Edit collections\" view, bound to the live config controller.\n *\n * Exists so the element stored in the navigation state does not close over a\n * controller instance — see the comment at its construction site.\n */\nfunction CollectionsStudioViewFromContext() {\n const configController = useCollectionsConfigController();\n return <CollectionsStudioView configController={configController}/>;\n}\n\n/**\n * Internal component that auto-registers admin controllers into the\n * self-assembling Studio bridge. Must be rendered inside both the\n * navigation contexts and the StudioBridgeRegistryProvider.\n */\nfunction BridgeAutoRegistrar({\n collectionRegistryController,\n urlController,\n navigationStateController,\n canWriteToCodebase\n}: {\n collectionRegistryController: CollectionRegistryController;\n urlController: UrlController;\n navigationStateController: NavigationStateController;\n canWriteToCodebase: boolean;\n}) {\n useBridgeRegistration(\"collectionRegistry\", collectionRegistryController);\n useBridgeRegistration(\"urlController\", urlController);\n useBridgeRegistration(\"navigationState\", navigationStateController);\n\n // Studio tools that would write into the project's collection source — the\n // RLS editor's policy save for a mapped table, its \"Import to codebase\" —\n // ask the bridge whether that write can land. The default is `true`, which\n // is what an admin panel sitting next to its own `collectionsDir` assumes;\n // it is wrong for exactly the same backends that make the collection editor\n // read-only, so the two now answer from one source.\n const capabilities = useMemo(() => ({ codebase: canWriteToCodebase }), [canWriteToCodebase]);\n useBridgeRegistration(\"capabilities\", capabilities);\n return null;\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;AA6BA,IAAM,gBAAgC,CAAC;AACvC,IAAM,iBAAoC,CAAC;AAC3C,IAAM,oBAAmD,CAAC;AAC1D,IAAM,0BAAsD,CAAC;AAwB7D,IAAM,wBAAwB,gBAC1B,OAAO,2EAAwE,CAC1E,MAAK,OAAM,EAAE,SAAS,EAAE,4BAA4B,EAAE,CAC/D;;;;;;;;;;;;;;;;;;;;AAyBA,SAAgB,iBAAiB,EAAE,YAAmC;CAClE,MAAM,WAAW,kBAAkB;CAGnC,gBAAgB,oBAAoB,GAAG,CAAC,CAAC;CACzC,MAAM,UAAU,iBAAiB;CACjC,MAAM,sBAAsB,uBAAuB;CAInD,MAAM,+BAA+B,gCAAgC;CAOrE,MAAM,yBAAyB,SAAS,WAAW;CACnD,MAAM,0BAA0B,QAAQ,sBAAsB,KAAK,QAAQ,SAAS,YAAY;CAChG,MAAM,0BAA+D,cAAc;EAC/E,IAAI,2BAA2B,QAAQ,CAAC,wBAAwB,OAAO,CAAC;EACxE,OAAO;CACX,GAAG,CAAC,sBAAsB,CAAC;CAO3B,MAAM,sBAAsB,SAAS,WAAW,uBAAuB;CACvE,MAAM,sBAAsB,SAAS,WAAW,uBAAuB;CACvE,MAAM,cAAc,eAAe,SAAS,WAAW,QAAQ,SAAS,cAAc,IAAI;CAC1F,MAAM,eAAe,YAAY;CAKjC,MAAM,sBAAsB,mBAAmB,CAAC,EAAE;CAClD,MAA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AAO;AACX"}
@@ -11,8 +11,13 @@ export interface RebaseShellProps {
11
11
  autoOpenDrawer?: boolean;
12
12
  /** Start with the drawer expanded instead of collapsed to icons. Ignored on small layouts. */
13
13
  defaultDrawerOpen?: boolean;
14
- /** Path to the logo shown in the drawer and top bar. Falls back to the Rebase mark. */
14
+ /** Path to the logo shown in the drawer, the top bar and the sign-in screen. Falls back to the Rebase mark. */
15
15
  logo?: string;
16
+ /**
17
+ * The logo for the dark theme, for a logo drawn in dark ink that would
18
+ * disappear on the dark admin. Falls back to `logo`.
19
+ */
20
+ logoDark?: string;
16
21
  children?: React.ReactNode;
17
22
  }
18
23
  /**