@rebasepro/cms 0.29.1 → 0.29.3

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 (87) hide show
  1. package/dist/collection_editor/serializable_types.d.ts +2 -0
  2. package/dist/collection_editor/ui/collection_editor/CollectionRelationsTab.d.ts +1 -1
  3. package/dist/components/CollectionPanel.js +22 -13
  4. package/dist/components/CollectionPanel.js.map +1 -1
  5. package/dist/components/CollectionTableBinding/fields/TableStorageUpload.js +1 -1
  6. package/dist/components/CollectionTableBinding/fields/TableStorageUpload.js.map +1 -1
  7. package/dist/components/CollectionTableBinding/internal/popup_field/PopupFormField.d.ts +1 -1
  8. package/dist/components/CollectionTableBinding/internal/popup_field/PopupFormField.js.map +1 -1
  9. package/dist/components/CollectionViewBinding/CollectionCardViewBinding.js.map +1 -1
  10. package/dist/components/CollectionViewBinding/CollectionListViewBinding.js +39 -14
  11. package/dist/components/CollectionViewBinding/CollectionListViewBinding.js.map +1 -1
  12. package/dist/components/CollectionViewBinding/CollectionViewContent.d.ts +11 -0
  13. package/dist/components/CollectionViewBinding/CollectionViewContent.js +19 -2
  14. package/dist/components/CollectionViewBinding/CollectionViewContent.js.map +1 -1
  15. package/dist/components/CollectionViewBinding/EntityCardBinding.d.ts +1 -1
  16. package/dist/components/CollectionViewBinding/EntityCardBinding.js +1 -1
  17. package/dist/components/CollectionViewBinding/EntityCardBinding.js.map +1 -1
  18. package/dist/components/CollectionViewBinding/SlotValue.js.map +1 -1
  19. package/dist/components/CollectionViewBinding/usePreviewSlots.d.ts +19 -1
  20. package/dist/components/CollectionViewBinding/usePreviewSlots.js +18 -7
  21. package/dist/components/CollectionViewBinding/usePreviewSlots.js.map +1 -1
  22. package/dist/components/EntityPreviewBinding.d.ts +20 -0
  23. package/dist/components/EntityPreviewBinding.js +121 -18
  24. package/dist/components/EntityPreviewBinding.js.map +1 -1
  25. package/dist/components/HomePage/ContentHomePage.js +2 -3
  26. package/dist/components/HomePage/ContentHomePage.js.map +1 -1
  27. package/dist/components/RecordForm.d.ts +25 -4
  28. package/dist/components/RecordForm.js +21 -3
  29. package/dist/components/RecordForm.js.map +1 -1
  30. package/dist/components/RelationSelector.js.map +1 -1
  31. package/dist/components/SelectableTable/filters/FilterFieldBinding.d.ts +13 -1
  32. package/dist/components/SelectableTable/filters/FilterFieldBinding.js +19 -3
  33. package/dist/components/SelectableTable/filters/FilterFieldBinding.js.map +1 -1
  34. package/dist/components/SelectableTable/filters/RelationFilterField.d.ts +1 -1
  35. package/dist/components/SelectableTable/filters/RelationFilterField.js.map +1 -1
  36. package/dist/components/history/EntityHistoryEntry.js.map +1 -1
  37. package/dist/data_import/utils/save_entities.d.ts +10 -2
  38. package/dist/data_import/utils/save_entities.js.map +1 -1
  39. package/dist/editor/markdown.d.ts +10 -0
  40. package/dist/editor/markdown.js.map +1 -1
  41. package/dist/form/PropertyFieldBinding.js +4 -2
  42. package/dist/form/PropertyFieldBinding.js.map +1 -1
  43. package/dist/form/field_bindings/BinaryFieldBinding.js.map +1 -1
  44. package/dist/form/field_bindings/GeopointFieldBinding.js.map +1 -1
  45. package/dist/hooks/useBuildSidePanel.d.ts +10 -0
  46. package/dist/hooks/useBuildSidePanel.js +43 -4
  47. package/dist/hooks/useBuildSidePanel.js.map +1 -1
  48. package/dist/hooks/useResolvedNavigationFrom.d.ts +14 -2
  49. package/dist/hooks/useResolvedNavigationFrom.js.map +1 -1
  50. package/dist/index.d.ts +3 -1
  51. package/dist/index.js +4 -2
  52. package/dist/mcp_view/app_modules.js +4 -2
  53. package/dist/mcp_view/app_modules.js.map +1 -1
  54. package/dist/mcp_view/bridge.d.ts +21 -1
  55. package/dist/mcp_view/bridge.js.map +1 -1
  56. package/dist/mcp_view/index.d.ts +7 -7
  57. package/dist/mcp_view/index.js +7 -2
  58. package/dist/mcp_view/index.js.map +1 -1
  59. package/dist/mcp_view/payload.js +7 -2
  60. package/dist/mcp_view/payload.js.map +1 -1
  61. package/dist/mcp_view/screen.d.ts +6 -4
  62. package/dist/mcp_view/screen.js +15 -43
  63. package/dist/mcp_view/screen.js.map +1 -1
  64. package/dist/mcp_view/tool_driver.d.ts +58 -6
  65. package/dist/mcp_view/tool_driver.js +256 -117
  66. package/dist/mcp_view/tool_driver.js.map +1 -1
  67. package/dist/mcp_view/write_review.d.ts +35 -0
  68. package/dist/mcp_view/write_review.js +144 -0
  69. package/dist/mcp_view/write_review.js.map +1 -0
  70. package/dist/preview/compact_text.d.ts +1 -1
  71. package/dist/preview/compact_text.js.map +1 -1
  72. package/dist/preview/components/RelationPreview.js +7 -2
  73. package/dist/preview/components/RelationPreview.js.map +1 -1
  74. package/dist/saved_apps/SavedAppsView.d.ts +17 -0
  75. package/dist/saved_apps/SavedAppsView.js +167 -0
  76. package/dist/saved_apps/SavedAppsView.js.map +1 -0
  77. package/dist/saved_apps/admin_apps_client.d.ts +24 -0
  78. package/dist/saved_apps/admin_apps_client.js +46 -0
  79. package/dist/saved_apps/admin_apps_client.js.map +1 -0
  80. package/dist/saved_apps/saved_app_frame.d.ts +20 -0
  81. package/dist/saved_apps/saved_app_frame.js +143 -0
  82. package/dist/saved_apps/saved_app_frame.js.map +1 -0
  83. package/dist/selection/resolve_selection.d.ts +10 -2
  84. package/dist/selection/resolve_selection.js.map +1 -1
  85. package/dist/util/property_utils.d.ts +2 -2
  86. package/dist/util/property_utils.js.map +1 -1
  87. package/package.json +9 -9
@@ -10,9 +10,9 @@ import { PropertyPreview } from "../preview/PropertyPreview.js";
10
10
  import * as React$1 from "react";
11
11
  import { useMemo } from "react";
12
12
  import { Fragment, jsx, jsxs } from "react/jsx-runtime";
13
- import { ArrowRightToLineIcon, IconButton, Skeleton, Tooltip, Typography, cls, defaultBorderMixin } from "@rebasepro/ui";
14
- import "@rebasepro/common";
15
- import { ErrorView, IconForView, getEntityImagePreviewPropertyKey, useAnalyticsController, useAuthController, useCustomizationController } from "@rebasepro/app";
13
+ import { ArrowRightToLineIcon, Chip, IconButton, Skeleton, Tooltip, Typography, cls, defaultBorderMixin } from "@rebasepro/ui";
14
+ import { enumToObjectEntries } from "@rebasepro/common";
15
+ import { ErrorView, IconForView, buildEnumLabel, getEntityImagePreviewPropertyKey, useAnalyticsController, useAuthController, useCustomizationController } from "@rebasepro/app";
16
16
  import { getValueInPath } from "@rebasepro/utils";
17
17
  //#region src/components/EntityPreviewBinding.tsx
18
18
  /**
@@ -20,28 +20,15 @@ import { getValueInPath } from "@rebasepro/utils";
20
20
  * without any container wrapper. Used internally by EntityPreviewBinding.
21
21
  */
22
22
  function EntityPreviewBindingData({ actions, collection: collectionProp, previewKeys, size = "medium", includeId = true, onSidePanelClick, includeTitle = true, includeEntityLink = true, includeImage = true, layout = "card", entity }) {
23
- const authController = useAuthController();
24
23
  const analyticsController = useAnalyticsController();
25
24
  const sidePanelController = useSidePanel();
26
- const customizationController = useCustomizationController();
27
25
  const collectionRegistryController = useCollectionRegistryController();
28
26
  const collection = collectionProp ?? collectionRegistryController.getCollection(entity.path);
29
27
  const title = useEntityTitle({
30
28
  collection,
31
29
  entity
32
30
  });
33
- const statedKeys = previewKeys ?? collection?.previewProperties;
34
- const listProperties = useMemo(() => {
35
- if (!collection) return [];
36
- if (statedKeys && statedKeys.length > 0) return statedKeys.filter((key) => getPropertyInPath$1(collection.properties, key));
37
- const slotKeys = resolveCollectionSlotKeys(collection, authController, customizationController.propertyConfigs);
38
- return [slotKeys.subtitleKey, slotKeys.statusKey].filter(Boolean);
39
- }, [
40
- statedKeys,
41
- collection,
42
- authController,
43
- customizationController.propertyConfigs
44
- ]);
31
+ const { listProperties } = usePreviewCardKeys(collection, previewKeys);
45
32
  if (!collection) return /* @__PURE__ */ jsx(Fragment, { children: /* @__PURE__ */ jsx(ErrorView, { error: `Collection not found: ${entity.path}` }) });
46
33
  const titleProperty = includeTitle ? title.source?.key : void 0;
47
34
  const imagePropertyKey = includeImage ? getEntityImagePreviewPropertyKey(collection) : void 0;
@@ -231,6 +218,122 @@ function EntityRowPreviewContent({ size, entity, collection, title, imagePropert
231
218
  }) });
232
219
  }
233
220
  /**
221
+ * What a card says under its title, and the property its title would come
222
+ * from — one answer for the card and for the skeleton standing in for it, so
223
+ * the two always have the same lines.
224
+ *
225
+ * A stated list wins outright — `previewProperties` is the one place a
226
+ * developer says "show these", and nothing here is allowed to second-guess
227
+ * it. Failing that, the card fills the same slots as every other surface
228
+ * that renders one record in a row: a supporting line and a status. It used
229
+ * to take the first few properties in declaration order instead, which is
230
+ * how an author card ended up rendering an entire Markdown biography.
231
+ */
232
+ function usePreviewCardKeys(collection, previewKeys) {
233
+ const authController = useAuthController();
234
+ const customizationController = useCustomizationController();
235
+ const statedKeys = previewKeys ?? collection?.previewProperties;
236
+ return useMemo(() => {
237
+ if (!collection) return {
238
+ listProperties: [],
239
+ titleKey: void 0
240
+ };
241
+ const slotKeys = resolveCollectionSlotKeys(collection, authController, customizationController.propertyConfigs);
242
+ return {
243
+ listProperties: statedKeys && statedKeys.length > 0 ? statedKeys.filter((key) => getPropertyInPath$1(collection.properties, key)) : [slotKeys.subtitleKey, slotKeys.statusKey].filter(Boolean),
244
+ titleKey: slotKeys.titleKey
245
+ };
246
+ }, [
247
+ statedKeys,
248
+ collection,
249
+ authController,
250
+ customizationController.propertyConfigs
251
+ ]);
252
+ }
253
+ /**
254
+ * A card that has not loaded yet, drawn as the card it will be: the image
255
+ * slot, a title, one placeholder per line the card will show and the open
256
+ * button's room. A single bar in a 48px box grew to the full card when the
257
+ * record arrived and pushed everything under it down.
258
+ *
259
+ * Which lines a card shows is known before its record is — they come from
260
+ * the collection, not the values — so the count is right whatever the
261
+ * collection declares. Each placeholder sits in the line's own wrapper with
262
+ * the line's own type, and an enum's is a chip, so a line is as tall
263
+ * loading as loaded without any height written down here.
264
+ */
265
+ function EntityPreviewBindingSkeleton({ collection, previewKeys, size = "medium", includeTitle = true, includeImage = true, includeEntityLink = true }) {
266
+ const { listProperties, titleKey } = usePreviewCardKeys(collection, previewKeys);
267
+ const imagePropertyKey = includeImage ? getEntityImagePreviewPropertyKey(collection) : void 0;
268
+ const lines = listProperties.filter((key) => key !== (includeTitle ? titleKey : void 0) && key !== imagePropertyKey);
269
+ return /* @__PURE__ */ jsxs(Fragment, { children: [
270
+ /* @__PURE__ */ jsx("div", {
271
+ className: cls("flex shrink-0 overflow-hidden", {
272
+ "w-6 h-6 mx-1 my-0.5": size === "small" || size === "smallest",
273
+ "w-8 h-8 ml-1 mr-2 m-2 self-start": size === "medium",
274
+ "w-10 h-10 ml-2 mr-2 m-2 self-start": size === "large"
275
+ }),
276
+ children: imagePropertyKey ? /* @__PURE__ */ jsx(Skeleton, { className: "w-full h-full" }) : /* @__PURE__ */ jsx(IconForView, {
277
+ collectionOrView: collection,
278
+ color: "primary",
279
+ size,
280
+ className: "m-auto"
281
+ })
282
+ }),
283
+ /* @__PURE__ */ jsxs("div", {
284
+ className: "flex flex-col grow w-full m-1 shrink min-w-0 text-text-primary dark:text-text-primary-dark flex-1 mr-2",
285
+ "aria-busy": true,
286
+ children: [includeTitle && /* @__PURE__ */ jsxs("div", {
287
+ className: "truncate my-0.5 text-sm font-medium",
288
+ children: ["​", /* @__PURE__ */ jsx(Skeleton, {
289
+ className: "inline-block align-middle",
290
+ width: 160
291
+ })]
292
+ }), lines.map((key) => {
293
+ const property = getPropertyInPath$1(collection.properties, key);
294
+ if (!property) return null;
295
+ return /* @__PURE__ */ jsx("div", {
296
+ className: cls("truncate min-w-0 max-h-8 overflow-hidden", lines.length > 1 ? "my-0.5" : "my-0"),
297
+ children: /* @__PURE__ */ jsx(SkeletonCardLine, { property })
298
+ }, "ref_prev_" + key);
299
+ })]
300
+ }),
301
+ includeEntityLink && /* @__PURE__ */ jsx("div", {
302
+ className: "flex-shrink-0",
303
+ "aria-hidden": true,
304
+ children: /* @__PURE__ */ jsx(IconButton, {
305
+ size: "small",
306
+ "aria-label": "See details",
307
+ tabIndex: -1,
308
+ disabled: true,
309
+ className: cls("invisible", size !== "small" ? "self-start" : ""),
310
+ children: /* @__PURE__ */ jsx(ArrowRightToLineIcon, {})
311
+ })
312
+ })
313
+ ] });
314
+ }
315
+ /** One card line, loading: a chip for an enum, as the loaded line draws it, else a bar in a line of text. */
316
+ function SkeletonCardLine({ property }) {
317
+ const enumValues = property.type === "string" || property.type === "number" ? property.enum : void 0;
318
+ if (enumValues) {
319
+ const [first] = enumToObjectEntries(enumValues);
320
+ return /* @__PURE__ */ jsx(Chip, {
321
+ size: "small",
322
+ children: /* @__PURE__ */ jsx("span", {
323
+ className: "invisible",
324
+ children: first ? buildEnumLabel(first) : "\xA0"
325
+ })
326
+ });
327
+ }
328
+ return /* @__PURE__ */ jsxs("span", {
329
+ className: "text-sm",
330
+ children: ["​", /* @__PURE__ */ jsx(Skeleton, {
331
+ className: "inline-block align-middle",
332
+ width: 120
333
+ })]
334
+ });
335
+ }
336
+ /**
234
337
  * This view is used to display a preview of a entity.
235
338
  * It is used by default in reference fields and whenever a reference is displayed.
236
339
  */
@@ -278,6 +381,6 @@ var EntityPreviewContainer = React$1.forwardRef(({ children, hover, onClick, siz
278
381
  });
279
382
  EntityPreviewContainer.displayName = "EntityPreviewContainer";
280
383
  //#endregion
281
- export { EntityPreviewBinding, EntityPreviewBindingData, EntityPreviewContainer };
384
+ export { EntityPreviewBinding, EntityPreviewBindingData, EntityPreviewBindingSkeleton, EntityPreviewContainer };
282
385
 
283
386
  //# sourceMappingURL=EntityPreviewBinding.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"EntityPreviewBinding.js","names":[],"sources":["../../src/components/EntityPreviewBinding.tsx"],"sourcesContent":["\nimport type { Property } from \"@rebasepro/types\";\nimport { hasEntityId } from \"@rebasepro/common\";\nimport * as React from \"react\";\nimport { useEffect, useMemo } from \"react\";\n\nimport { Entity } from \"@rebasepro/types\";\nimport type { PreviewSize } from \"../types/components/PropertyPreviewProps\";\nimport { getEntityImagePreviewPropertyKey } from \"@rebasepro/app\";\nimport {\n ArrowRightToLineIcon,\n cls,\n defaultBorderMixin,\n IconButton,\n Skeleton,\n Tooltip,\n Typography\n} from \"@rebasepro/ui\";\nimport { PropertyPreview, SkeletonPropertyComponent } from \"../preview\";\nimport {\n useAuthController,\n useCustomizationController,\n useData,\n ErrorView\n} from \"@rebasepro/app\";\nimport { useAnalyticsController } from \"@rebasepro/app\";\nimport { IconForView } from \"@rebasepro/app\";\nimport { getPropertyInPath } from \"../util/property_utils\";\nimport { resolveCollectionSlotKeys } from \"./CollectionViewBinding/usePreviewSlots\";\nimport { useEntityTitle } from \"../hooks/useEntityDisplay\";\nimport { getValueInPath } from \"@rebasepro/utils\";\nimport { useCollectionRegistryController } from \"../hooks/navigation/contexts/CollectionRegistryContext\";\nimport { useSidePanel } from \"../hooks/useSidePanel\";\nimport { EntityPreviewLayout, NestedEntityPreviewBoundary } from \"./EntityPreviewNesting\";\nimport { isEmptyPreviewValue } from \"../preview/util\";\nimport type { AdminCollection } from \"@rebasepro/cms-types\";\n\nexport type EntityPreviewBindingProps = {\n size?: PreviewSize,\n actions?: React.ReactNode,\n collection?: AdminCollection,\n hover?: boolean;\n previewKeys?: string[],\n disabled?: boolean,\n entity: Entity<any>,\n includeId?: boolean,\n includeTitle?: boolean,\n includeEntityLink?: boolean,\n includeImage?: boolean,\n onClick?: (e: React.SyntheticEvent) => void;\n onSidePanelClick?: (entity: Entity) => void,\n};\n\nexport type EntityPreviewBindingDataProps = {\n size?: \"smallest\" | \"small\" | \"medium\" | \"large\",\n actions?: React.ReactNode,\n collection?: AdminCollection,\n previewKeys?: string[],\n entity: Entity<any>,\n onSidePanelClick?: (entity: Entity) => void,\n includeId?: boolean,\n includeTitle?: boolean,\n includeEntityLink?: boolean,\n includeImage?: boolean,\n /**\n * `row` draws the record as a line of a table row instead of a card: see\n * {@link EntityPreviewLayout}. No id, no open button — the title opens the\n * record — and only as many supporting lines as the row has room for.\n */\n layout?: EntityPreviewLayout,\n};\n\n/**\n * This component contains the main logic and content for displaying a entity preview,\n * without any container wrapper. Used internally by EntityPreviewBinding.\n */\nexport function EntityPreviewBindingData({\n actions,\n collection: collectionProp,\n previewKeys,\n size = \"medium\",\n includeId = true,\n onSidePanelClick,\n includeTitle = true,\n includeEntityLink = true,\n includeImage = true,\n layout = \"card\",\n entity\n}: EntityPreviewBindingDataProps) {\n\n const authController = useAuthController();\n const analyticsController = useAnalyticsController();\n const sidePanelController = useSidePanel();\n const customizationController = useCustomizationController();\n\n const collectionRegistryController = useCollectionRegistryController();\n\n const collection = collectionProp ?? collectionRegistryController.getCollection(entity.path);\n\n // Above the `!collection` return, because hooks are. `useEntityTitle`\n // tolerates a missing collection for exactly this reason.\n const title = useEntityTitle({\n collection,\n entity\n });\n\n // What the card says under the title.\n //\n // A stated list wins outright — `previewProperties` is the one place a\n // developer says \"show these\", and nothing here is allowed to second-guess\n // it. Failing that, the card fills the same slots as every other surface\n // that renders one record in a row: a supporting line and a status. It used\n // to take the first few properties in declaration order instead, which is\n // how an author card ended up rendering an entire Markdown biography.\n const statedKeys = previewKeys ?? (collection?.previewProperties as string[] | undefined);\n const listProperties = useMemo(() => {\n if (!collection) return [];\n if (statedKeys && statedKeys.length > 0) {\n return statedKeys.filter(key => getPropertyInPath(collection.properties, key));\n }\n const slotKeys = resolveCollectionSlotKeys(\n collection as AdminCollection<Record<string, unknown>>,\n authController,\n customizationController.propertyConfigs);\n return [slotKeys.subtitleKey, slotKeys.statusKey].filter(Boolean) as string[];\n }, [statedKeys, collection, authController, customizationController.propertyConfigs]);\n\n if (!collection) {\n return (\n <>\n <ErrorView error={`Collection not found: ${entity.path}`}/>\n </>\n );\n }\n\n const titleProperty = includeTitle ? title.source?.key : undefined;\n const imagePropertyKey = includeImage ? getEntityImagePreviewPropertyKey(collection) : undefined;\n const imageProperty = imagePropertyKey ? collection.properties[imagePropertyKey] : undefined;\n const ofProp = imageProperty && \"of\" in imageProperty ? imageProperty.of : undefined;\n const usedImageProperty = ofProp ? (Array.isArray(ofProp) ? ofProp[0] : ofProp) : imageProperty;\n const restProperties = listProperties.filter(p => p !== titleProperty && p !== imagePropertyKey);\n\n const openInSidePanel = () => {\n onSidePanelClick?.(entity);\n analyticsController.onAnalyticsEvent?.(\"entity_click_from_reference\", {\n path: entity.path,\n entityId: entity.id\n });\n sidePanelController.open({\n id: entity.id,\n path: entity.path,\n collection,\n updateUrl: true\n });\n };\n\n const imageValue = imagePropertyKey ? getValueInPath(entity.values, imagePropertyKey) : undefined;\n const usedImageValue = imageProperty !== undefined ? (\"of\" in imageProperty\n ? (((imageValue as unknown[]) ?? []).length > 0\n ? (imageValue as unknown[])[0] : undefined)\n : imageValue)\n : undefined;\n\n if (layout === \"row\")\n return <EntityRowPreviewContent size={size}\n entity={entity}\n collection={collection}\n title={title.value ?? String(entity.id)}\n imageProperty={usedImageProperty}\n imagePropertyKey={imagePropertyKey}\n imageValue={usedImageValue}\n supportingKeys={restProperties}\n onOpen={includeEntityLink ? openInSidePanel : undefined}/>;\n\n return (\n // Everything below renders *inside* this preview: a reference or\n // relation among the preview properties collapses to one line instead\n // of nesting another bordered card with its own id and action button.\n <NestedEntityPreviewBoundary>\n {/* `overflow-hidden`: the image slot is a fixed box, and a thumbnail\n that fails to load renders a \"file not found\" message sized for a\n full preview — which spilled across the title beside it. */}\n <div className={cls(\"flex shrink-0 overflow-hidden\", {\n \"w-6 h-6 mx-1 my-0.5\": size === \"small\" || size === \"smallest\",\n \"w-8 h-8 ml-1 mr-2 m-2 self-start\": size === \"medium\",\n \"w-10 h-10 ml-2 mr-2 m-2 self-start\": size === \"large\"\n })}>\n {usedImageProperty && usedImageValue ? <PropertyPreview property={usedImageProperty}\n propertyKey={imagePropertyKey as string}\n size={\"small\"}\n value={usedImageValue as never}/> : null}\n {(!usedImageProperty || !usedImageValue) ? <IconForView collectionOrView={collection}\n color={\"primary\"}\n size={size}\n className={\"m-auto\"}/> : null}\n </div>\n\n <div\n className={\"flex flex-col grow w-full m-1 shrink min-w-0 text-text-primary dark:text-text-primary-dark flex-1 mr-2\"}>\n\n {includeId && (\n entity\n ? <div className={\"block whitespace-nowrap overflow-hidden truncate\"}>\n <Typography variant={\"caption\"}\n color={\"disabled\"}\n className={\"font-mono\"}>\n {entity.id}\n </Typography>\n </div>\n : <Skeleton/>)}\n\n {/* A title that came from a property keeps that property's own\n rendering — an enum stays its coloured chip, a relation stays\n a link. A computed one is text, because that is all a\n resolver returns. */}\n {includeTitle && (titleProperty || title.value) && (\n <div\n className={\"truncate my-0.5 text-sm font-medium text-text-primary dark:text-text-primary-dark\"}>\n {!entity && titleProperty\n ? <SkeletonPropertyComponent\n property={getPropertyInPath(collection.properties, titleProperty) as Property}\n size={\"medium\"}/>\n : titleProperty\n ? <PropertyPreview\n propertyKey={titleProperty}\n value={title.source?.value as never}\n property={getPropertyInPath(collection.properties, titleProperty) as Property}\n size={\"medium\"}/>\n : title.value}\n </div>\n )}\n\n {restProperties && restProperties.map((key) => {\n const childProperty = getPropertyInPath(collection.properties, key);\n if (!childProperty) return null;\n\n const valueInPath = getValueInPath(entity.values, key);\n return (\n // `truncate` clamps a line of text; it does nothing to a\n // preview that renders blocks. Custom `admin.Preview`\n // components can render anything at all, so the height\n // is capped here as well — a card that loses the tail of\n // an unusual value beats a card the size of a document.\n <div key={\"ref_prev_\" + key}\n className={cls(\"truncate min-w-0 max-h-8 overflow-hidden\",\n restProperties.length > 1 ? \"my-0.5\" : \"my-0\")}>\n {\n entity\n ? <PropertyPreview\n propertyKey={key as string}\n value={valueInPath as never}\n property={childProperty as Property}\n size={\"small\"}/>\n : <SkeletonPropertyComponent\n property={childProperty as Property}\n size={\"small\"}/>\n }\n </div>\n );\n })}\n\n </div>\n\n {entity && includeEntityLink &&\n <div className=\"flex-shrink-0\">\n <Tooltip title={`See details for ${entity.id}`} className={\"shrink-0\"}>\n <IconButton aria-label={`See details for ${entity.id}`}\n size={\"small\"}\n className={size !== \"small\" ? \"self-start\" : \"\"}\n onClick={(e) => {\n e.stopPropagation();\n e.preventDefault();\n openInSidePanel();\n }}>\n <ArrowRightToLineIcon/>\n </IconButton>\n </Tooltip>\n </div>}\n\n {actions && <div className=\"flex-shrink-0\">{actions}</div>}\n </NestedEntityPreviewBoundary>\n );\n}\n\n/**\n * A record as a line of a table row: its image, a title that opens it, and the\n * supporting lines that fit — one at `medium`, two at `large`. Supporting\n * values that are empty are skipped rather than drawn as an empty bar, so the\n * line under a name is the first thing the record actually has to say.\n */\nfunction EntityRowPreviewContent({\n size,\n entity,\n collection,\n title,\n imageProperty,\n imagePropertyKey,\n imageValue,\n supportingKeys,\n onOpen\n}: {\n size: \"smallest\" | \"small\" | \"medium\" | \"large\";\n entity: Entity<Record<string, unknown>>;\n collection: AdminCollection;\n title: string;\n imageProperty?: Property;\n imagePropertyKey?: string;\n imageValue: unknown;\n supportingKeys: string[];\n onOpen?: () => void;\n}) {\n const maxLines = size === \"large\" ? 2 : 1;\n const lines = supportingKeys\n .map(key => ({\n key,\n property: getPropertyInPath(collection.properties, key),\n value: getValueInPath(entity.values, key)\n }))\n .filter((line): line is { key: string, property: Property, value: unknown } =>\n Boolean(line.property) && !isEmptyPreviewValue(line.value))\n .slice(0, maxLines);\n\n const titleNode = <span className={\"truncate\"}>{title}</span>;\n\n return (\n <NestedEntityPreviewBoundary>\n <div className={\"flex items-center gap-2.5 min-w-0 w-full text-left\"}>\n {imagePropertyKey && <div className={cls(\"flex shrink-0 items-center justify-center overflow-hidden rounded-md\",\n size === \"large\" ? \"w-10 h-10\" : \"w-8 h-8\")}>\n {imageProperty && imageValue\n ? <PropertyPreview property={imageProperty}\n propertyKey={imagePropertyKey}\n size={\"small\"}\n value={imageValue as never}/>\n : <IconForView collectionOrView={collection}\n color={\"primary\"}\n size={\"small\"}/>}\n </div>}\n <div className={\"flex flex-col min-w-0 flex-1\"}>\n <div className={\"flex min-w-0 text-sm font-medium text-text-primary dark:text-text-primary-dark\"}>\n {onOpen\n ? <Tooltip title={`See details for ${title}`} asChild={true}>\n <span role={\"button\"}\n tabIndex={0}\n className={\"inline-flex min-w-0 max-w-full cursor-pointer hover:underline underline-offset-2\"}\n // See InlineEntityPreview: a press does not\n // move the focus, or a table cell would\n // select itself mid-click.\n onMouseDown={(event) => event.preventDefault()}\n onClick={(event) => {\n event.preventDefault();\n event.stopPropagation();\n onOpen();\n }}\n onKeyDown={(event) => {\n if (event.key !== \"Enter\" && event.key !== \" \") return;\n event.preventDefault();\n event.stopPropagation();\n onOpen();\n }}>\n {titleNode}\n </span>\n </Tooltip>\n : titleNode}\n </div>\n {lines.map(({ key, property, value }) =>\n <div key={key}\n className={\"truncate min-w-0 max-h-5 overflow-hidden text-xs text-text-secondary dark:text-text-secondary-dark\"}>\n <PropertyPreview propertyKey={key}\n value={value as never}\n property={property}\n size={\"small\"}/>\n </div>)}\n </div>\n </div>\n </NestedEntityPreviewBoundary>\n );\n}\n\nexport function EntityPreviewBindingWithId({\n entityId,\n path,\n ...props\n}: Omit<EntityPreviewBindingProps, \"entity\"> & {\n entityId: string | number;\n path: string;\n databaseId?: string;\n}) {\n\n const [entity, setEntity] = React.useState<Entity | undefined>();\n const [dataLoading, setDataLoading] = React.useState(false);\n const dataClient = useData();\n\n useEffect(() => {\n let isMounted = true;\n if (!hasEntityId(entityId) || !path) {\n setEntity(undefined);\n return;\n }\n const fetchOne = async () => {\n setDataLoading(true);\n try {\n const fetchedEntity = await dataClient.collection(path).findById(entityId);\n if (isMounted) {\n setEntity(fetchedEntity);\n }\n } catch (error) {\n console.error(\"Error fetching entity:\", error);\n if (isMounted) {\n setEntity(undefined);\n }\n } finally {\n if (isMounted) {\n setDataLoading(false);\n }\n }\n }\n\n fetchOne();\n\n return () => {\n isMounted = false;\n }\n }, [entityId, path]);\n\n if (dataLoading && !entity) {\n return (\n <EntityPreviewContainer\n hover={props.hover}\n size={props.size}>\n <Skeleton/>\n </EntityPreviewContainer>\n );\n }\n\n if (!entity) {\n return (\n <EntityPreviewContainer\n hover={props.hover}\n size={props.size}>\n <div className={\"text-text-secondary dark:text-text-secondary-dark\"}>\n Entity not found\n </div>\n </EntityPreviewContainer>\n );\n }\n\n return <EntityPreviewBindingData\n {...props}\n entity={entity}/>;\n}\n\n/**\n * This view is used to display a preview of a entity.\n * It is used by default in reference fields and whenever a reference is displayed.\n */\nexport function EntityPreviewBinding({\n actions,\n disabled,\n hover,\n collection,\n previewKeys,\n onClick,\n size = \"medium\",\n includeId = true,\n includeTitle = true,\n includeEntityLink = true,\n includeImage = true,\n onSidePanelClick,\n entity\n}: EntityPreviewBindingProps) {\n\n return (\n <EntityPreviewContainer\n onClick={disabled ? undefined : onClick}\n hover={disabled ? undefined : hover}\n size={size}>\n <EntityPreviewBindingData\n actions={actions}\n collection={collection}\n previewKeys={previewKeys}\n size={size}\n includeId={includeId}\n includeTitle={includeTitle}\n includeEntityLink={includeEntityLink}\n includeImage={includeImage}\n onSidePanelClick={onSidePanelClick}\n entity={entity}\n />\n </EntityPreviewContainer>\n );\n}\n\nexport type EntityPreviewContainerProps = {\n children: React.ReactNode;\n hover?: boolean;\n fullwidth?: boolean;\n size?: PreviewSize;\n className?: string;\n style?: React.CSSProperties;\n onClick?: (e: React.SyntheticEvent) => void;\n};\n\nexport const EntityPreviewContainer = React.forwardRef<HTMLDivElement, EntityPreviewContainerProps>(({\n children,\n hover,\n onClick,\n size = \"medium\",\n style,\n className,\n fullwidth = true,\n ...props\n}, ref) => {\n return <div\n ref={ref}\n tabIndex={0}\n style={style}\n className={cls(\n \"bg-surface-card\",\n // On the shared 28/32/40/48 control scale. `44px` was between two\n // steps of it, so a reference in a form was 4px short of the field\n // next to it and their boxes never quite agreed.\n size === \"small\" ? \"min-h-[32px]\" : \"min-h-[48px]\",\n fullwidth ? \"w-full\" : \"\",\n \"items-center overflow-hidden\",\n hover ? \"hover:bg-surface-hover group-hover:bg-surface-hover\" : \"\",\n size === \"small\" ? \"p-1\" : \"px-2 py-1\",\n \"flex border rounded-lg\",\n onClick ? \"cursor-pointer\" : \"\",\n defaultBorderMixin,\n className)}\n role={onClick ? \"button\" : undefined}\n onClick={(event) => {\n if (onClick) {\n event.preventDefault();\n onClick(event);\n }\n }}\n onKeyDown={(event) => {\n if (onClick && (event.key === \"Enter\" || event.key === \" \")) {\n event.preventDefault();\n onClick(event);\n }\n }}\n {...props}>\n {children}\n </div>;\n});\n\nEntityPreviewContainer.displayName = \"EntityPreviewContainer\";\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;AA4EA,SAAgB,yBAAyB,EACrC,SACA,YAAY,gBACZ,aACA,OAAO,UACP,YAAY,MACZ,kBACA,eAAe,MACf,oBAAoB,MACpB,eAAe,MACf,SAAS,QACT,UAC8B;CAE9B,MAAM,iBAAiB,kBAAkB;CACzC,MAAM,sBAAsB,uBAAuB;CACnD,MAAM,sBAAsB,aAAa;CACzC,MAAM,0BAA0B,2BAA2B;CAE3D,MAAM,+BAA+B,gCAAgC;CAErE,MAAM,aAAa,kBAAkB,6BAA6B,cAAc,OAAO,IAAI;CAI3F,MAAM,QAAQ,eAAe;EACzB;EACA;CACJ,CAAC;CAUD,MAAM,aAAa,eAAgB,YAAY;CAC/C,MAAM,iBAAiB,cAAc;EACjC,IAAI,CAAC,YAAY,OAAO,CAAC;EACzB,IAAI,cAAc,WAAW,SAAS,GAClC,OAAO,WAAW,QAAO,QAAO,oBAAkB,WAAW,YAAY,GAAG,CAAC;EAEjF,MAAM,WAAW,0BACb,YACA,gBACA,wBAAwB,eAAe;EAC3C,OAAO,CAAC,SAAS,aAAa,SAAS,SAAS,CAAC,CAAC,OAAO,OAAO;CACpE,GAAG;EAAC;EAAY;EAAY;EAAgB,wBAAwB;CAAe,CAAC;CAEpF,IAAI,CAAC,YACD,OACI,oBAAA,UAAA,EAAA,UACI,oBAAC,WAAD,EAAW,OAAO,yBAAyB,OAAO,OAAQ,CAAA,EAC5D,CAAA;CAIV,MAAM,gBAAgB,eAAe,MAAM,QAAQ,MAAM,KAAA;CACzD,MAAM,mBAAmB,eAAe,iCAAiC,UAAU,IAAI,KAAA;CACvF,MAAM,gBAAgB,mBAAmB,WAAW,WAAW,oBAAoB,KAAA;CACnF,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;GACL,CAAA,GACJ,MAAM,KAAK,EAAE,KAAK,UAAU,YACzB,oBAAC,OAAD;IACI,WAAW;cACX,oBAAC,iBAAD;KAAiB,aAAa;KACnB;KACG;KACV,MAAM;IAAS,CAAA;GAClB,GANK,GAML,CAAC,CACT;IACJ;IACoB,CAAA;AAErC;;;;;AA+EA,SAAgB,qBAAqB,EACjC,SACA,UACA,OACA,YACA,aACA,SACA,OAAO,UACP,YAAY,MACZ,eAAe,MACf,oBAAoB,MACpB,eAAe,MACf,kBACA,UAC0B;CAE1B,OACI,oBAAC,wBAAD;EACI,SAAS,WAAW,KAAA,IAAY;EAChC,OAAO,WAAW,KAAA,IAAY;EACxB;YACN,oBAAC,0BAAD;GACa;GACG;GACC;GACP;GACK;GACG;GACK;GACL;GACI;GACV;EACX,CAAA;CACmB,CAAA;AAEhC;AAYA,IAAa,yBAAyB,QAAM,YAAyD,EACjG,UACA,OACA,SACA,OAAO,UACP,OACA,WACA,YAAY,MACZ,GAAG,SACJ,QAAQ;CACP,OAAO,oBAAC,OAAD;EACE;EACL,UAAU;EACH;EACP,WAAW,IACP,mBAIA,SAAS,UAAU,iBAAiB,gBACpC,YAAY,WAAW,IACvB,gCACA,QAAQ,wDAAwD,IAChE,SAAS,UAAU,QAAQ,aAC3B,0BACA,UAAU,mBAAmB,IAC7B,oBACA,SAAS;EACb,MAAM,UAAU,WAAW,KAAA;EAC3B,UAAU,UAAU;GAChB,IAAI,SAAS;IACT,MAAM,eAAe;IACrB,QAAQ,KAAK;GACjB;EACJ;EACA,YAAY,UAAU;GAClB,IAAI,YAAY,MAAM,QAAQ,WAAW,MAAM,QAAQ,MAAM;IACzD,MAAM,eAAe;IACrB,QAAQ,KAAK;GACjB;EACJ;EACA,GAAI;EACH;CACA,CAAA;AACT,CAAC;AAED,uBAAuB,cAAc"}
1
+ {"version":3,"file":"EntityPreviewBinding.js","names":[],"sources":["../../src/components/EntityPreviewBinding.tsx"],"sourcesContent":["\nimport type { Property } from \"@rebasepro/types\";\nimport { hasEntityId } from \"@rebasepro/common\";\nimport * as React from \"react\";\nimport { useEffect, useMemo } from \"react\";\n\nimport { Entity } from \"@rebasepro/types\";\nimport type { PreviewSize } from \"../types/components/PropertyPreviewProps\";\nimport { buildEnumLabel, getEntityImagePreviewPropertyKey } from \"@rebasepro/app\";\nimport { enumToObjectEntries } from \"@rebasepro/common\";\nimport {\n ArrowRightToLineIcon,\n Chip,\n cls,\n defaultBorderMixin,\n IconButton,\n Skeleton,\n Tooltip,\n Typography\n} from \"@rebasepro/ui\";\nimport { PropertyPreview, SkeletonPropertyComponent } from \"../preview\";\nimport {\n useAuthController,\n useCustomizationController,\n useData,\n ErrorView\n} from \"@rebasepro/app\";\nimport { useAnalyticsController } from \"@rebasepro/app\";\nimport { IconForView } from \"@rebasepro/app\";\nimport { getPropertyInPath } from \"../util/property_utils\";\nimport { resolveCollectionSlotKeys } from \"./CollectionViewBinding/usePreviewSlots\";\nimport { useEntityTitle } from \"../hooks/useEntityDisplay\";\nimport { getValueInPath } from \"@rebasepro/utils\";\nimport { useCollectionRegistryController } from \"../hooks/navigation/contexts/CollectionRegistryContext\";\nimport { useSidePanel } from \"../hooks/useSidePanel\";\nimport { EntityPreviewLayout, NestedEntityPreviewBoundary } from \"./EntityPreviewNesting\";\nimport { isEmptyPreviewValue } from \"../preview/util\";\nimport type { AdminCollection } from \"@rebasepro/cms-types\";\n\nexport type EntityPreviewBindingProps = {\n size?: PreviewSize,\n actions?: React.ReactNode,\n collection?: AdminCollection,\n hover?: boolean;\n previewKeys?: string[],\n disabled?: boolean,\n entity: Entity<any>,\n includeId?: boolean,\n includeTitle?: boolean,\n includeEntityLink?: boolean,\n includeImage?: boolean,\n onClick?: (e: React.SyntheticEvent) => void;\n onSidePanelClick?: (entity: Entity) => void,\n};\n\nexport type EntityPreviewBindingDataProps = {\n size?: \"smallest\" | \"small\" | \"medium\" | \"large\",\n actions?: React.ReactNode,\n collection?: AdminCollection,\n previewKeys?: string[],\n entity: Entity<any>,\n onSidePanelClick?: (entity: Entity) => void,\n includeId?: boolean,\n includeTitle?: boolean,\n includeEntityLink?: boolean,\n includeImage?: boolean,\n /**\n * `row` draws the record as a line of a table row instead of a card: see\n * {@link EntityPreviewLayout}. No id, no open button — the title opens the\n * record — and only as many supporting lines as the row has room for.\n */\n layout?: EntityPreviewLayout,\n};\n\n/**\n * This component contains the main logic and content for displaying a entity preview,\n * without any container wrapper. Used internally by EntityPreviewBinding.\n */\nexport function EntityPreviewBindingData({\n actions,\n collection: collectionProp,\n previewKeys,\n size = \"medium\",\n includeId = true,\n onSidePanelClick,\n includeTitle = true,\n includeEntityLink = true,\n includeImage = true,\n layout = \"card\",\n entity\n}: EntityPreviewBindingDataProps) {\n\n const analyticsController = useAnalyticsController();\n const sidePanelController = useSidePanel();\n\n const collectionRegistryController = useCollectionRegistryController();\n\n const collection = collectionProp ?? collectionRegistryController.getCollection(entity.path);\n\n // Above the `!collection` return, because hooks are. `useEntityTitle`\n // tolerates a missing collection for exactly this reason.\n const title = useEntityTitle({\n collection,\n entity\n });\n\n // What the card says under the title: see `usePreviewCardKeys`.\n const { listProperties } = usePreviewCardKeys(collection, previewKeys);\n\n if (!collection) {\n return (\n <>\n <ErrorView error={`Collection not found: ${entity.path}`}/>\n </>\n );\n }\n\n const titleProperty = includeTitle ? title.source?.key : undefined;\n const imagePropertyKey = includeImage ? getEntityImagePreviewPropertyKey(collection) : undefined;\n const imageProperty = imagePropertyKey ? collection.properties[imagePropertyKey] : undefined;\n const ofProp = imageProperty && \"of\" in imageProperty ? imageProperty.of : undefined;\n const usedImageProperty = ofProp ? (Array.isArray(ofProp) ? ofProp[0] : ofProp) : imageProperty;\n const restProperties = listProperties.filter(p => p !== titleProperty && p !== imagePropertyKey);\n\n const openInSidePanel = () => {\n onSidePanelClick?.(entity);\n analyticsController.onAnalyticsEvent?.(\"entity_click_from_reference\", {\n path: entity.path,\n entityId: entity.id\n });\n sidePanelController.open({\n id: entity.id,\n path: entity.path,\n collection,\n updateUrl: true\n });\n };\n\n const imageValue = imagePropertyKey ? getValueInPath(entity.values, imagePropertyKey) : undefined;\n const usedImageValue = imageProperty !== undefined ? (\"of\" in imageProperty\n ? (((imageValue as unknown[]) ?? []).length > 0\n ? (imageValue as unknown[])[0] : undefined)\n : imageValue)\n : undefined;\n\n if (layout === \"row\")\n return <EntityRowPreviewContent size={size}\n entity={entity}\n collection={collection}\n title={title.value ?? String(entity.id)}\n imageProperty={usedImageProperty}\n imagePropertyKey={imagePropertyKey}\n imageValue={usedImageValue}\n supportingKeys={restProperties}\n onOpen={includeEntityLink ? openInSidePanel : undefined}/>;\n\n return (\n // Everything below renders *inside* this preview: a reference or\n // relation among the preview properties collapses to one line instead\n // of nesting another bordered card with its own id and action button.\n <NestedEntityPreviewBoundary>\n {/* `overflow-hidden`: the image slot is a fixed box, and a thumbnail\n that fails to load renders a \"file not found\" message sized for a\n full preview — which spilled across the title beside it. */}\n <div className={cls(\"flex shrink-0 overflow-hidden\", {\n \"w-6 h-6 mx-1 my-0.5\": size === \"small\" || size === \"smallest\",\n \"w-8 h-8 ml-1 mr-2 m-2 self-start\": size === \"medium\",\n \"w-10 h-10 ml-2 mr-2 m-2 self-start\": size === \"large\"\n })}>\n {usedImageProperty && usedImageValue ? <PropertyPreview property={usedImageProperty}\n propertyKey={imagePropertyKey as string}\n size={\"small\"}\n value={usedImageValue}/> : null}\n {(!usedImageProperty || !usedImageValue) ? <IconForView collectionOrView={collection}\n color={\"primary\"}\n size={size}\n className={\"m-auto\"}/> : null}\n </div>\n\n <div\n className={\"flex flex-col grow w-full m-1 shrink min-w-0 text-text-primary dark:text-text-primary-dark flex-1 mr-2\"}>\n\n {includeId && (\n entity\n ? <div className={\"block whitespace-nowrap overflow-hidden truncate\"}>\n <Typography variant={\"caption\"}\n color={\"disabled\"}\n className={\"font-mono\"}>\n {entity.id}\n </Typography>\n </div>\n : <Skeleton/>)}\n\n {/* A title that came from a property keeps that property's own\n rendering — an enum stays its coloured chip, a relation stays\n a link. A computed one is text, because that is all a\n resolver returns. */}\n {includeTitle && (titleProperty || title.value) && (\n <div\n className={\"truncate my-0.5 text-sm font-medium text-text-primary dark:text-text-primary-dark\"}>\n {!entity && titleProperty\n ? <SkeletonPropertyComponent\n property={getPropertyInPath(collection.properties, titleProperty) as Property}\n size={\"medium\"}/>\n : titleProperty\n ? <PropertyPreview\n propertyKey={titleProperty}\n value={title.source?.value}\n property={getPropertyInPath(collection.properties, titleProperty) as Property}\n size={\"medium\"}/>\n : title.value}\n </div>\n )}\n\n {restProperties && restProperties.map((key) => {\n const childProperty = getPropertyInPath(collection.properties, key);\n if (!childProperty) return null;\n\n const valueInPath = getValueInPath(entity.values, key);\n return (\n // `truncate` clamps a line of text; it does nothing to a\n // preview that renders blocks. Custom `admin.Preview`\n // components can render anything at all, so the height\n // is capped here as well — a card that loses the tail of\n // an unusual value beats a card the size of a document.\n <div key={\"ref_prev_\" + key}\n className={cls(\"truncate min-w-0 max-h-8 overflow-hidden\",\n restProperties.length > 1 ? \"my-0.5\" : \"my-0\")}>\n {\n entity\n ? <PropertyPreview\n propertyKey={key as string}\n value={valueInPath}\n property={childProperty as Property}\n size={\"small\"}/>\n : <SkeletonPropertyComponent\n property={childProperty as Property}\n size={\"small\"}/>\n }\n </div>\n );\n })}\n\n </div>\n\n {entity && includeEntityLink &&\n <div className=\"flex-shrink-0\">\n <Tooltip title={`See details for ${entity.id}`} className={\"shrink-0\"}>\n <IconButton aria-label={`See details for ${entity.id}`}\n size={\"small\"}\n className={size !== \"small\" ? \"self-start\" : \"\"}\n onClick={(e) => {\n e.stopPropagation();\n e.preventDefault();\n openInSidePanel();\n }}>\n <ArrowRightToLineIcon/>\n </IconButton>\n </Tooltip>\n </div>}\n\n {actions && <div className=\"flex-shrink-0\">{actions}</div>}\n </NestedEntityPreviewBoundary>\n );\n}\n\n/**\n * A record as a line of a table row: its image, a title that opens it, and the\n * supporting lines that fit — one at `medium`, two at `large`. Supporting\n * values that are empty are skipped rather than drawn as an empty bar, so the\n * line under a name is the first thing the record actually has to say.\n */\nfunction EntityRowPreviewContent({\n size,\n entity,\n collection,\n title,\n imageProperty,\n imagePropertyKey,\n imageValue,\n supportingKeys,\n onOpen\n}: {\n size: \"smallest\" | \"small\" | \"medium\" | \"large\";\n entity: Entity<Record<string, unknown>>;\n collection: AdminCollection;\n title: string;\n imageProperty?: Property;\n imagePropertyKey?: string;\n imageValue: unknown;\n supportingKeys: string[];\n onOpen?: () => void;\n}) {\n const maxLines = size === \"large\" ? 2 : 1;\n const lines = supportingKeys\n .map(key => ({\n key,\n property: getPropertyInPath(collection.properties, key),\n value: getValueInPath(entity.values, key)\n }))\n .filter((line): line is { key: string, property: Property, value: unknown } =>\n Boolean(line.property) && !isEmptyPreviewValue(line.value))\n .slice(0, maxLines);\n\n const titleNode = <span className={\"truncate\"}>{title}</span>;\n\n return (\n <NestedEntityPreviewBoundary>\n <div className={\"flex items-center gap-2.5 min-w-0 w-full text-left\"}>\n {imagePropertyKey && <div className={cls(\"flex shrink-0 items-center justify-center overflow-hidden rounded-md\",\n size === \"large\" ? \"w-10 h-10\" : \"w-8 h-8\")}>\n {imageProperty && imageValue\n ? <PropertyPreview property={imageProperty}\n propertyKey={imagePropertyKey}\n size={\"small\"}\n value={imageValue}/>\n : <IconForView collectionOrView={collection}\n color={\"primary\"}\n size={\"small\"}/>}\n </div>}\n <div className={\"flex flex-col min-w-0 flex-1\"}>\n <div className={\"flex min-w-0 text-sm font-medium text-text-primary dark:text-text-primary-dark\"}>\n {onOpen\n ? <Tooltip title={`See details for ${title}`} asChild={true}>\n <span role={\"button\"}\n tabIndex={0}\n className={\"inline-flex min-w-0 max-w-full cursor-pointer hover:underline underline-offset-2\"}\n // See InlineEntityPreview: a press does not\n // move the focus, or a table cell would\n // select itself mid-click.\n onMouseDown={(event) => event.preventDefault()}\n onClick={(event) => {\n event.preventDefault();\n event.stopPropagation();\n onOpen();\n }}\n onKeyDown={(event) => {\n if (event.key !== \"Enter\" && event.key !== \" \") return;\n event.preventDefault();\n event.stopPropagation();\n onOpen();\n }}>\n {titleNode}\n </span>\n </Tooltip>\n : titleNode}\n </div>\n {lines.map(({ key, property, value }) =>\n <div key={key}\n className={\"truncate min-w-0 max-h-5 overflow-hidden text-xs text-text-secondary dark:text-text-secondary-dark\"}>\n <PropertyPreview propertyKey={key}\n value={value}\n property={property}\n size={\"small\"}/>\n </div>)}\n </div>\n </div>\n </NestedEntityPreviewBoundary>\n );\n}\n\n/**\n * What a card says under its title, and the property its title would come\n * from — one answer for the card and for the skeleton standing in for it, so\n * the two always have the same lines.\n *\n * A stated list wins outright — `previewProperties` is the one place a\n * developer says \"show these\", and nothing here is allowed to second-guess\n * it. Failing that, the card fills the same slots as every other surface\n * that renders one record in a row: a supporting line and a status. It used\n * to take the first few properties in declaration order instead, which is\n * how an author card ended up rendering an entire Markdown biography.\n */\nfunction usePreviewCardKeys(collection: AdminCollection | undefined, previewKeys: string[] | undefined) {\n const authController = useAuthController();\n const customizationController = useCustomizationController();\n const statedKeys = previewKeys ?? (collection?.previewProperties as string[] | undefined);\n return useMemo(() => {\n if (!collection) return { listProperties: [], titleKey: undefined };\n const slotKeys = resolveCollectionSlotKeys(\n collection as AdminCollection<Record<string, unknown>>,\n authController,\n customizationController.propertyConfigs);\n const listProperties = statedKeys && statedKeys.length > 0\n ? statedKeys.filter(key => getPropertyInPath(collection.properties, key))\n : [slotKeys.subtitleKey, slotKeys.statusKey].filter(Boolean) as string[];\n return { listProperties, titleKey: slotKeys.titleKey };\n }, [statedKeys, collection, authController, customizationController.propertyConfigs]);\n}\n\n/**\n * A card that has not loaded yet, drawn as the card it will be: the image\n * slot, a title, one placeholder per line the card will show and the open\n * button's room. A single bar in a 48px box grew to the full card when the\n * record arrived and pushed everything under it down.\n *\n * Which lines a card shows is known before its record is — they come from\n * the collection, not the values — so the count is right whatever the\n * collection declares. Each placeholder sits in the line's own wrapper with\n * the line's own type, and an enum's is a chip, so a line is as tall\n * loading as loaded without any height written down here.\n */\nexport function EntityPreviewBindingSkeleton({\n collection,\n previewKeys,\n size = \"medium\",\n includeTitle = true,\n includeImage = true,\n includeEntityLink = true\n}: {\n collection: AdminCollection,\n previewKeys?: string[],\n size?: \"smallest\" | \"small\" | \"medium\" | \"large\",\n includeTitle?: boolean,\n includeImage?: boolean,\n includeEntityLink?: boolean\n}) {\n const { listProperties, titleKey } = usePreviewCardKeys(collection, previewKeys);\n const imagePropertyKey = includeImage ? getEntityImagePreviewPropertyKey(collection) : undefined;\n const lines = listProperties.filter(key => key !== (includeTitle ? titleKey : undefined) && key !== imagePropertyKey);\n\n return (\n <>\n <div className={cls(\"flex shrink-0 overflow-hidden\", {\n \"w-6 h-6 mx-1 my-0.5\": size === \"small\" || size === \"smallest\",\n \"w-8 h-8 ml-1 mr-2 m-2 self-start\": size === \"medium\",\n \"w-10 h-10 ml-2 mr-2 m-2 self-start\": size === \"large\"\n })}>\n {imagePropertyKey\n ? <Skeleton className={\"w-full h-full\"}/>\n : <IconForView collectionOrView={collection}\n color={\"primary\"}\n size={size}\n className={\"m-auto\"}/>}\n </div>\n\n <div className={\"flex flex-col grow w-full m-1 shrink min-w-0 text-text-primary dark:text-text-primary-dark flex-1 mr-2\"}\n aria-busy={true}>\n {includeTitle && (\n <div className={\"truncate my-0.5 text-sm font-medium\"}>\n {\"\\u200b\"}<Skeleton className={\"inline-block align-middle\"} width={160}/>\n </div>\n )}\n {lines.map(key => {\n const property = getPropertyInPath(collection.properties, key);\n if (!property) return null;\n return (\n <div key={\"ref_prev_\" + key}\n className={cls(\"truncate min-w-0 max-h-8 overflow-hidden\",\n lines.length > 1 ? \"my-0.5\" : \"my-0\")}>\n <SkeletonCardLine property={property as Property}/>\n </div>\n );\n })}\n </div>\n\n {includeEntityLink &&\n <div className=\"flex-shrink-0\" aria-hidden={true}>\n <IconButton size={\"small\"}\n aria-label=\"See details\"\n tabIndex={-1}\n disabled={true}\n className={cls(\"invisible\", size !== \"small\" ? \"self-start\" : \"\")}>\n <ArrowRightToLineIcon/>\n </IconButton>\n </div>}\n </>\n );\n}\n\n/** One card line, loading: a chip for an enum, as the loaded line draws it, else a bar in a line of text. */\nfunction SkeletonCardLine({ property }: { property: Property }) {\n const enumValues = (property.type === \"string\" || property.type === \"number\") ? property.enum : undefined;\n if (enumValues) {\n const [first] = enumToObjectEntries(enumValues);\n return (\n <Chip size={\"small\"}>\n <span className={\"invisible\"}>{first ? buildEnumLabel(first) : \"\\u00a0\"}</span>\n </Chip>\n );\n }\n return (\n <span className={\"text-sm\"}>\n {\"\\u200b\"}<Skeleton className={\"inline-block align-middle\"} width={120}/>\n </span>\n );\n}\n\nexport function EntityPreviewBindingWithId({\n entityId,\n path,\n ...props\n}: Omit<EntityPreviewBindingProps, \"entity\"> & {\n entityId: string | number;\n path: string;\n databaseId?: string;\n}) {\n\n const [entity, setEntity] = React.useState<Entity | undefined>();\n const [dataLoading, setDataLoading] = React.useState(false);\n const dataClient = useData();\n\n useEffect(() => {\n let isMounted = true;\n if (!hasEntityId(entityId) || !path) {\n setEntity(undefined);\n return;\n }\n const fetchOne = async () => {\n setDataLoading(true);\n try {\n const fetchedEntity = await dataClient.collection(path).findById(entityId);\n if (isMounted) {\n setEntity(fetchedEntity);\n }\n } catch (error) {\n console.error(\"Error fetching entity:\", error);\n if (isMounted) {\n setEntity(undefined);\n }\n } finally {\n if (isMounted) {\n setDataLoading(false);\n }\n }\n }\n\n fetchOne();\n\n return () => {\n isMounted = false;\n }\n }, [entityId, path]);\n\n if (dataLoading && !entity) {\n return (\n <EntityPreviewContainer\n hover={props.hover}\n size={props.size}>\n <Skeleton/>\n </EntityPreviewContainer>\n );\n }\n\n if (!entity) {\n return (\n <EntityPreviewContainer\n hover={props.hover}\n size={props.size}>\n <div className={\"text-text-secondary dark:text-text-secondary-dark\"}>\n Entity not found\n </div>\n </EntityPreviewContainer>\n );\n }\n\n return <EntityPreviewBindingData\n {...props}\n entity={entity}/>;\n}\n\n/**\n * This view is used to display a preview of a entity.\n * It is used by default in reference fields and whenever a reference is displayed.\n */\nexport function EntityPreviewBinding({\n actions,\n disabled,\n hover,\n collection,\n previewKeys,\n onClick,\n size = \"medium\",\n includeId = true,\n includeTitle = true,\n includeEntityLink = true,\n includeImage = true,\n onSidePanelClick,\n entity\n}: EntityPreviewBindingProps) {\n\n return (\n <EntityPreviewContainer\n onClick={disabled ? undefined : onClick}\n hover={disabled ? undefined : hover}\n size={size}>\n <EntityPreviewBindingData\n actions={actions}\n collection={collection}\n previewKeys={previewKeys}\n size={size}\n includeId={includeId}\n includeTitle={includeTitle}\n includeEntityLink={includeEntityLink}\n includeImage={includeImage}\n onSidePanelClick={onSidePanelClick}\n entity={entity}\n />\n </EntityPreviewContainer>\n );\n}\n\nexport type EntityPreviewContainerProps = {\n children: React.ReactNode;\n hover?: boolean;\n fullwidth?: boolean;\n size?: PreviewSize;\n className?: string;\n style?: React.CSSProperties;\n onClick?: (e: React.SyntheticEvent) => void;\n};\n\nexport const EntityPreviewContainer = React.forwardRef<HTMLDivElement, EntityPreviewContainerProps>(({\n children,\n hover,\n onClick,\n size = \"medium\",\n style,\n className,\n fullwidth = true,\n ...props\n}, ref) => {\n return <div\n ref={ref}\n tabIndex={0}\n style={style}\n className={cls(\n \"bg-surface-card\",\n // On the shared 28/32/40/48 control scale. `44px` was between two\n // steps of it, so a reference in a form was 4px short of the field\n // next to it and their boxes never quite agreed.\n size === \"small\" ? \"min-h-[32px]\" : \"min-h-[48px]\",\n fullwidth ? \"w-full\" : \"\",\n \"items-center overflow-hidden\",\n hover ? \"hover:bg-surface-hover group-hover:bg-surface-hover\" : \"\",\n size === \"small\" ? \"p-1\" : \"px-2 py-1\",\n \"flex border rounded-lg\",\n onClick ? \"cursor-pointer\" : \"\",\n defaultBorderMixin,\n className)}\n role={onClick ? \"button\" : undefined}\n onClick={(event) => {\n if (onClick) {\n event.preventDefault();\n onClick(event);\n }\n }}\n onKeyDown={(event) => {\n if (onClick && (event.key === \"Enter\" || event.key === \" \")) {\n event.preventDefault();\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AW,IACvB,gCACA,QAAQ,wDAAwD,IAChE,SAAS,UAAU,QAAQ,aAC3B,0BACA,UAAU,mBAAmB,IAC7B,oBACA,SAAS;EACb,MAAM,UAAU,WAAW,KAAA;EAC3B,UAAU,UAAU;GAChB,IAAI,SAAS;IACT,MAAM,eAAe;IACrB,QAAQ,KAAK;GACjB;EACJ;EACA,YAAY,UAAU;GAClB,IAAI,YAAY,MAAM,QAAQ,WAAW,MAAM,QAAQ,MAAM;IACzD,MAAM,eAAe;IACrB,QAAQ,KAAK;GACjB;EACJ;EACA,GAAI;EACH;CACA,CAAA;AACT,CAAC;AAED,uBAAuB,cAAc"}
@@ -178,13 +178,12 @@ function ContentHomePage({ additionalActions, additionalChildrenStart, additiona
178
178
  /* @__PURE__ */ jsx(SearchBar, {
179
179
  onTextSearch: updateSearch,
180
180
  placeholder: t("search_collections"),
181
- autoFocus: true,
182
181
  size: "small",
183
182
  innerClassName: "w-full",
184
183
  className: "w-full grow"
185
184
  }),
186
- additionalActions,
187
- additionalPluginActions
185
+ Boolean(additionalActions) && additionalActions,
186
+ Array.isArray(additionalPluginActions) && additionalPluginActions.length > 0 && additionalPluginActions
188
187
  ]
189
188
  }),
190
189
  navigationStateController.navigationLoadingError && /* @__PURE__ */ jsx("div", {
@@ -1 +1 @@
1
- {"version":3,"file":"ContentHomePage.js","names":[],"sources":["../../../src/components/HomePage/ContentHomePage.tsx"],"sourcesContent":["import type { HomePageSection, NavigationEntry, NavigationGroupMapping, PluginGenericProps } from \"@rebasepro/cms-types\";\nimport React, { useCallback, useEffect, useMemo, useRef, useState } from \"react\";\nimport Fuse from \"fuse.js\";\nimport { Container, SearchBar } from \"@rebasepro/ui\";\nimport { AnalyticsEvent, studioSchemaToolEnabled } from \"@rebasepro/cms-types\";\nimport { FavouritesView } from \"./FavouritesView\";\nimport { ErrorBoundary } from \"@rebasepro/ui\";\nimport { NavigationGroup } from \"./NavigationGroup\";\nimport {\n NavigationGroupDroppable,\n NewGroupDropZone,\n SortableNavigationCard,\n SortableNavigationGroup,\n useHomePageDnd\n} from \"./HomePageDnD\";\nimport { DndContext, DragOverlay, MeasuringStrategy } from \"@dnd-kit/core\";\nimport { NavigationCardBinding } from \"./NavigationCardBinding\";\nimport { SortableContext, verticalListSortingStrategy } from \"@dnd-kit/sortable\";\nimport { restrictToVerticalAxis, restrictToWindowEdges } from \"@dnd-kit/modifiers\";\nimport { RenameGroupDialog } from \"./RenameGroupDialog\";\nimport { toArray } from \"@rebasepro/utils\";\nimport { useCollapsedGroups, buildCollapsedDefaults, useComponentOverride, useCustomizationController, useTranslation, useSlot, useAdminModeController, useRebaseRegistry } from \"@rebasepro/app\";\nimport { useRestoreScroll } from \"@rebasepro/app\";\n\nimport { SchemaDriftBanner } from \"@rebasepro/app\";\nimport { useBreadcrumbsController } from \"../../hooks/useBreadcrumbsController\";\nimport { useAdminContext } from \"../../hooks/useAdminContext\";\nimport { NavigationLoadingErrorView } from \"../NavigationLoadingErrorView\";\n\nexport const DEFAULT_GROUP_NAME = \"Views\";\nexport const ADMIN_GROUP_NAME = \"Admin\";\n\nexport function ContentHomePage({\n additionalActions,\n additionalChildrenStart,\n additionalChildrenEnd,\n sections,\n hiddenGroups\n}: {\n additionalActions?: React.ReactNode;\n additionalChildrenStart?: React.ReactNode;\n additionalChildrenEnd?: React.ReactNode;\n sections?: HomePageSection[];\n hiddenGroups?: string[];\n}) {\n\n const context = useAdminContext();\n const { navigationStateController } = context;\n const customizationController = useCustomizationController();\n const adminModeController = useAdminModeController();\n const registry = useRebaseRegistry();\n\n const { resolvedSlots } = customizationController;\n const ResolvedCollectionCard = useComponentOverride(\"HomePage.CollectionCard\", NavigationCardBinding);\n const breadcrumbs = useBreadcrumbsController();\n const { t } = useTranslation();\n\n useEffect(() => {\n breadcrumbs.set({ breadcrumbs: [] });\n }, [breadcrumbs.set]);\n\n const {\n allowDragAndDrop = false,\n navigationEntries: unFilteredNavigationEntries = [],\n groups: unFilteredGroupOrder = [],\n onNavigationEntriesUpdate = () => {}\n } = navigationStateController.topLevelNavigation || {};\n\n // Build a set of Studio-only dev view slugs so we can distinguish them from\n // admin custom views added via <RebaseCMS views={...}> or plugins.\n const studioViewSlugs = useMemo(() => {\n const slugs = new Set<string>();\n (registry.studioConfig?.devViews ?? []).forEach(v => slugs.add(v.slug));\n if (studioSchemaToolEnabled(registry)) slugs.add(\"schema\");\n return slugs;\n }, [registry]);\n\n // Studio mode shows Studio dev views + admin entries (Users/Roles).\n // Content mode shows collections, admin custom views, and admin entries — but not Studio dev views.\n const rawNavigationEntries = useMemo(() => {\n if (adminModeController.mode === \"studio\") {\n return unFilteredNavigationEntries.filter(e => (e.type === \"view\" && studioViewSlugs.has(e.slug)) || e.type === \"admin\");\n }\n return unFilteredNavigationEntries.filter(e => e.type !== \"view\" || !studioViewSlugs.has(e.slug));\n }, [unFilteredNavigationEntries, adminModeController.mode, studioViewSlugs]);\n\n const groupOrderFromNavController = useMemo(() => {\n const entryGroups = new Set(rawNavigationEntries.map(e => e.group).filter(Boolean));\n return unFilteredGroupOrder.filter(g => entryGroups.has(g));\n }, [unFilteredGroupOrder, rawNavigationEntries]);\n\n const fuse = useRef<Fuse<NavigationEntry> | null>(null);\n const [filteredUrls, setFilteredUrls] = useState<string[] | null>(null);\n const performingSearch = Boolean(filteredUrls);\n\n // Memoize filtered navigation entries to prevent unnecessary recalculations\n const filteredNavigationEntries = useMemo(() => {\n return filteredUrls\n ? rawNavigationEntries.filter((e) => filteredUrls.includes(e.url))\n : rawNavigationEntries;\n }, [filteredUrls, rawNavigationEntries]);\n\n useEffect(() => {\n fuse.current = new Fuse(rawNavigationEntries, {\n keys: [\"name\", \"description\", \"group\", \"path\"]\n });\n }, [rawNavigationEntries]);\n\n const updateSearch = useCallback((v?: string) => {\n if (!v?.trim()) {\n setFilteredUrls(null);\n return;\n }\n const results = fuse.current?.search(v.trim());\n setFilteredUrls(results ? results.map((x) => x.item.url) : []);\n }, []);\n\n /* ───────────────────────────────────────────────────────────────\n Build groups (all items) + isolate Admin\n ─────────────────────────────────────────────────────────────── */\n const [items, setItems] = useState<\n { name: string; entries: NavigationEntry[] }[]\n >([]);\n const [adminGroupData, setAdminGroupData] = useState<{\n name: string;\n entries: NavigationEntry[];\n } | null>(null);\n\n // Flag to prevent useEffect from overwriting local DnD state\n const isDndDirtyRef = useRef(false);\n const dndDirtyTimeoutRef = useRef<ReturnType<typeof setTimeout> | null>(null);\n\n // Memoize the processed groups to avoid unnecessary recalculations\n const processedGroups = useMemo(() => {\n const src = filteredNavigationEntries;\n const entriesByGroup: Record<string, NavigationEntry[]> = {};\n\n src.forEach((e) => {\n const g =\n e.type === \"admin\"\n ? ADMIN_GROUP_NAME\n : e.group ?? DEFAULT_GROUP_NAME;\n (entriesByGroup[g] ??= []).push(e);\n });\n\n // Check if there are custom additional card components from plugins\n const hasPluginAdditionalCards = customizationController.resolvedSlots.some(s => s.slot === \"home.cards\");\n\n let allProcessed: { name: string; entries: NavigationEntry[] }[];\n\n if (performingSearch) {\n const ordered = [\n ...new Set(src.map((e) => e.group ?? DEFAULT_GROUP_NAME))\n ];\n allProcessed = ordered\n .map((name) => ({\n name,\n entries: entriesByGroup[name] || []\n }))\n .filter((g) => g.entries.length);\n } else {\n allProcessed = groupOrderFromNavController.map((g) => ({\n name: g,\n entries: entriesByGroup[g] || []\n }));\n Object.keys(entriesByGroup).forEach((g) => {\n if (!groupOrderFromNavController.includes(g))\n allProcessed.push({\n name: g,\n entries: entriesByGroup[g]\n });\n });\n\n // Ensure default group exists if there are plugin additional cards but no collections\n if (hasPluginAdditionalCards && !allProcessed.some(g => g.name === DEFAULT_GROUP_NAME)) {\n allProcessed.push({\n name: DEFAULT_GROUP_NAME,\n entries: []\n });\n }\n\n allProcessed = allProcessed.filter(\n (g) =>\n g.entries.length ||\n (g.name === DEFAULT_GROUP_NAME && hasPluginAdditionalCards)\n );\n }\n\n const admin = allProcessed.find((g) => g.name === ADMIN_GROUP_NAME);\n return {\n adminGroupData: admin || null,\n items: allProcessed.filter((g) => g.name !== ADMIN_GROUP_NAME && !hiddenGroups?.includes(g.name))\n };\n }, [filteredNavigationEntries, performingSearch, groupOrderFromNavController, customizationController.resolvedSlots, hiddenGroups]);\n\n // Update state only when processedGroups actually changes\n // Skip update if DnD just made a local change (dirty flag is set)\n useEffect(() => {\n if (isDndDirtyRef.current) {\n // DnD just updated the state, skip this sync\n return;\n }\n setAdminGroupData(processedGroups.adminGroupData);\n setItems(processedGroups.items);\n }, [processedGroups]);\n\n /* ───────────────────────────────────────────────────────────────\n Local update vs. persistence helpers\n ─────────────────────────────────────────────────────────────── */\n const updateItems = (\n updater:\n | { name: string; entries: NavigationEntry[] }[]\n | ((\n prev: { name: string; entries: NavigationEntry[] }[]\n ) => { name: string; entries: NavigationEntry[] }[])\n ) => {\n setItems(updater); // local only\n };\n\n const persistNavigationGroups = (\n latest: { name: string; entries: NavigationEntry[] }[]\n ) => {\n // Set dirty flag to prevent useEffect from overwriting local state\n isDndDirtyRef.current = true;\n\n // Clear any existing timeout\n if (dndDirtyTimeoutRef.current) {\n clearTimeout(dndDirtyTimeoutRef.current);\n }\n\n // Clear dirty flag after a delay to allow navigation to update\n dndDirtyTimeoutRef.current = setTimeout(() => {\n isDndDirtyRef.current = false;\n }, 1000);\n\n // Map ALL groups including \"Views\"\n const draggable: NavigationGroupMapping[] = latest.map((g) => ({\n name: g.name,\n entries: g.entries.map((e) => e.slug)\n }));\n\n const all: NavigationGroupMapping[] = adminGroupData\n ? [\n ...draggable,\n {\n name: adminGroupData.name,\n entries: adminGroupData.entries.map((e) => e.slug)\n }\n ]\n : draggable;\n\n onNavigationEntriesUpdate(all);\n };\n\n // Use custom hook for collapsed groups with localStorage persistence\n const groupNames = useMemo(() => [\n ...items.map(item => item.name),\n ...(adminGroupData ? [adminGroupData.name] : [])\n ], [items, adminGroupData]);\n\n const collapsedDefaults = useMemo(\n () => buildCollapsedDefaults(registry.cmsConfig?.navigationGroupMappings, \"home\"),\n [registry.cmsConfig?.navigationGroupMappings]\n );\n const { isGroupCollapsed, toggleGroupCollapsed } = useCollapsedGroups(groupNames, \"home\", collapsedDefaults);\n\n const {\n sensors,\n collisionDetection,\n onDragStart,\n onDragOver,\n onDragEnd,\n dropAnimation,\n activeItemForOverlay,\n activeGroupData,\n draggingGroupId,\n containers,\n dndKitActiveNode,\n onDragCancel,\n isDraggingCardOnly,\n dialogOpenForGroup,\n setDialogOpenForGroup,\n handleRenameGroup,\n handleDialogClose,\n isHoveringNewGroupDropZone,\n setIsHoveringNewGroupDropZone\n } = useHomePageDnd({\n items,\n setItems: updateItems,\n disabled: !allowDragAndDrop || performingSearch,\n onPersist: persistNavigationGroups,\n onGroupMoved: (g) =>\n context.analyticsController?.onAnalyticsEvent?.(\"home_move_group\", {\n name: g\n }),\n onCardMovedBetweenGroups: (card) =>\n context.analyticsController?.onAnalyticsEvent?.(\"home_move_card\", {\n id: card.id\n }),\n onNewGroupDrop: () =>\n context.analyticsController?.onAnalyticsEvent?.(\n \"home_drop_new_group\"\n )\n });\n\n const {\n containerRef,\n direction\n } = useRestoreScroll();\n\n const dndDisabled = !allowDragAndDrop || performingSearch;\n\n const dndModifiers = dndKitActiveNode?.data.current?.type === \"group\"\n ? [restrictToVerticalAxis, restrictToWindowEdges]\n : [restrictToWindowEdges];\n\n const sectionProps: PluginGenericProps = { context };\n const additionalPluginChildrenStart = useSlot(\"home.children.start\", sectionProps);\n const additionalPluginChildrenEnd = useSlot(\"home.children.end\", sectionProps);\n const additionalPluginActions = useSlot(\"home.actions\", sectionProps);\n\n // Pre-compute home.cards slot contributions (cannot call useSlot inside .map loop)\n const homeCardContributions = useMemo(() => {\n return resolvedSlots\n .filter(s => s.slot === \"home.cards\")\n .sort((a, b) => (a.order ?? 50) - (b.order ?? 50));\n }, [resolvedSlots]);\n\n /* ───────────────────────────────────────────────────────────────\n Render\n ─────────────────────────────────────────────────────────────── */\n return (\n <div ref={containerRef} className=\"py-2 overflow-auto h-full w-full bg-surface-sheet\">\n <Container maxWidth=\"6xl\">\n <div className=\"mb-4 flex flex-col gap-2\">\n <SchemaDriftBanner />\n </div>\n {/* search & actions */}\n <div\n className=\"w-full sticky py-4 transition-all duration-400 ease-in-out top-0 z-10 flex flex-row gap-4\"\n style={{ top: direction === \"down\" ? -84 : 0 }}\n >\n <SearchBar\n onTextSearch={updateSearch}\n placeholder={t(\"search_collections\")}\n autoFocus\n size=\"small\"\n innerClassName=\"w-full\"\n className=\"w-full grow\"\n />\n {additionalActions}\n {additionalPluginActions}\n </div>\n\n {navigationStateController.navigationLoadingError &&\n <div className=\"mb-4\">\n <NavigationLoadingErrorView error={navigationStateController.navigationLoadingError}\n onRetry={navigationStateController.refreshNavigation}/>\n </div>}\n\n <FavouritesView hidden={performingSearch}/>\n\n {additionalChildrenStart}\n {additionalPluginChildrenStart}\n\n {/* ─────── DND context ─────── */}\n <DndContext\n sensors={sensors}\n collisionDetection={collisionDetection}\n measuring={{\n droppable: {\n strategy: MeasuringStrategy.Always,\n frequency: 500\n }\n }}\n onDragStart={onDragStart}\n onDragOver={onDragOver}\n onDragEnd={onDragEnd}\n onDragCancel={onDragCancel}\n modifiers={dndModifiers}\n >\n <SortableContext\n key={containers.join(\",\")}\n items={containers}\n strategy={verticalListSortingStrategy}\n >\n {items.map((groupData, groupIndex) => {\n const groupKey = groupData.name;\n const entriesInGroup = groupData.entries;\n\n const homeCardsProps = {\n group:\n groupKey === DEFAULT_GROUP_NAME\n ? undefined\n : groupKey,\n context\n };\n // Render home.cards contributions inline (no hook call inside loop)\n const additionalCards = homeCardContributions.map((s, i) => (\n <ErrorBoundary key={`home_cards_${groupKey}_${i}`}>\n <s.Component {...homeCardsProps} {...(s.props ?? {})}/>\n </ErrorBoundary>\n ));\n\n if (\n entriesInGroup.length === 0 &&\n (additionalCards.length === 0 || performingSearch)\n )\n return null;\n\n return (\n <SortableNavigationGroup\n key={`group-${groupIndex}`}\n groupName={groupKey}\n disabled={dndDisabled}\n >\n <NavigationGroup\n group={\n groupKey === DEFAULT_GROUP_NAME\n ? undefined\n : groupKey\n }\n minimised={\n draggingGroupId === groupKey &&\n !isDraggingCardOnly\n }\n isPotentialCardDropTarget={\n isDraggingCardOnly\n }\n dndDisabled={dndDisabled}\n onEditGroup={() => {\n if (dndDisabled) return;\n setDialogOpenForGroup(groupKey);\n }}\n collapsed={isGroupCollapsed(groupKey)}\n onToggleCollapsed={() => toggleGroupCollapsed(groupKey)}\n >\n <NavigationGroupDroppable\n id={groupKey}\n itemIds={entriesInGroup.map(\n (e) => e.url\n )}\n isPotentialCardDropTarget={\n isDraggingCardOnly\n }\n >\n <div className=\"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-4 \">\n {entriesInGroup.map(\n (entry) => (\n <SortableNavigationCard\n key={entry.url}\n entry={entry}\n onClick={() => {\n let event: AnalyticsEvent =\n \"unmapped_event\";\n if (\n entry.type ===\n \"collection\"\n )\n event =\n \"home_navigate_to_collection\";\n else if (\n entry.type ===\n \"view\"\n )\n event =\n \"home_navigate_to_view\";\n else if (\n entry.type ===\n \"admin\"\n )\n event =\n \"home_navigate_to_admin_view\";\n\n context.analyticsController?.onAnalyticsEvent?.(\n event,\n {\n path: entry.slug\n }\n );\n }}\n />\n )\n )}\n {!performingSearch &&\n groupKey.toLowerCase() !==\n ADMIN_GROUP_NAME.toLowerCase() &&\n additionalCards}\n </div>\n </NavigationGroupDroppable>\n </NavigationGroup>\n </SortableNavigationGroup>\n );\n })}\n </SortableContext>\n\n <NewGroupDropZone\n disabled={dndDisabled}\n setIsHovering={setIsHoveringNewGroupDropZone}\n />\n\n <DragOverlay adjustScale={false} dropAnimation={dropAnimation}>\n {activeGroupData &&\n draggingGroupId === activeGroupData.name ? (\n <div\n className=\"rounded-lg bg-transparent\"\n style={{\n padding: 0,\n margin: 0\n }}\n >\n <NavigationGroup\n group={\n activeGroupData.name ===\n DEFAULT_GROUP_NAME\n ? undefined\n : activeGroupData.name\n }\n isPreview={false}\n minimised\n />\n </div>\n ) : activeItemForOverlay ? (\n <ResolvedCollectionCard\n {...activeItemForOverlay}\n shrink={isHoveringNewGroupDropZone}\n />\n ) : null}\n </DragOverlay>\n </DndContext>\n\n {!performingSearch && adminGroupData && (\n <NavigationGroup\n group={adminGroupData.name}\n collapsed={isGroupCollapsed(adminGroupData.name)}\n onToggleCollapsed={() => toggleGroupCollapsed(adminGroupData.name)}\n >\n <div className=\"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-4 \">\n {adminGroupData.entries.map((entry) => (\n <ResolvedCollectionCard\n key={entry.url}\n {...entry}\n onClick={() => {\n let event: AnalyticsEvent =\n \"unmapped_event\";\n if (entry.type === \"collection\")\n event =\n \"home_navigate_to_collection\";\n else if (entry.type === \"view\")\n event = \"home_navigate_to_view\";\n else if (entry.type === \"admin\")\n event =\n \"home_navigate_to_admin_view\";\n\n context.analyticsController?.onAnalyticsEvent?.(\n event,\n { path: entry.slug }\n );\n }}\n />\n ))}\n </div>\n </NavigationGroup>\n )}\n\n {sections && sections.map((section) => (\n <NavigationGroup\n key={section.key}\n group={section.title}\n >\n {section.children}\n </NavigationGroup>\n ))}\n\n {additionalPluginChildrenEnd}\n {additionalChildrenEnd}\n </Container>\n\n {dialogOpenForGroup && (\n <RenameGroupDialog\n open\n initialName={dialogOpenForGroup}\n existingGroupNames={items\n .map((g) => g.name)\n .filter((n) => n !== dialogOpenForGroup)}\n onClose={handleDialogClose}\n onRename={(newName) => {\n handleRenameGroup(dialogOpenForGroup, newName);\n }}\n />\n )}\n </div>\n );\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;AA6BA,IAAa,qBAAqB;AAClC,IAAa,mBAAmB;AAEhC,SAAgB,gBAAgB,EAC5B,mBACA,yBACA,uBACA,UACA,gBAOD;CAEC,MAAM,UAAU,gBAAgB;CAChC,MAAM,EAAE,8BAA8B;CACtC,MAAM,0BAA0B,2BAA2B;CAC3D,MAAM,sBAAsB,uBAAuB;CACnD,MAAM,WAAW,kBAAkB;CAEnC,MAAM,EAAE,kBAAkB;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AK,UACzB,oBAAC,wBAAD;OAEI,GAAI;OACJ,eAAe;QACX,IAAI,QACA;QACJ,IAAI,MAAM,SAAS,cACf,QACI;aACH,IAAI,MAAM,SAAS,QACpB,QAAQ;aACP,IAAI,MAAM,SAAS,SACpB,QACI;QAER,QAAQ,qBAAqB,mBACzB,OACA,EAAE,MAAM,MAAM,KAAK,CACvB;OACJ;MACH,GAnBQ,MAAM,GAmBd,CACJ;KACA,CAAA;IACQ,CAAA;IAGpB,YAAY,SAAS,KAAK,YACvB,oBAAC,iBAAD;KAEI,OAAO,QAAQ;eAEd,QAAQ;IACI,GAJR,QAAQ,GAIA,CACpB;IAEA;IACA;GACM;MAEV,sBACG,oBAAC,mBAAD;GACI,MAAA;GACA,aAAa;GACb,oBAAoB,MACf,KAAK,MAAM,EAAE,IAAI,CAAC,CAClB,QAAQ,MAAM,MAAM,kBAAkB;GAC3C,SAAS;GACT,WAAW,YAAY;IACnB,kBAAkB,oBAAoB,OAAO;GACjD;EACH,CAAA,CAEJ;;AAEb"}
1
+ {"version":3,"file":"ContentHomePage.js","names":[],"sources":["../../../src/components/HomePage/ContentHomePage.tsx"],"sourcesContent":["import type { HomePageSection, NavigationEntry, NavigationGroupMapping, PluginGenericProps } from \"@rebasepro/cms-types\";\nimport React, { useCallback, useEffect, useMemo, useRef, useState } from \"react\";\nimport Fuse from \"fuse.js\";\nimport { Container, SearchBar } from \"@rebasepro/ui\";\nimport { AnalyticsEvent, studioSchemaToolEnabled } from \"@rebasepro/cms-types\";\nimport { FavouritesView } from \"./FavouritesView\";\nimport { ErrorBoundary } from \"@rebasepro/ui\";\nimport { NavigationGroup } from \"./NavigationGroup\";\nimport {\n NavigationGroupDroppable,\n NewGroupDropZone,\n SortableNavigationCard,\n SortableNavigationGroup,\n useHomePageDnd\n} from \"./HomePageDnD\";\nimport { DndContext, DragOverlay, MeasuringStrategy } from \"@dnd-kit/core\";\nimport { NavigationCardBinding } from \"./NavigationCardBinding\";\nimport { SortableContext, verticalListSortingStrategy } from \"@dnd-kit/sortable\";\nimport { restrictToVerticalAxis, restrictToWindowEdges } from \"@dnd-kit/modifiers\";\nimport { RenameGroupDialog } from \"./RenameGroupDialog\";\nimport { toArray } from \"@rebasepro/utils\";\nimport { useCollapsedGroups, buildCollapsedDefaults, useComponentOverride, useCustomizationController, useTranslation, useSlot, useAdminModeController, useRebaseRegistry } from \"@rebasepro/app\";\nimport { useRestoreScroll } from \"@rebasepro/app\";\n\nimport { SchemaDriftBanner } from \"@rebasepro/app\";\nimport { useBreadcrumbsController } from \"../../hooks/useBreadcrumbsController\";\nimport { useAdminContext } from \"../../hooks/useAdminContext\";\nimport { NavigationLoadingErrorView } from \"../NavigationLoadingErrorView\";\n\nexport const DEFAULT_GROUP_NAME = \"Views\";\nexport const ADMIN_GROUP_NAME = \"Admin\";\n\nexport function ContentHomePage({\n additionalActions,\n additionalChildrenStart,\n additionalChildrenEnd,\n sections,\n hiddenGroups\n}: {\n additionalActions?: React.ReactNode;\n additionalChildrenStart?: React.ReactNode;\n additionalChildrenEnd?: React.ReactNode;\n sections?: HomePageSection[];\n hiddenGroups?: string[];\n}) {\n\n const context = useAdminContext();\n const { navigationStateController } = context;\n const customizationController = useCustomizationController();\n const adminModeController = useAdminModeController();\n const registry = useRebaseRegistry();\n\n const { resolvedSlots } = customizationController;\n const ResolvedCollectionCard = useComponentOverride(\"HomePage.CollectionCard\", NavigationCardBinding);\n const breadcrumbs = useBreadcrumbsController();\n const { t } = useTranslation();\n\n useEffect(() => {\n breadcrumbs.set({ breadcrumbs: [] });\n }, [breadcrumbs.set]);\n\n const {\n allowDragAndDrop = false,\n navigationEntries: unFilteredNavigationEntries = [],\n groups: unFilteredGroupOrder = [],\n onNavigationEntriesUpdate = () => {}\n } = navigationStateController.topLevelNavigation || {};\n\n // Build a set of Studio-only dev view slugs so we can distinguish them from\n // admin custom views added via <RebaseCMS views={...}> or plugins.\n const studioViewSlugs = useMemo(() => {\n const slugs = new Set<string>();\n (registry.studioConfig?.devViews ?? []).forEach(v => slugs.add(v.slug));\n if (studioSchemaToolEnabled(registry)) slugs.add(\"schema\");\n return slugs;\n }, [registry]);\n\n // Studio mode shows Studio dev views + admin entries (Users/Roles).\n // Content mode shows collections, admin custom views, and admin entries — but not Studio dev views.\n const rawNavigationEntries = useMemo(() => {\n if (adminModeController.mode === \"studio\") {\n return unFilteredNavigationEntries.filter(e => (e.type === \"view\" && studioViewSlugs.has(e.slug)) || e.type === \"admin\");\n }\n return unFilteredNavigationEntries.filter(e => e.type !== \"view\" || !studioViewSlugs.has(e.slug));\n }, [unFilteredNavigationEntries, adminModeController.mode, studioViewSlugs]);\n\n const groupOrderFromNavController = useMemo(() => {\n const entryGroups = new Set(rawNavigationEntries.map(e => e.group).filter(Boolean));\n return unFilteredGroupOrder.filter(g => entryGroups.has(g));\n }, [unFilteredGroupOrder, rawNavigationEntries]);\n\n const fuse = useRef<Fuse<NavigationEntry> | null>(null);\n const [filteredUrls, setFilteredUrls] = useState<string[] | null>(null);\n const performingSearch = Boolean(filteredUrls);\n\n // Memoize filtered navigation entries to prevent unnecessary recalculations\n const filteredNavigationEntries = useMemo(() => {\n return filteredUrls\n ? rawNavigationEntries.filter((e) => filteredUrls.includes(e.url))\n : rawNavigationEntries;\n }, [filteredUrls, rawNavigationEntries]);\n\n useEffect(() => {\n fuse.current = new Fuse(rawNavigationEntries, {\n keys: [\"name\", \"description\", \"group\", \"path\"]\n });\n }, [rawNavigationEntries]);\n\n const updateSearch = useCallback((v?: string) => {\n if (!v?.trim()) {\n setFilteredUrls(null);\n return;\n }\n const results = fuse.current?.search(v.trim());\n setFilteredUrls(results ? results.map((x) => x.item.url) : []);\n }, []);\n\n /* ───────────────────────────────────────────────────────────────\n Build groups (all items) + isolate Admin\n ─────────────────────────────────────────────────────────────── */\n const [items, setItems] = useState<\n { name: string; entries: NavigationEntry[] }[]\n >([]);\n const [adminGroupData, setAdminGroupData] = useState<{\n name: string;\n entries: NavigationEntry[];\n } | null>(null);\n\n // Flag to prevent useEffect from overwriting local DnD state\n const isDndDirtyRef = useRef(false);\n const dndDirtyTimeoutRef = useRef<ReturnType<typeof setTimeout> | null>(null);\n\n // Memoize the processed groups to avoid unnecessary recalculations\n const processedGroups = useMemo(() => {\n const src = filteredNavigationEntries;\n const entriesByGroup: Record<string, NavigationEntry[]> = {};\n\n src.forEach((e) => {\n const g =\n e.type === \"admin\"\n ? ADMIN_GROUP_NAME\n : e.group ?? DEFAULT_GROUP_NAME;\n (entriesByGroup[g] ??= []).push(e);\n });\n\n // Check if there are custom additional card components from plugins\n const hasPluginAdditionalCards = customizationController.resolvedSlots.some(s => s.slot === \"home.cards\");\n\n let allProcessed: { name: string; entries: NavigationEntry[] }[];\n\n if (performingSearch) {\n const ordered = [\n ...new Set(src.map((e) => e.group ?? DEFAULT_GROUP_NAME))\n ];\n allProcessed = ordered\n .map((name) => ({\n name,\n entries: entriesByGroup[name] || []\n }))\n .filter((g) => g.entries.length);\n } else {\n allProcessed = groupOrderFromNavController.map((g) => ({\n name: g,\n entries: entriesByGroup[g] || []\n }));\n Object.keys(entriesByGroup).forEach((g) => {\n if (!groupOrderFromNavController.includes(g))\n allProcessed.push({\n name: g,\n entries: entriesByGroup[g]\n });\n });\n\n // Ensure default group exists if there are plugin additional cards but no collections\n if (hasPluginAdditionalCards && !allProcessed.some(g => g.name === DEFAULT_GROUP_NAME)) {\n allProcessed.push({\n name: DEFAULT_GROUP_NAME,\n entries: []\n });\n }\n\n allProcessed = allProcessed.filter(\n (g) =>\n g.entries.length ||\n (g.name === DEFAULT_GROUP_NAME && hasPluginAdditionalCards)\n );\n }\n\n const admin = allProcessed.find((g) => g.name === ADMIN_GROUP_NAME);\n return {\n adminGroupData: admin || null,\n items: allProcessed.filter((g) => g.name !== ADMIN_GROUP_NAME && !hiddenGroups?.includes(g.name))\n };\n }, [filteredNavigationEntries, performingSearch, groupOrderFromNavController, customizationController.resolvedSlots, hiddenGroups]);\n\n // Update state only when processedGroups actually changes\n // Skip update if DnD just made a local change (dirty flag is set)\n useEffect(() => {\n if (isDndDirtyRef.current) {\n // DnD just updated the state, skip this sync\n return;\n }\n setAdminGroupData(processedGroups.adminGroupData);\n setItems(processedGroups.items);\n }, [processedGroups]);\n\n /* ───────────────────────────────────────────────────────────────\n Local update vs. persistence helpers\n ─────────────────────────────────────────────────────────────── */\n const updateItems = (\n updater:\n | { name: string; entries: NavigationEntry[] }[]\n | ((\n prev: { name: string; entries: NavigationEntry[] }[]\n ) => { name: string; entries: NavigationEntry[] }[])\n ) => {\n setItems(updater); // local only\n };\n\n const persistNavigationGroups = (\n latest: { name: string; entries: NavigationEntry[] }[]\n ) => {\n // Set dirty flag to prevent useEffect from overwriting local state\n isDndDirtyRef.current = true;\n\n // Clear any existing timeout\n if (dndDirtyTimeoutRef.current) {\n clearTimeout(dndDirtyTimeoutRef.current);\n }\n\n // Clear dirty flag after a delay to allow navigation to update\n dndDirtyTimeoutRef.current = setTimeout(() => {\n isDndDirtyRef.current = false;\n }, 1000);\n\n // Map ALL groups including \"Views\"\n const draggable: NavigationGroupMapping[] = latest.map((g) => ({\n name: g.name,\n entries: g.entries.map((e) => e.slug)\n }));\n\n const all: NavigationGroupMapping[] = adminGroupData\n ? [\n ...draggable,\n {\n name: adminGroupData.name,\n entries: adminGroupData.entries.map((e) => e.slug)\n }\n ]\n : draggable;\n\n onNavigationEntriesUpdate(all);\n };\n\n // Use custom hook for collapsed groups with localStorage persistence\n const groupNames = useMemo(() => [\n ...items.map(item => item.name),\n ...(adminGroupData ? [adminGroupData.name] : [])\n ], [items, adminGroupData]);\n\n const collapsedDefaults = useMemo(\n () => buildCollapsedDefaults(registry.cmsConfig?.navigationGroupMappings, \"home\"),\n [registry.cmsConfig?.navigationGroupMappings]\n );\n const { isGroupCollapsed, toggleGroupCollapsed } = useCollapsedGroups(groupNames, \"home\", collapsedDefaults);\n\n const {\n sensors,\n collisionDetection,\n onDragStart,\n onDragOver,\n onDragEnd,\n dropAnimation,\n activeItemForOverlay,\n activeGroupData,\n draggingGroupId,\n containers,\n dndKitActiveNode,\n onDragCancel,\n isDraggingCardOnly,\n dialogOpenForGroup,\n setDialogOpenForGroup,\n handleRenameGroup,\n handleDialogClose,\n isHoveringNewGroupDropZone,\n setIsHoveringNewGroupDropZone\n } = useHomePageDnd({\n items,\n setItems: updateItems,\n disabled: !allowDragAndDrop || performingSearch,\n onPersist: persistNavigationGroups,\n onGroupMoved: (g) =>\n context.analyticsController?.onAnalyticsEvent?.(\"home_move_group\", {\n name: g\n }),\n onCardMovedBetweenGroups: (card) =>\n context.analyticsController?.onAnalyticsEvent?.(\"home_move_card\", {\n id: card.id\n }),\n onNewGroupDrop: () =>\n context.analyticsController?.onAnalyticsEvent?.(\n \"home_drop_new_group\"\n )\n });\n\n const {\n containerRef,\n direction\n } = useRestoreScroll();\n\n const dndDisabled = !allowDragAndDrop || performingSearch;\n\n const dndModifiers = dndKitActiveNode?.data.current?.type === \"group\"\n ? [restrictToVerticalAxis, restrictToWindowEdges]\n : [restrictToWindowEdges];\n\n const sectionProps: PluginGenericProps = { context };\n const additionalPluginChildrenStart = useSlot(\"home.children.start\", sectionProps);\n const additionalPluginChildrenEnd = useSlot(\"home.children.end\", sectionProps);\n const additionalPluginActions = useSlot(\"home.actions\", sectionProps);\n\n // Pre-compute home.cards slot contributions (cannot call useSlot inside .map loop)\n const homeCardContributions = useMemo(() => {\n return resolvedSlots\n .filter(s => s.slot === \"home.cards\")\n .sort((a, b) => (a.order ?? 50) - (b.order ?? 50));\n }, [resolvedSlots]);\n\n /* ───────────────────────────────────────────────────────────────\n Render\n ─────────────────────────────────────────────────────────────── */\n return (\n <div ref={containerRef} className=\"py-2 overflow-auto h-full w-full bg-surface-sheet\">\n <Container maxWidth=\"6xl\">\n <div className=\"mb-4 flex flex-col gap-2\">\n <SchemaDriftBanner />\n </div>\n {/* search & actions */}\n <div\n className=\"w-full sticky py-4 transition-all duration-400 ease-in-out top-0 z-10 flex flex-row gap-4\"\n style={{ top: direction === \"down\" ? -84 : 0 }}\n >\n <SearchBar\n onTextSearch={updateSearch}\n placeholder={t(\"search_collections\")}\n size=\"small\"\n innerClassName=\"w-full\"\n className=\"w-full grow\"\n />\n {Boolean(additionalActions) && additionalActions}\n {Array.isArray(additionalPluginActions) && additionalPluginActions.length > 0 && additionalPluginActions}\n </div>\n\n {navigationStateController.navigationLoadingError &&\n <div className=\"mb-4\">\n <NavigationLoadingErrorView error={navigationStateController.navigationLoadingError}\n onRetry={navigationStateController.refreshNavigation}/>\n </div>}\n\n <FavouritesView hidden={performingSearch}/>\n\n {additionalChildrenStart}\n {additionalPluginChildrenStart}\n\n {/* ─────── DND context ─────── */}\n <DndContext\n sensors={sensors}\n collisionDetection={collisionDetection}\n measuring={{\n droppable: {\n strategy: MeasuringStrategy.Always,\n frequency: 500\n }\n }}\n onDragStart={onDragStart}\n onDragOver={onDragOver}\n onDragEnd={onDragEnd}\n onDragCancel={onDragCancel}\n modifiers={dndModifiers}\n >\n <SortableContext\n key={containers.join(\",\")}\n items={containers}\n strategy={verticalListSortingStrategy}\n >\n {items.map((groupData, groupIndex) => {\n const groupKey = groupData.name;\n const entriesInGroup = groupData.entries;\n\n const homeCardsProps = {\n group:\n groupKey === DEFAULT_GROUP_NAME\n ? undefined\n : groupKey,\n context\n };\n // Render home.cards contributions inline (no hook call inside loop)\n const additionalCards = homeCardContributions.map((s, i) => (\n <ErrorBoundary key={`home_cards_${groupKey}_${i}`}>\n <s.Component {...homeCardsProps} {...(s.props ?? {})}/>\n </ErrorBoundary>\n ));\n\n if (\n entriesInGroup.length === 0 &&\n (additionalCards.length === 0 || performingSearch)\n )\n return null;\n\n return (\n <SortableNavigationGroup\n key={`group-${groupIndex}`}\n groupName={groupKey}\n disabled={dndDisabled}\n >\n <NavigationGroup\n group={\n groupKey === DEFAULT_GROUP_NAME\n ? undefined\n : groupKey\n }\n minimised={\n draggingGroupId === groupKey &&\n !isDraggingCardOnly\n }\n isPotentialCardDropTarget={\n isDraggingCardOnly\n }\n dndDisabled={dndDisabled}\n onEditGroup={() => {\n if (dndDisabled) return;\n setDialogOpenForGroup(groupKey);\n }}\n collapsed={isGroupCollapsed(groupKey)}\n onToggleCollapsed={() => toggleGroupCollapsed(groupKey)}\n >\n <NavigationGroupDroppable\n id={groupKey}\n itemIds={entriesInGroup.map(\n (e) => e.url\n )}\n isPotentialCardDropTarget={\n isDraggingCardOnly\n }\n >\n <div className=\"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-4 \">\n {entriesInGroup.map(\n (entry) => (\n <SortableNavigationCard\n key={entry.url}\n entry={entry}\n onClick={() => {\n let event: AnalyticsEvent =\n \"unmapped_event\";\n if (\n entry.type ===\n \"collection\"\n )\n event =\n \"home_navigate_to_collection\";\n else if (\n entry.type ===\n \"view\"\n )\n event =\n \"home_navigate_to_view\";\n else if (\n entry.type ===\n \"admin\"\n )\n event =\n \"home_navigate_to_admin_view\";\n\n context.analyticsController?.onAnalyticsEvent?.(\n event,\n {\n path: entry.slug\n }\n );\n }}\n />\n )\n )}\n {!performingSearch &&\n groupKey.toLowerCase() !==\n ADMIN_GROUP_NAME.toLowerCase() &&\n additionalCards}\n </div>\n </NavigationGroupDroppable>\n </NavigationGroup>\n </SortableNavigationGroup>\n );\n })}\n </SortableContext>\n\n <NewGroupDropZone\n disabled={dndDisabled}\n setIsHovering={setIsHoveringNewGroupDropZone}\n />\n\n <DragOverlay adjustScale={false} dropAnimation={dropAnimation}>\n {activeGroupData &&\n draggingGroupId === activeGroupData.name ? (\n <div\n className=\"rounded-lg bg-transparent\"\n style={{\n padding: 0,\n margin: 0\n }}\n >\n <NavigationGroup\n group={\n activeGroupData.name ===\n DEFAULT_GROUP_NAME\n ? undefined\n : activeGroupData.name\n }\n isPreview={false}\n minimised\n />\n </div>\n ) : activeItemForOverlay ? (\n <ResolvedCollectionCard\n {...activeItemForOverlay}\n shrink={isHoveringNewGroupDropZone}\n />\n ) : null}\n </DragOverlay>\n </DndContext>\n\n {!performingSearch && adminGroupData && (\n <NavigationGroup\n group={adminGroupData.name}\n collapsed={isGroupCollapsed(adminGroupData.name)}\n onToggleCollapsed={() => toggleGroupCollapsed(adminGroupData.name)}\n >\n <div className=\"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-4 \">\n {adminGroupData.entries.map((entry) => (\n <ResolvedCollectionCard\n key={entry.url}\n {...entry}\n onClick={() => {\n let event: AnalyticsEvent =\n \"unmapped_event\";\n if (entry.type === \"collection\")\n event =\n \"home_navigate_to_collection\";\n else if (entry.type === \"view\")\n event = \"home_navigate_to_view\";\n else if (entry.type === \"admin\")\n event =\n \"home_navigate_to_admin_view\";\n\n context.analyticsController?.onAnalyticsEvent?.(\n event,\n { path: entry.slug }\n );\n }}\n />\n ))}\n </div>\n </NavigationGroup>\n )}\n\n {sections && sections.map((section) => (\n <NavigationGroup\n key={section.key}\n group={section.title}\n >\n {section.children}\n </NavigationGroup>\n ))}\n\n {additionalPluginChildrenEnd}\n {additionalChildrenEnd}\n </Container>\n\n {dialogOpenForGroup && (\n <RenameGroupDialog\n open\n initialName={dialogOpenForGroup}\n existingGroupNames={items\n .map((g) => g.name)\n .filter((n) => n !== dialogOpenForGroup)}\n onClose={handleDialogClose}\n onRename={(newName) => {\n handleRenameGroup(dialogOpenForGroup, newName);\n }}\n />\n )}\n </div>\n );\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;AA6BA,IAAa,qBAAqB;AAClC,IAAa,mBAAmB;AAEhC,SAAgB,gBAAgB,EAC5B,mBACA,yBACA,uBACA,UACA,gBAOD;CAEC,MAAM,UAAU,gBAAgB;CAChC,MAAM,EAAE,8BAA8B;CACtC,MAAM,0BAA0B,2BAA2B;CAC3D,MAAM,sBAAsB,uBAAuB;CACnD,MAAM,WAAW,kBAAkB;CAEnC,MAAM,EAAE,kBAAkB;CAC1B,MAAM,yBAAyB,qBAAqB,2BAA2B,qBAAqB;CACpG,MAAM,cAAc,yBAAyB;CAC7C,MAAM,EAAE,MAAM,eAAe;CAE7B,gBAA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AAI,QACA;QACJ,IAAI,MAAM,SAAS,cACf,QACI;aACH,IAAI,MAAM,SAAS,QACpB,QAAQ;aACP,IAAI,MAAM,SAAS,SACpB,QACI;QAER,QAAQ,qBAAqB,mBACzB,OACA,EAAE,MAAM,MAAM,KAAK,CACvB;OACJ;MACH,GAnBQ,MAAM,GAmBd,CACJ;KACA,CAAA;IACQ,CAAA;IAGpB,YAAY,SAAS,KAAK,YACvB,oBAAC,iBAAD;KAEI,OAAO,QAAQ;eAEd,QAAQ;IACI,GAJR,QAAQ,GAIA,CACpB;IAEA;IACA;GACM;MAEV,sBACG,oBAAC,mBAAD;GACI,MAAA;GACA,aAAa;GACb,oBAAoB,MACf,KAAK,MAAM,EAAE,IAAI,CAAC,CAClB,QAAQ,MAAM,MAAM,kBAAkB;GAC3C,SAAS;GACT,WAAW,YAAY;IACnB,kBAAkB,oBAAoB,OAAO;GACjD;EACH,CAAA,CAEJ;;AAEb"}
@@ -1,4 +1,5 @@
1
1
  import React from "react";
2
+ import type { Entity } from "@rebasepro/types";
2
3
  import type { AdminCollection } from "@rebasepro/cms-types";
3
4
  import type { EntityFormBindingProps } from "../form/EntityFormBinding.js";
4
5
  import type { OnSavedParams } from "../types/components/EntityFormProps.js";
@@ -115,12 +116,32 @@ export type RecordFormOptions<M extends Record<string, unknown> = Record<string,
115
116
  */
116
117
  export declare function RecordForm<M extends Record<string, unknown> = Record<string, unknown>>(rawProps: RecordFormProps<M>): React.JSX.Element;
117
118
  /**
118
- * @deprecated Renamed {@link RecordForm}, with the same props. It warns once.
119
+ * What {@link EntityFormPanel}'s `onSaved` is called with: {@link OnSavedParams},
120
+ * and the saved record as 0.28 handed it over.
121
+ *
122
+ * @deprecated Use {@link RecordForm}, whose `onSaved` gets {@link OnSavedParams}.
119
123
  * @group Components
120
124
  */
121
- export type EntityFormPanelProps<M extends Record<string, unknown> = Record<string, unknown>> = RecordFormProps<M>;
125
+ export type EntityFormPanelSavedParams = OnSavedParams & {
126
+ /** @deprecated The saved record as an `Entity`: read `row` and `id`. It warns once. */
127
+ entity: Entity<Record<string, unknown>>;
128
+ };
129
+ /**
130
+ * @deprecated Renamed {@link RecordForm}. It also takes 0.28's `entityId`
131
+ * for `id`, and hands `onSaved` the saved record as `entity` beside `row` and
132
+ * `id`. It warns once.
133
+ * @group Components
134
+ */
135
+ export type EntityFormPanelProps<M extends Record<string, unknown> = Record<string, unknown>> = Omit<RecordFormProps<M>, "onSaved"> & {
136
+ /** @deprecated The record to edit is `id`. It warns once. */
137
+ entityId?: string | number;
138
+ /** Called after every successful save, with the saved record. */
139
+ onSaved?: (params: EntityFormPanelSavedParams) => void;
140
+ };
122
141
  /**
123
- * @deprecated Renamed {@link RecordForm}, with the same props. It warns once.
142
+ * @deprecated Renamed {@link RecordForm}. It also takes 0.28's `entityId`
143
+ * for `id`, and hands `onSaved` the saved record as `entity` beside `row` and
144
+ * `id`. It warns once.
124
145
  * @group Components
125
146
  */
126
- export declare function EntityFormPanel<M extends Record<string, unknown> = Record<string, unknown>>(props: RecordFormProps<M>): React.JSX.Element;
147
+ export declare function EntityFormPanel<M extends Record<string, unknown> = Record<string, unknown>>({ entityId, onSaved, ...props }: EntityFormPanelProps<M>): React.JSX.Element;
@@ -184,12 +184,30 @@ function RecordFormInScope({ collection: collectionProp, id: entityId, path: pat
184
184
  });
185
185
  }
186
186
  /**
187
- * @deprecated Renamed {@link RecordForm}, with the same props. It warns once.
187
+ * @deprecated Renamed {@link RecordForm}. It also takes 0.28's `entityId`
188
+ * for `id`, and hands `onSaved` the saved record as `entity` beside `row` and
189
+ * `id`. It warns once.
188
190
  * @group Components
189
191
  */
190
- function EntityFormPanel(props) {
192
+ function EntityFormPanel({ entityId, onSaved, ...props }) {
191
193
  warnDeprecated("EntityFormPanel", "`EntityFormPanel` is now `RecordForm`, with the same props.");
192
- return /* @__PURE__ */ jsx(RecordForm, { ...props });
194
+ if (entityId !== void 0) warnDeprecated("EntityFormPanel.entityId", "`EntityFormPanel`'s `entityId` is `id` now: `<RecordForm id=\"…\"/>`.");
195
+ const onSavedWithEntity = onSaved && ((params) => {
196
+ let entity;
197
+ onSaved({
198
+ ...params,
199
+ get entity() {
200
+ warnDeprecated("EntityFormPanel.onSaved.entity", "`EntityFormPanel`'s `onSaved` hands over the saved record as `row` and `id` now; `entity` is going away.");
201
+ entity ??= entityOfRow(params.row, params.id, params.path, params.collection);
202
+ return entity;
203
+ }
204
+ });
205
+ });
206
+ return /* @__PURE__ */ jsx(RecordForm, {
207
+ ...props,
208
+ id: props.id ?? entityId,
209
+ onSaved: onSavedWithEntity
210
+ });
193
211
  }
194
212
  //#endregion
195
213
  export { EntityFormPanel, RecordForm };