@rebasepro/cms 0.25.1 → 0.26.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (111) hide show
  1. package/dist/collection_editor/ui/collection_editor/AICollectionGeneratorPopover.js +1 -1
  2. package/dist/collection_editor/ui/collection_editor/AICollectionGeneratorPopover.js.map +1 -1
  3. package/dist/collection_editor/ui/collection_editor/SchemaChangeDialog.d.ts +7 -1
  4. package/dist/collection_editor/ui/collection_editor/SchemaChangeDialog.js +9 -2
  5. package/dist/collection_editor/ui/collection_editor/SchemaChangeDialog.js.map +1 -1
  6. package/dist/collection_editor/useLiveSchemaEditing.js +4 -1
  7. package/dist/collection_editor/useLiveSchemaEditing.js.map +1 -1
  8. package/dist/components/CollectionTableBinding/fields/TableReferenceField.js +1 -1
  9. package/dist/components/CollectionTableBinding/fields/TableReferenceField.js.map +1 -1
  10. package/dist/components/CollectionTableBinding/internal/CollectionTableToolbar.d.ts +1 -2
  11. package/dist/components/CollectionTableBinding/internal/CollectionTableToolbar.js.map +1 -1
  12. package/dist/components/CollectionTableBinding/internal/EntityTableCell.d.ts +1 -2
  13. package/dist/components/CollectionTableBinding/internal/EntityTableCell.js.map +1 -1
  14. package/dist/components/CollectionViewBinding/CollectionViewActions.js +1 -1
  15. package/dist/components/CollectionViewBinding/CollectionViewActions.js.map +1 -1
  16. package/dist/components/CollectionViewBinding/CollectionViewBinding.js +2 -28
  17. package/dist/components/CollectionViewBinding/CollectionViewBinding.js.map +1 -1
  18. package/dist/components/CollectionViewBinding/DefaultCollectionEmptyState.d.ts +12 -0
  19. package/dist/components/CollectionViewBinding/DefaultCollectionEmptyState.js +33 -0
  20. package/dist/components/CollectionViewBinding/DefaultCollectionEmptyState.js.map +1 -0
  21. package/dist/components/CollectionsScopeContext.d.ts +5 -1
  22. package/dist/components/CollectionsScopeContext.js +10 -2
  23. package/dist/components/CollectionsScopeContext.js.map +1 -1
  24. package/dist/components/DefaultAppBar.js +2 -1
  25. package/dist/components/DefaultAppBar.js.map +1 -1
  26. package/dist/components/DefaultDrawer.js +16 -4
  27. package/dist/components/DefaultDrawer.js.map +1 -1
  28. package/dist/components/DefaultMissingReference.d.ts +8 -0
  29. package/dist/components/DefaultMissingReference.js +13 -0
  30. package/dist/components/DefaultMissingReference.js.map +1 -0
  31. package/dist/components/EntityFormPanel.d.ts +7 -2
  32. package/dist/components/EntityFormPanel.js +72 -29
  33. package/dist/components/EntityFormPanel.js.map +1 -1
  34. package/dist/components/HomePage/ContentHomePage.js +4 -3
  35. package/dist/components/HomePage/ContentHomePage.js.map +1 -1
  36. package/dist/components/HomePage/HomePageDnD.js +3 -1
  37. package/dist/components/HomePage/HomePageDnD.js.map +1 -1
  38. package/dist/components/HomePage/SmallNavigationCard.js +25 -0
  39. package/dist/components/HomePage/SmallNavigationCard.js.map +1 -0
  40. package/dist/components/RebaseAuthGate.js +3 -2
  41. package/dist/components/RebaseAuthGate.js.map +1 -1
  42. package/dist/components/RebaseLayout.d.ts +4 -1
  43. package/dist/components/RebaseLayout.js +7 -1
  44. package/dist/components/RebaseLayout.js.map +1 -1
  45. package/dist/components/RebaseShell.d.ts +4 -1
  46. package/dist/components/RebaseShell.js.map +1 -1
  47. package/dist/components/SideDialogs.js +10 -4
  48. package/dist/components/SideDialogs.js.map +1 -1
  49. package/dist/components/app/Scaffold.js +5 -1
  50. package/dist/components/app/Scaffold.js.map +1 -1
  51. package/dist/components/field_configs.js +1 -1
  52. package/dist/components/history/EntityHistoryView.js +6 -4
  53. package/dist/components/history/EntityHistoryView.js.map +1 -1
  54. package/dist/components/history/LastEditedByIndicator.d.ts +2 -1
  55. package/dist/data_export/export/export.d.ts +2 -13
  56. package/dist/data_export/export/export.js +1 -36
  57. package/dist/data_export/export/export.js.map +1 -1
  58. package/dist/form/EntityForm.d.ts +1 -1
  59. package/dist/form/EntityForm.js +17 -13
  60. package/dist/form/EntityForm.js.map +1 -1
  61. package/dist/form/EntityFormBinding.d.ts +1 -1
  62. package/dist/form/EntityFormBinding.js +42 -4
  63. package/dist/form/EntityFormBinding.js.map +1 -1
  64. package/dist/form/PropertyFieldBinding.js +1 -1
  65. package/dist/form/components/FieldBlock.d.ts +8 -1
  66. package/dist/form/components/FieldBlock.js +16 -2
  67. package/dist/form/components/FieldBlock.js.map +1 -1
  68. package/dist/form/components/FormSections.js +1 -1
  69. package/dist/form/components/FormSections.js.map +1 -1
  70. package/dist/form/components/LabelWithIcon.js +5 -2
  71. package/dist/form/components/LabelWithIcon.js.map +1 -1
  72. package/dist/form/field_bindings/DateTimeFieldBinding.js +2 -1
  73. package/dist/form/field_bindings/DateTimeFieldBinding.js.map +1 -1
  74. package/dist/form/field_bindings/ReadOnlyFieldBinding.js +28 -1
  75. package/dist/form/field_bindings/ReadOnlyFieldBinding.js.map +1 -1
  76. package/dist/form/field_bindings/RelationFieldBinding.js +7 -3
  77. package/dist/form/field_bindings/RelationFieldBinding.js.map +1 -1
  78. package/dist/form/field_bindings/SelectFieldBinding.js +63 -42
  79. package/dist/form/field_bindings/SelectFieldBinding.js.map +1 -1
  80. package/dist/form/field_bindings/SwitchFieldBinding.js +2 -1
  81. package/dist/form/field_bindings/SwitchFieldBinding.js.map +1 -1
  82. package/dist/form/field_bindings/TextFieldBinding.js +8 -6
  83. package/dist/form/field_bindings/TextFieldBinding.js.map +1 -1
  84. package/dist/form/form_utils.d.ts +18 -1
  85. package/dist/form/form_utils.js +38 -2
  86. package/dist/form/form_utils.js.map +1 -1
  87. package/dist/form/index.d.ts +1 -1
  88. package/dist/form/label_placement.d.ts +23 -0
  89. package/dist/form/label_placement.js +71 -0
  90. package/dist/form/label_placement.js.map +1 -0
  91. package/dist/form/resolve_form_properties.d.ts +35 -3
  92. package/dist/form/resolve_form_properties.js +67 -6
  93. package/dist/form/resolve_form_properties.js.map +1 -1
  94. package/dist/hooks/useHistory.d.ts +5 -0
  95. package/dist/hooks/useHistory.js +22 -6
  96. package/dist/hooks/useHistory.js.map +1 -1
  97. package/dist/index.d.ts +50 -0
  98. package/dist/index.js +34 -7
  99. package/dist/preview/components/ReferencePreview.js +1 -1
  100. package/dist/preview/components/ReferencePreview.js.map +1 -1
  101. package/dist/preview/components/RelationPreview.js +1 -1
  102. package/dist/preview/components/RelationPreview.js.map +1 -1
  103. package/dist/types/components/EntityFormProps.d.ts +11 -0
  104. package/package.json +11 -10
  105. package/recipes/README.md +131 -0
  106. package/recipes/bulk-set-status.tsx +62 -0
  107. package/recipes/calendar-view.tsx +123 -0
  108. package/recipes/custom-login.tsx +60 -0
  109. package/recipes/my-preferences.tsx +68 -0
  110. package/recipes/orders-dashboard.tsx +125 -0
  111. package/recipes/site-settings.tsx +63 -0
@@ -11,13 +11,21 @@ import { createContext } from "react";
11
11
  */
12
12
  var CollectionsScopeContext = createContext(false);
13
13
  /**
14
- * Whether a scope's top-level collections include the one at `path` — asked
14
+ * Whether a scope's top-level collections hold the one at `path` — asked
15
15
  * quietly, unlike a registry lookup, which warns about a path it cannot place.
16
16
  *
17
+ * A subcollection's path (`posts/p1/comments`) is held by the scope that holds
18
+ * its root, so the path's leading segments are matched, longest run first,
19
+ * since a slug may itself contain slashes (`content/de-DE/podcasts`).
20
+ *
17
21
  * @internal
18
22
  */
19
23
  function isRegistered(collections, path) {
20
- return collections?.some((collection) => collection.slug === path) ?? false;
24
+ if (!collections?.length) return false;
25
+ const slugs = new Set(collections.map((collection) => collection.slug));
26
+ const segments = path.split("/").filter(Boolean);
27
+ for (let length = segments.length; length > 0; length--) if (slugs.has(segments.slice(0, length).join("/"))) return true;
28
+ return false;
21
29
  }
22
30
  //#endregion
23
31
  export { CollectionsScopeContext, isRegistered };
@@ -1 +1 @@
1
- {"version":3,"file":"CollectionsScopeContext.js","names":[],"sources":["../../src/components/CollectionsScopeContext.ts"],"sourcesContent":["import { createContext } from \"react\";\nimport type { AdminCollection } from \"@rebasepro/cms-types\";\n\n/**\n * Whether a collections scope — the registry, URL controller, navigation state\n * and record panels — is mounted above: `<RebaseNavigation>` (the full CMS) or\n * a `<CollectionsProvider>`. The components that can stand on their own\n * (`CollectionPanel`, `EntityFormPanel`) read it to decide whether to bring\n * their own.\n *\n * @internal\n */\nexport const CollectionsScopeContext = createContext<boolean>(false);\n\n/**\n * Whether a scope's top-level collections include the one at `path` — asked\n * quietly, unlike a registry lookup, which warns about a path it cannot place.\n *\n * @internal\n */\nexport function isRegistered(collections: AdminCollection[] | undefined, path: string): boolean {\n return collections?.some(collection => collection.slug === path) ?? false;\n}\n"],"mappings":";;;;;;;;;;;AAYA,IAAa,0BAA0B,cAAuB,KAAK;;;;;;;AAQnE,SAAgB,aAAa,aAA4C,MAAuB;CAC5F,OAAO,aAAa,MAAK,eAAc,WAAW,SAAS,IAAI,KAAK;AACxE"}
1
+ {"version":3,"file":"CollectionsScopeContext.js","names":[],"sources":["../../src/components/CollectionsScopeContext.ts"],"sourcesContent":["import { createContext } from \"react\";\nimport type { AdminCollection } from \"@rebasepro/cms-types\";\n\n/**\n * Whether a collections scope — the registry, URL controller, navigation state\n * and record panels — is mounted above: `<RebaseNavigation>` (the full CMS) or\n * a `<CollectionsProvider>`. The components that can stand on their own\n * (`CollectionPanel`, `EntityFormPanel`) read it to decide whether to bring\n * their own.\n *\n * @internal\n */\nexport const CollectionsScopeContext = createContext<boolean>(false);\n\n/**\n * Whether a scope's top-level collections hold the one at `path` — asked\n * quietly, unlike a registry lookup, which warns about a path it cannot place.\n *\n * A subcollection's path (`posts/p1/comments`) is held by the scope that holds\n * its root, so the path's leading segments are matched, longest run first,\n * since a slug may itself contain slashes (`content/de-DE/podcasts`).\n *\n * @internal\n */\nexport function isRegistered(collections: AdminCollection[] | undefined, path: string): boolean {\n if (!collections?.length) return false;\n const slugs = new Set(collections.map(collection => collection.slug));\n const segments = path.split(\"/\").filter(Boolean);\n for (let length = segments.length; length > 0; length--) {\n if (slugs.has(segments.slice(0, length).join(\"/\"))) return true;\n }\n return false;\n}\n"],"mappings":";;;;;;;;;;;AAYA,IAAa,0BAA0B,cAAuB,KAAK;;;;;;;;;;;AAYnE,SAAgB,aAAa,aAA4C,MAAuB;CAC5F,IAAI,CAAC,aAAa,QAAQ,OAAO;CACjC,MAAM,QAAQ,IAAI,IAAI,YAAY,KAAI,eAAc,WAAW,IAAI,CAAC;CACpE,MAAM,WAAW,KAAK,MAAM,GAAG,CAAC,CAAC,OAAO,OAAO;CAC/C,KAAK,IAAI,SAAS,SAAS,QAAQ,SAAS,GAAG,UAC3C,IAAI,MAAM,IAAI,SAAS,MAAM,GAAG,MAAM,CAAC,CAAC,KAAK,GAAG,CAAC,GAAG,OAAO;CAE/D,OAAO;AACX"}
@@ -4,7 +4,7 @@ import { useApp } from "./app/useApp.js";
4
4
  import React from "react";
5
5
  import { Fragment, jsx, jsxs } from "react/jsx-runtime";
6
6
  import { Avatar, ErrorBoundary, IconButton, LogOutIcon, Menu, MenuItem, MoonIcon, SettingsIcon, Skeleton, SunIcon, SunMoonIcon, Typography, cls, iconSize } from "@rebasepro/ui";
7
- import { LanguageToggle, RebaseLogo, useAdminModeController, useAuthController, useLargeLayout, useModeController, useRebaseContext, useSlot, useTranslation } from "@rebasepro/app";
7
+ import { LanguageToggle, RebaseLogo, RlsSimulatorBar, useAdminModeController, useAuthController, useLargeLayout, useModeController, useRebaseContext, useSlot, useTranslation } from "@rebasepro/app";
8
8
  import { Link, useNavigate } from "react-router";
9
9
  //#region src/components/DefaultAppBar.tsx
10
10
  /**
@@ -104,6 +104,7 @@ var DefaultAppBar = function DefaultAppBar({ title, endAdornment, startAdornment
104
104
  /* @__PURE__ */ jsx("div", { className: "grow" }),
105
105
  endAdornment && /* @__PURE__ */ jsx(ErrorBoundary, { children: endAdornment }),
106
106
  shellToolbar,
107
+ !(hasDrawer && largeLayout) && /* @__PURE__ */ jsx(RlsSimulatorBar, {}),
107
108
  includeLanguageToggle && /* @__PURE__ */ jsx(LanguageToggle, {}),
108
109
  includeModeToggle && /* @__PURE__ */ jsxs(Menu, {
109
110
  trigger: /* @__PURE__ */ jsx(IconButton, {
@@ -1 +1 @@
1
- {"version":3,"file":"DefaultAppBar.js","names":[],"sources":["../../src/components/DefaultAppBar.tsx"],"sourcesContent":["\nimport React from \"react\";\n\nimport { Link, useNavigate } from \"react-router\";\nimport { RebaseLogo, LanguageToggle } from \"@rebasepro/app\";\nimport { ErrorBoundary, iconSize } from \"@rebasepro/ui\";\nimport {\n Avatar,\n cls,\n IconButton,\n LogOutIcon,\n Menu,\n MenuItem,\n MoonIcon,\n SettingsIcon,\n Skeleton,\n SunIcon,\n SunMoonIcon,\n Typography\n} from \"@rebasepro/ui\";\nimport { useAuthController, useLargeLayout, useModeController, useAdminModeController, useTranslation, useRebaseContext, useSlot } from \"@rebasepro/app\";\nimport { useUrlController } from \"../hooks/navigation/contexts/UrlContext\";\nimport { User } from \"@rebasepro/types\";\nimport { useApp } from \"./app/useApp\";\nimport { useBreadcrumbsController } from \"../hooks/useBreadcrumbsController\";\nimport { UserSettingsView } from \"@rebasepro/app\";\n\nexport type DefaultAppBarProps<ADDITIONAL_PROPS = object> = {\n\n /**\n * The content of the app bar, usually a title or logo. This includes a link to the home page.\n */\n title?: React.ReactNode;\n\n /**\n * A component that gets rendered on the upper side to the end of the main toolbar\n */\n endAdornment?: React.ReactNode;\n\n /**\n * A component that gets rendered on the upper side to the start of the main toolbar\n */\n startAdornment?: React.ReactNode;\n\n dropDownActions?: React.ReactNode;\n\n /**\n * Whether to render the dark/light/system mode toggle in the app bar.\n * Set to `false` when the drawer owns this action.\n * @default true\n */\n includeModeToggle?: boolean;\n\n /**\n * Whether to render the language switcher in the app bar.\n * Set to `false` when the drawer owns this action.\n * @default true\n */\n includeLanguageToggle?: boolean;\n\n /**\n * Whether to render the user avatar / menu in the app bar.\n * Set to `false` when the drawer owns this action.\n * @default true\n */\n includeUserMenu?: boolean;\n\n className?: string;\n\n style?: React.CSSProperties;\n\n logo?: string;\n\n user?: User;\n} & ADDITIONAL_PROPS;\n\n/**\n * This component renders the main app bar of Rebase.\n * You will likely not need to use this component directly.\n *\n\n */\nexport const DefaultAppBar = function DefaultAppBar({\n title,\n endAdornment,\n startAdornment,\n dropDownActions,\n includeModeToggle = true,\n includeLanguageToggle = true,\n includeUserMenu = true,\n className,\n style,\n user: userProp,\n logo: logoProp\n}: DefaultAppBarProps) {\n\n const {\n hasDrawer,\n drawerOpen,\n logo: appLogo\n } = useApp();\n\n const logo = logoProp ?? appLogo;\n\n const navigation = useUrlController();\n\n const breadcrumbs = useBreadcrumbsController();\n\n const authController = useAuthController();\n const adminModeController = useAdminModeController();\n const {\n mode,\n setMode\n } = useModeController();\n\n const navigate = useNavigate();\n\n const largeLayout = useLargeLayout();\n\n const user = userProp ?? authController.user;\n const { t } = useTranslation();\n\n // The two shell slots. Both take the context and nothing else, which is why\n // they are told apart by *where* they render rather than by their props: a\n // cross-collection search belongs beside the breadcrumbs, where a search\n // box goes, and a toolbar action belongs with the other actions at the end.\n const rebaseContext = useRebaseContext();\n const slotProps = React.useMemo(() => ({ context: rebaseContext }), [rebaseContext]);\n const globalSearch = useSlot(\"global.search\", slotProps);\n const shellToolbar = useSlot(\"shell.toolbar\", slotProps);\n\n let avatarComponent: React.ReactElement | null;\n\n if (user) {\n const initial = user?.displayName\n ? user.displayName[0].toUpperCase()\n : (user?.email ? user.email[0].toUpperCase() : \"A\");\n avatarComponent = <Avatar src={user.photoURL ?? undefined}>\n {initial}\n </Avatar>;\n } else if (user === undefined || authController.initialLoading) {\n avatarComponent = <div className={\"p-1 flex justify-center\"}>\n <Skeleton className={\"w-10 h-10 rounded-full\"}/>\n </div>;\n } else {\n avatarComponent = null;\n }\n\n\n return (\n <div\n style={style}\n role=\"banner\"\n className={cls(\"w-full h-14 transition-all ease-in duration-75 absolute top-0 max-w-full overflow-x-auto no-scrollbar\",\n \"flex flex-row gap-2 px-4 items-center\",\n \"backdrop-blur-sm bg-surface-frame/90\",\n {\n \"pl-[19rem]\": drawerOpen && largeLayout,\n \"pl-24\": hasDrawer && !(drawerOpen && largeLayout),\n \"z-10\": largeLayout,\n \"duration-100\": drawerOpen && largeLayout\n },\n className)}>\n\n {navigation && (!hasDrawer || title) && <div className=\"mr-2 hidden lg:block\">\n <Link\n className=\"visited:text-inherit dark:visited:text-inherit block\"\n to={navigation?.basePath ?? \"/\"}\n >\n <div className={\"flex flex-row gap-4\"}>\n {!hasDrawer && (logo\n ? <img src={logo}\n alt=\"Logo\"\n className={cls(\"w-[32px] h-[32px] object-contain\")}/>\n : <RebaseLogo width={\"32px\"} height={\"32px\"}/>)}\n\n {typeof title === \"string\"\n ? <Typography variant=\"subtitle1\"\n noWrap>\n {title}\n </Typography>\n : title}\n </div>\n </Link>\n </div>}\n\n <div className=\"mr-8 hidden lg:block\">\n <nav aria-label=\"Breadcrumb\">\n <div className={\"flex flex-row gap-2 items-center\"}>\n {breadcrumbs.breadcrumbs.map((breadcrumb, index) => {\n return <React.Fragment key={breadcrumb.url + \"_\" + index}>\n {index > 0 && (\n <Typography variant={\"caption\"} color={\"secondary\"}>\n /\n </Typography>\n )}\n <Link\n key={index}\n className=\"visited:text-inherit dark:visited:text-inherit block\"\n to={breadcrumb.url}\n >\n <div className=\"flex flex-row items-center gap-2 whitespace-nowrap\">\n <Typography variant={\"body2\"}>\n {breadcrumb.title}\n </Typography>\n </div>\n </Link>\n </React.Fragment>;\n })}\n </div>\n </nav>\n </div>\n {startAdornment}\n\n {globalSearch}\n\n <div className={\"grow\"}/>\n\n {endAdornment &&\n <ErrorBoundary>\n {endAdornment}\n </ErrorBoundary>}\n\n {shellToolbar}\n\n {includeLanguageToggle && <LanguageToggle/>}\n\n {includeModeToggle &&\n <Menu\n trigger={<IconButton\n aria-label=\"Toggle theme\"\n>\n {mode === \"dark\"\n ? <MoonIcon size={iconSize.small}/>\n : <SunIcon size={iconSize.small}/>}\n </IconButton>}>\n <MenuItem onClick={() => setMode(\"dark\")}><MoonIcon size={iconSize.smallest}/> {t(\"dark_mode\")}</MenuItem>\n <MenuItem onClick={() => setMode(\"light\")}><SunIcon size={iconSize.smallest}/> {t(\"light_mode\")} </MenuItem>\n <MenuItem onClick={() => setMode(\"system\")}> <SunMoonIcon\n size={iconSize.smallest}/>{t(\"system_mode\")}</MenuItem>\n </Menu>}\n\n\n {includeUserMenu &&\n <Menu trigger={<div aria-label=\"User menu\" role=\"button\">{avatarComponent}</div>}>\n {user && <div className={\"px-4 py-2 mb-2\"}>\n {user.displayName && <Typography variant={\"body1\"} color={\"secondary\"}>\n {user.displayName}\n </Typography>}\n {user.email && <Typography variant={\"body2\"} color={\"secondary\"}>\n {user.email}\n </Typography>}\n </div>}\n\n {dropDownActions}\n\n {!dropDownActions && <>\n <MenuItem onClick={() => navigate(\"/settings\")}>\n <SettingsIcon/>\n {t(\"account_settings\")}\n </MenuItem>\n <MenuItem onClick={async () => {\n await authController.signOut();\n // replace current route with home\n navigate(\"/\");\n }}>\n <LogOutIcon/>\n {t(\"log_out\")}\n </MenuItem>\n </>}\n\n </Menu>}\n\n </div>\n );\n}\n"],"mappings":";;;;;;;;;;;;;;;AAkFA,IAAa,gBAAgB,SAAS,cAAc,EAChD,OACA,cACA,gBACA,iBACA,oBAAoB,MACpB,wBAAwB,MACxB,kBAAkB,MAClB,WACA,OACA,MAAM,UACN,MAAM,YACa;CAEnB,MAAM,EACF,WACA,YACA,MAAM,YACN,OAAO;CAEX,MAAM,OAAO,YAAY;CAEzB,MAAM,aAAa,iBAAiB;CAEpC,MAAM,cAAc,yBAAyB;CAE7C,MAAM,iBAAiB,kBAAkB;CACb,uBAAuB;CACnD,MAAM,EACF,MACA,YACA,kBAAkB;CAEtB,MAAM,WAAW,YAAY;CAE7B,MAAM,cAAc,eAAe;CAEnC,MAAM,OAAO,YAAY,eAAe;CACxC,MAAM,EAAE,MAAM,eAAe;CAM7B,MAAM,gBAAgB,iBAAiB;CACvC,MAAM,YAAY,MAAM,eAAe,EAAE,SAAS,cAAc,IAAI,CAAC,aAAa,CAAC;CACnF,MAAM,eAAe,QAAQ,iBAAiB,SAAS;CACvD,MAAM,eAA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OAAO;iBACrD,KAAK;MACE,CAAA,GACX,KAAK,SAAS,oBAAC,YAAD;OAAY,SAAS;OAAS,OAAO;iBAC/C,KAAK;MACE,CAAA,CACX;;KAEJ;KAEA,CAAC,mBAAmB,qBAAA,UAAA,EAAA,UAAA,CACjB,qBAAC,UAAD;MAAU,eAAe,SAAS,WAAW;gBAA7C,CACI,oBAAC,cAAD,CAAc,CAAA,GACb,EAAE,kBAAkB,CACf;SACV,qBAAC,UAAD;MAAU,SAAS,YAAY;OAC3B,MAAM,eAAe,QAAQ;OAE7B,SAAS,GAAG;MAChB;gBAJA,CAKI,oBAAC,YAAD,CAAY,CAAA,GACX,EAAE,SAAS,CACN;OACZ,EAAA,CAAA;IAEA;;EAET;;AAEb"}
1
+ {"version":3,"file":"DefaultAppBar.js","names":[],"sources":["../../src/components/DefaultAppBar.tsx"],"sourcesContent":["\nimport React from \"react\";\n\nimport { Link, useNavigate } from \"react-router\";\nimport { RebaseLogo, LanguageToggle, RlsSimulatorBar } from \"@rebasepro/app\";\nimport { ErrorBoundary, iconSize } from \"@rebasepro/ui\";\nimport {\n Avatar,\n cls,\n IconButton,\n LogOutIcon,\n Menu,\n MenuItem,\n MoonIcon,\n SettingsIcon,\n Skeleton,\n SunIcon,\n SunMoonIcon,\n Typography\n} from \"@rebasepro/ui\";\nimport { useAuthController, useLargeLayout, useModeController, useAdminModeController, useTranslation, useRebaseContext, useSlot } from \"@rebasepro/app\";\nimport { useUrlController } from \"../hooks/navigation/contexts/UrlContext\";\nimport { User } from \"@rebasepro/types\";\nimport { useApp } from \"./app/useApp\";\nimport { useBreadcrumbsController } from \"../hooks/useBreadcrumbsController\";\nimport { UserSettingsView } from \"@rebasepro/app\";\n\nexport type DefaultAppBarProps<ADDITIONAL_PROPS = object> = {\n\n /**\n * The content of the app bar, usually a title or logo. This includes a link to the home page.\n */\n title?: React.ReactNode;\n\n /**\n * A component that gets rendered on the upper side to the end of the main toolbar\n */\n endAdornment?: React.ReactNode;\n\n /**\n * A component that gets rendered on the upper side to the start of the main toolbar\n */\n startAdornment?: React.ReactNode;\n\n dropDownActions?: React.ReactNode;\n\n /**\n * Whether to render the dark/light/system mode toggle in the app bar.\n * Set to `false` when the drawer owns this action.\n * @default true\n */\n includeModeToggle?: boolean;\n\n /**\n * Whether to render the language switcher in the app bar.\n * Set to `false` when the drawer owns this action.\n * @default true\n */\n includeLanguageToggle?: boolean;\n\n /**\n * Whether to render the user avatar / menu in the app bar.\n * Set to `false` when the drawer owns this action.\n * @default true\n */\n includeUserMenu?: boolean;\n\n className?: string;\n\n style?: React.CSSProperties;\n\n logo?: string;\n\n user?: User;\n} & ADDITIONAL_PROPS;\n\n/**\n * This component renders the main app bar of Rebase.\n * You will likely not need to use this component directly.\n *\n\n */\nexport const DefaultAppBar = function DefaultAppBar({\n title,\n endAdornment,\n startAdornment,\n dropDownActions,\n includeModeToggle = true,\n includeLanguageToggle = true,\n includeUserMenu = true,\n className,\n style,\n user: userProp,\n logo: logoProp\n}: DefaultAppBarProps) {\n\n const {\n hasDrawer,\n drawerOpen,\n logo: appLogo\n } = useApp();\n\n const logo = logoProp ?? appLogo;\n\n const navigation = useUrlController();\n\n const breadcrumbs = useBreadcrumbsController();\n\n const authController = useAuthController();\n const adminModeController = useAdminModeController();\n const {\n mode,\n setMode\n } = useModeController();\n\n const navigate = useNavigate();\n\n const largeLayout = useLargeLayout();\n\n const user = userProp ?? authController.user;\n const { t } = useTranslation();\n\n // The two shell slots. Both take the context and nothing else, which is why\n // they are told apart by *where* they render rather than by their props: a\n // cross-collection search belongs beside the breadcrumbs, where a search\n // box goes, and a toolbar action belongs with the other actions at the end.\n const rebaseContext = useRebaseContext();\n const slotProps = React.useMemo(() => ({ context: rebaseContext }), [rebaseContext]);\n const globalSearch = useSlot(\"global.search\", slotProps);\n const shellToolbar = useSlot(\"shell.toolbar\", slotProps);\n\n let avatarComponent: React.ReactElement | null;\n\n if (user) {\n const initial = user?.displayName\n ? user.displayName[0].toUpperCase()\n : (user?.email ? user.email[0].toUpperCase() : \"A\");\n avatarComponent = <Avatar src={user.photoURL ?? undefined}>\n {initial}\n </Avatar>;\n } else if (user === undefined || authController.initialLoading) {\n avatarComponent = <div className={\"p-1 flex justify-center\"}>\n <Skeleton className={\"w-10 h-10 rounded-full\"}/>\n </div>;\n } else {\n avatarComponent = null;\n }\n\n\n return (\n <div\n style={style}\n role=\"banner\"\n className={cls(\"w-full h-14 transition-all ease-in duration-75 absolute top-0 max-w-full overflow-x-auto no-scrollbar\",\n \"flex flex-row gap-2 px-4 items-center\",\n \"backdrop-blur-sm bg-surface-frame/90\",\n {\n \"pl-[19rem]\": drawerOpen && largeLayout,\n \"pl-24\": hasDrawer && !(drawerOpen && largeLayout),\n \"z-10\": largeLayout,\n \"duration-100\": drawerOpen && largeLayout\n },\n className)}>\n\n {navigation && (!hasDrawer || title) && <div className=\"mr-2 hidden lg:block\">\n <Link\n className=\"visited:text-inherit dark:visited:text-inherit block\"\n to={navigation?.basePath ?? \"/\"}\n >\n <div className={\"flex flex-row gap-4\"}>\n {!hasDrawer && (logo\n ? <img src={logo}\n alt=\"Logo\"\n className={cls(\"w-[32px] h-[32px] object-contain\")}/>\n : <RebaseLogo width={\"32px\"} height={\"32px\"}/>)}\n\n {typeof title === \"string\"\n ? <Typography variant=\"subtitle1\"\n noWrap>\n {title}\n </Typography>\n : title}\n </div>\n </Link>\n </div>}\n\n <div className=\"mr-8 hidden lg:block\">\n <nav aria-label=\"Breadcrumb\">\n <div className={\"flex flex-row gap-2 items-center\"}>\n {breadcrumbs.breadcrumbs.map((breadcrumb, index) => {\n return <React.Fragment key={breadcrumb.url + \"_\" + index}>\n {index > 0 && (\n <Typography variant={\"caption\"} color={\"secondary\"}>\n /\n </Typography>\n )}\n <Link\n key={index}\n className=\"visited:text-inherit dark:visited:text-inherit block\"\n to={breadcrumb.url}\n >\n <div className=\"flex flex-row items-center gap-2 whitespace-nowrap\">\n <Typography variant={\"body2\"}>\n {breadcrumb.title}\n </Typography>\n </div>\n </Link>\n </React.Fragment>;\n })}\n </div>\n </nav>\n </div>\n {startAdornment}\n\n {globalSearch}\n\n <div className={\"grow\"}/>\n\n {endAdornment &&\n <ErrorBoundary>\n {endAdornment}\n </ErrorBoundary>}\n\n {shellToolbar}\n\n {/* On a large layout the drawer is always on screen and carries\n this control; one per screen. */}\n {!(hasDrawer && largeLayout) && <RlsSimulatorBar/>}\n\n {includeLanguageToggle && <LanguageToggle/>}\n\n {includeModeToggle &&\n <Menu\n trigger={<IconButton\n aria-label=\"Toggle theme\"\n>\n {mode === \"dark\"\n ? <MoonIcon size={iconSize.small}/>\n : <SunIcon size={iconSize.small}/>}\n </IconButton>}>\n <MenuItem onClick={() => setMode(\"dark\")}><MoonIcon size={iconSize.smallest}/> {t(\"dark_mode\")}</MenuItem>\n <MenuItem onClick={() => setMode(\"light\")}><SunIcon size={iconSize.smallest}/> {t(\"light_mode\")} </MenuItem>\n <MenuItem onClick={() => setMode(\"system\")}> <SunMoonIcon\n size={iconSize.smallest}/>{t(\"system_mode\")}</MenuItem>\n </Menu>}\n\n\n {includeUserMenu &&\n <Menu trigger={<div aria-label=\"User menu\" role=\"button\">{avatarComponent}</div>}>\n {user && <div className={\"px-4 py-2 mb-2\"}>\n {user.displayName && <Typography variant={\"body1\"} color={\"secondary\"}>\n {user.displayName}\n </Typography>}\n {user.email && <Typography variant={\"body2\"} color={\"secondary\"}>\n {user.email}\n </Typography>}\n </div>}\n\n {dropDownActions}\n\n {!dropDownActions && <>\n <MenuItem onClick={() => navigate(\"/settings\")}>\n <SettingsIcon/>\n {t(\"account_settings\")}\n </MenuItem>\n <MenuItem onClick={async () => {\n await authController.signOut();\n // replace current route with home\n navigate(\"/\");\n }}>\n <LogOutIcon/>\n {t(\"log_out\")}\n </MenuItem>\n </>}\n\n </Menu>}\n\n </div>\n );\n}\n"],"mappings":";;;;;;;;;;;;;;;AAkFA,IAAa,gBAAgB,SAAS,cAAc,EAChD,OACA,cACA,gBACA,iBACA,oBAAoB,MAC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eAAe,QAAQ,MAAM;gBAAvC;OAA0C,oBAAC,UAAD,EAAU,MAAM,SAAS,SAAU,CAAA;OAAC;OAAE,EAAE,WAAW;MAAY;;KACzG,qBAAC,UAAD;MAAU,eAAe,QAAQ,OAAO;gBAAxC;OAA2C,oBAAC,SAAD,EAAS,MAAM,SAAS,SAAU,CAAA;OAAC;OAAE,EAAE,YAAY;OAAE;MAAW;;KAC3G,qBAAC,UAAD;MAAU,eAAe,QAAQ,QAAQ;gBAAzC;OAA4C;OAAC,oBAAC,aAAD,EACzC,MAAM,SAAS,SAAU,CAAA;OAAE,EAAE,aAAa;MAAY;;IACxD;;GAGT,mBACG,qBAAC,MAAD;IAAM,SAAS,oBAAC,OAAD;KAAK,cAAW;KAAY,MAAK;eAAU;IAAqB,CAAA;cAA/E;KACK,QAAQ,qBAAC,OAAD;MAAK,WAAW;gBAAhB,CACJ,KAAK,eAAe,oBAAC,YAAD;OAAY,SAAS;OAAS,OAAO;iBACrD,KAAK;MACE,CAAA,GACX,KAAK,SAAS,oBAAC,YAAD;OAAY,SAAS;OAAS,OAAO;iBAC/C,KAAK;MACE,CAAA,CACX;;KAEJ;KAEA,CAAC,mBAAmB,qBAAA,UAAA,EAAA,UAAA,CACjB,qBAAC,UAAD;MAAU,eAAe,SAAS,WAAW;gBAA7C,CACI,oBAAC,cAAD,CAAc,CAAA,GACb,EAAE,kBAAkB,CACf;SACV,qBAAC,UAAD;MAAU,SAAS,YAAY;OAC3B,MAAM,eAAe,QAAQ;OAE7B,SAAS,GAAG;MAChB;gBAJA,CAKI,oBAAC,YAAD,CAAY,CAAA,GACX,EAAE,SAAS,CACN;OACZ,EAAA,CAAA;IAEA;;EAET;;AAEb"}
@@ -6,7 +6,7 @@ import { DrawerNavigationGroup } from "./DrawerNavigationGroup.js";
6
6
  import React, { useCallback, useMemo } from "react";
7
7
  import { Fragment, jsx, jsxs } from "react/jsx-runtime";
8
8
  import { Avatar, ChevronsLeftIcon, ChevronsRightIcon, IconButton, LogOutIcon, Menu, MenuItem, MoonIcon, SettingsIcon, Skeleton, SunIcon, SunMoonIcon, ToggleButtonGroup, Tooltip, Typography, cls, iconSize } from "@rebasepro/ui";
9
- import { LanguageToggle, RebaseLogo, buildCollapsedDefaults, useAdminModeController, useAnalyticsController, useAuthController, useCollapsedGroups, useComponentOverride, useLargeLayout, useModeController, useRebaseContext, useRebaseRegistry, useSlot, useTranslation } from "@rebasepro/app";
9
+ import { LanguageToggle, RebaseLogo, RlsSimulatorBar, buildCollapsedDefaults, useAdminModeController, useAnalyticsController, useAuthController, useCanSimulateAccess, useCollapsedGroups, useComponentOverride, useLargeLayout, useModeController, useRebaseContext, useRebaseRegistry, useSlot, useTranslation } from "@rebasepro/app";
10
10
  import { Link, useNavigate } from "react-router";
11
11
  //#region src/components/DefaultDrawer.tsx
12
12
  /**
@@ -267,6 +267,7 @@ function DrawerFooterActions({ drawerOpen, drawerHovered, dropDownActions, user:
267
267
  const user = userProp ?? authController.user;
268
268
  const showFullContent = drawerOpen || drawerHovered;
269
269
  const portalRef = React.useRef(null);
270
+ const canSimulateAccess = useCanSimulateAccess();
270
271
  let avatarComponent;
271
272
  if (user) {
272
273
  const initial = user?.displayName ? user.displayName[0].toUpperCase() : user?.email ? user.email[0].toUpperCase() : "A";
@@ -277,10 +278,21 @@ function DrawerFooterActions({ drawerOpen, drawerHovered, dropDownActions, user:
277
278
  });
278
279
  } else if (user === void 0 || authController.initialLoading) avatarComponent = /* @__PURE__ */ jsx(Skeleton, { className: "w-8 h-8 rounded-full" });
279
280
  else avatarComponent = null;
280
- return /* @__PURE__ */ jsx("div", {
281
+ return /* @__PURE__ */ jsxs("div", {
281
282
  className: "shrink-0 pt-2 pb-0",
282
283
  ref: portalRef,
283
- children: avatarComponent && /* @__PURE__ */ jsxs("div", {
284
+ children: [canSimulateAccess && /* @__PURE__ */ jsx("div", {
285
+ className: "flex items-center px-[16px] py-1",
286
+ children: /* @__PURE__ */ jsx("div", {
287
+ className: cls("flex", { "w-[44px] justify-center": !showFullContent }),
288
+ children: /* @__PURE__ */ jsx(RlsSimulatorBar, {
289
+ compact: !showFullContent,
290
+ side: "right",
291
+ align: "end",
292
+ portalContainer: portalRef.current
293
+ })
294
+ })
295
+ }), avatarComponent && /* @__PURE__ */ jsxs("div", {
284
296
  className: "flex items-center px-[16px] py-1",
285
297
  children: [/* @__PURE__ */ jsxs(Menu, {
286
298
  trigger: /* @__PURE__ */ jsx("div", {
@@ -355,7 +367,7 @@ function DrawerFooterActions({ drawerOpen, drawerHovered, dropDownActions, user:
355
367
  ]
356
368
  })]
357
369
  })]
358
- })
370
+ })]
359
371
  });
360
372
  }
361
373
  //#endregion
@@ -1 +1 @@
1
- {"version":3,"file":"DefaultDrawer.js","names":[],"sources":["../../src/components/DefaultDrawer.tsx"],"sourcesContent":["import type { NavigationEntry, NavigationResult } from \"@rebasepro/cms-types\";\nimport React, { useCallback, useMemo } from \"react\";\n\nimport { useCollapsedGroups, buildCollapsedDefaults, useLargeLayout, useAdminModeController, useAuthController, useModeController, useTranslation, useSlot, useRebaseContext, useAnalyticsController, useRebaseRegistry, useComponentOverride } from \"@rebasepro/app\";\nimport type { AdminModeController } from \"@rebasepro/app\";\nimport { useUrlController } from \"../hooks/navigation/contexts/UrlContext\";\nimport { useNavigationStateController } from \"../hooks/navigation/contexts/NavigationStateContext\";\n\n\nimport { Link, useNavigate } from \"react-router\";\nimport { AnalyticsEvent } from \"@rebasepro/cms-types\";\nimport {\n Avatar,\n ChevronsLeftIcon,\n ChevronsRightIcon,\n cls,\n iconSize,\n IconButton,\n LanguagesIcon,\n LogOutIcon,\n Menu,\n MenuItem,\n MoonIcon,\n Separator,\n SettingsIcon,\n Skeleton,\n SunIcon,\n SunMoonIcon,\n ToggleButtonGroup,\n Tooltip,\n Typography\n} from \"@rebasepro/ui\";\nimport { DrawerNavigationGroup } from \"./DrawerNavigationGroup\";\nimport { DrawerExpansionContext, useDrawerExpansion } from \"./drawer_expansion\";\nimport { LanguageToggle, RebaseLogo } from \"@rebasepro/app\";\nimport { useApp } from \"./app/useApp\";\n\n/**\n * Default drawer used in the admin.\n *\n * When no `children` are provided, renders the full admin navigation\n * (collection groups, mode switch, plugin slots).\n *\n * When `children` **are** provided, renders the shared drawer shell\n * (logo, scrollable area, footer actions, collapse toggle) with the\n * custom content injected in the scrollable area. This lets consumers\n * like the SaaS dashboard reuse the identical structural layout while\n * supplying their own navigation items.\n *\n * @group Core\n */\nexport function DefaultDrawer({\n title,\n logo,\n logoDestination,\n children,\n footerActions,\n className,\n style\n}: {\n title?: React.ReactNode;\n logo?: string;\n logoDestination?: string;\n /**\n * Custom navigation content for the drawer.\n * When provided, replaces the default admin navigation (collection groups,\n * mode switch, slots). The shared shell (logo, scroll area, footer\n * actions, collapse toggle) is still rendered around it.\n */\n children?: React.ReactNode;\n /**\n * Custom content for the drawer footer actions area (language, theme, user menu).\n * - `undefined` — renders the default `DrawerFooterActions`.\n * - `null` — renders nothing (hides the footer actions).\n * - `ReactNode` — renders the provided custom content.\n */\n footerActions?: React.ReactNode | null;\n className?: string;\n style?: React.CSSProperties;\n}) {\n\n const {\n drawerHovered,\n drawerOpen,\n openDrawer,\n closeDrawer,\n logo: appLogo\n } = useApp();\n\n const resolvedLogo = logo ?? appLogo;\n\n const scrollRef = React.useRef<HTMLDivElement>(null);\n const [scrolled, setScrolled] = React.useState(false);\n\n // Open, pinned or floating under the pointer. The rows read it from the\n // `data-expanded` attribute (through CSS) and the expansion store, not as a\n // prop, so the rail opening under the pointer re-renders none of them.\n const expanded = drawerOpen || drawerHovered;\n const expansion = useDrawerExpansion(expanded);\n\n const handleScroll = () => {\n if (scrollRef.current) {\n setScrolled(scrollRef.current.scrollTop > 0);\n }\n };\n\n return (\n <div role=\"navigation\" aria-label=\"Main navigation\"\n data-expanded={expanded}\n className={cls(\"group/drawer flex flex-col h-full relative grow w-full\", className)} style={style}>\n\n <DrawerLogo\n logo={resolvedLogo}\n title={title}\n logoDestination={logoDestination}\n drawerOpen={drawerOpen}\n drawerHovered={drawerHovered}\n />\n\n <div\n ref={scrollRef}\n onScroll={handleScroll}\n className={\"flex-grow min-h-0 overflow-y-auto overflow-x-hidden no-scrollbar px-2\"}\n style={{\n maskImage: scrolled\n ? \"linear-gradient(to bottom, transparent 0, black 20px, black calc(100% - 20px), transparent 100%)\"\n : \"linear-gradient(to bottom, black 0, black calc(100% - 20px), transparent 100%)\"\n }}>\n <DrawerExpansionContext.Provider value={expansion}>\n {children ?? <AdminNavigationContent />}\n </DrawerExpansionContext.Provider>\n </div>\n\n {footerActions !== null && (\n footerActions !== undefined\n ? footerActions\n : <DrawerFooterActions\n drawerOpen={drawerOpen}\n drawerHovered={drawerHovered}\n />\n )}\n\n <DrawerToggle\n drawerOpen={drawerOpen}\n drawerHovered={drawerHovered}\n openDrawer={openDrawer}\n closeDrawer={closeDrawer}\n />\n </div>\n );\n}\n\n/**\n * Default admin navigation content — rendered inside DefaultDrawer when no\n * custom `children` are provided. Contains the mode switch, navigation\n * groups, and header / footer plugin slots.\n */\nfunction AdminNavigationContent() {\n\n const {\n drawerHovered,\n drawerOpen,\n closeDrawer,\n closeHover\n } = useApp();\n\n const analyticsController = useAnalyticsController();\n const navigationState = useNavigationStateController();\n const context = useRebaseContext();\n\n const largeLayout = useLargeLayout();\n const adminModeController = useAdminModeController();\n const registry = useRebaseRegistry();\n const ResolvedDrawerNavigationGroup = useComponentOverride(\"Shell.DrawerNavigationGroup\", DrawerNavigationGroup);\n\n const allNavigationEntries = navigationState.topLevelNavigation?.navigationEntries ?? [];\n\n // Build a set of Studio-only dev view slugs so we can distinguish them from\n // admin custom views added via <RebaseCMS views={...}> or plugins.\n const studioViewSlugs = useMemo(() => {\n const slugs = new Set<string>();\n (registry.studioConfig?.devViews ?? []).forEach(v => slugs.add(v.slug));\n // The schema view is also a Studio dev view (auto-injected when collectionEditor is enabled)\n if (registry.studioConfig && registry.cmsConfig?.collectionEditor) slugs.add(\"schema\");\n return slugs;\n }, [registry.studioConfig, registry.cmsConfig?.collectionEditor]);\n\n // Studio mode shows Studio dev views + admin entries (Users/Roles).\n // Content mode shows collections, admin custom views, and admin entries — but not Studio dev views.\n const filteredEntries = adminModeController.mode === \"studio\"\n ? allNavigationEntries.filter(e => (e.type === \"view\" && studioViewSlugs.has(e.slug)) || e.type === \"admin\")\n : allNavigationEntries.filter(e => e.type !== \"view\" || !studioViewSlugs.has(e.slug));\n\n // Derive groups from the filtered entries, preserving the order from topLevelNavigation.groups\n const entryGroups = new Set(filteredEntries.map(e => e.group).filter(Boolean));\n const orderedGroups = navigationState.topLevelNavigation?.groups ?? [];\n const groupsToRender = [\n ...orderedGroups.filter(g => entryGroups.has(g)),\n ...[...entryGroups].filter(g => !orderedGroups.includes(g))\n ];\n\n // Group header icons, declared on `navigationGroupMappings`. Keyed by name\n // because that is what a navigation entry's `group` holds.\n const groupIcons = useMemo(() => {\n const icons = new Map<string, string>();\n (registry.cmsConfig?.navigationGroupMappings ?? []).forEach(mapping => {\n if (mapping.icon) icons.set(mapping.name, mapping.icon);\n });\n return icons;\n }, [registry.cmsConfig?.navigationGroupMappings]);\n\n // Collapsible groups state - using \"drawer\" namespace for independent state from home page\n const collapsedDefaults = useMemo(\n () => buildCollapsedDefaults(registry.cmsConfig?.navigationGroupMappings, \"drawer\"),\n [registry.cmsConfig?.navigationGroupMappings]\n );\n const { isGroupCollapsed, toggleGroupCollapsed } = useCollapsedGroups(groupsToRender, \"drawer\", collapsedDefaults);\n\n const headerSlot = useSlot(\"navigation.header\", { drawerOpen,\ndrawerHovered,\ncontext });\n const footerSlot = useSlot(\"navigation.footer\", { drawerOpen,\ndrawerHovered,\ncontext });\n\n // The same handler across a hover: every row is handed it.\n const onItemClick = useCallback((view: NavigationEntry) => {\n const eventName: AnalyticsEvent = view.type === \"collection\"\n ? \"drawer_navigate_to_collection\"\n : (view.type === \"view\" ? \"drawer_navigate_to_view\" : \"unmapped_event\");\n analyticsController.onAnalyticsEvent?.(eventName, { url: view.url });\n if (!largeLayout) {\n closeDrawer();\n } else if (!drawerOpen) {\n closeHover();\n }\n }, [analyticsController, largeLayout, drawerOpen, closeDrawer, closeHover]);\n\n if (!navigationState.topLevelNavigation)\n return null;\n\n const drawerVisuallyOpen = drawerOpen || drawerHovered;\n\n return (\n <>\n {registry.studioConfig && (\n <DrawerModeSwitch\n drawerOpen={drawerOpen}\n drawerHovered={drawerHovered}\n />\n )}\n\n {headerSlot}\n\n {groupsToRender.map((group) => {\n const entriesInGroup = filteredEntries.filter(e => e.group === group);\n return (\n <ResolvedDrawerNavigationGroup\n key={`drawer_group_${group}`}\n group={group}\n entries={entriesInGroup}\n collapsed={isGroupCollapsed(group)}\n onToggleCollapsed={() => toggleGroupCollapsed(group)}\n drawerOpen={drawerVisuallyOpen}\n onItemClick={onItemClick}\n icon={groupIcons.get(group)}\n />\n );\n })}\n\n {footerSlot}\n </>\n );\n}\n\nexport function DrawerLogo({\n logo,\n title,\n logoDestination = \"/\",\n drawerOpen,\n drawerHovered\n}: {\n logo?: string;\n title?: React.ReactNode;\n logoDestination?: string;\n drawerOpen: boolean;\n drawerHovered: boolean;\n}) {\n\n const showFullContent = drawerOpen || drawerHovered;\n const { t } = useTranslation();\n\n return (\n <div className=\"flex flex-row items-center shrink-0 pt-4 pb-0 px-2\">\n {/* Logo — always visible */}\n {/* Named explicitly because neither branch below carries text: the\n stock `RebaseLogo` is a bare <svg> with no <title>, and a custom\n `logo` only ever gets the generic alt \"Logo\", which names the image\n rather than saying where the link goes. The title link beside it is\n no help either — it renders only when a `title` is set. */}\n <Link\n className=\"shrink-0 flex items-center justify-center w-[56px] h-[40px]\"\n to={logoDestination}\n aria-label={t(\"home\", { defaultValue: \"Home\" })}\n >\n {logo\n ? <img src={logo} alt=\"Logo\" className=\"w-[28px] h-[28px] object-contain\"/>\n : <RebaseLogo width=\"28px\" height=\"28px\"/>\n }\n </Link>\n\n {/* Title (fades in when expanded or hovered) */}\n <div\n className={cls(\n \"flex flex-row items-center overflow-hidden transition-all duration-200 ease-in-out\",\n showFullContent ? \"opacity-100 w-full ml-1\" : \"opacity-0 w-0 ml-0\"\n )}\n >\n {title && (\n <Link\n className=\"visited:text-inherit dark:visited:text-inherit block truncate\"\n to={logoDestination}\n >\n {typeof title === \"string\"\n ? <Typography variant=\"subtitle1\" noWrap className=\"truncate\">{title}</Typography>\n : title\n }\n </Link>\n )}\n </div>\n </div>\n );\n}\n\n/**\n * Toggle button at the bottom of the drawer.\n * Uses double-chevron icons to indicate collapse/expand direction.\n */\nexport function DrawerToggle({\n drawerOpen,\n drawerHovered,\n openDrawer,\n closeDrawer\n}: {\n drawerOpen: boolean;\n drawerHovered: boolean;\n openDrawer: () => void;\n closeDrawer: () => void;\n}) {\n const isExpanded = drawerOpen;\n const isHovered = drawerHovered && !drawerOpen;\n const showFullContent = isExpanded || isHovered;\n\n const [wantsTooltip, setWantsTooltip] = React.useState(false);\n // See {@link DrawerNavigationItem}: a masked tooltip never hears the pointer\n // leave, so the stale state is dropped as the mask goes on.\n if (showFullContent && wantsTooltip) setWantsTooltip(false);\n\n const { t } = useTranslation();\n\n return (\n <div className=\"shrink-0 mt-auto px-4 pt-0.5 pb-2\">\n <Tooltip\n title={isExpanded ? t(\"collapse\") : t(\"expand\")}\n // The row spells out \"Collapse\"/\"Expand\" itself whenever it is wide\n // enough to show the label — expanded, or floating open under the\n // pointer. A tooltip repeating that word is noise; it earns its\n // place only on a bare rail, where the chevron stands alone.\n //\n // Masked, not withheld: see {@link DrawerNavigationItem} for why\n // this stays controlled in both states.\n open={!showFullContent && wantsTooltip}\n onOpenChange={setWantsTooltip}\n side=\"right\"\n sideOffset={12}\n asChild={true}\n >\n <button\n type=\"button\"\n className={cls(\n \"flex flex-row items-center rounded-lg cursor-pointer w-full\",\n \"hover:bg-surface-hover\",\n \"transition-colors duration-150\",\n \"py-2\"\n )}\n aria-expanded={isExpanded}\n aria-label={isExpanded ? t(\"collapse\") : t(\"expand\")}\n onClick={() => isExpanded ? closeDrawer() : openDrawer()}\n >\n {/* 44px in both states, on the same grid as the rows above and\n for the same reason: the rail floats open under the pointer,\n and a slot that changed width with it walked the chevron\n sideways on hover. See the note in DrawerNavigationItem. */}\n <div className=\"shrink-0 flex items-center justify-center w-[44px] h-[24px] text-surface-500 dark:text-surface-400\">\n {isExpanded\n ? <ChevronsLeftIcon size={iconSize.small}/>\n : <ChevronsRightIcon size={iconSize.small}/>\n }\n </div>\n <div className={cls(\n \"overflow-hidden transition-all duration-200 ease-in-out\",\n showFullContent ? \"opacity-100 w-auto\" : \"opacity-0 w-0\"\n )}>\n <Typography\n variant=\"body2\"\n className=\"text-surface-500 dark:text-surface-400 select-none whitespace-nowrap\"\n >\n {isExpanded ? t(\"collapse\") : t(\"expand\")}\n </Typography>\n </div>\n </button>\n </Tooltip>\n </div>\n );\n}\n\n/**\n * Segmented Content / Studio switch rendered inside the drawer.\n * Animates in/out with the drawer open state via opacity + max-height.\n */\nfunction DrawerModeSwitch({\n drawerOpen,\n drawerHovered\n}: {\n drawerOpen: boolean;\n drawerHovered: boolean;\n}) {\n const adminModeController = useAdminModeController();\n const urlController = useUrlController();\n const navigate = useNavigate();\n const { t } = useTranslation();\n const showSwitch = drawerOpen || drawerHovered;\n\n return (\n <div\n // Hidden by opacity so it can fade with the rail; `inert` takes it\n // out of the tab order and the accessibility tree while it is.\n inert={!showSwitch}\n className={cls(\n \"shrink-0 overflow-hidden transition-all duration-200 ease-in-out px-3 h-8 mt-2 mb-0\",\n showSwitch ? \"opacity-100\" : \"opacity-0 pointer-events-none\"\n )}\n >\n <ToggleButtonGroup<AdminModeController[\"mode\"]>\n fullWidth\n aria-label={t(\"panel_mode\")}\n value={adminModeController.mode}\n onValueChange={(mode) => {\n adminModeController.setMode(mode);\n if (mode === \"cms\") navigate(urlController.basePath ?? \"/\");\n else navigate(urlController.basePath === \"/\" ? \"/s\" : `${urlController.basePath ?? \"\"}/s`);\n }}\n options={[\n { value: \"cms\", label: \"CMS\" },\n { value: \"studio\", label: \"Studio\" }\n ]}\n />\n </div>\n );\n}\n\n/**\n * Footer actions rendered at the bottom of the drawer, above the collapse/expand toggle.\n * Replaces the app bar icons (language, theme, user avatar) with a drawer-native layout\n * that adapts between collapsed (icons only) and expanded (full labels + user bar) states.\n *\n * @group Core\n */\nexport function DrawerFooterActions({\n drawerOpen,\n drawerHovered,\n /**\n * Custom content to render inside the user dropdown menu.\n * When provided, these items are appended after the user info header\n * and before the default Sign Out item.\n */\n dropDownActions,\n /**\n * Override the user object displayed in the footer.\n * When omitted, falls back to `authController.user`.\n */\n user: userProp\n}: {\n drawerOpen: boolean;\n drawerHovered: boolean;\n dropDownActions?: React.ReactNode;\n user?: import(\"@rebasepro/types\").User;\n}) {\n const authController = useAuthController();\n const {\n mode,\n setMode\n } = useModeController();\n const navigate = useNavigate();\n const { t } = useTranslation();\n\n const user = userProp ?? authController.user;\n const showFullContent = drawerOpen || drawerHovered;\n const isFloating = drawerHovered && !drawerOpen;\n const portalRef = React.useRef<HTMLDivElement>(null);\n\n // User avatar\n let avatarComponent: React.ReactElement | null;\n if (user) {\n const initial = user?.displayName\n ? user.displayName[0].toUpperCase()\n : (user?.email ? user.email[0].toUpperCase() : \"A\");\n avatarComponent = <Avatar src={user.photoURL ?? undefined} className=\"w-8 h-8 text-xs\">\n {initial}\n </Avatar>;\n } else if (user === undefined || authController.initialLoading) {\n avatarComponent = <Skeleton className=\"w-8 h-8 rounded-full\"/>;\n } else {\n avatarComponent = null;\n }\n\n return (\n <div className=\"shrink-0 pt-2 pb-0\" ref={portalRef}>\n {avatarComponent && (\n <div className=\"flex items-center px-[16px] py-1\">\n <Menu\n trigger={\n <div\n className={cls(\n // Same 44px grid, and fixed across both states for\n // the same reason — see DrawerNavigationItem.\n \"shrink-0 flex items-center justify-center w-[44px] cursor-pointer\",\n \"rounded-md py-1\",\n \"hover:bg-surface-hover\",\n \"transition-colors duration-150\"\n )}\n role=\"button\"\n tabIndex={0}\n aria-label={t(\"user_menu\", { defaultValue: \"User menu\" })}\n >\n {avatarComponent}\n </div>\n }\n side=\"top\"\n align=\"start\"\n >\n {user && <div className=\"px-4 py-2 mb-1\">\n {user.displayName && <Typography variant=\"body1\" color=\"secondary\">\n {user.displayName}\n </Typography>}\n {user.email && <Typography variant=\"body2\" color=\"secondary\">\n {user.email}\n </Typography>}\n </div>}\n\n {dropDownActions}\n\n {!dropDownActions && <>\n <MenuItem onClick={() => navigate(\"/settings\")}>\n <SettingsIcon/>\n {t(\"account_settings\")}\n </MenuItem>\n <MenuItem onClick={async () => {\n await authController.signOut();\n navigate(\"/\");\n }}>\n <LogOutIcon/>\n {t(\"log_out\")}\n </MenuItem>\n </>}\n </Menu>\n\n {/* Language + Theme — only when expanded */}\n {showFullContent && (\n <div className=\"flex items-center gap-0\">\n <LanguageToggle/>\n <Menu\n trigger={\n <IconButton\n aria-label={t(\"toggle_theme\", { defaultValue: \"Toggle theme\" })}\n className=\"text-surface-500 dark:text-surface-400\"\n >\n {mode === \"dark\"\n ? <MoonIcon size={iconSize.small}/>\n : mode === \"light\"\n ? <SunIcon size={iconSize.small}/>\n : <SunMoonIcon size={iconSize.small}/>}\n </IconButton>\n }\n portalContainer={portalRef.current}\n side=\"top\"\n >\n <MenuItem onClick={() => setMode(\"dark\")}><MoonIcon size={iconSize.smallest}/> {t(\"dark_mode\")}</MenuItem>\n <MenuItem onClick={() => setMode(\"light\")}><SunIcon size={iconSize.smallest}/> {t(\"light_mode\")}</MenuItem>\n <MenuItem onClick={() => setMode(\"system\")}><SunMoonIcon size={iconSize.smallest}/> {t(\"system_mode\")}</MenuItem>\n </Menu>\n </div>\n )}\n </div>\n )}\n </div>\n );\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;AAmDA,SAAgB,cAAc,EAC1B,OACA,MACA,iBACA,UACA,eACA,WACA,SAqBD;CAEC,MAAM,EACF,eACA,YACA,YACA,aACA,MAAM,YACN,OAAO;CAEX,MAAM,eAAe,QAAQ;CAE7B,MAAM,YAAY,MAAM,OAAuB,IAAI;CACnD,MAAM,C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SAAD,EAAS,MAAM,SAAS,SAAU,CAAA;QAAC;QAAE,EAAE,YAAY;OAAY;;MAC1G,qBAAC,UAAD;OAAU,eAAe,QAAQ,QAAQ;iBAAzC;QAA4C,oBAAC,aAAD,EAAa,MAAM,SAAS,SAAU,CAAA;QAAC;QAAE,EAAE,aAAa;OAAY;;KAC9G;MACL;KAER;;CAER,CAAA;AAEb"}
1
+ {"version":3,"file":"DefaultDrawer.js","names":[],"sources":["../../src/components/DefaultDrawer.tsx"],"sourcesContent":["import type { NavigationEntry, NavigationResult } from \"@rebasepro/cms-types\";\nimport React, { useCallback, useMemo } from \"react\";\n\nimport { useCollapsedGroups, buildCollapsedDefaults, useLargeLayout, useAdminModeController, useAuthController, useModeController, useTranslation, useSlot, useRebaseContext, useAnalyticsController, useRebaseRegistry, useComponentOverride } from \"@rebasepro/app\";\nimport type { AdminModeController } from \"@rebasepro/app\";\nimport { useUrlController } from \"../hooks/navigation/contexts/UrlContext\";\nimport { useNavigationStateController } from \"../hooks/navigation/contexts/NavigationStateContext\";\n\n\nimport { Link, useNavigate } from \"react-router\";\nimport { AnalyticsEvent } from \"@rebasepro/cms-types\";\nimport {\n Avatar,\n ChevronsLeftIcon,\n ChevronsRightIcon,\n cls,\n iconSize,\n IconButton,\n LanguagesIcon,\n LogOutIcon,\n Menu,\n MenuItem,\n MoonIcon,\n Separator,\n SettingsIcon,\n Skeleton,\n SunIcon,\n SunMoonIcon,\n ToggleButtonGroup,\n Tooltip,\n Typography\n} from \"@rebasepro/ui\";\nimport { DrawerNavigationGroup } from \"./DrawerNavigationGroup\";\nimport { DrawerExpansionContext, useDrawerExpansion } from \"./drawer_expansion\";\nimport { LanguageToggle, RebaseLogo, RlsSimulatorBar, useCanSimulateAccess } from \"@rebasepro/app\";\nimport { useApp } from \"./app/useApp\";\n\n/**\n * Default drawer used in the admin.\n *\n * When no `children` are provided, renders the full admin navigation\n * (collection groups, mode switch, plugin slots).\n *\n * When `children` **are** provided, renders the shared drawer shell\n * (logo, scrollable area, footer actions, collapse toggle) with the\n * custom content injected in the scrollable area. This lets consumers\n * like the SaaS dashboard reuse the identical structural layout while\n * supplying their own navigation items.\n *\n * @group Core\n */\nexport function DefaultDrawer({\n title,\n logo,\n logoDestination,\n children,\n footerActions,\n className,\n style\n}: {\n title?: React.ReactNode;\n logo?: string;\n logoDestination?: string;\n /**\n * Custom navigation content for the drawer.\n * When provided, replaces the default admin navigation (collection groups,\n * mode switch, slots). The shared shell (logo, scroll area, footer\n * actions, collapse toggle) is still rendered around it.\n */\n children?: React.ReactNode;\n /**\n * Custom content for the drawer footer actions area (language, theme, user menu).\n * - `undefined` — renders the default `DrawerFooterActions`.\n * - `null` — renders nothing (hides the footer actions).\n * - `ReactNode` — renders the provided custom content.\n */\n footerActions?: React.ReactNode | null;\n className?: string;\n style?: React.CSSProperties;\n}) {\n\n const {\n drawerHovered,\n drawerOpen,\n openDrawer,\n closeDrawer,\n logo: appLogo\n } = useApp();\n\n const resolvedLogo = logo ?? appLogo;\n\n const scrollRef = React.useRef<HTMLDivElement>(null);\n const [scrolled, setScrolled] = React.useState(false);\n\n // Open, pinned or floating under the pointer. The rows read it from the\n // `data-expanded` attribute (through CSS) and the expansion store, not as a\n // prop, so the rail opening under the pointer re-renders none of them.\n const expanded = drawerOpen || drawerHovered;\n const expansion = useDrawerExpansion(expanded);\n\n const handleScroll = () => {\n if (scrollRef.current) {\n setScrolled(scrollRef.current.scrollTop > 0);\n }\n };\n\n return (\n <div role=\"navigation\" aria-label=\"Main navigation\"\n data-expanded={expanded}\n className={cls(\"group/drawer flex flex-col h-full relative grow w-full\", className)} style={style}>\n\n <DrawerLogo\n logo={resolvedLogo}\n title={title}\n logoDestination={logoDestination}\n drawerOpen={drawerOpen}\n drawerHovered={drawerHovered}\n />\n\n <div\n ref={scrollRef}\n onScroll={handleScroll}\n className={\"flex-grow min-h-0 overflow-y-auto overflow-x-hidden no-scrollbar px-2\"}\n style={{\n maskImage: scrolled\n ? \"linear-gradient(to bottom, transparent 0, black 20px, black calc(100% - 20px), transparent 100%)\"\n : \"linear-gradient(to bottom, black 0, black calc(100% - 20px), transparent 100%)\"\n }}>\n <DrawerExpansionContext.Provider value={expansion}>\n {children ?? <AdminNavigationContent />}\n </DrawerExpansionContext.Provider>\n </div>\n\n {footerActions !== null && (\n footerActions !== undefined\n ? footerActions\n : <DrawerFooterActions\n drawerOpen={drawerOpen}\n drawerHovered={drawerHovered}\n />\n )}\n\n <DrawerToggle\n drawerOpen={drawerOpen}\n drawerHovered={drawerHovered}\n openDrawer={openDrawer}\n closeDrawer={closeDrawer}\n />\n </div>\n );\n}\n\n/**\n * Default admin navigation content — rendered inside DefaultDrawer when no\n * custom `children` are provided. Contains the mode switch, navigation\n * groups, and header / footer plugin slots.\n */\nfunction AdminNavigationContent() {\n\n const {\n drawerHovered,\n drawerOpen,\n closeDrawer,\n closeHover\n } = useApp();\n\n const analyticsController = useAnalyticsController();\n const navigationState = useNavigationStateController();\n const context = useRebaseContext();\n\n const largeLayout = useLargeLayout();\n const adminModeController = useAdminModeController();\n const registry = useRebaseRegistry();\n const ResolvedDrawerNavigationGroup = useComponentOverride(\"Shell.DrawerNavigationGroup\", DrawerNavigationGroup);\n\n const allNavigationEntries = navigationState.topLevelNavigation?.navigationEntries ?? [];\n\n // Build a set of Studio-only dev view slugs so we can distinguish them from\n // admin custom views added via <RebaseCMS views={...}> or plugins.\n const studioViewSlugs = useMemo(() => {\n const slugs = new Set<string>();\n (registry.studioConfig?.devViews ?? []).forEach(v => slugs.add(v.slug));\n // The schema view is also a Studio dev view (auto-injected when collectionEditor is enabled)\n if (registry.studioConfig && registry.cmsConfig?.collectionEditor) slugs.add(\"schema\");\n return slugs;\n }, [registry.studioConfig, registry.cmsConfig?.collectionEditor]);\n\n // Studio mode shows Studio dev views + admin entries (Users/Roles).\n // Content mode shows collections, admin custom views, and admin entries — but not Studio dev views.\n const filteredEntries = adminModeController.mode === \"studio\"\n ? allNavigationEntries.filter(e => (e.type === \"view\" && studioViewSlugs.has(e.slug)) || e.type === \"admin\")\n : allNavigationEntries.filter(e => e.type !== \"view\" || !studioViewSlugs.has(e.slug));\n\n // Derive groups from the filtered entries, preserving the order from topLevelNavigation.groups\n const entryGroups = new Set(filteredEntries.map(e => e.group).filter(Boolean));\n const orderedGroups = navigationState.topLevelNavigation?.groups ?? [];\n const groupsToRender = [\n ...orderedGroups.filter(g => entryGroups.has(g)),\n ...[...entryGroups].filter(g => !orderedGroups.includes(g))\n ];\n\n // Group header icons, declared on `navigationGroupMappings`. Keyed by name\n // because that is what a navigation entry's `group` holds.\n const groupIcons = useMemo(() => {\n const icons = new Map<string, string>();\n (registry.cmsConfig?.navigationGroupMappings ?? []).forEach(mapping => {\n if (mapping.icon) icons.set(mapping.name, mapping.icon);\n });\n return icons;\n }, [registry.cmsConfig?.navigationGroupMappings]);\n\n // Collapsible groups state - using \"drawer\" namespace for independent state from home page\n const collapsedDefaults = useMemo(\n () => buildCollapsedDefaults(registry.cmsConfig?.navigationGroupMappings, \"drawer\"),\n [registry.cmsConfig?.navigationGroupMappings]\n );\n const { isGroupCollapsed, toggleGroupCollapsed } = useCollapsedGroups(groupsToRender, \"drawer\", collapsedDefaults);\n\n const headerSlot = useSlot(\"navigation.header\", { drawerOpen,\ndrawerHovered,\ncontext });\n const footerSlot = useSlot(\"navigation.footer\", { drawerOpen,\ndrawerHovered,\ncontext });\n\n // The same handler across a hover: every row is handed it.\n const onItemClick = useCallback((view: NavigationEntry) => {\n const eventName: AnalyticsEvent = view.type === \"collection\"\n ? \"drawer_navigate_to_collection\"\n : (view.type === \"view\" ? \"drawer_navigate_to_view\" : \"unmapped_event\");\n analyticsController.onAnalyticsEvent?.(eventName, { url: view.url });\n if (!largeLayout) {\n closeDrawer();\n } else if (!drawerOpen) {\n closeHover();\n }\n }, [analyticsController, largeLayout, drawerOpen, closeDrawer, closeHover]);\n\n if (!navigationState.topLevelNavigation)\n return null;\n\n const drawerVisuallyOpen = drawerOpen || drawerHovered;\n\n return (\n <>\n {registry.studioConfig && (\n <DrawerModeSwitch\n drawerOpen={drawerOpen}\n drawerHovered={drawerHovered}\n />\n )}\n\n {headerSlot}\n\n {groupsToRender.map((group) => {\n const entriesInGroup = filteredEntries.filter(e => e.group === group);\n return (\n <ResolvedDrawerNavigationGroup\n key={`drawer_group_${group}`}\n group={group}\n entries={entriesInGroup}\n collapsed={isGroupCollapsed(group)}\n onToggleCollapsed={() => toggleGroupCollapsed(group)}\n drawerOpen={drawerVisuallyOpen}\n onItemClick={onItemClick}\n icon={groupIcons.get(group)}\n />\n );\n })}\n\n {footerSlot}\n </>\n );\n}\n\nexport function DrawerLogo({\n logo,\n title,\n logoDestination = \"/\",\n drawerOpen,\n drawerHovered\n}: {\n logo?: string;\n title?: React.ReactNode;\n logoDestination?: string;\n drawerOpen: boolean;\n drawerHovered: boolean;\n}) {\n\n const showFullContent = drawerOpen || drawerHovered;\n const { t } = useTranslation();\n\n return (\n <div className=\"flex flex-row items-center shrink-0 pt-4 pb-0 px-2\">\n {/* Logo — always visible */}\n {/* Named explicitly because neither branch below carries text: the\n stock `RebaseLogo` is a bare <svg> with no <title>, and a custom\n `logo` only ever gets the generic alt \"Logo\", which names the image\n rather than saying where the link goes. The title link beside it is\n no help either — it renders only when a `title` is set. */}\n <Link\n className=\"shrink-0 flex items-center justify-center w-[56px] h-[40px]\"\n to={logoDestination}\n aria-label={t(\"home\", { defaultValue: \"Home\" })}\n >\n {logo\n ? <img src={logo} alt=\"Logo\" className=\"w-[28px] h-[28px] object-contain\"/>\n : <RebaseLogo width=\"28px\" height=\"28px\"/>\n }\n </Link>\n\n {/* Title (fades in when expanded or hovered) */}\n <div\n className={cls(\n \"flex flex-row items-center overflow-hidden transition-all duration-200 ease-in-out\",\n showFullContent ? \"opacity-100 w-full ml-1\" : \"opacity-0 w-0 ml-0\"\n )}\n >\n {title && (\n <Link\n className=\"visited:text-inherit dark:visited:text-inherit block truncate\"\n to={logoDestination}\n >\n {typeof title === \"string\"\n ? <Typography variant=\"subtitle1\" noWrap className=\"truncate\">{title}</Typography>\n : title\n }\n </Link>\n )}\n </div>\n </div>\n );\n}\n\n/**\n * Toggle button at the bottom of the drawer.\n * Uses double-chevron icons to indicate collapse/expand direction.\n */\nexport function DrawerToggle({\n drawerOpen,\n drawerHovered,\n openDrawer,\n closeDrawer\n}: {\n drawerOpen: boolean;\n drawerHovered: boolean;\n openDrawer: () => void;\n closeDrawer: () => void;\n}) {\n const isExpanded = drawerOpen;\n const isHovered = drawerHovered && !drawerOpen;\n const showFullContent = isExpanded || isHovered;\n\n const [wantsTooltip, setWantsTooltip] = React.useState(false);\n // See {@link DrawerNavigationItem}: a masked tooltip never hears the pointer\n // leave, so the stale state is dropped as the mask goes on.\n if (showFullContent && wantsTooltip) setWantsTooltip(false);\n\n const { t } = useTranslation();\n\n return (\n <div className=\"shrink-0 mt-auto px-4 pt-0.5 pb-2\">\n <Tooltip\n title={isExpanded ? t(\"collapse\") : t(\"expand\")}\n // The row spells out \"Collapse\"/\"Expand\" itself whenever it is wide\n // enough to show the label — expanded, or floating open under the\n // pointer. A tooltip repeating that word is noise; it earns its\n // place only on a bare rail, where the chevron stands alone.\n //\n // Masked, not withheld: see {@link DrawerNavigationItem} for why\n // this stays controlled in both states.\n open={!showFullContent && wantsTooltip}\n onOpenChange={setWantsTooltip}\n side=\"right\"\n sideOffset={12}\n asChild={true}\n >\n <button\n type=\"button\"\n className={cls(\n \"flex flex-row items-center rounded-lg cursor-pointer w-full\",\n \"hover:bg-surface-hover\",\n \"transition-colors duration-150\",\n \"py-2\"\n )}\n aria-expanded={isExpanded}\n aria-label={isExpanded ? t(\"collapse\") : t(\"expand\")}\n onClick={() => isExpanded ? closeDrawer() : openDrawer()}\n >\n {/* 44px in both states, on the same grid as the rows above and\n for the same reason: the rail floats open under the pointer,\n and a slot that changed width with it walked the chevron\n sideways on hover. See the note in DrawerNavigationItem. */}\n <div className=\"shrink-0 flex items-center justify-center w-[44px] h-[24px] text-surface-500 dark:text-surface-400\">\n {isExpanded\n ? <ChevronsLeftIcon size={iconSize.small}/>\n : <ChevronsRightIcon size={iconSize.small}/>\n }\n </div>\n <div className={cls(\n \"overflow-hidden transition-all duration-200 ease-in-out\",\n showFullContent ? \"opacity-100 w-auto\" : \"opacity-0 w-0\"\n )}>\n <Typography\n variant=\"body2\"\n className=\"text-surface-500 dark:text-surface-400 select-none whitespace-nowrap\"\n >\n {isExpanded ? t(\"collapse\") : t(\"expand\")}\n </Typography>\n </div>\n </button>\n </Tooltip>\n </div>\n );\n}\n\n/**\n * Segmented Content / Studio switch rendered inside the drawer.\n * Animates in/out with the drawer open state via opacity + max-height.\n */\nfunction DrawerModeSwitch({\n drawerOpen,\n drawerHovered\n}: {\n drawerOpen: boolean;\n drawerHovered: boolean;\n}) {\n const adminModeController = useAdminModeController();\n const urlController = useUrlController();\n const navigate = useNavigate();\n const { t } = useTranslation();\n const showSwitch = drawerOpen || drawerHovered;\n\n return (\n <div\n // Hidden by opacity so it can fade with the rail; `inert` takes it\n // out of the tab order and the accessibility tree while it is.\n inert={!showSwitch}\n className={cls(\n \"shrink-0 overflow-hidden transition-all duration-200 ease-in-out px-3 h-8 mt-2 mb-0\",\n showSwitch ? \"opacity-100\" : \"opacity-0 pointer-events-none\"\n )}\n >\n <ToggleButtonGroup<AdminModeController[\"mode\"]>\n fullWidth\n aria-label={t(\"panel_mode\")}\n value={adminModeController.mode}\n onValueChange={(mode) => {\n adminModeController.setMode(mode);\n if (mode === \"cms\") navigate(urlController.basePath ?? \"/\");\n else navigate(urlController.basePath === \"/\" ? \"/s\" : `${urlController.basePath ?? \"\"}/s`);\n }}\n options={[\n { value: \"cms\", label: \"CMS\" },\n { value: \"studio\", label: \"Studio\" }\n ]}\n />\n </div>\n );\n}\n\n/**\n * Footer actions rendered at the bottom of the drawer, above the collapse/expand toggle.\n * Replaces the app bar icons (language, theme, user avatar) with a drawer-native layout\n * that adapts between collapsed (icons only) and expanded (full labels + user bar) states.\n *\n * @group Core\n */\nexport function DrawerFooterActions({\n drawerOpen,\n drawerHovered,\n /**\n * Custom content to render inside the user dropdown menu.\n * When provided, these items are appended after the user info header\n * and before the default Sign Out item.\n */\n dropDownActions,\n /**\n * Override the user object displayed in the footer.\n * When omitted, falls back to `authController.user`.\n */\n user: userProp\n}: {\n drawerOpen: boolean;\n drawerHovered: boolean;\n dropDownActions?: React.ReactNode;\n user?: import(\"@rebasepro/types\").User;\n}) {\n const authController = useAuthController();\n const {\n mode,\n setMode\n } = useModeController();\n const navigate = useNavigate();\n const { t } = useTranslation();\n\n const user = userProp ?? authController.user;\n const showFullContent = drawerOpen || drawerHovered;\n const isFloating = drawerHovered && !drawerOpen;\n const portalRef = React.useRef<HTMLDivElement>(null);\n const canSimulateAccess = useCanSimulateAccess();\n\n // User avatar\n let avatarComponent: React.ReactElement | null;\n if (user) {\n const initial = user?.displayName\n ? user.displayName[0].toUpperCase()\n : (user?.email ? user.email[0].toUpperCase() : \"A\");\n avatarComponent = <Avatar src={user.photoURL ?? undefined} className=\"w-8 h-8 text-xs\">\n {initial}\n </Avatar>;\n } else if (user === undefined || authController.initialLoading) {\n avatarComponent = <Skeleton className=\"w-8 h-8 rounded-full\"/>;\n } else {\n avatarComponent = null;\n }\n\n return (\n <div className=\"shrink-0 pt-2 pb-0\" ref={portalRef}>\n {/* The RLS simulator: an icon on the collapsed rail, the pill when expanded. */}\n {canSimulateAccess && (\n <div className=\"flex items-center px-[16px] py-1\">\n {/* The avatar's 44px column, so the icon lines up with it. */}\n <div className={cls(\"flex\", { \"w-[44px] justify-center\": !showFullContent })}>\n <RlsSimulatorBar\n compact={!showFullContent}\n side=\"right\"\n align=\"end\"\n portalContainer={portalRef.current}/>\n </div>\n </div>\n )}\n {avatarComponent && (\n <div className=\"flex items-center px-[16px] py-1\">\n <Menu\n trigger={\n <div\n className={cls(\n // Same 44px grid, and fixed across both states for\n // the same reason — see DrawerNavigationItem.\n \"shrink-0 flex items-center justify-center w-[44px] cursor-pointer\",\n \"rounded-md py-1\",\n \"hover:bg-surface-hover\",\n \"transition-colors duration-150\"\n )}\n role=\"button\"\n tabIndex={0}\n aria-label={t(\"user_menu\", { defaultValue: \"User menu\" })}\n >\n {avatarComponent}\n </div>\n }\n side=\"top\"\n align=\"start\"\n >\n {user && <div className=\"px-4 py-2 mb-1\">\n {user.displayName && <Typography variant=\"body1\" color=\"secondary\">\n {user.displayName}\n </Typography>}\n {user.email && <Typography variant=\"body2\" color=\"secondary\">\n {user.email}\n </Typography>}\n </div>}\n\n {dropDownActions}\n\n {!dropDownActions && <>\n <MenuItem onClick={() => navigate(\"/settings\")}>\n <SettingsIcon/>\n {t(\"account_settings\")}\n </MenuItem>\n <MenuItem onClick={async () => {\n await authController.signOut();\n navigate(\"/\");\n }}>\n <LogOutIcon/>\n {t(\"log_out\")}\n </MenuItem>\n </>}\n </Menu>\n\n {/* Language + Theme — only when expanded */}\n {showFullContent && (\n <div className=\"flex items-center gap-0\">\n <LanguageToggle/>\n <Menu\n trigger={\n <IconButton\n aria-label={t(\"toggle_theme\", { defaultValue: \"Toggle theme\" })}\n className=\"text-surface-500 dark:text-surface-400\"\n >\n {mode === \"dark\"\n ? <MoonIcon size={iconSize.small}/>\n : mode === \"light\"\n ? <SunIcon size={iconSize.small}/>\n : <SunMoonIcon size={iconSize.small}/>}\n </IconButton>\n }\n portalContainer={portalRef.current}\n side=\"top\"\n >\n <MenuItem onClick={() => setMode(\"dark\")}><MoonIcon size={iconSize.smallest}/> {t(\"dark_mode\")}</MenuItem>\n <MenuItem onClick={() => setMode(\"light\")}><SunIcon size={iconSize.smallest}/> {t(\"light_mode\")}</MenuItem>\n <MenuItem onClick={() => setMode(\"system\")}><SunMoonIcon size={iconSize.smallest}/> {t(\"system_mode\")}</MenuItem>\n </Menu>\n </div>\n )}\n </div>\n )}\n </div>\n );\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;AAmDA,SAAgB,cAAc,EAC1B,OACA,MACA,iBACA,UACA,eACA,WACA,SAqBD;CA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U,MAAM,SAAS,MAAO,CAAA,IAChC,SAAS,UACL,oBAAC,SAAD,EAAS,MAAM,SAAS,MAAO,CAAA,IAC/B,oBAAC,aAAD,EAAa,MAAM,SAAS,MAAO,CAAA;KACrC,CAAA;KAEhB,iBAAiB,UAAU;KAC3B,MAAK;eAdT;MAgBI,qBAAC,UAAD;OAAU,eAAe,QAAQ,MAAM;iBAAvC;QAA0C,oBAAC,UAAD,EAAU,MAAM,SAAS,SAAU,CAAA;QAAC;QAAE,EAAE,WAAW;OAAY;;MACzG,qBAAC,UAAD;OAAU,eAAe,QAAQ,OAAO;iBAAxC;QAA2C,oBAAC,SAAD,EAAS,MAAM,SAAS,SAAU,CAAA;QAAC;QAAE,EAAE,YAAY;OAAY;;MAC1G,qBAAC,UAAD;OAAU,eAAe,QAAQ,QAAQ;iBAAzC;QAA4C,oBAAC,aAAD,EAAa,MAAM,SAAS,SAAU,CAAA;QAAC;QAAE,EAAE,aAAa;OAAY;;KAC9G;MACL;KAER;IAER;;AAEb"}
@@ -0,0 +1,8 @@
1
+ /**
2
+ * The default of the `"Entity.MissingReference"` override: nothing. A
3
+ * reference or relation whose collection is not registered shows an error
4
+ * unless an app overrides this, which is how a caller tells the two apart.
5
+ */
6
+ export declare function DefaultMissingReference(_props: {
7
+ path: string;
8
+ }): null;
@@ -0,0 +1,13 @@
1
+ //#region src/components/DefaultMissingReference.tsx
2
+ /**
3
+ * The default of the `"Entity.MissingReference"` override: nothing. A
4
+ * reference or relation whose collection is not registered shows an error
5
+ * unless an app overrides this, which is how a caller tells the two apart.
6
+ */
7
+ function DefaultMissingReference(_props) {
8
+ return null;
9
+ }
10
+ //#endregion
11
+ export { DefaultMissingReference };
12
+
13
+ //# sourceMappingURL=DefaultMissingReference.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"DefaultMissingReference.js","names":[],"sources":["../../src/components/DefaultMissingReference.tsx"],"sourcesContent":["/**\n * The default of the `\"Entity.MissingReference\"` override: nothing. A\n * reference or relation whose collection is not registered shows an error\n * unless an app overrides this, which is how a caller tells the two apart.\n */\nexport function DefaultMissingReference(_props: { path: string }): null {\n return null;\n}\n"],"mappings":";;;;;;AAKA,SAAgB,wBAAwB,QAAgC;CACpE,OAAO;AACX"}
@@ -13,7 +13,12 @@ export type EntityFormPanelProps<M extends Record<string, unknown> = Record<stri
13
13
  * config or a resolved collection.
14
14
  */
15
15
  collection: AdminCollection<M>;
16
- /** The record to edit. Omit it to create a new one. */
16
+ /**
17
+ * The record to edit. When no record has this id yet, the form creates
18
+ * it under this id — so a record kept at a known key (a settings record,
19
+ * a profile keyed by its user's id) needs no seeding. Omit it to create a
20
+ * new record under an id the data source assigns.
21
+ */
17
22
  entityId?: string | number;
18
23
  /**
19
24
  * Where the collection is addressed. Defaults to `collection.slug`; a
@@ -28,7 +33,7 @@ export type EntityFormPanelProps<M extends Record<string, unknown> = Record<stri
28
33
  * leads is yours to say; without it, nothing happens.
29
34
  */
30
35
  onClose?: () => void;
31
- /** Values a new record starts with. */
36
+ /** Values a new record starts with — one created without an id, or under an id no record has yet. */
32
37
  defaultValues?: Partial<M>;
33
38
  className?: string;
34
39
  /** Anything else {@link EntityFormBinding} takes. */
@@ -3,9 +3,9 @@ import { useNavigationStateController } from "../hooks/navigation/contexts/Navig
3
3
  import { EntityFormBinding } from "../form/EntityFormBinding.js";
4
4
  import { CollectionsScopeContext, isRegistered } from "./CollectionsScopeContext.js";
5
5
  import { CollectionsProvider } from "./CollectionsProvider.js";
6
- import { useCallback, useContext, useMemo, useState } from "react";
6
+ import { createElement, useCallback, useContext, useEffect, useMemo, useRef, useState } from "react";
7
7
  import { jsx, jsxs } from "react/jsx-runtime";
8
- import { CenteredView, CircularProgressCenter, Typography } from "@rebasepro/ui";
8
+ import { Alert, Button, CenteredView, CircularProgressCenter, Typography } from "@rebasepro/ui";
9
9
  import { CollectionScopeProvider, ErrorView, useFetch, usePermissions, useTranslation } from "@rebasepro/app";
10
10
  //#region src/components/EntityFormPanel.tsx
11
11
  /**
@@ -35,18 +35,20 @@ function EntityFormPanel(props) {
35
35
  const navigationState = useNavigationStateController();
36
36
  const { collection } = props;
37
37
  const ownCollections = useMemo(() => [collection], [collection]);
38
- if (!inScope || !navigationState.loading && !isRegistered(collectionRegistry.collections, props.path ?? collection.slug)) return /* @__PURE__ */ jsx(CollectionsProvider, {
38
+ const needsOwnScope = !inScope || !navigationState.loading && !isRegistered(collectionRegistry.collections, props.path ?? collection.slug);
39
+ const recordKey = `${props.path ?? collection.slug}/${props.entityId ?? "new"}`;
40
+ if (needsOwnScope) return /* @__PURE__ */ jsx(CollectionsProvider, {
39
41
  collections: ownCollections,
40
- children: /* @__PURE__ */ jsx(EntityFormPanelInScope, { ...props })
42
+ children: /* @__PURE__ */ jsx(EntityFormPanelInScope, { ...props }, recordKey)
41
43
  });
42
- return /* @__PURE__ */ jsx(EntityFormPanelInScope, { ...props });
44
+ return /* @__PURE__ */ jsx(EntityFormPanelInScope, { ...props }, recordKey);
43
45
  }
44
46
  function EntityFormPanelInScope({ collection: collectionProp, entityId, path: pathProp, onSaved, onClose, defaultValues, className, formProps }) {
45
47
  const { t } = useTranslation();
46
48
  const path = pathProp ?? collectionProp.slug;
47
49
  const collectionRegistry = useCollectionRegistryController();
48
50
  const navigationState = useNavigationStateController();
49
- const { canEdit } = usePermissions();
51
+ const { canCreate, canEdit } = usePermissions();
50
52
  const lookUp = collectionRegistry.initialised || !navigationState.loading;
51
53
  const collection = useMemo(() => lookUp ? collectionRegistry.getCollection(path) : void 0, [
52
54
  lookUp,
@@ -61,8 +63,22 @@ function EntityFormPanelInScope({ collection: collectionProp, entityId, path: pa
61
63
  useCache: false
62
64
  });
63
65
  const [savedEntity, setSavedEntity] = useState(void 0);
64
- const shownEntity = entity ?? savedEntity;
66
+ const [lastSeenEntity, setLastSeenEntity] = useState(void 0);
67
+ useEffect(() => {
68
+ if (entity) setLastSeenEntity(entity);
69
+ }, [entity]);
70
+ const [asNew, setAsNew] = useState(null);
71
+ const typedValues = useRef(void 0);
72
+ const deletedElsewhere = !asNew && entityId !== void 0 && !dataLoading && !entity && lastSeenEntity !== void 0 && String(lastSeenEntity.id) === String(entityId);
73
+ const shownEntity = deletedElsewhere ? lastSeenEntity : entity ?? savedEntity;
65
74
  const navigateBack = useCallback(() => onClose?.(), [onClose]);
75
+ const saveAsNew = useCallback(() => {
76
+ const values = typedValues.current ?? lastSeenEntity?.values ?? {};
77
+ setAsNew((previous) => ({
78
+ values,
79
+ n: (previous?.n ?? 0) + 1
80
+ }));
81
+ }, [lastSeenEntity]);
66
82
  if (!collection) {
67
83
  if (navigationState.loading) return /* @__PURE__ */ jsx(CircularProgressCenter, {});
68
84
  return /* @__PURE__ */ jsx(CenteredView, {
@@ -74,49 +90,76 @@ function EntityFormPanelInScope({ collection: collectionProp, entityId, path: pa
74
90
  })
75
91
  });
76
92
  }
93
+ if (asNew) return /* @__PURE__ */ jsx(CollectionScopeProvider, {
94
+ collection,
95
+ children: /* @__PURE__ */ createElement(EntityFormBinding, {
96
+ ...formProps,
97
+ key: `as-new-${asNew.n}`,
98
+ className: className ?? formProps?.className,
99
+ path,
100
+ collection,
101
+ entity: asNew.saved,
102
+ initialStatus: "new",
103
+ initialDirtyValues: asNew.values,
104
+ disabled: !canCreate(collection, path) || formProps?.disabled,
105
+ onEntityChange: (changed) => {
106
+ setAsNew((current) => current && {
107
+ ...current,
108
+ saved: changed
109
+ });
110
+ formProps?.onEntityChange?.(changed);
111
+ },
112
+ onSaved: (params) => {
113
+ formProps?.onSaved?.(params);
114
+ onSaved?.(params);
115
+ },
116
+ navigateBack
117
+ })
118
+ });
77
119
  if (entityId !== void 0 && dataLoadingError) return /* @__PURE__ */ jsx(CenteredView, {
78
120
  className,
79
121
  children: /* @__PURE__ */ jsx(ErrorView, { error: dataLoadingError })
80
122
  });
81
- if (entityId !== void 0 && !shownEntity) {
82
- if (dataLoading) return /* @__PURE__ */ jsx(CircularProgressCenter, {});
83
- return /* @__PURE__ */ jsx(CenteredView, {
84
- className,
85
- children: /* @__PURE__ */ jsxs("div", {
86
- className: "flex flex-col items-center gap-2 text-center",
87
- children: [/* @__PURE__ */ jsx(Typography, {
88
- variant: "label",
89
- children: t("entity_not_found")
90
- }), /* @__PURE__ */ jsx(Typography, {
91
- variant: "body2",
92
- color: "secondary",
93
- children: t("entity_not_found_body")
94
- })]
95
- })
96
- });
97
- }
98
- const editable = shownEntity === void 0 || canEdit(collection, path, shownEntity);
123
+ if (entityId !== void 0 && !shownEntity && dataLoading) return /* @__PURE__ */ jsx(CircularProgressCenter, {});
124
+ const creating = shownEntity === void 0;
125
+ const editable = creating ? canCreate(collection, path) : canEdit(collection, path, shownEntity);
99
126
  return /* @__PURE__ */ jsx(CollectionScopeProvider, {
100
127
  collection,
101
- children: /* @__PURE__ */ jsx(EntityFormBinding, {
128
+ children: /* @__PURE__ */ jsxs(EntityFormBinding, {
102
129
  ...formProps,
103
130
  className: className ?? formProps?.className,
104
131
  path,
105
132
  collection,
106
133
  entityId,
107
134
  entity: shownEntity,
108
- initialStatus: entityId !== void 0 ? "existing" : "new",
109
- initialDirtyValues: entityId === void 0 ? defaultValues : formProps?.initialDirtyValues,
135
+ initialStatus: creating ? "new" : "existing",
136
+ initialDirtyValues: creating ? defaultValues : formProps?.initialDirtyValues,
110
137
  disabled: !editable || formProps?.disabled,
111
138
  onEntityChange: (changed) => {
112
139
  setSavedEntity(changed);
113
140
  formProps?.onEntityChange?.(changed);
114
141
  },
142
+ onValuesModified: (modified, values) => {
143
+ typedValues.current = values;
144
+ formProps?.onValuesModified?.(modified, values);
145
+ },
115
146
  onSaved: (params) => {
116
147
  formProps?.onSaved?.(params);
117
148
  onSaved?.(params);
118
149
  },
119
- navigateBack
150
+ navigateBack,
151
+ children: [deletedElsewhere && /* @__PURE__ */ jsx(Alert, {
152
+ color: "warning",
153
+ size: "small",
154
+ outerClassName: "w-full mb-4",
155
+ action: /* @__PURE__ */ jsx(Button, {
156
+ size: "small",
157
+ variant: "text",
158
+ onClick: saveAsNew,
159
+ children: t("save_as_new")
160
+ }),
161
+ children: t("entity_deleted_elsewhere")
162
+ }), formProps?.children]
120
163
  })
121
164
  });
122
165
  }
@@ -1 +1 @@
1
- {"version":3,"file":"EntityFormPanel.js","names":[],"sources":["../../src/components/EntityFormPanel.tsx"],"sourcesContent":["import React, { useCallback, useContext, useMemo, useState } from \"react\";\nimport type { Entity } from \"@rebasepro/types\";\nimport type { AdminCollection } from \"@rebasepro/cms-types\";\nimport { CenteredView, CircularProgressCenter, Typography } from \"@rebasepro/ui\";\nimport { CollectionScopeProvider, ErrorView, useFetch, usePermissions, useTranslation } from \"@rebasepro/app\";\n\nimport { EntityFormBinding } from \"../form/EntityFormBinding\";\nimport type { EntityFormBindingProps } from \"../form/EntityFormBinding\";\nimport type { OnUpdateParams } from \"../types/components/EntityFormProps\";\nimport { useCollectionRegistryController } from \"../hooks/navigation/contexts/CollectionRegistryContext\";\nimport { useNavigationStateController } from \"../hooks/navigation/contexts/NavigationStateContext\";\nimport { CollectionsScopeContext, isRegistered } from \"./CollectionsScopeContext\";\nimport { CollectionsProvider } from \"./CollectionsProvider\";\n\n/**\n * Props for {@link EntityFormPanel}.\n *\n * @group Components\n */\nexport type EntityFormPanelProps<M extends Record<string, unknown> = Record<string, unknown>> = {\n /**\n * The collection the record belongs to, as a value — a `defineCollection`\n * config or a resolved collection.\n */\n collection: AdminCollection<M>;\n\n /** The record to edit. Omit it to create a new one. */\n entityId?: string | number;\n\n /**\n * Where the collection is addressed. Defaults to `collection.slug`; a\n * subcollection's record takes its full path (`posts/p1/comments`).\n */\n path?: string;\n\n /** Called after every successful save, with the saved record. */\n onSaved?: (params: OnUpdateParams) => void;\n\n /**\n * Called when the form asks to be left — after its record is deleted, or\n * by an action that closes it. The form is your page's, so where that\n * leads is yours to say; without it, nothing happens.\n */\n onClose?: () => void;\n\n /** Values a new record starts with. */\n defaultValues?: Partial<M>;\n\n className?: string;\n\n /** Anything else {@link EntityFormBinding} takes. */\n formProps?: Partial<Omit<EntityFormBindingProps<M>, \"path\" | \"collection\" | \"entityId\" | \"entity\" | \"initialStatus\">>;\n};\n\n/**\n * One record's form — loaded by id, saved through `<Rebase>`'s data layer —\n * to drop into a page of your own app.\n *\n * Needs `<Rebase>` and a React Router router above it (any router, any path).\n * Where no CMS navigation is mounted above, it brings its own\n * {@link CollectionsProvider}, so `<RebaseCMS>`, `<RebaseNavigation>` and\n * `<RebaseShell>` are not needed.\n *\n * @example\n * ```tsx\n * <Rebase client={client} authController={authController}>\n * <BrowserRouter>\n * <EntityFormPanel collection={postsCollection} entityId=\"123\"\n * onSaved={({ entity }) => toast(`Saved ${entity.id}`)}/>\n * </BrowserRouter>\n * </Rebase>\n * ```\n *\n * @group Components\n */\nexport function EntityFormPanel<M extends Record<string, unknown> = Record<string, unknown>>(props: EntityFormPanelProps<M>) {\n const inScope = useContext(CollectionsScopeContext);\n const collectionRegistry = useCollectionRegistryController();\n const navigationState = useNavigationStateController();\n const { collection } = props;\n const ownCollections = useMemo(() => [collection], [collection]);\n\n // As `CollectionPanel`: its own scope where none is above, or where the\n // one above has settled without this collection.\n const needsOwnScope = !inScope\n || (!navigationState.loading && !isRegistered(collectionRegistry.collections, props.path ?? collection.slug));\n if (needsOwnScope) {\n return (\n <CollectionsProvider collections={ownCollections}>\n <EntityFormPanelInScope {...props}/>\n </CollectionsProvider>\n );\n }\n return <EntityFormPanelInScope {...props}/>;\n}\n\nfunction EntityFormPanelInScope<M extends Record<string, unknown>>({\n collection: collectionProp,\n entityId,\n path: pathProp,\n onSaved,\n onClose,\n defaultValues,\n className,\n formProps\n}: EntityFormPanelProps<M>) {\n const { t } = useTranslation();\n const path = pathProp ?? collectionProp.slug;\n const collectionRegistry = useCollectionRegistryController<Record<string, unknown>, AdminCollection<M>>();\n const navigationState = useNavigationStateController();\n const { canEdit } = usePermissions();\n\n // The registry's copy: it carries the plugins' changes and the user's\n // saved overrides.\n // Looked up once per registry: each lookup builds a new object, and the\n // record's subscription is keyed on the collection it was opened with.\n const lookUp = collectionRegistry.initialised || !navigationState.loading;\n const collection = useMemo(\n () => lookUp ? collectionRegistry.getCollection(path) : undefined,\n [lookUp, collectionRegistry, path]);\n\n const { entity, dataLoading, dataLoadingError } = useFetch<M>({\n path,\n entityId,\n collection: collection ?? collectionProp,\n relations: true,\n useCache: false\n });\n\n // The record as the form last saved it. A record created here has no id\n // to read it back by from the outside, and the form, existing from then\n // on, needs it.\n const [savedEntity, setSavedEntity] = useState<Entity<M> | undefined>(undefined);\n const shownEntity = entity ?? savedEntity;\n\n const navigateBack = useCallback(() => onClose?.(), [onClose]);\n\n if (!collection) {\n if (navigationState.loading) return <CircularProgressCenter/>;\n return (\n <CenteredView className={className}>\n <Typography variant=\"body2\" color=\"secondary\">\n {t(\"entity_not_found\")}\n </Typography>\n </CenteredView>\n );\n }\n\n if (entityId !== undefined && dataLoadingError) {\n return <CenteredView className={className}><ErrorView error={dataLoadingError}/></CenteredView>;\n }\n if (entityId !== undefined && !shownEntity) {\n if (dataLoading) return <CircularProgressCenter/>;\n return (\n <CenteredView className={className}>\n <div className=\"flex flex-col items-center gap-2 text-center\">\n <Typography variant=\"label\">{t(\"entity_not_found\")}</Typography>\n <Typography variant=\"body2\" color=\"secondary\">{t(\"entity_not_found_body\")}</Typography>\n </div>\n </CenteredView>\n );\n }\n\n const editable = shownEntity === undefined || canEdit(collection, path, shownEntity);\n\n return (\n <CollectionScopeProvider collection={collection}>\n <EntityFormBinding<M>\n {...formProps}\n className={className ?? formProps?.className}\n path={path}\n collection={collection}\n entityId={entityId}\n entity={shownEntity}\n initialStatus={entityId !== undefined ? \"existing\" : \"new\"}\n initialDirtyValues={entityId === undefined ? defaultValues : formProps?.initialDirtyValues}\n disabled={!editable || formProps?.disabled}\n onEntityChange={(changed) => {\n setSavedEntity(changed);\n formProps?.onEntityChange?.(changed);\n }}\n onSaved={(params) => {\n formProps?.onSaved?.(params);\n onSaved?.(params);\n }}\n navigateBack={navigateBack}\n />\n </CollectionScopeProvider>\n );\n}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,oBAAC,cAAD;GAAyB;aACrB,oBAAC,YAAD;IAAY,SAAQ;IAAQ,OAAM;cAC7B,EAAE,kBAAkB;GACb,CAAA;EACF,CAAA;CAEtB;CAEA,IAAI,aAAa,KAAA,KAAa,kBAC1B,OAAO,oBAAC,cAAD;EAAyB;YAAW,oBAAC,WAAD,EAAW,OAAO,iBAAkB,CAAA;CAAe,CAAA;CAElG,IAAI,aAAa,KAAA,KAAa,CAAC,aAAa;EACxC,IAAI,aAAa,OAAO,oBAAC,wBAAD,CAAwB,CAAA;EAChD,OACI,oBAAC,cAAD;GAAyB;aACrB,qBAAC,OAAD;IAAK,WAAU;cAAf,CACI,oBAAC,YAAD;KAAY,SAAQ;eAAS,EAAE,kBAAkB;IAAc,CAAA,GAC/D,oBAAC,YAAD;KAAY,SAAQ;KAAQ,OAAM;eAAa,EAAE,uBAAuB;IAAc,CAAA,CACrF;;EACK,CAAA;CAEtB;CAEA,MAAM,WAAW,gBAAgB,KAAA,KAAa,QAAQ,YAAY,MAAM,WAAW;CAEnF,OACI,oBAAC,yBAAD;EAAqC;YACjC,oBAAC,mBAAD;GACI,GAAI;GACJ,WAAW,aAAa,WAAW;GAC7B;GACM;GACF;GACV,QAAQ;GACR,eAAe,aAAa,KAAA,IAAY,aAAa;GACrD,oBAAoB,aAAa,KAAA,IAAY,gBAAgB,WAAW;GACxE,UAAU,CAAC,YAAY,WAAW;GAClC,iBAAiB,YAAY;IACzB,eAAe,OAAO;IACtB,WAAW,iBAAiB,OAAO;GACvC;GACA,UAAU,WAAW;IACjB,WAAW,UAAU,MAAM;IAC3B,UAAU,MAAM;GACpB;GACc;EACjB,CAAA;CACoB,CAAA;AAEjC"}
1
+ {"version":3,"file":"EntityFormPanel.js","names":[],"sources":["../../src/components/EntityFormPanel.tsx"],"sourcesContent":["import React, { useCallback, useContext, useEffect, useMemo, useRef, useState } from \"react\";\nimport type { Entity } from \"@rebasepro/types\";\nimport type { AdminCollection } from \"@rebasepro/cms-types\";\nimport { Alert, Button, CenteredView, CircularProgressCenter, Typography } from \"@rebasepro/ui\";\nimport { CollectionScopeProvider, ErrorView, useFetch, usePermissions, useTranslation } from \"@rebasepro/app\";\n\nimport { EntityFormBinding } from \"../form/EntityFormBinding\";\nimport type { EntityFormBindingProps } from \"../form/EntityFormBinding\";\nimport type { OnUpdateParams } from \"../types/components/EntityFormProps\";\nimport { useCollectionRegistryController } from \"../hooks/navigation/contexts/CollectionRegistryContext\";\nimport { useNavigationStateController } from \"../hooks/navigation/contexts/NavigationStateContext\";\nimport { CollectionsScopeContext, isRegistered } from \"./CollectionsScopeContext\";\nimport { CollectionsProvider } from \"./CollectionsProvider\";\n\n/**\n * Props for {@link EntityFormPanel}.\n *\n * @group Components\n */\nexport type EntityFormPanelProps<M extends Record<string, unknown> = Record<string, unknown>> = {\n /**\n * The collection the record belongs to, as a value — a `defineCollection`\n * config or a resolved collection.\n */\n collection: AdminCollection<M>;\n\n /**\n * The record to edit. When no record has this id yet, the form creates\n * it under this id — so a record kept at a known key (a settings record,\n * a profile keyed by its user's id) needs no seeding. Omit it to create a\n * new record under an id the data source assigns.\n */\n entityId?: string | number;\n\n /**\n * Where the collection is addressed. Defaults to `collection.slug`; a\n * subcollection's record takes its full path (`posts/p1/comments`).\n */\n path?: string;\n\n /** Called after every successful save, with the saved record. */\n onSaved?: (params: OnUpdateParams) => void;\n\n /**\n * Called when the form asks to be left — after its record is deleted, or\n * by an action that closes it. The form is your page's, so where that\n * leads is yours to say; without it, nothing happens.\n */\n onClose?: () => void;\n\n /** Values a new record starts with — one created without an id, or under an id no record has yet. */\n defaultValues?: Partial<M>;\n\n className?: string;\n\n /** Anything else {@link EntityFormBinding} takes. */\n formProps?: Partial<Omit<EntityFormBindingProps<M>, \"path\" | \"collection\" | \"entityId\" | \"entity\" | \"initialStatus\">>;\n};\n\n/**\n * One record's form — loaded by id, saved through `<Rebase>`'s data layer —\n * to drop into a page of your own app.\n *\n * Needs `<Rebase>` and a React Router router above it (any router, any path).\n * Where no CMS navigation is mounted above, it brings its own\n * {@link CollectionsProvider}, so `<RebaseCMS>`, `<RebaseNavigation>` and\n * `<RebaseShell>` are not needed.\n *\n * @example\n * ```tsx\n * <Rebase client={client} authController={authController}>\n * <BrowserRouter>\n * <EntityFormPanel collection={postsCollection} entityId=\"123\"\n * onSaved={({ entity }) => toast(`Saved ${entity.id}`)}/>\n * </BrowserRouter>\n * </Rebase>\n * ```\n *\n * @group Components\n */\nexport function EntityFormPanel<M extends Record<string, unknown> = Record<string, unknown>>(props: EntityFormPanelProps<M>) {\n const inScope = useContext(CollectionsScopeContext);\n const collectionRegistry = useCollectionRegistryController();\n const navigationState = useNavigationStateController();\n const { collection } = props;\n const ownCollections = useMemo(() => [collection], [collection]);\n\n // As `CollectionPanel`: its own scope where none is above, or where the\n // one above has settled without this collection.\n const needsOwnScope = !inScope\n || (!navigationState.loading && !isRegistered(collectionRegistry.collections, props.path ?? collection.slug));\n // One form per record: the binding keeps the id and status it mounted\n // with, so a page that hands over another id (a route `/posts/:id` going\n // from p1 to p2) gets a fresh form instead of one that shows p2 and saves\n // into p1. Keyed on the prop, so the id a create assigns keeps the form.\n const recordKey = `${props.path ?? collection.slug}/${props.entityId ?? \"new\"}`;\n if (needsOwnScope) {\n return (\n <CollectionsProvider collections={ownCollections}>\n <EntityFormPanelInScope key={recordKey} {...props}/>\n </CollectionsProvider>\n );\n }\n return <EntityFormPanelInScope key={recordKey} {...props}/>;\n}\n\nfunction EntityFormPanelInScope<M extends Record<string, unknown>>({\n collection: collectionProp,\n entityId,\n path: pathProp,\n onSaved,\n onClose,\n defaultValues,\n className,\n formProps\n}: EntityFormPanelProps<M>) {\n const { t } = useTranslation();\n const path = pathProp ?? collectionProp.slug;\n const collectionRegistry = useCollectionRegistryController<Record<string, unknown>, AdminCollection<M>>();\n const navigationState = useNavigationStateController();\n const { canCreate, canEdit } = usePermissions();\n\n // The registry's copy: it carries the plugins' changes and the user's\n // saved overrides.\n // Looked up once per registry: each lookup builds a new object, and the\n // record's subscription is keyed on the collection it was opened with.\n const lookUp = collectionRegistry.initialised || !navigationState.loading;\n const collection = useMemo(\n () => lookUp ? collectionRegistry.getCollection(path) : undefined,\n [lookUp, collectionRegistry, path]);\n\n const { entity, dataLoading, dataLoadingError } = useFetch<M>({\n path,\n entityId,\n collection: collection ?? collectionProp,\n relations: true,\n useCache: false\n });\n\n // The record as the form last saved it. A record created here has no id\n // to read it back by from the outside, and the form, existing from then\n // on, needs it.\n const [savedEntity, setSavedEntity] = useState<Entity<M> | undefined>(undefined);\n\n // The record as it was last delivered. A live read that stops delivering\n // it — someone deleted it — is not a record that was never there: as in\n // the CMS's own edit view, the form keeps showing it, with what was typed,\n // and says so. Without this the form lost its record mid-edit and threw.\n const [lastSeenEntity, setLastSeenEntity] = useState<Entity<M> | undefined>(undefined);\n useEffect(() => {\n if (entity) setLastSeenEntity(entity);\n }, [entity]);\n // \"Save as new\": the same values, in a form that creates a record. Counted,\n // so that each one is a fresh form.\n const [asNew, setAsNew] = useState<{ values: Partial<M>, n: number, saved?: Entity<M> } | null>(null);\n const typedValues = useRef<Partial<M> | undefined>(undefined);\n const deletedElsewhere = !asNew && entityId !== undefined && !dataLoading && !entity\n && lastSeenEntity !== undefined && String(lastSeenEntity.id) === String(entityId);\n const shownEntity = deletedElsewhere ? lastSeenEntity : (entity ?? savedEntity);\n\n const navigateBack = useCallback(() => onClose?.(), [onClose]);\n const saveAsNew = useCallback(() => {\n const values: Partial<M> = typedValues.current ?? lastSeenEntity?.values ?? {};\n setAsNew(previous => ({ values, n: (previous?.n ?? 0) + 1 }));\n }, [lastSeenEntity]);\n\n if (!collection) {\n if (navigationState.loading) return <CircularProgressCenter/>;\n return (\n <CenteredView className={className}>\n <Typography variant=\"body2\" color=\"secondary\">\n {t(\"entity_not_found\")}\n </Typography>\n </CenteredView>\n );\n }\n\n if (asNew) {\n return (\n <CollectionScopeProvider collection={collection}>\n <EntityFormBinding<M>\n {...formProps}\n key={`as-new-${asNew.n}`}\n className={className ?? formProps?.className}\n path={path}\n collection={collection}\n entity={asNew.saved}\n initialStatus={\"new\"}\n initialDirtyValues={asNew.values}\n disabled={!canCreate(collection, path) || formProps?.disabled}\n onEntityChange={(changed) => {\n // The record it created, which it edits from then on.\n setAsNew(current => current && { ...current, saved: changed });\n formProps?.onEntityChange?.(changed);\n }}\n onSaved={(params) => {\n formProps?.onSaved?.(params);\n onSaved?.(params);\n }}\n navigateBack={navigateBack}\n />\n </CollectionScopeProvider>\n );\n }\n\n if (entityId !== undefined && dataLoadingError) {\n return <CenteredView className={className}><ErrorView error={dataLoadingError}/></CenteredView>;\n }\n if (entityId !== undefined && !shownEntity && dataLoading) return <CircularProgressCenter/>;\n\n // An id no record has yet is a record to create under that id. The form\n // keeps the status it opened with, so once it creates the record it edits\n // it from then on.\n const creating = shownEntity === undefined;\n // As the CMS's own New button and save actions: a record to create needs\n // canCreate (false while access is simulated), an existing one canEdit.\n const editable = creating ? canCreate(collection, path) : canEdit(collection, path, shownEntity);\n\n return (\n <CollectionScopeProvider collection={collection}>\n <EntityFormBinding<M>\n {...formProps}\n className={className ?? formProps?.className}\n path={path}\n collection={collection}\n entityId={entityId}\n entity={shownEntity}\n initialStatus={creating ? \"new\" : \"existing\"}\n initialDirtyValues={creating ? defaultValues : formProps?.initialDirtyValues}\n disabled={!editable || formProps?.disabled}\n onEntityChange={(changed) => {\n setSavedEntity(changed);\n formProps?.onEntityChange?.(changed);\n }}\n onValuesModified={(modified, values) => {\n typedValues.current = values;\n formProps?.onValuesModified?.(modified, values);\n }}\n onSaved={(params) => {\n formProps?.onSaved?.(params);\n onSaved?.(params);\n }}\n navigateBack={navigateBack}\n >\n {deletedElsewhere &&\n <Alert color={\"warning\"} size={\"small\"} outerClassName={\"w-full mb-4\"}\n action={<Button size={\"small\"} variant={\"text\"} onClick={saveAsNew}>{t(\"save_as_new\")}</Button>}>\n {t(\"entity_deleted_elsewhere\")}\n </Alert>}\n {formProps?.children}\n </EntityFormBinding>\n </CollectionScopeProv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