@rebasepro/cms 0.25.0 → 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 (125) hide show
  1. package/dist/collection_editor/liveSchemaClient.d.ts +3 -3
  2. package/dist/collection_editor/liveSchemaClient.js.map +1 -1
  3. package/dist/collection_editor/ui/collection_editor/AICollectionGeneratorPopover.js +1 -1
  4. package/dist/collection_editor/ui/collection_editor/AICollectionGeneratorPopover.js.map +1 -1
  5. package/dist/collection_editor/ui/collection_editor/SchemaChangeDialog.d.ts +7 -1
  6. package/dist/collection_editor/ui/collection_editor/SchemaChangeDialog.js +61 -50
  7. package/dist/collection_editor/ui/collection_editor/SchemaChangeDialog.js.map +1 -1
  8. package/dist/collection_editor/ui/collection_editor/properties/DateTimePropertyField.js +22 -22
  9. package/dist/collection_editor/ui/collection_editor/properties/DateTimePropertyField.js.map +1 -1
  10. package/dist/collection_editor/ui/collection_editor/properties/NumberPropertyField.js +14 -14
  11. package/dist/collection_editor/ui/collection_editor/properties/NumberPropertyField.js.map +1 -1
  12. package/dist/collection_editor/ui/collection_editor/properties/StringPropertyField.js +24 -24
  13. package/dist/collection_editor/ui/collection_editor/properties/StringPropertyField.js.map +1 -1
  14. package/dist/collection_editor/useLiveSchemaEditing.js +4 -1
  15. package/dist/collection_editor/useLiveSchemaEditing.js.map +1 -1
  16. package/dist/components/CollectionTableBinding/fields/TableReferenceField.js +1 -1
  17. package/dist/components/CollectionTableBinding/fields/TableReferenceField.js.map +1 -1
  18. package/dist/components/CollectionTableBinding/internal/CollectionTableToolbar.d.ts +1 -2
  19. package/dist/components/CollectionTableBinding/internal/CollectionTableToolbar.js.map +1 -1
  20. package/dist/components/CollectionTableBinding/internal/EntityTableCell.d.ts +1 -2
  21. package/dist/components/CollectionTableBinding/internal/EntityTableCell.js.map +1 -1
  22. package/dist/components/CollectionViewBinding/CollectionViewActions.js +1 -1
  23. package/dist/components/CollectionViewBinding/CollectionViewActions.js.map +1 -1
  24. package/dist/components/CollectionViewBinding/CollectionViewBinding.js +2 -28
  25. package/dist/components/CollectionViewBinding/CollectionViewBinding.js.map +1 -1
  26. package/dist/components/CollectionViewBinding/DefaultCollectionEmptyState.d.ts +12 -0
  27. package/dist/components/CollectionViewBinding/DefaultCollectionEmptyState.js +33 -0
  28. package/dist/components/CollectionViewBinding/DefaultCollectionEmptyState.js.map +1 -0
  29. package/dist/components/CollectionsScopeContext.d.ts +5 -1
  30. package/dist/components/CollectionsScopeContext.js +10 -2
  31. package/dist/components/CollectionsScopeContext.js.map +1 -1
  32. package/dist/components/DefaultAppBar.js +2 -1
  33. package/dist/components/DefaultAppBar.js.map +1 -1
  34. package/dist/components/DefaultDrawer.js +16 -4
  35. package/dist/components/DefaultDrawer.js.map +1 -1
  36. package/dist/components/DefaultMissingReference.d.ts +8 -0
  37. package/dist/components/DefaultMissingReference.js +13 -0
  38. package/dist/components/DefaultMissingReference.js.map +1 -0
  39. package/dist/components/DeleteEntityDialog.js +9 -9
  40. package/dist/components/DeleteEntityDialog.js.map +1 -1
  41. package/dist/components/EntityFormPanel.d.ts +7 -2
  42. package/dist/components/EntityFormPanel.js +72 -29
  43. package/dist/components/EntityFormPanel.js.map +1 -1
  44. package/dist/components/HomePage/ContentHomePage.js +4 -3
  45. package/dist/components/HomePage/ContentHomePage.js.map +1 -1
  46. package/dist/components/HomePage/HomePageDnD.js +3 -1
  47. package/dist/components/HomePage/HomePageDnD.js.map +1 -1
  48. package/dist/components/HomePage/SmallNavigationCard.js +25 -0
  49. package/dist/components/HomePage/SmallNavigationCard.js.map +1 -0
  50. package/dist/components/RebaseAuthGate.js +3 -2
  51. package/dist/components/RebaseAuthGate.js.map +1 -1
  52. package/dist/components/RebaseLayout.d.ts +4 -1
  53. package/dist/components/RebaseLayout.js +7 -1
  54. package/dist/components/RebaseLayout.js.map +1 -1
  55. package/dist/components/RebaseShell.d.ts +4 -1
  56. package/dist/components/RebaseShell.js.map +1 -1
  57. package/dist/components/ReferenceTable/SelectionTableBinding.js +4 -3
  58. package/dist/components/ReferenceTable/SelectionTableBinding.js.map +1 -1
  59. package/dist/components/RelationSelector.js +2 -2
  60. package/dist/components/RelationSelector.js.map +1 -1
  61. package/dist/components/SideDialogs.js +10 -4
  62. package/dist/components/SideDialogs.js.map +1 -1
  63. package/dist/components/app/Scaffold.js +5 -1
  64. package/dist/components/app/Scaffold.js.map +1 -1
  65. package/dist/components/field_configs.js +1 -1
  66. package/dist/components/history/EntityHistoryView.js +6 -4
  67. package/dist/components/history/EntityHistoryView.js.map +1 -1
  68. package/dist/components/history/LastEditedByIndicator.d.ts +2 -1
  69. package/dist/data_export/export/export.d.ts +2 -13
  70. package/dist/data_export/export/export.js +1 -36
  71. package/dist/data_export/export/export.js.map +1 -1
  72. package/dist/form/EntityForm.d.ts +1 -1
  73. package/dist/form/EntityForm.js +17 -13
  74. package/dist/form/EntityForm.js.map +1 -1
  75. package/dist/form/EntityFormBinding.d.ts +1 -1
  76. package/dist/form/EntityFormBinding.js +42 -4
  77. package/dist/form/EntityFormBinding.js.map +1 -1
  78. package/dist/form/PropertyFieldBinding.js +1 -1
  79. package/dist/form/components/FieldBlock.d.ts +8 -1
  80. package/dist/form/components/FieldBlock.js +16 -2
  81. package/dist/form/components/FieldBlock.js.map +1 -1
  82. package/dist/form/components/FormSections.js +1 -1
  83. package/dist/form/components/FormSections.js.map +1 -1
  84. package/dist/form/components/LabelWithIcon.js +5 -2
  85. package/dist/form/components/LabelWithIcon.js.map +1 -1
  86. package/dist/form/field_bindings/DateTimeFieldBinding.js +2 -1
  87. package/dist/form/field_bindings/DateTimeFieldBinding.js.map +1 -1
  88. package/dist/form/field_bindings/ReadOnlyFieldBinding.js +28 -1
  89. package/dist/form/field_bindings/ReadOnlyFieldBinding.js.map +1 -1
  90. package/dist/form/field_bindings/RelationFieldBinding.js +7 -3
  91. package/dist/form/field_bindings/RelationFieldBinding.js.map +1 -1
  92. package/dist/form/field_bindings/SelectFieldBinding.js +63 -42
  93. package/dist/form/field_bindings/SelectFieldBinding.js.map +1 -1
  94. package/dist/form/field_bindings/SwitchFieldBinding.js +2 -1
  95. package/dist/form/field_bindings/SwitchFieldBinding.js.map +1 -1
  96. package/dist/form/field_bindings/TextFieldBinding.js +8 -6
  97. package/dist/form/field_bindings/TextFieldBinding.js.map +1 -1
  98. package/dist/form/form_utils.d.ts +18 -1
  99. package/dist/form/form_utils.js +38 -2
  100. package/dist/form/form_utils.js.map +1 -1
  101. package/dist/form/index.d.ts +1 -1
  102. package/dist/form/label_placement.d.ts +23 -0
  103. package/dist/form/label_placement.js +71 -0
  104. package/dist/form/label_placement.js.map +1 -0
  105. package/dist/form/resolve_form_properties.d.ts +35 -3
  106. package/dist/form/resolve_form_properties.js +67 -6
  107. package/dist/form/resolve_form_properties.js.map +1 -1
  108. package/dist/hooks/useHistory.d.ts +5 -0
  109. package/dist/hooks/useHistory.js +22 -6
  110. package/dist/hooks/useHistory.js.map +1 -1
  111. package/dist/index.d.ts +50 -0
  112. package/dist/index.js +34 -7
  113. package/dist/preview/components/ReferencePreview.js +1 -1
  114. package/dist/preview/components/ReferencePreview.js.map +1 -1
  115. package/dist/preview/components/RelationPreview.js +1 -1
  116. package/dist/preview/components/RelationPreview.js.map +1 -1
  117. package/dist/types/components/EntityFormProps.d.ts +11 -0
  118. package/package.json +11 -10
  119. package/recipes/README.md +131 -0
  120. package/recipes/bulk-set-status.tsx +62 -0
  121. package/recipes/calendar-view.tsx +123 -0
  122. package/recipes/custom-login.tsx +60 -0
  123. package/recipes/my-preferences.tsx +68 -0
  124. package/recipes/orders-dashboard.tsx +125 -0
  125. 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":";;;;;;;;;;;;;;;AA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C,UAAD;MAAU,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"}
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,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,eAAe,QAAQ,iBAAiB,SAAS;CAEvD,IAAI;CAEJ,IAAI,MAAM;EACN,MAAM,UAAU,MAAM,cAChB,KAAK,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AAK,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,CAAC,UAAU,eAAe,MAAM,SAAS,KAAK;CAKpD,MAAM,WAAW,cAAc;CAC/B,MAAM,YAAY,mBAAmB,QAAQ;CAE7C,MAAM,qBAAqB;EACvB,IAAI,UAAU,SACV,YAAY,UAAU,QAAQ,YAAY,CAAC;CAEnD;CAEA,OACI,qBAAC,OAAD;EAAK,MAAK;EAAa,cAAW;EAC9B,iBAAe;EACf,WAAW,IAAI,0DAA0D,SAAS;EAAU;YAFhG;GAII,oBAAC,YAAD;IACI,MAAM;IACC;IACU;IACL;IACG;GAClB,CAAA;GAED,oBAAC,OAAD;IACI,KAAK;IACL,UAAU;IACV,WAAW;IACX,OAAO,EACH,WAAW,WACL,qGACA,iFACV;cACA,oBAAC,uBAAuB,UAAxB;KAAiC,OAAO;eACnC,YAAY,oBAAC,wBAAD,CAAyB,CAAA;IACT,CAAA;GAChC,CAAA;GAEJ,kBAAkB,SACf,kBAAkB,KAAA,IACZ,gBACA,oBAAC,qBAAD;IACc;IACG;GAClB,CAAA;GAGT,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L,mBACG,qBAAC,OAAD;IAAK,WAAU;cAAf,CACI,oBAAC,gBAAD,CAAgB,CAAA,GAChB,qBAAC,MAAD;KACI,SACI,oBAAC,YAAD;MACI,cAAY,EAAE,gBAAgB,EAAE,cAAc,eAAe,CAAC;MAC9D,WAAU;gBAET,SAAS,SACJ,oBAAC,UAAD,EAAU,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;;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;CAEC,MAAM,EACF,eACA,YACA,YACA,aACA,MAAM,YACN,OAAO;CAEX,MAAM,eAAe,QAAQ;CAE7B,MAAM,YAAY,MAAM,OAAuB,IAAI;CACnD,MAAM,CAAC,UAAU,eAAe,MAAM,SAAS,KAAK;CAKpD,MAAM,WAAW,cAAc;CAC/B,MAAM,YAAY,mBAAmB,QAAQ;CAE7C,MAAM,qBAAqB;EACvB,IAAI,UAAU,SACV,YAAY,UAAU,QAAQ,YAAY,CAAC;CAEnD;CAEA,OACI,qBAAC,OAAD;EAAK,MAAK;EAAa,cAAW;EAC9B,iBAAe;EACf,WAAW,IAAI,0DAA0D,SAAS;EAAU;YAFhG;GAII,oBAAC,YAAD;IACI,MAAM;IACC;IACU;IACL;IACG;GAClB,CAAA;GAED,oBAAC,OAAD;IACI,KAAK;IACL,UAAU;IACV,WAAW;IACX,OAAO,EACH,WAAW,WACL,qGACA,iFACV;cACA,oBAAC,uBAAuB,UAAxB;KAAiC,OAAO;eACnC,YAAY,oBAAC,wBAA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}
@@ -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"}
@@ -100,10 +100,10 @@ function DeleteEntityDialog({ target, collection, onClose, open, onEntityDelete,
100
100
  selection,
101
101
  accessor: dataClient.collection(path),
102
102
  signal: cancelledRef.current,
103
- onProgress: (loaded, total) => setProgress(total === void 0 ? t("selection_reading_rows_unknown", { loaded: loaded.toLocaleString() }) ?? `Reading rows… ${loaded}` : t("selection_reading_rows", {
103
+ onProgress: (loaded, total) => setProgress(total === void 0 ? t("selection_reading_rows_unknown", { loaded: loaded.toLocaleString() }) : t("selection_reading_rows", {
104
104
  loaded: loaded.toLocaleString(),
105
105
  total: total.toLocaleString()
106
- }) ?? `Reading rows… ${loaded} of ${total}`)
106
+ }))
107
107
  });
108
108
  } catch (e) {
109
109
  setLoading(false);
@@ -130,7 +130,7 @@ function DeleteEntityDialog({ target, collection, onClose, open, onEntityDelete,
130
130
  results = await mapWithConcurrency(entities, DELETE_CONCURRENCY, (entity) => cancelledRef.current.aborted ? Promise.resolve(false) : performDelete(entity, recordFailure), (completed, total) => setProgress(t("selection_deleting_progress", {
131
131
  completed: completed.toLocaleString(),
132
132
  total: total.toLocaleString()
133
- }) ?? `Deleted ${completed} of ${total}`));
133
+ })));
134
134
  } catch (e) {
135
135
  console.error("Error deleting entities", e);
136
136
  }
@@ -175,17 +175,17 @@ function DeleteEntityDialog({ target, collection, onClose, open, onEntityDelete,
175
175
  ]);
176
176
  const entityName = collection.singularName ?? collection.name;
177
177
  let dialogTitle;
178
- if (singleEntity) dialogTitle = variant === "unlink" ? t("unlink_entity_confirm_title", { entityName }) ?? `Remove this ${entityName} from this record?` : t("delete_entity_confirm_title", { entityName });
178
+ if (singleEntity) dialogTitle = variant === "unlink" ? t("unlink_entity_confirm_title", { entityName }) : t("delete_entity_confirm_title", { entityName });
179
179
  else if (variant === "unlink") dialogTitle = /* @__PURE__ */ jsxs(Fragment, { children: [
180
180
  /* @__PURE__ */ jsx("b", { children: collection.name }),
181
181
  ": ",
182
- t("confirm_multiple_unlink") ?? "Remove these from this record?"
182
+ t("confirm_multiple_unlink")
183
183
  ] });
184
- else if (selectionCount === void 0) dialogTitle = t("confirm_delete_selection_unknown") ?? "Delete every row matching the current filter?";
184
+ else if (selectionCount === void 0) dialogTitle = t("confirm_delete_selection_unknown");
185
185
  else dialogTitle = t("confirm_delete_selection", {
186
186
  total: selectionCount.toLocaleString(),
187
187
  collection: collection.name
188
- }) ?? `Delete ${selectionCount.toLocaleString()} ${collection.name}?`;
188
+ });
189
189
  return /* @__PURE__ */ jsxs(Dialog, {
190
190
  maxWidth: singleEntity ? "2xl" : "lg",
191
191
  "aria-labelledby": "delete-dialog",
@@ -206,7 +206,7 @@ function DeleteEntityDialog({ target, collection, onClose, open, onEntityDelete,
206
206
  children: /* @__PURE__ */ jsx(Typography, {
207
207
  variant: "body2",
208
208
  color: "secondary",
209
- children: t("unlink_entity_confirm_body", { collectionName: collection.name }) ?? `It stays in ${collection.name} and remains available to other records.`
209
+ children: t("unlink_entity_confirm_body", { collectionName: collection.name })
210
210
  })
211
211
  }),
212
212
  singleEntity && /* @__PURE__ */ jsx("div", {
@@ -222,7 +222,7 @@ function DeleteEntityDialog({ target, collection, onClose, open, onEntityDelete,
222
222
  children: /* @__PURE__ */ jsx(Typography, {
223
223
  variant: "body2",
224
224
  color: "secondary",
225
- children: t("confirm_delete_selection_body") ?? "This cannot be undone. Each row is deleted individually, so this may take a while."
225
+ children: t("confirm_delete_selection_body")
226
226
  })
227
227
  })
228
228
  ]
@@ -1 +1 @@
1
- {"version":3,"file":"DeleteEntityDialog.js","names":[],"sources":["../../src/components/DeleteEntityDialog.tsx"],"sourcesContent":["import { Entity } from \"@rebasepro/types\";\nimport React, { useCallback, useMemo, useRef, useState } from \"react\";\nimport { Button, CircularProgress, Dialog, DialogActions, DialogContent, DialogTitle, Typography } from \"@rebasepro/ui\";\nimport {\n deleteEntityWithCallbacks,\n useData,\n useSnackbarController,\n useTranslation\n} from \"@rebasepro/app\";\nimport { useAdminContext } from \"../hooks\";\nimport { EntityViewBinding } from \"./EntityViewBinding\";\nimport type { AdminCollection, EntitySelection } from \"@rebasepro/cms-types\";\nimport { resolveSelection } from \"../selection\";\nimport { mapWithConcurrency } from \"../util/map_with_concurrency\";\n\n/**\n * Deletes in flight at once.\n *\n * The bulk delete used to be `Promise.all(entities.map(performDelete))`, which\n * is unremarkable for the handful of rows anyone could tick by hand and\n * untenable the moment \"select all 12,480 matching\" can reach it.\n */\nconst DELETE_CONCURRENCY = 8;\n\nexport interface DeleteEntityDialogProps<M extends Record<string, unknown>> {\n /**\n * What to delete: one row, or a whole selection.\n *\n * A selection may be a *query* — every row matching a filter, most of them\n * never read. That is why this is not an `Entity[]`: the rows do not exist\n * until {@link resolveSelection} reads them, and it only does that once the\n * user has confirmed.\n */\n target?: Entity<M> | EntitySelection<M>,\n path: string,\n collection: AdminCollection<M>\n open: boolean;\n onClose: () => void;\n\n onEntityDelete?(path: string, entity: Entity<M>): void;\n\n onMultipleEntitiesDelete?(path: string, entities: Entity<M>[]): void;\n\n /**\n * What the DELETE at this path actually does.\n *\n * `\"unlink\"` when the rows are shared through a junction: the server removes\n * the link and leaves the row alone, so a dialog promising deletion would be\n * describing something else.\n */\n variant?: \"delete\" | \"unlink\";\n}\n\nfunction isSelection<M extends Record<string, unknown>>(\n target: Entity<M> | EntitySelection<M>\n): target is EntitySelection<M> {\n return (target as EntitySelection<M>).type === \"entities\" || (target as EntitySelection<M>).type === \"query\";\n}\n\nexport function DeleteEntityDialog<M extends Record<string, unknown>>({\n target,\n collection,\n onClose,\n open,\n onEntityDelete,\n onMultipleEntitiesDelete,\n path,\n variant = \"delete\"\n}: DeleteEntityDialogProps<M>) {\n const dataClient = useData();\n const snackbarController = useSnackbarController();\n const { t } = useTranslation();\n const [loading, setLoading] = useState(false);\n const [progress, setProgress] = useState<string | undefined>(undefined);\n const cancelledRef = useRef({ aborted: false });\n\n const context = useAdminContext();\n\n // A one-row selection is a single delete: the dialog shows that row rather\n // than the anonymous \"these entities\" copy, which is what anyone ticking\n // exactly one checkbox expects to see.\n const { singleEntity, selection } = useMemo(() => {\n if (!target)\n return { singleEntity: undefined,\n selection: undefined };\n if (!isSelection(target))\n return { singleEntity: target,\n selection: undefined };\n if (target.type === \"entities\" && target.entities.length === 1)\n return { singleEntity: target.entities[0],\n selection: undefined };\n return { singleEntity: undefined,\n selection: target };\n }, [target]);\n\n /** How many rows this will delete; `undefined` when only the server knows. */\n const selectionCount = selection === undefined\n ? 1\n : selection.type === \"entities\"\n ? selection.entities.length\n : selection.count === undefined\n ? undefined\n : Math.max(0, selection.count - selection.excluded.length);\n\n const handleCancel = useCallback(() => {\n cancelledRef.current.aborted = true;\n onClose();\n }, [onClose]);\n\n const onDeleteSuccess = useCallback((entity: Entity<any>) => {\n console.debug(\"Deleted\", entity);\n }, []);\n\n const onDeleteFailure = useCallback((entity: Entity<any>, e: Error) => {\n snackbarController.open({\n type: \"error\",\n title: t(\"error_deleting\"),\n message: e?.message\n });\n\n console.error(\"Error deleting entity\");\n console.error(e);\n }, [collection.name]);\n\n const performDelete = useCallback((entity: Entity<M>, onFailure: (entity: Entity<any>, e: Error) => void = onDeleteFailure): Promise<boolean> =>\n deleteEntityWithCallbacks({\n data: dataClient,\n entity,\n collection: collection,\n onDeleteSuccess,\n onDeleteFailure: onFailure,\n context\n }), [dataClient, collection, onDeleteSuccess, onDeleteFailure, context]);\n\n const handleOk = useCallback(async () => {\n\n if (singleEntity) {\n setLoading(true);\n const success = await performDelete(singleEntity);\n setLoading(false);\n if (success) {\n onEntityDelete?.(path, singleEntity);\n snackbarController.open({\n type: \"success\",\n message: variant === \"unlink\"\n ? t(\"removed_from_record\")\n : t(\"deleted\", { name: collection.singularName ?? collection.name })\n });\n onClose();\n }\n return;\n }\n\n if (!selection) return;\n\n setLoading(true);\n cancelledRef.current = { aborted: false };\n\n let entities: Entity<M>[];\n try {\n // Reading happens *after* the confirmation, not before it: a query\n // selection over a large collection is tens of requests, and doing\n // them up front would make clicking the bin — an action the user has\n // not yet agreed to — the expensive part.\n entities = await resolveSelection<M>({\n selection,\n accessor: dataClient.collection<M>(path),\n signal: cancelledRef.current,\n onProgress: (loaded, total) => setProgress(\n total === undefined\n ? (t(\"selection_reading_rows_unknown\", { loaded: loaded.toLocaleString() }) ?? `Reading rows… ${loaded}`)\n : (t(\"selection_reading_rows\", {\n loaded: loaded.toLocaleString(),\n total: total.toLocaleString()\n }) ?? `Reading rows… ${loaded} of ${total}`)\n )\n });\n } catch (e) {\n setLoading(false);\n setProgress(undefined);\n snackbarController.open({\n type: \"error\",\n title: t(\"error_deleting_entities\", { collection: collection.name }),\n message: (e as Error)?.message\n });\n return;\n }\n\n if (cancelledRef.current.aborted) {\n setLoading(false);\n setProgress(undefined);\n return;\n }\n\n // Collected, not one snackbar per row: a mass refusal (a foreign key\n // every row trips) queued a toast per row of a delete that can walk\n // 20,000 of them. The summary below names how many, and the first cause.\n const failures: Error[] = [];\n const recordFailure = (_entity: Entity<any>, e: Error) => {\n failures.push(e);\n console.error(\"Error deleting entity\", e);\n };\n\n let results: boolean[] = [];\n try {\n results = await mapWithConcurrency(\n entities,\n DELETE_CONCURRENCY,\n // Cancel has to reach the deletes too, not just the read that\n // precedes them. It cannot recall the ones already in flight,\n // but it stops the queue — otherwise closing the dialog on a\n // 12,000-row delete would leave it running with nothing on\n // screen saying so.\n (entity) => cancelledRef.current.aborted\n ? Promise.resolve(false)\n : performDelete(entity, recordFailure),\n (completed, total) => setProgress(t(\"selection_deleting_progress\", {\n completed: completed.toLocaleString(),\n total: total.toLocaleString()\n }) ?? `Deleted ${completed} of ${total}`)\n );\n } catch (e) {\n // `mapWithConcurrency` runs every task before it rethrows, so the\n // rows that could be deleted have been. The per-row failure handler\n // has already reported the cause.\n console.error(\"Error deleting entities\", e);\n }\n\n setLoading(false);\n setProgress(undefined);\n\n onMultipleEntitiesDelete?.(path, entities.filter((_, i) => results[i]));\n\n const deleted = results.filter(Boolean).length;\n const failedSummary = failures.length > 0\n ? t(\"delete_rows_failed\", {\n failed: failures.length.toLocaleString(),\n total: entities.length.toLocaleString(),\n reason: failures[0]?.message ?? \"\"\n })\n : undefined;\n if (deleted === entities.length && entities.length > 0) {\n snackbarController.open({\n type: \"success\",\n message: variant === \"unlink\"\n ? t(\"removed_from_record\")\n : t(\"multiple_deleted\", { collection: collection.name })\n });\n } else if (deleted > 0) {\n snackbarController.open({\n type: \"warning\",\n title: failedSummary ? t(\"some_entities_deleted\", { collection: collection.name }) : undefined,\n message: failedSummary ?? t(\"some_entities_deleted\", { collection: collection.name })\n });\n } else {\n snackbarController.open({\n type: \"error\",\n title: failedSummary ? t(\"error_deleting_entities\", { collection: collection.name }) : undefined,\n message: failedSummary ?? t(\"error_deleting_entities\", { collection: collection.name })\n });\n }\n onClose();\n }, [singleEntity, selection, performDelete, dataClient, path, onEntityDelete, onMultipleEntitiesDelete, onClose, snackbarController, collection.name, collection.singularName, t, variant]);\n\n const entityName = collection.singularName ?? collection.name;\n\n let dialogTitle: React.ReactNode;\n if (singleEntity) {\n dialogTitle = variant === \"unlink\"\n ? (t(\"unlink_entity_confirm_title\", { entityName }) ?? `Remove this ${entityName} from this record?`)\n : t(\"delete_entity_confirm_title\", { entityName });\n } else if (variant === \"unlink\") {\n dialogTitle = <><b>{collection.name}</b>: {t(\"confirm_multiple_unlink\") ?? \"Remove these from this record?\"}</>;\n } else if (selectionCount === undefined) {\n // \"Every matching row, and the server has not said how many.\" Naming a\n // number here would be inventing one for an irreversible action.\n dialogTitle = t(\"confirm_delete_selection_unknown\") ?? \"Delete every row matching the current filter?\";\n } else {\n dialogTitle = t(\"confirm_delete_selection\", {\n total: selectionCount.toLocaleString(),\n collection: collection.name\n }) ?? `Delete ${selectionCount.toLocaleString()} ${collection.name}?`;\n }\n\n return (\n <Dialog\n maxWidth={singleEntity ? \"2xl\" : \"lg\"}\n aria-labelledby=\"delete-dialog\"\n open={open}\n // Escape and a click outside are a cancel, not just a close: the\n // abort flag is what stops a bulk delete's queue, and a dialog that\n // only closed left it deleting with nothing on screen.\n onOpenChange={(open) => {\n if (!open) handleCancel();\n }}\n >\n <DialogTitle id=\"delete-dialog-title\">\n {dialogTitle}\n </DialogTitle>\n <DialogContent fullHeight={true}>\n {variant === \"unlink\" && <div className={\"px-4 pt-4\"}>\n <Typography variant={\"body2\"} color={\"secondary\"}>\n {t(\"unlink_entity_confirm_body\", { collectionName: collection.name })\n ?? `It stays in ${collection.name} and remains available to other records.`}\n </Typography>\n </div>}\n {singleEntity && <div className={\"p-4\"}>\n <EntityViewBinding\n entity={singleEntity}\n collection={collection}\n path={path}/>\n </div>}\n {!singleEntity && variant === \"delete\" && <div className={\"px-4 pt-4\"}>\n <Typography variant={\"body2\"} color={\"secondary\"}>\n {t(\"confirm_delete_selection_body\")\n ?? \"This cannot be undone. Each row is deleted individually, so this may take a while.\"}\n </Typography>\n </div>}\n </DialogContent>\n <DialogActions>\n\n {loading && <CircularProgress size={\"smallest\"}/>}\n {progress && <Typography variant={\"caption\"} color={\"secondary\"}>{progress}</Typography>}\n\n <Button onClick={handleCancel}\n variant=\"text\">\n {t(\"cancel\")}\n </Button>\n <Button\n autoFocus\n disabled={loading}\n onClick={handleOk}\n variant=\"filled\">\n {t(\"ok\")}\n </Button>\n </DialogActions>\n\n </Dialog>\n );\n}\n"],"mappings":";;;;;;;;;;;;;;;;AAsBA,IAAM,qBAAqB;AA+B3B,SAAS,YACL,QAC4B;CAC5B,OAAQ,OAA8B,SAAS,cAAe,OAA8B,SAAS;AACzG;AAEA,SAAgB,mBAAsD,EAClE,QACA,YACA,SACA,MACA,gBACA,0BACA,MACA,UAAU,YACiB;CAC3B,MAAM,aAAa,QAAQ;CAC3B,MAAM,qBAAqB,sBAAsB;CACjD,MAAM,EAAE,MAAM,eAAe;CAC7B,MAAM,CAAC,SAAS,cAAc,SAAS,KAAK;CAC5C,MAAM,CAAC,UAAU,eAAe,SAA6B,KAAA,CAAS;CACtE,MAAM,eAAe,OAAO,EAAE,SAAS,MAAM,CAAC;CAE9C,MAAM,UAAU,gBAAgB;CAKhC,MAAM,EAAE,cAAc,cAAc,cAAc;EAC9C,IAAI,CAAC,QACD,OAAO;GAAE,cAAc,KAAA;GACnB,WAAW,KAAA;EAAU;EAC7B,IAAI,CAAC,YAAY,MAAM,GACnB,OAAO;GAAE,cAAc;GACnB,WAAW,KAAA;EAAU;EAC7B,IAAI,OAAO,SAAS,cAAc,OAAO,SAAS,WAAW,GACzD,OAAO;GAAE,cAAc,OAAO,SAAS;GACnC,WAAW,KAAA;EAAU;EAC7B,OAAO;GAAE,cAAc,KAAA;GACnB,WAAW;EAAO;CAC1B,GAAG,CAAC,MAAM,CAAC;;CAGX,MAAM,iBAAiB,cAAc,KAAA,IAC/B,IACA,UAAU,SAAS,aACf,UAAU,SAAS,SACnB,UAAU,UAAU,KAAA,IACh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E,OACI,qBAAC,QAAD;EACI,UAAU,eAAe,QAAQ;EACjC,mBAAgB;EACV;EAIN,eAAe,SAAS;GACpB,IAAI,CAAC,MAAM,aAAa;EAC5B;YATJ;GAWI,oBAAC,aAAD;IAAa,IAAG;cACX;GACQ,CAAA;GACb,qBAAC,eAAD;IAAe,YAAY;cAA3B;KACK,YAAY,YAAY,oBAAC,OAAD;MAAK,WAAW;gBACrC,oBAAC,YAAD;OAAY,SAAS;OAAS,OAAO;iBAChC,EAAE,8BAA8B,EAAE,gBAAgB,WAAW,KAAK,CAAC,KAC7D,eAAe,WAAW,KAAK;MAC9B,CAAA;KACX,CAAA;KACJ,gBAAgB,oBAAC,OAAD;MAAK,WAAW;gBAC7B,oBAAC,mBAAD;OACI,QAAQ;OACI;OACN;MAAM,CAAA;KACf,CAAA;KACJ,CAAC,gBAAgB,YAAY,YAAY,oBAAC,OAAD;MAAK,WAAW;gBACtD,oBAAC,YAAD;OAAY,SAAS;OAAS,OAAO;iBAChC,EAAE,+BAA+B,KAC3B;MACC,CAAA;KACX,CAAA;IACM;;GACf,qBAAC,eAAD,EAAA,UAAA;IAEK,WAAW,oBAAC,kBAAD,EAAkB,MAAM,WAAY,CAAA;IAC/C,YAAY,oBAAC,YAAD;KAAY,SAAS;KAAW,OAAO;eAAc;IAAqB,CAAA;IAEvF,oBAAC,QAAD;KAAQ,SAAS;KACb,SAAQ;eACP,EAAE,QAAQ;IACP,CAAA;IACR,oBAAC,QAAD;KACI,WAAA;KACA,UAAU;KACV,SAAS;KACT,SAAQ;eACP,EAAE,IAAI;IACH,CAAA;GACG,EAAA,CAAA;EAEX;;AAEhB"}
1
+ {"version":3,"file":"DeleteEntityDialog.js","names":[],"sources":["../../src/components/DeleteEntityDialog.tsx"],"sourcesContent":["import { Entity } from \"@rebasepro/types\";\nimport React, { useCallback, useMemo, useRef, useState } from \"react\";\nimport { Button, CircularProgress, Dialog, DialogActions, DialogContent, DialogTitle, Typography } from \"@rebasepro/ui\";\nimport {\n deleteEntityWithCallbacks,\n useData,\n useSnackbarController,\n useTranslation\n} from \"@rebasepro/app\";\nimport { useAdminContext } from \"../hooks\";\nimport { EntityViewBinding } from \"./EntityViewBinding\";\nimport type { AdminCollection, EntitySelection } from \"@rebasepro/cms-types\";\nimport { resolveSelection } from \"../selection\";\nimport { mapWithConcurrency } from \"../util/map_with_concurrency\";\n\n/**\n * Deletes in flight at once.\n *\n * The bulk delete used to be `Promise.all(entities.map(performDelete))`, which\n * is unremarkable for the handful of rows anyone could tick by hand and\n * untenable the moment \"select all 12,480 matching\" can reach it.\n */\nconst DELETE_CONCURRENCY = 8;\n\nexport interface DeleteEntityDialogProps<M extends Record<string, unknown>> {\n /**\n * What to delete: one row, or a whole selection.\n *\n * A selection may be a *query* — every row matching a filter, most of them\n * never read. That is why this is not an `Entity[]`: the rows do not exist\n * until {@link resolveSelection} reads them, and it only does that once the\n * user has confirmed.\n */\n target?: Entity<M> | EntitySelection<M>,\n path: string,\n collection: AdminCollection<M>\n open: boolean;\n onClose: () => void;\n\n onEntityDelete?(path: string, entity: Entity<M>): void;\n\n onMultipleEntitiesDelete?(path: string, entities: Entity<M>[]): void;\n\n /**\n * What the DELETE at this path actually does.\n *\n * `\"unlink\"` when the rows are shared through a junction: the server removes\n * the link and leaves the row alone, so a dialog promising deletion would be\n * describing something else.\n */\n variant?: \"delete\" | \"unlink\";\n}\n\nfunction isSelection<M extends Record<string, unknown>>(\n target: Entity<M> | EntitySelection<M>\n): target is EntitySelection<M> {\n return (target as EntitySelection<M>).type === \"entities\" || (target as EntitySelection<M>).type === \"query\";\n}\n\nexport function DeleteEntityDialog<M extends Record<string, unknown>>({\n target,\n collection,\n onClose,\n open,\n onEntityDelete,\n onMultipleEntitiesDelete,\n path,\n variant = \"delete\"\n}: DeleteEntityDialogProps<M>) {\n const dataClient = useData();\n const snackbarController = useSnackbarController();\n const { t } = useTranslation();\n const [loading, setLoading] = useState(false);\n const [progress, setProgress] = useState<string | undefined>(undefined);\n const cancelledRef = useRef({ aborted: false });\n\n const context = useAdminContext();\n\n // A one-row selection is a single delete: the dialog shows that row rather\n // than the anonymous \"these entities\" copy, which is what anyone ticking\n // exactly one checkbox expects to see.\n const { singleEntity, selection } = useMemo(() => {\n if (!target)\n return { singleEntity: undefined,\n selection: undefined };\n if (!isSelection(target))\n return { singleEntity: target,\n selection: undefined };\n if (target.type === \"entities\" && target.entities.length === 1)\n return { singleEntity: target.entities[0],\n selection: undefined };\n return { singleEntity: undefined,\n selection: target };\n }, [target]);\n\n /** How many rows this will delete; `undefined` when only the server knows. */\n const selectionCount = selection === undefined\n ? 1\n : selection.type === \"entities\"\n ? selection.entities.length\n : selection.count === undefined\n ? undefined\n : Math.max(0, selection.count - selection.excluded.length);\n\n const handleCancel = useCallback(() => {\n cancelledRef.current.aborted = true;\n onClose();\n }, [onClose]);\n\n const onDeleteSuccess = useCallback((entity: Entity<any>) => {\n console.debug(\"Deleted\", entity);\n }, []);\n\n const onDeleteFailure = useCallback((entity: Entity<any>, e: Error) => {\n snackbarController.open({\n type: \"error\",\n title: t(\"error_deleting\"),\n message: e?.message\n });\n\n console.error(\"Error deleting entity\");\n console.error(e);\n }, [collection.name]);\n\n const performDelete = useCallback((entity: Entity<M>, onFailure: (entity: Entity<any>, e: Error) => void = onDeleteFailure): Promise<boolean> =>\n deleteEntityWithCallbacks({\n data: dataClient,\n entity,\n collection: collection,\n onDeleteSuccess,\n onDeleteFailure: onFailure,\n context\n }), [dataClient, collection, onDeleteSuccess, onDeleteFailure, context]);\n\n const handleOk = useCallback(async () => {\n\n if (singleEntity) {\n setLoading(true);\n const success = await performDelete(singleEntity);\n setLoading(false);\n if (success) {\n onEntityDelete?.(path, singleEntity);\n snackbarController.open({\n type: \"success\",\n message: variant === \"unlink\"\n ? t(\"removed_from_record\")\n : t(\"deleted\", { name: collection.singularName ?? collection.name })\n });\n onClose();\n }\n return;\n }\n\n if (!selection) return;\n\n setLoading(true);\n cancelledRef.current = { aborted: false };\n\n let entities: Entity<M>[];\n try {\n // Reading happens *after* the confirmation, not before it: a query\n // selection over a large collection is tens of requests, and doing\n // them up front would make clicking the bin — an action the user has\n // not yet agreed to — the expensive part.\n entities = await resolveSelection<M>({\n selection,\n accessor: dataClient.collection<M>(path),\n signal: cancelledRef.current,\n onProgress: (loaded, total) => setProgress(\n total === undefined\n ? t(\"selection_reading_rows_unknown\", { loaded: loaded.toLocaleString() })\n : t(\"selection_reading_rows\", {\n loaded: loaded.toLocaleString(),\n total: total.toLocaleString()\n })\n )\n });\n } catch (e) {\n setLoading(false);\n setProgress(undefined);\n snackbarController.open({\n type: \"error\",\n title: t(\"error_deleting_entities\", { collection: collection.name }),\n message: (e as Error)?.message\n });\n return;\n }\n\n if (cancelledRef.current.aborted) {\n setLoading(false);\n setProgress(undefined);\n return;\n }\n\n // Collected, not one snackbar per row: a mass refusal (a foreign key\n // every row trips) queued a toast per row of a delete that can walk\n // 20,000 of them. The summary below names how many, and the first cause.\n const failures: Error[] = [];\n const recordFailure = (_entity: Entity<any>, e: Error) => {\n failures.push(e);\n console.error(\"Error deleting entity\", e);\n };\n\n let results: boolean[] = [];\n try {\n results = await mapWithConcurrency(\n entities,\n DELETE_CONCURRENCY,\n // Cancel has to reach the deletes too, not just the read that\n // precedes them. It cannot recall the ones already in flight,\n // but it stops the queue — otherwise closing the dialog on a\n // 12,000-row delete would leave it running with nothing on\n // screen saying so.\n (entity) => cancelledRef.current.aborted\n ? Promise.resolve(false)\n : performDelete(entity, recordFailure),\n (completed, total) => setProgress(t(\"selection_deleting_progress\", {\n completed: completed.toLocaleString(),\n total: total.toLocaleString()\n }))\n );\n } catch (e) {\n // `mapWithConcurrency` runs every task before it rethrows, so the\n // rows that could be deleted have been. The per-row failure handler\n // has already reported the cause.\n console.error(\"Error deleting entities\", e);\n }\n\n setLoading(false);\n setProgress(undefined);\n\n onMultipleEntitiesDelete?.(path, entities.filter((_, i) => results[i]));\n\n const deleted = results.filter(Boolean).length;\n const failedSummary = failures.length > 0\n ? t(\"delete_rows_failed\", {\n failed: failures.length.toLocaleString(),\n total: entities.length.toLocaleString(),\n reason: failures[0]?.message ?? \"\"\n })\n : undefined;\n if (deleted === entities.length && entities.length > 0) {\n snackbarController.open({\n type: \"success\",\n message: variant === \"unlink\"\n ? t(\"removed_from_record\")\n : t(\"multiple_deleted\", { collection: collection.name })\n });\n } else if (deleted > 0) {\n snackbarController.open({\n type: \"warning\",\n title: failedSummary ? t(\"some_entities_deleted\", { collection: collection.name }) : undefined,\n message: failedSummary ?? t(\"some_entities_deleted\", { collection: collection.name })\n });\n } else {\n snackbarController.open({\n type: \"error\",\n title: failedSummary ? t(\"error_deleting_entities\", { collection: collection.name }) : undefined,\n message: failedSummary ?? t(\"error_deleting_entities\", { collection: collection.name })\n });\n }\n onClose();\n }, [singleEntity, selection, performDelete, dataClient, path, onEntityDelete, onMultipleEntitiesDelete, onClose, snackbarController, collection.name, collection.singularName, t, variant]);\n\n const entityName = collection.singularName ?? collection.name;\n\n let dialogTitle: React.ReactNode;\n if (singleEntity) {\n dialogTitle = variant === \"unlink\"\n ? t(\"unlink_entity_confirm_title\", { entityName })\n : t(\"delete_entity_confirm_title\", { entityName });\n } else if (variant === \"unlink\") {\n dialogTitle = <><b>{collection.name}</b>: {t(\"confirm_multiple_unlink\")}</>;\n } else if (selectionCount === undefined) {\n // \"Every matching row, and the server has not said how many.\" Naming a\n // number here would be inventing one for an irreversible action.\n dialogTitle = t(\"confirm_delete_selection_unknown\");\n } else {\n dialogTitle = t(\"confirm_delete_selection\", {\n total: selectionCount.toLocaleString(),\n collection: collection.name\n });\n }\n\n return (\n <Dialog\n maxWidth={singleEntity ? \"2xl\" : \"lg\"}\n aria-labelledby=\"delete-dialog\"\n open={open}\n // Escape and a click outside are a cancel, not just a close: the\n // abort flag is what stops a bulk delete's queue, and a dialog that\n // only closed left it deleting with nothing on screen.\n onOpenChange={(open) => {\n if (!open) handleCancel();\n }}\n >\n <DialogTitle id=\"delete-dialog-title\">\n {dialogTitle}\n </DialogTitle>\n <DialogContent fullHeight={true}>\n {variant === \"unlink\" && <div className={\"px-4 pt-4\"}>\n <Typography variant={\"body2\"} color={\"secondary\"}>\n {t(\"unlink_entity_confirm_body\", { collectionName: collection.name })}\n </Typography>\n </div>}\n {singleEntity && <div className={\"p-4\"}>\n <EntityViewBinding\n entity={singleEntity}\n collection={collection}\n path={path}/>\n </div>}\n {!singleEntity && variant === \"delete\" && <div className={\"px-4 pt-4\"}>\n <Typography variant={\"body2\"} color={\"secondary\"}>\n {t(\"confirm_delete_selection_body\")}\n </Typography>\n </div>}\n </DialogContent>\n <DialogActions>\n\n {loading && <CircularProgress size={\"smallest\"}/>}\n {progress && <Typography variant={\"caption\"} color={\"secondary\"}>{progress}</Typography>}\n\n <Button onClick={handleCancel}\n variant=\"text\">\n {t(\"cancel\")}\n </Button>\n <Button\n autoFocus\n disabled={loading}\n onClick={handleOk}\n variant=\"filled\">\n {t(\"ok\")}\n </Button>\n </DialogActions>\n\n </Dialog>\n );\n}\n"],"mappings":";;;;;;;;;;;;;;;;AAsBA,IAAM,qBAAqB;AA+B3B,SAAS,YACL,QAC4B;CAC5B,OAAQ,OAA8B,SAAS,cAAe,OAA8B,SAAS;AACzG;AAEA,SAAgB,mBAAsD,EAClE,QACA,YACA,SACA,MACA,gBACA,0BACA,MACA,UAAU,YACiB;CAC3B,MAAM,aAAa,QAAQ;CAC3B,MAAM,qBAAqB,sBAAsB;CACjD,MAAM,EAAE,MAAM,eAAe;CAC7B,MAAM,CAAC,SAAS,cAAc,SAAS,KAAK;CAC5C,MAAM,CAAC,UAAU,eAAe,SAA6B,KAAA,CAAS;CACtE,MAAM,eAAe,OAAO,EAAE,SAAS,MAAM,CAAC;CAE9C,MAAM,UAAU,gBAAgB;CAKhC,MAAM,EAAE,cAAc,cAAc,cAAc;EAC9C,IAAI,CAAC,QACD,OAAO;GAAE,cAAc,KAAA;GACnB,WAAW,KAAA;EAAU;EAC7B,IAAI,CAAC,YAAY,MAAM,GACnB,OAAO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olved 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. */