@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
@@ -13,7 +13,7 @@ export type EntityCardBindingProps<M extends Record<string, unknown> = Record<st
13
13
  * own handler needs it: `CardView` hands `renderCard` an
14
14
  * `(e: React.MouseEvent) => void` that reads `e.metaKey` / `e.ctrlKey` and
15
15
  * calls `e.preventDefault()`. That handler used to be passed here through
16
- * `onClick as any` and then invoked with the *entity*, so its modifier
16
+ * a cast of `onClick` to `any` and then invoked with the *entity*, so its modifier
17
17
  * branch read `entity.metaKey` — always undefined — and never ran.
18
18
  */
19
19
  onClick?: (entity: Entity<M>, event?: React.MouseEvent) => void;
@@ -52,7 +52,7 @@ function EntityCardBinding({ entity, collection, onClick, selected, highlighted,
52
52
  className: cls("cursor-pointer overflow-hidden group relative", "transition-all duration-200", "hover:shadow-lg hover:-translate-y-0.5", selected && "ring-2 ring-primary bg-surface-raised", highlighted && !selected && "ring-2 ring-primary/50 bg-surface-card-hover"),
53
53
  onClick: handleClick,
54
54
  children: [imagePlace && /* @__PURE__ */ jsxs("div", {
55
- className: "aspect-[4/3] relative overflow-hidden bg-surface-raised",
55
+ className: "aspect-[4/3] relative overflow-hidden bg-surface-well border-b border-hairline p-3 [&_img]:!object-contain",
56
56
  children: [
57
57
  slots.image ? /* @__PURE__ */ jsx("div", {
58
58
  className: "w-full h-full",
@@ -1 +1 @@
1
- {"version":3,"file":"EntityCardBinding.js","names":[],"sources":["../../../src/components/CollectionViewBinding/EntityCardBinding.tsx"],"sourcesContent":["\nimport React, { useMemo } from \"react\";\nimport { Entity } from \"@rebasepro/types\";\nimport { CollectionSize, AdminCollection } from \"@rebasepro/cms-types\";\nimport {\n Card,\n Checkbox,\n Chip,\n cls,\n Typography\n} from \"@rebasepro/ui\";\nimport { PropertyPreview } from \"../../preview\";\nimport {\n useAuthController,\n useCustomizationController\n} from \"@rebasepro/app\";\nimport { useAnalyticsController, useTranslation } from \"@rebasepro/app\";\nimport { IconForView } from \"@rebasepro/app\";\nimport { useCollectionSlotKeys, useEntitySlots, useImagePlace } from \"./usePreviewSlots\";\nimport { Highlighted } from \"./SearchHighlight\";\nimport { useSearchExplanation, MatchExplanation, fieldLabel } from \"./SearchExplanation\";\nimport { SlotValue, TagChips } from \"./SlotValue\";\n\nexport type EntityCardBindingProps<M extends Record<string, unknown> = Record<string, unknown>> = {\n /** The active search, so a card can mark the hit and say where it was. */\n searchString?: string;\n entity: Entity<M>;\n collection: AdminCollection<M>;\n /**\n * The card was clicked.\n *\n * Carries the originating event as well as the entity, because the grid's\n * own handler needs it: `CardView` hands `renderCard` an\n * `(e: React.MouseEvent) => void` that reads `e.metaKey` / `e.ctrlKey` and\n * calls `e.preventDefault()`. That handler used to be passed here through\n * `onClick as any` and then invoked with the *entity*, so its modifier\n * branch read `entity.metaKey` — always undefined — and never ran.\n */\n onClick?: (entity: Entity<M>, event?: React.MouseEvent) => void;\n selected?: boolean;\n highlighted?: boolean;\n onSelectionChange?: (entity: Entity<M>, selected: boolean) => void;\n selectionEnabled?: boolean;\n /**\n * Size of the card - affects checkbox styling\n */\n size?: CollectionSize;\n /**\n * Draws the record's actions — the collection's `entityActions` with\n * Copy and Delete, placed as a table row places them. The card puts them\n * beside its title; a copy of this card calls it where it wants them.\n */\n renderActions?: (entity: Entity<M>) => React.ReactNode;\n};\n\n/**\n * Card component for displaying a entity in a grid view.\n * Shows thumbnail, title, and preview properties via the shared slot system.\n */\nexport function EntityCardBinding<M extends Record<string, unknown> = Record<string, unknown>>({\n entity,\n collection,\n onClick,\n selected,\n highlighted,\n onSelectionChange,\n selectionEnabled,\n size = \"m\",\n searchString,\n renderActions\n}: EntityCardBindingProps<M>) {\n const { t } = useTranslation();\n const authController = useAuthController();\n const analyticsController = useAnalyticsController();\n const customizationController = useCustomizationController();\n\n const slotKeys = useCollectionSlotKeys(\n collection as AdminCollection<Record<string, unknown>>,\n authController,\n customizationController.propertyConfigs\n );\n\n const slots = useEntitySlots(\n entity as Entity<Record<string, unknown>>,\n collection as AdminCollection<Record<string, unknown>>,\n slotKeys\n );\n const imagePlace = useImagePlace(slotKeys.imageKey);\n\n // Same explanation the list shows, so a reader switching view modes does\n // not lose the reason a card is in front of them.\n const { terms, offSlot } = useSearchExplanation(\n entity,\n collection.properties as Record<string, unknown>,\n [slotKeys.titleKey, slotKeys.subtitleKey],\n searchString\n );\n\n // The event is optional because `Card` activates by keyboard too, calling\n // `onClick?.()` with nothing on Enter/Space. That path is real, and it is\n // why this cannot simply require one.\n const handleClick = (e?: React.MouseEvent) => {\n // Cmd+click (Mac) or Ctrl+click (Windows) toggles selection\n if (e && (e.metaKey || e.ctrlKey) && selectionEnabled) {\n e.preventDefault();\n onSelectionChange?.(entity, !selected);\n return;\n }\n if (onClick) {\n analyticsController.onAnalyticsEvent?.(\"card_view_entity_click\", {\n path: entity.path,\n entityId: entity.id\n });\n onClick(entity, e);\n }\n };\n\n const handleCheckboxClick = (e: React.MouseEvent) => {\n e.stopPropagation();\n };\n\n const handleSelectionChange = (checked: boolean) => {\n onSelectionChange?.(entity, checked);\n };\n\n const checkbox = (\n <div onClick={handleCheckboxClick}>\n <Checkbox\n aria-label={t(\"select_row\", { id: String(entity.id) })}\n checked={selected ?? false}\n onCheckedChange={handleSelectionChange}\n size={size === \"xs\" ? \"smallest\" : \"small\"}\n />\n </div>\n );\n\n return (\n <Card\n className={cls(\n \"cursor-pointer overflow-hidden group relative\",\n \"transition-all duration-200\",\n \"hover:shadow-lg hover:-translate-y-0.5\",\n selected && \"ring-2 ring-primary bg-surface-raised\",\n highlighted && !selected && \"ring-2 ring-primary/50 bg-surface-card-hover\"\n )}\n onClick={handleClick}\n >\n {/* Thumbnail area — image slot. Where `fields` leaves every image\n out there is none, and the checkbox goes beside the title. */}\n {imagePlace && (\n <div className=\"aspect-[4/3] relative overflow-hidden bg-surface-raised\">\n {slots.image ? (\n <div className=\"w-full h-full\">\n <SlotValue slot={slots.image} size=\"medium\" fill={true}/>\n </div>\n ) : (\n <div className=\"w-full h-full flex items-center justify-center\">\n <IconForView\n collectionOrView={collection}\n color=\"disabled\"\n />\n </div>\n )}\n\n {/* Hover overlay */}\n <div className={cls(\n \"absolute inset-0 bg-white/0 group-hover:bg-white/[0.06]\",\n \"transition-colors duration-200\"\n )}/>\n\n {selectionEnabled && (\n <div className={cls(\"absolute\", size === \"xs\" || size === \"s\" ? \"top-1 left-1\" : \"top-2 left-2\")}>\n {checkbox}\n </div>\n )}\n </div>\n )}\n\n {/* Content area */}\n <div className=\"p-3\">\n {/* No id line here.\n A card used to print the row id above its title, always —\n a truncated uuid (`isId: \"uuid\"` is the default) too short\n to copy and not what a card is read for. The list row and\n the board card show an id only when nothing else names the\n record; the card was the one surface that showed it even\n when it had a title, and the id is still the fallback below\n for a record that has none. The table's ID column, which is\n full width, copyable and governed by\n `hideIdFromCollection`, is where an id is actually read. */}\n\n {/* Title slot, and the record's actions beside it */}\n <div className=\"flex items-start gap-1\">\n {selectionEnabled && !imagePlace && checkbox}\n <div className=\"flex-1 min-w-0 truncate my-1 text-sm font-medium min-h-[20px]\">\n {slots.title ? (\n terms.length > 0 && typeof slots.title.value === \"string\"\n ? <Highlighted text={slots.title.value} terms={terms}/>\n : <SlotValue slot={slots.title} size=\"small\"/>\n ) : (\n <Typography variant=\"body2\" className=\"text-surface-500\">\n {entity.id}\n </Typography>\n )}\n </div>\n {renderActions?.(entity)}\n </div>\n\n {/* Subtitle slot — or, while searching, where the hit was. A\n card whose match is in a field it does not show looks as\n arbitrary as a list row does. */}\n {offSlot ? (\n <MatchExplanation\n match={offSlot}\n label={fieldLabel(collection.properties as Record<string, unknown>, offSlot.field)}\n />\n ) : slots.subtitle && (\n <div className=\"line-clamp-3 [&_div]:line-clamp-3 text-xs text-surface-600 dark:text-surface-400 [&_p]:!my-1 [&_p:first-child]:!mt-0 [&_p:last-child]:!mb-0\">\n {terms.length > 0 && typeof slots.subtitle.value === \"string\"\n ? <Highlighted text={slots.subtitle.value} terms={terms}/>\n : <SlotValue slot={slots.subtitle} size=\"small\"/>}\n </div>\n )}\n\n {/* Relation chips slot */}\n {slots.relations.length > 0 && (\n <div className=\"flex items-center gap-1 mt-1 overflow-hidden max-w-full flex-wrap\">\n {slots.relations.map((rel) => (\n rel.items.map((item) => (\n <Chip\n key={`${rel.propertyKey}-${item.id}`}\n size=\"smallest\"\n colorScheme={rel.colorScheme}\n className=\"!text-[10px] !leading-tight !py-0 shrink-0 max-w-[100px] truncate\"\n >\n {item.displayName}\n </Chip>\n ))\n ))}\n {slots.relations.some(r => r.totalCount > r.items.length) && (\n <span className=\"text-[10px] text-surface-400 dark:text-surface-500 shrink-0\">\n +{slots.relations.reduce((acc, r) => acc + Math.max(0, r.totalCount - r.items.length), 0)}\n </span>\n )}\n </div>\n )}\n\n {/* Status + tags slot — \"free chips beside the status\" */}\n {(slots.status || slots.tags) && (\n <div className=\"flex items-center gap-1 mt-1 flex-wrap\">\n {slots.status && <SlotValue slot={slots.status} size=\"small\"/>}\n {slots.tags && <TagChips slot={slots.tags}/>}\n </div>\n )}\n\n {/* Date slot — a card is a list row with the image on top, and the\n row has always shown it. It was the one slot the card resolved\n and never rendered. */}\n {slots.date && (\n <div className=\"mt-1 text-[10px] text-surface-500 dark:text-surface-400\">\n {slots.date.formatted}\n </div>\n )}\n </div>\n </Card>\n );\n}\n"],"mappings":";;;;;;;;;;;;;AA2DA,SAAgB,kBAA+E,EAC3F,QACA,YACA,SACA,UACA,aACA,mBACA,kBACA,OAAO,KACP,cACA,iBAC0B;CAC1B,MAAM,EAAE,MAAM,eAAe;CAC7B,MAAM,iBAAiB,kBAAkB;CACzC,MAAM,sBAAsB,uBAAuB;CAGnD,MAAM,WAAW,sBACb,YACA,gBAJ4B,2BAK5B,CAAA,CAAwB,eAC5B;CAEA,MAAM,QAAQ,eACV,QACA,YACA,QACJ;CACA,MAAM,aAAa,cAAc,SAAS,QAAQ;CAIlD,MAAM,EAAE,OAAO,YAAY,qBACvB,QACA,WAAW,YACX,CAAC,SAAS,UAAU,SAAS,WAAW,GACxC,YACJ;CAKA,MAAM,eAAe,MAAyB;EAE1C,IAAI,MAAM,EAAE,WAAW,EAAE,YAAY,kBAAkB;GACnD,EAAE,eAAe;GACjB,oBAAoB,QAAQ,CAAC,QAAQ;GACrC;EACJ;EACA,IAAI,SAAS;GACT,oBAAoB,mBAAmB,0BAA0B;IAC7D,MAAM,OAAO;IACb,UAAU,OAAO;GACrB,CAAC;GACD,QAAQ,QAAQ,CAAC;EACrB;CACJ;CAEA,MAAM,uBAAuB,MAAwB;EACjD,EAAE,gBAAgB;CACtB;CAEA,MAAM,yBAAyB,YAAqB;EAChD,oBAAoB,QAAQ,OAAO;CACvC;CAEA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AW,WAAW,YAAuC,QAAQ,KAAK;IACpF,CAAA,IACD,MAAM,YACN,oBAAC,OAAD;KAAK,WAAU;eACV,MAAM,SAAS,KAAK,OAAO,MAAM,SAAS,UAAU,WAC/C,oBAAC,aAAD;MAAa,MAAM,MAAM,SAAS;MAAc;KAAO,CAAA,IACvD,oBAAC,WAAD;MAAW,MAAM,MAAM;MAAU,MAAK;KAAQ,CAAA;IACnD,CAAA;IAIR,MAAM,UAAU,SAAS,KACtB,qBAAC,OAAD;KAAK,WAAU;eAAf,CACK,MAAM,UAAU,KAAK,QAClB,IAAI,MAAM,KAAK,SACX,oBAAC,MAAD;MAEI,MAAK;MACL,aAAa,IAAI;MACjB,WAAU;gBAET,KAAK;KACJ,GANG,GAAG,IAAI,YAAY,GAAG,KAAK,IAM9B,CACT,CACJ,GACA,MAAM,UAAU,MAAK,MAAK,EAAE,aAAa,EAAE,MAAM,MAAM,KACpD,qBAAC,QAAD;MAAM,WAAU;gBAAhB,CAA8E,KACxE,MAAM,UAAU,QAAQ,KAAK,MAAM,MAAM,KAAK,IAAI,GAAG,EAAE,aAAa,EAAE,MAAM,MAAM,GAAG,CAAC,CACtF;OAET;;KAIP,MAAM,UAAU,MAAM,SACpB,qBAAC,OAAD;KAAK,WAAU;eAAf,CACK,MAAM,UAAU,oBAAC,WAAD;MAAW,MAAM,MAAM;MAAQ,MAAK;KAAQ,CAAA,GAC5D,MAAM,QAAQ,oBAAC,UAAD,EAAU,MAAM,MAAM,KAAM,CAAA,CAC1C;;IAMR,MAAM,QACH,oBAAC,OAAD;KAAK,WAAU;eACV,MAAM,KAAK;IACX,CAAA;GAER;IACH;;AAEd"}
1
+ {"version":3,"file":"EntityCardBinding.js","names":[],"sources":["../../../src/components/CollectionViewBinding/EntityCardBinding.tsx"],"sourcesContent":["\nimport React, { useMemo } from \"react\";\nimport { Entity } from \"@rebasepro/types\";\nimport { CollectionSize, AdminCollection } from \"@rebasepro/cms-types\";\nimport {\n Card,\n Checkbox,\n Chip,\n cls,\n Typography\n} from \"@rebasepro/ui\";\nimport { PropertyPreview } from \"../../preview\";\nimport {\n useAuthController,\n useCustomizationController\n} from \"@rebasepro/app\";\nimport { useAnalyticsController, useTranslation } from \"@rebasepro/app\";\nimport { IconForView } from \"@rebasepro/app\";\nimport { useCollectionSlotKeys, useEntitySlots, useImagePlace } from \"./usePreviewSlots\";\nimport { Highlighted } from \"./SearchHighlight\";\nimport { useSearchExplanation, MatchExplanation, fieldLabel } from \"./SearchExplanation\";\nimport { SlotValue, TagChips } from \"./SlotValue\";\n\nexport type EntityCardBindingProps<M extends Record<string, unknown> = Record<string, unknown>> = {\n /** The active search, so a card can mark the hit and say where it was. */\n searchString?: string;\n entity: Entity<M>;\n collection: AdminCollection<M>;\n /**\n * The card was clicked.\n *\n * Carries the originating event as well as the entity, because the grid's\n * own handler needs it: `CardView` hands `renderCard` an\n * `(e: React.MouseEvent) => void` that reads `e.metaKey` / `e.ctrlKey` and\n * calls `e.preventDefault()`. That handler used to be passed here through\n * a cast of `onClick` to `any` and then invoked with the *entity*, so its modifier\n * branch read `entity.metaKey` — always undefined — and never ran.\n */\n onClick?: (entity: Entity<M>, event?: React.MouseEvent) => void;\n selected?: boolean;\n highlighted?: boolean;\n onSelectionChange?: (entity: Entity<M>, selected: boolean) => void;\n selectionEnabled?: boolean;\n /**\n * Size of the card - affects checkbox styling\n */\n size?: CollectionSize;\n /**\n * Draws the record's actions — the collection's `entityActions` with\n * Copy and Delete, placed as a table row places them. The card puts them\n * beside its title; a copy of this card calls it where it wants them.\n */\n renderActions?: (entity: Entity<M>) => React.ReactNode;\n};\n\n/**\n * Card component for displaying a entity in a grid view.\n * Shows thumbnail, title, and preview properties via the shared slot system.\n */\nexport function EntityCardBinding<M extends Record<string, unknown> = Record<string, unknown>>({\n entity,\n collection,\n onClick,\n selected,\n highlighted,\n onSelectionChange,\n selectionEnabled,\n size = \"m\",\n searchString,\n renderActions\n}: EntityCardBindingProps<M>) {\n const { t } = useTranslation();\n const authController = useAuthController();\n const analyticsController = useAnalyticsController();\n const customizationController = useCustomizationController();\n\n const slotKeys = useCollectionSlotKeys(\n collection as AdminCollection<Record<string, unknown>>,\n authController,\n customizationController.propertyConfigs\n );\n\n const slots = useEntitySlots(\n entity as Entity<Record<string, unknown>>,\n collection as AdminCollection<Record<string, unknown>>,\n slotKeys\n );\n const imagePlace = useImagePlace(slotKeys.imageKey);\n\n // Same explanation the list shows, so a reader switching view modes does\n // not lose the reason a card is in front of them.\n const { terms, offSlot } = useSearchExplanation(\n entity,\n collection.properties as Record<string, unknown>,\n [slotKeys.titleKey, slotKeys.subtitleKey],\n searchString\n );\n\n // The event is optional because `Card` activates by keyboard too, calling\n // `onClick?.()` with nothing on Enter/Space. That path is real, and it is\n // why this cannot simply require one.\n const handleClick = (e?: React.MouseEvent) => {\n // Cmd+click (Mac) or Ctrl+click (Windows) toggles selection\n if (e && (e.metaKey || e.ctrlKey) && selectionEnabled) {\n e.preventDefault();\n onSelectionChange?.(entity, !selected);\n return;\n }\n if (onClick) {\n analyticsController.onAnalyticsEvent?.(\"card_view_entity_click\", {\n path: entity.path,\n entityId: entity.id\n });\n onClick(entity, e);\n }\n };\n\n const handleCheckboxClick = (e: React.MouseEvent) => {\n e.stopPropagation();\n };\n\n const handleSelectionChange = (checked: boolean) => {\n onSelectionChange?.(entity, checked);\n };\n\n const checkbox = (\n <div onClick={handleCheckboxClick}>\n <Checkbox\n aria-label={t(\"select_row\", { id: String(entity.id) })}\n checked={selected ?? false}\n onCheckedChange={handleSelectionChange}\n size={size === \"xs\" ? \"smallest\" : \"small\"}\n />\n </div>\n );\n\n return (\n <Card\n className={cls(\n \"cursor-pointer overflow-hidden group relative\",\n \"transition-all duration-200\",\n \"hover:shadow-lg hover:-translate-y-0.5\",\n selected && \"ring-2 ring-primary bg-surface-raised\",\n highlighted && !selected && \"ring-2 ring-primary/50 bg-surface-card-hover\"\n )}\n onClick={handleClick}\n >\n {/* Thumbnail area — image slot. Where `fields` leaves every image\n out there is none, and the checkbox goes beside the title. */}\n {imagePlace && (\n <div className=\"aspect-[4/3] relative overflow-hidden bg-surface-well border-b border-hairline p-3 [&_img]:!object-contain\">\n {slots.image ? (\n <div className=\"w-full h-full\">\n <SlotValue slot={slots.image} size=\"medium\" fill={true}/>\n </div>\n ) : (\n <div className=\"w-full h-full flex items-center justify-center\">\n <IconForView\n collectionOrView={collection}\n color=\"disabled\"\n />\n </div>\n )}\n\n {/* Hover overlay */}\n <div className={cls(\n \"absolute inset-0 bg-white/0 group-hover:bg-white/[0.06]\",\n \"transition-colors duration-200\"\n )}/>\n\n {selectionEnabled && (\n <div className={cls(\"absolute\", size === \"xs\" || size === \"s\" ? \"top-1 left-1\" : \"top-2 left-2\")}>\n {checkbox}\n </div>\n )}\n </div>\n )}\n\n {/* Content area */}\n <div className=\"p-3\">\n {/* No id line here.\n A card used to print the row id above its title, always —\n a truncated uuid (`isId: \"uuid\"` is the default) too short\n to copy and not what a card is read for. The list row and\n the board card show an id only when nothing else names the\n record; the card was the one surface that showed it even\n when it had a title, and the id is still the fallback below\n for a record that has none. The table's ID column, which is\n full width, copyable and governed by\n `hideIdFromCollection`, is where an id is actually read. */}\n\n {/* Title slot, and the record's actions beside it */}\n <div className=\"flex items-start gap-1\">\n {selectionEnabled && !imagePlace && checkbox}\n <div className=\"flex-1 min-w-0 truncate my-1 text-sm font-medium min-h-[20px]\">\n {slots.title ? (\n terms.length > 0 && typeof slots.title.value === \"string\"\n ? <Highlighted text={slots.title.value} terms={terms}/>\n : <SlotValue slot={slots.title} size=\"small\"/>\n ) : (\n <Typography variant=\"body2\" className=\"text-surface-500\">\n {entity.id}\n </Typography>\n )}\n </div>\n {renderActions?.(entity)}\n </div>\n\n {/* Subtitle slot — or, while searching, where the hit was. A\n card whose match is in a field it does not show looks as\n arbitrary as a list row does. */}\n {offSlot ? (\n <MatchExplanation\n match={offSlot}\n label={fieldLabel(collection.properties as Record<string, unknown>, offSlot.field)}\n />\n ) : slots.subtitle && (\n <div className=\"line-clamp-3 [&_div]:line-clamp-3 text-xs text-surface-600 dark:text-surface-400 [&_p]:!my-1 [&_p:first-child]:!mt-0 [&_p:last-child]:!mb-0\">\n {terms.length > 0 && typeof slots.subtitle.value === \"string\"\n ? <Highlighted text={slots.subtitle.value} terms={terms}/>\n : <SlotValue slot={slots.subtitle} size=\"small\"/>}\n </div>\n )}\n\n {/* Relation chips slot */}\n {slots.relations.length > 0 && (\n <div className=\"flex items-center gap-1 mt-1 overflow-hidden max-w-full flex-wrap\">\n {slots.relations.map((rel) => (\n rel.items.map((item) => (\n <Chip\n key={`${rel.propertyKey}-${item.id}`}\n size=\"smallest\"\n colorScheme={rel.colorScheme}\n className=\"!text-[10px] !leading-tight !py-0 shrink-0 max-w-[100px] truncate\"\n >\n {item.displayName}\n </Chip>\n ))\n ))}\n {slots.relations.some(r => r.totalCount > r.items.length) && (\n <span className=\"text-[10px] text-surface-400 dark:text-surface-500 shrink-0\">\n +{slots.relations.reduce((acc, r) => acc + Math.max(0, r.totalCount - r.items.length), 0)}\n </span>\n )}\n </div>\n )}\n\n {/* Status + tags slot — \"free chips beside the status\" */}\n {(slots.status || slots.tags) && (\n <div className=\"flex items-center gap-1 mt-1 flex-wrap\">\n {slots.status && <SlotValue slot={slots.status} size=\"small\"/>}\n {slots.tags && <TagChips slot={slots.tags}/>}\n </div>\n )}\n\n {/* Date slot — a card is a list row with the image on top, and the\n row has always shown it. It was the one slot the card resolved\n and never rendered. */}\n {slots.date && (\n <div className=\"mt-1 text-[10px] text-surface-500 dark:text-surface-400\">\n {slots.date.formatted}\n </div>\n )}\n </div>\n </Card>\n );\n}\n"],"mappings":";;;;;;;;;;;;;AA2DA,SAAgB,kBAA+E,EAC3F,QACA,YACA,SACA,UACA,aACA,mBACA,kBACA,OAAO,KACP,cACA,iBAC0B;CAC1B,MAAM,EAAE,MAAM,eAAe;CAC7B,MAAM,iBAAiB,kBAAkB;CACzC,MAAM,sBAAsB,uBAAuB;CAGnD,MAAM,WAAW,sB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AAM,UAAU,QAAQ,KAAK,MAAM,MAAM,KAAK,IAAI,GAAG,EAAE,aAAa,EAAE,MAAM,MAAM,GAAG,CAAC,CACtF;OAET;;KAIP,MAAM,UAAU,MAAM,SACpB,qBAAC,OAAD;KAAK,WAAU;eAAf,CACK,MAAM,UAAU,oBAAC,WAAD;MAAW,MAAM,MAAM;MAAQ,MAAK;KAAQ,CAAA,GAC5D,MAAM,QAAQ,oBAAC,UAAD,EAAU,MAAM,MAAM,KAAM,CAAA,CAC1C;;IAMR,MAAM,QACH,oBAAC,OAAD;KAAK,WAAU;eACV,MAAM,KAAK;IACX,CAAA;GAER;IACH;;AAEd"}
@@ -1 +1 @@
1
- {"version":3,"file":"SlotValue.js","names":[],"sources":["../../../src/components/CollectionViewBinding/SlotValue.tsx"],"sourcesContent":["import React from \"react\";\nimport type { PreviewSize } from \"../../types/components/PropertyPreviewProps\";\nimport { PropertyPreview } from \"../../preview\";\nimport { StorageThumbnail } from \"../../preview/components/StorageThumbnail\";\nimport { UrlComponentPreview } from \"../../preview/components/UrlComponentPreview\";\nimport { Chip } from \"@rebasepro/ui\";\nimport type { PreviewSlot } from \"./usePreviewSlots\";\n\nexport interface SlotValueProps {\n slot: PreviewSlot | undefined;\n size: PreviewSize;\n /**\n * Relations and references render as one line of linked text rather than as\n * a card. Defaults to true: a slot is a line in a row or a card, and a\n * relation that renders its own bordered card there — with its own id line\n * and its own side-panel button — is a card inside a card.\n *\n * Pass `false` only for a slot with room for one, which in practice is\n * none of them.\n */\n textOnly?: boolean;\n /** Images only: fill the container rather than fitting inside it. */\n fill?: boolean;\n}\n\n/**\n * One display slot, rendered.\n *\n * A slot's value arrives one of two ways and they cannot be rendered the same:\n *\n * - **From a property** — render it with that property's own preview, so an\n * enum status keeps its colour, a date keeps its format and a storage path\n * becomes a thumbnail. This is why a declared path beats a resolver whenever\n * the value is actually on the record.\n * - **From a resolver** — there is no property, because the value was computed\n * or fetched. All that can be said about it is that it is text.\n *\n * The branch lives here, once, rather than at each of the fourteen places the\n * list row, the card and the board card render a slot. That count is the reason:\n * the last time a rule like this was inlined per call site, it drifted into\n * seven versions.\n */\nexport function SlotValue({ slot, size, textOnly = true, fill }: SlotValueProps) {\n\n if (!slot || slot.value === undefined || slot.value === null) return null;\n\n if (!slot.property || !slot.propertyKey) {\n // A computed image is still an image. \"There is no property, so all that\n // can be said about it is that it is text\" holds for a title and fails\n // here: `display.image` accepts \"a storage path or a URL … so a resolver\n // may return either\", and both used to be printed as their own string\n // inside the image frame.\n if (slot.role === \"image\" && typeof slot.value === \"string\" && slot.value.trim()) {\n return <ComputedImage value={slot.value.trim()} size={size} fill={fill}/>;\n }\n\n // Computed. Arrays (a `tags` resolver) join rather than rendering as\n // \"[object Object]\" via String().\n const text = Array.isArray(slot.value)\n ? slot.value.map(item => String(item)).join(\", \")\n : String(slot.value);\n return <>{text}</>;\n }\n\n return <PropertyPreview\n propertyKey={slot.propertyKey}\n value={slot.value as never}\n property={slot.property}\n size={size}\n textOnly={textOnly}\n fill={fill}/>;\n}\n\n/**\n * The `tags` slot, as chips beside the status.\n *\n * Honours both arms the same way the rest of the file does. A declared **path**\n * goes through {@link SlotValue}, so an array of enum values keeps its own\n * colours — that is the stated advantage of naming a property. A **resolver**\n * returns bare strings with no property to render them as, so they become plain\n * chips; a single string is accepted as one tag, which the role's type documents.\n *\n * Lives here rather than in the list, the card and the board card because that is\n * three copies of the same decision, and this file exists to hold exactly one.\n */\nexport function TagChips({ slot, max = 4 }: { slot: PreviewSlot, max?: number }) {\n\n if (slot.property && slot.propertyKey) {\n return <SlotValue slot={slot} size=\"small\"/>;\n }\n\n const values = (Array.isArray(slot.value) ? slot.value : [slot.value])\n .filter(item => item !== undefined && item !== null && String(item).trim() !== \"\")\n .map(item => String(item));\n\n if (values.length === 0) return null;\n\n const shown = values.slice(0, max);\n const hidden = values.length - shown.length;\n\n return <>\n {shown.map(value => (\n <Chip key={value}\n size=\"smallest\"\n className=\"!text-[10px] !leading-tight !py-0 shrink-0 max-w-[100px] truncate\">\n {value}\n </Chip>\n ))}\n {hidden > 0 && (\n <span className=\"text-[10px] text-surface-400 dark:text-surface-500 shrink-0\">+{hidden}</span>\n )}\n </>;\n}\n\n/**\n * Whether a computed image string can be fetched as-is, or has to be resolved\n * through storage first.\n *\n * Exported because it is the whole decision: rendering either branch needs a\n * provider (a storage source, a DOM), and the thing worth pinning is which\n * branch a given string takes. `//host/x` is protocol-relative and equally\n * fetchable; `data:` and `blob:` are already the bytes.\n */\nexport function isFetchableImageUrl(value: string): boolean {\n return /^(https?:)?\\/\\//i.test(value) || /^(data|blob):/i.test(value);\n}\n\n/**\n * A string a resolver returned for the `image` role, rendered as a picture.\n *\n * Two things can arrive here and they need different handling, which is the whole\n * reason a property-path image is preferable: a storage property knows which\n * backend holds it, and a bare string does not.\n *\n * - An **absolute URL** is already fetchable. Rendering it through the storage\n * layer would ask a bucket to sign a path that was never in it.\n * - Anything else is read as a **storage path** on the default source, which is\n * the only source a value with no property can be attributed to. A resolver\n * pointing at a named source should name the property instead.\n */\nfunction ComputedImage({ value, size, fill }: { value: string, size: PreviewSize, fill?: boolean }) {\n const isAbsolute = isFetchableImageUrl(value);\n\n if (isAbsolute) {\n return <UrlComponentPreview previewType=\"image\"\n url={value}\n size={size}\n fill={fill}\n hint={value}/>;\n }\n\n return <StorageThumbnail storagePathOrDownloadUrl={value}\n storeUrl={false}\n size={size}\n fill={fill}/>;\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;AA0CA,SAAgB,UAAU,EAAE,MAAM,MAAM,WAAW,MAAM,QAAwB;CAE7E,IAAI,CAAC,QAAQ,KAAK,UAAU,KAAA,KAAa,KAAK,UAAU,MAAM,OAAO;CAErE,IAAI,CAAC,KAAK,YAAY,CAAC,KAAK,aAAa;EAMrC,IAAI,KAAK,SAAS,WAAW,OAAO,KAAK,UAAU,YAAY,KAAK,MAAM,KAAK,GAC3E,OAAO,oBAAC,eAAD;GAAe,OAAO,KAAK,MAAM,KAAK;G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qBAAD;EAAqB,aAAY;EACpC,KAAK;EACC;EACA;EACN,MAAM;CAAO,CAAA;CAGrB,OAAO,oBAAC,kBAAD;EAAkB,0BAA0B;EAC/C,UAAU;EACJ;EACA;CAAM,CAAA;AACpB"}
1
+ {"version":3,"file":"SlotValue.js","names":[],"sources":["../../../src/components/CollectionViewBinding/SlotValue.tsx"],"sourcesContent":["import React from \"react\";\nimport type { PreviewSize } from \"../../types/components/PropertyPreviewProps\";\nimport { PropertyPreview } from \"../../preview\";\nimport { StorageThumbnail } from \"../../preview/components/StorageThumbnail\";\nimport { UrlComponentPreview } from \"../../preview/components/UrlComponentPreview\";\nimport { Chip } from \"@rebasepro/ui\";\nimport type { PreviewSlot } from \"./usePreviewSlots\";\n\nexport interface SlotValueProps {\n slot: PreviewSlot | undefined;\n size: PreviewSize;\n /**\n * Relations and references render as one line of linked text rather than as\n * a card. Defaults to true: a slot is a line in a row or a card, and a\n * relation that renders its own bordered card there — with its own id line\n * and its own side-panel button — is a card inside a card.\n *\n * Pass `false` only for a slot with room for one, which in practice is\n * none of them.\n */\n textOnly?: boolean;\n /** Images only: fill the container rather than fitting inside it. */\n fill?: boolean;\n}\n\n/**\n * One display slot, rendered.\n *\n * A slot's value arrives one of two ways and they cannot be rendered the same:\n *\n * - **From a property** — render it with that property's own preview, so an\n * enum status keeps its colour, a date keeps its format and a storage path\n * becomes a thumbnail. This is why a declared path beats a resolver whenever\n * the value is actually on the record.\n * - **From a resolver** — there is no property, because the value was computed\n * or fetched. All that can be said about it is that it is text.\n *\n * The branch lives here, once, rather than at each of the fourteen places the\n * list row, the card and the board card render a slot. That count is the reason:\n * the last time a rule like this was inlined per call site, it drifted into\n * seven versions.\n */\nexport function SlotValue({ slot, size, textOnly = true, fill }: SlotValueProps) {\n\n if (!slot || slot.value === undefined || slot.value === null) return null;\n\n if (!slot.property || !slot.propertyKey) {\n // A computed image is still an image. \"There is no property, so all that\n // can be said about it is that it is text\" holds for a title and fails\n // here: `display.image` accepts \"a storage path or a URL … so a resolver\n // may return either\", and both used to be printed as their own string\n // inside the image frame.\n if (slot.role === \"image\" && typeof slot.value === \"string\" && slot.value.trim()) {\n return <ComputedImage value={slot.value.trim()} size={size} fill={fill}/>;\n }\n\n // Computed. Arrays (a `tags` resolver) join rather than rendering as\n // \"[object Object]\" via String().\n const text = Array.isArray(slot.value)\n ? slot.value.map(item => String(item)).join(\", \")\n : String(slot.value);\n return <>{text}</>;\n }\n\n return <PropertyPreview\n propertyKey={slot.propertyKey}\n value={slot.value}\n property={slot.property}\n size={size}\n textOnly={textOnly}\n fill={fill}/>;\n}\n\n/**\n * The `tags` slot, as chips beside the status.\n *\n * Honours both arms the same way the rest of the file does. A declared **path**\n * goes through {@link SlotValue}, so an array of enum values keeps its own\n * colours — that is the stated advantage of naming a property. A **resolver**\n * returns bare strings with no property to render them as, so they become plain\n * chips; a single string is accepted as one tag, which the role's type documents.\n *\n * Lives here rather than in the list, the card and the board card because that is\n * three copies of the same decision, and this file exists to hold exactly one.\n */\nexport function TagChips({ slot, max = 4 }: { slot: PreviewSlot, max?: number }) {\n\n if (slot.property && slot.propertyKey) {\n return <SlotValue slot={slot} size=\"small\"/>;\n }\n\n const values = (Array.isArray(slot.value) ? slot.value : [slot.value])\n .filter(item => item !== undefined && item !== null && String(item).trim() !== \"\")\n .map(item => String(item));\n\n if (values.length === 0) return null;\n\n const shown = values.slice(0, max);\n const hidden = values.length - shown.length;\n\n return <>\n {shown.map(value => (\n <Chip key={value}\n size=\"smallest\"\n className=\"!text-[10px] !leading-tight !py-0 shrink-0 max-w-[100px] truncate\">\n {value}\n </Chip>\n ))}\n {hidden > 0 && (\n <span className=\"text-[10px] text-surface-400 dark:text-surface-500 shrink-0\">+{hidden}</span>\n )}\n </>;\n}\n\n/**\n * Whether a computed image string can be fetched as-is, or has to be resolved\n * through storage first.\n *\n * Exported because it is the whole decision: rendering either branch needs a\n * provider (a storage source, a DOM), and the thing worth pinning is which\n * branch a given string takes. `//host/x` is protocol-relative and equally\n * fetchable; `data:` and `blob:` are already the bytes.\n */\nexport function isFetchableImageUrl(value: string): boolean {\n return /^(https?:)?\\/\\//i.test(value) || /^(data|blob):/i.test(value);\n}\n\n/**\n * A string a resolver returned for the `image` role, rendered as a picture.\n *\n * Two things can arrive here and they need different handling, which is the whole\n * reason a property-path image is preferable: a storage property knows which\n * backend holds it, and a bare string does not.\n *\n * - An **absolute URL** is already fetchable. Rendering it through the storage\n * layer would ask a bucket to sign a path that was never in it.\n * - Anything else is read as a **storage path** on the default source, which is\n * the only source a value with no property can be attributed to. A resolver\n * pointing at a named source should name the property instead.\n */\nfunction ComputedImage({ value, size, fill }: { value: string, size: PreviewSize, fill?: boolean }) {\n const isAbsolute = isFetchableImageUrl(value);\n\n if (isAbsolute) {\n return <UrlComponentPreview previewType=\"image\"\n url={value}\n size={size}\n fill={fill}\n hint={value}/>;\n }\n\n return <StorageThumbnail storagePathOrDownloadUrl={value}\n storeUrl={false}\n size={size}\n fill={fill}/>;\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;AA0CA,SAAgB,UAAU,EAAE,MAAM,MAAM,WAAW,MAAM,QAAwB;CAE7E,IAAI,CAAC,QAAQ,KAAK,UAAU,KAAA,KAAa,KAAK,UAAU,MAAM,OAAO;CAErE,IAAI,CAAC,KAAK,YAAY,CAAC,KAAK,aAAa;EAMrC,IAAI,KAAK,SAAS,WAAW,OAAO,KAAK,UAAU,YAAY,KAAK,MAAM,KAAK,GAC3E,OAAO,oBAAC,eAAD;GAAe,OAAO,KAAK,MAAM,KAAK;GAAS;GAAY;EAAM,CAAA;EAQ5E,OAAO,oBAAA,UAAA,EAAA,UAHM,MAAM,QAAQ,KAAK,KAAK,IAC/B,KAAK,MAAM,KAAI,SAAQ,OAAO,IAAI,CAAC,CAAC,CAAC,KAAK,IAAI,IAC9C,OAAO,KAAK,KAAK,EACN,CAAA;CACrB;CAEA,OAAO,oBAAC,iBAAD;EACH,aAAa,KAAK;EAClB,OAAO,KAAK;EACZ,UAAU,KAAK;EACT;EACI;EACJ;CAAM,CAAA;AACpB;;;;;;;;;;;;;AAcA,SAAgB,SAAS,EAAE,MAAM,MAAM,KAA0C;CAE7E,IAAI,KAAK,YAAY,KAAK,aACtB,OAAO,oBAAC,WAAD;EAAiB;EAAM,MAAK;CAAQ,CAAA;CAG/C,MAAM,UAAU,MAAM,QAAQ,KAAK,KAAK,IAAI,KAAK,QAAQ,CAAC,KAAK,KAAK,EAAA,CAC/D,QAAO,SAAQ,SAAS,KAAA,KAAa,SAAS,QAAQ,OAAO,IAAI,CAAC,CAAC,KAAK,MAAM,EAAE,CAAC,CACjF,KAAI,SAAQ,OAAO,IAAI,CAAC;CAE7B,IAAI,OAAO,WAAW,GAAG,OAAO;CAEhC,MAAM,QAAQ,OAAO,MAAM,GAAG,GAAG;CACjC,MAAM,SAAS,OAAO,SAAS,MAAM;CAErC,OAAO,qBAAA,UAAA,EAAA,UAAA,CACF,MAAM,KAAI,UACP,oBAAC,MAAD;EACI,MAAK;EACL,WAAU;YACT;CACC,GAJK,KAIL,CACT,GACA,SAAS,KACN,qBAAC,QAAD;EAAM,WAAU;YAAhB,CAA8E,KAAE,MAAa;GAEnG,EAAA,CAAA;AACN;;;;;;;;;;AAWA,SAAgB,oBAAoB,OAAwB;CACxD,OAAO,mBAAmB,KAAK,KAAK,KAAK,iBAAiB,KAAK,KAAK;AACxE;;;;;;;;;;;;;;AAeA,SAAS,cAAc,EAAE,OAAO,MAAM,QAA8D;CAGhG,IAFmB,oBAAoB,KAEnC,GACA,OAAO,oBAAC,qBAAD;EAAqB,aAAY;EACpC,KAAK;EACC;EACA;EACN,MAAM;CAAO,CAAA;CAGrB,OAAO,oBAAC,kBAAD;EAAkB,0BAA0B;EAC/C,UAAU;EACJ;EACA;CAAM,CAAA;AACpB"}
@@ -1,10 +1,15 @@
1
1
  import React from "react";
2
2
  import type { Property, RelationProperty } from "@rebasepro/types";
3
- import type { Entity } from "@rebasepro/types";
3
+ import type { Entity, EntityRelation } from "@rebasepro/types";
4
4
  import type { PropertyConfig, AdminCollection, EntityDisplayRole } from "@rebasepro/cms-types";
5
5
  import { type FormatCollectionDateOptions } from "../../util/format_collection_date.js";
6
6
  import type { AuthController } from "@rebasepro/cms-types";
7
7
  import { ChipColorScheme } from "@rebasepro/ui";
8
+ /** Whether an authored relation yields many rows. Derived from its kind. */
9
+ export declare function relationCardinality(relation: {
10
+ kind?: string;
11
+ cardinality?: string;
12
+ } | undefined): "one" | "many" | undefined;
8
13
  /**
9
14
  * A resolved "slot": what fills one display role for one record.
10
15
  *
@@ -156,6 +161,19 @@ export declare function useCollectionSlotKeys(collection: AdminCollection<Record
156
161
  export declare function resolveEntitySlots(entity: Entity<Record<string, unknown>>, collection: AdminCollection<Record<string, unknown>>, slotKeys: CollectionSlotKeys,
157
162
  /** How the date slot is written: the relative phrases' language, say. */
158
163
  dateOptions?: FormatCollectionDateOptions): EntityPreviewSlots;
164
+ /**
165
+ * Extract a human-readable display name from an eagerly-loaded EntityRelation.
166
+ * Uses the target collection's title property when available, otherwise
167
+ * walks the entity values for the first short string; with neither, the id.
168
+ */
169
+ export declare function resolveRelationDisplayName(relation: EntityRelation | Record<string, unknown>, prop: RelationProperty): string | undefined;
170
+ /**
171
+ * The related row's name from what is already on hand — values loaded with
172
+ * the relation, or the entity cache — and nothing else: no id. A bare
173
+ * foreign key has neither, and its caller fetches the row instead of
174
+ * printing the key as though it were the name.
175
+ */
176
+ export declare function loadedRelationName(relation: EntityRelation | Record<string, unknown>, prop: RelationProperty): string | undefined;
159
177
  /**
160
178
  * The slots for one record, with `admin.display` resolvers applied.
161
179
  *
@@ -229,12 +229,12 @@ function resolveEntitySlots(entity, collection, slotKeys, dateOptions) {
229
229
  } else if (!isMany && val && typeof val === "object") {
230
230
  const obj = val;
231
231
  if ("__type" in obj && obj.__type === "relation" || typeof obj.isEntityRelation === "function" && obj.isEntityRelation()) {
232
- const relation = obj;
233
- const displayName = resolveRelationDisplayName(relation, prop);
232
+ const displayName = resolveRelationDisplayName(obj, prop);
234
233
  totalCount = 1;
235
- if (displayName) items.push({
234
+ const id = obj.id;
235
+ if (displayName && (typeof id === "string" || typeof id === "number")) items.push({
236
236
  displayName,
237
- id: relation.id
237
+ id
238
238
  });
239
239
  }
240
240
  }
@@ -299,9 +299,21 @@ function resolveEntitySlots(entity, collection, slotKeys, dateOptions) {
299
299
  /**
300
300
  * Extract a human-readable display name from an eagerly-loaded EntityRelation.
301
301
  * Uses the target collection's title property when available, otherwise
302
- * walks the entity values for the first short string.
302
+ * walks the entity values for the first short string; with neither, the id.
303
303
  */
304
304
  function resolveRelationDisplayName(relation, prop) {
305
+ const name = loadedRelationName(relation, prop);
306
+ if (name !== void 0) return name;
307
+ const id = "id" in relation ? relation.id : void 0;
308
+ return id !== void 0 ? String(id) : void 0;
309
+ }
310
+ /**
311
+ * The related row's name from what is already on hand — values loaded with
312
+ * the relation, or the entity cache — and nothing else: no id. A bare
313
+ * foreign key has neither, and its caller fetches the row instead of
314
+ * printing the key as though it were the name.
315
+ */
316
+ function loadedRelationName(relation, prop) {
305
317
  const data = "data" in relation ? relation.data : void 0;
306
318
  let targetCollection;
307
319
  try {
@@ -332,7 +344,6 @@ function resolveRelationDisplayName(relation, prop) {
332
344
  }
333
345
  }
334
346
  } catch {}
335
- return id !== void 0 ? String(id) : void 0;
336
347
  }
337
348
  /**
338
349
  * The slots for one record, with `admin.display` resolvers applied.
@@ -400,6 +411,6 @@ function useEntitySlots(entity, collection, slotKeys) {
400
411
  ]);
401
412
  }
402
413
  //#endregion
403
- export { EmptyImagePlaceContext, resolveCollectionSlotKeys, resolveEntitySlots, useCollectionSlotKeys, useEntitySlots, useImagePlace };
414
+ export { EmptyImagePlaceContext, loadedRelationName, relationCardinality, resolveCollectionSlotKeys, resolveEntitySlots, resolveRelationDisplayName, useCollectionSlotKeys, useEntitySlots, useImagePlace };
404
415
 
405
416
  //# sourceMappingURL=usePreviewSlots.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"usePreviewSlots.js","names":[],"sources":["../../../src/components/CollectionViewBinding/usePreviewSlots.ts"],"sourcesContent":["import React, { useMemo } from \"react\";\nimport type { Property, RelationProperty } from \"@rebasepro/types\";\nimport type { Entity, EntityRelation } from \"@rebasepro/types\";\nimport type { PropertyConfig, AdminCollection, EntityDisplayRole } from \"@rebasepro/cms-types\";\nimport { getEntityImagePreviewPropertyKey } from \"@rebasepro/app\";\nimport { getDisplayPropertyKey } from \"@rebasepro/app\";\nimport { getLeadingRelationTitleKey, getTitlePropertyCandidates, looksLikeIdentifierValue } from \"@rebasepro/app\";\nimport { getEntityFromCache } from \"@rebasepro/app\";\nimport { getEntityPreviewKeys } from \"../../util/previews\";\nimport { getValueInPath } from \"@rebasepro/utils\";\nimport { formatCollectionDate, type FormatCollectionDateOptions } from \"../../util/format_collection_date\";\nimport type { AuthController } from \"@rebasepro/cms-types\";\nimport { ChipColorScheme, CHIP_COLORS, CHIP_SEED_KEYS, useUiLabels } from \"@rebasepro/ui\";\nimport { useEntityDisplay } from \"../../hooks/useEntityDisplay\";\n\n/** Whether an authored relation yields many rows. Derived from its kind. */\nfunction relationCardinality(relation: { kind?: string; cardinality?: string } | undefined): \"one\" | \"many\" | undefined {\n if (!relation) return undefined;\n if (relation.kind === \"via\") return relation.cardinality as \"one\" | \"many\" | undefined;\n if (relation.kind === \"hasMany\" || relation.kind === \"manyToMany\") return \"many\";\n if (relation.kind === \"belongsTo\" || relation.kind === \"hasOne\") return \"one\";\n return relation.cardinality as \"one\" | \"many\" | undefined;\n}\n\n\n// ── Slot types ────────────────────────────────────────────────────────\n\n/**\n * A resolved \"slot\": what fills one display role for one record.\n *\n * `property` and `propertyKey` are set when the value was read off the record,\n * and absent when a `display` resolver computed it — a computed title has no\n * column behind it, so there is nothing to render it *as*. Renderers must go\n * through {@link SlotValue}, which makes that choice once: a property renders\n * with its own preview (an enum keeps its coloured chip, a date its format), a\n * computed value renders as text.\n */\nexport interface PreviewSlot {\n property?: Property;\n propertyKey?: string;\n value: unknown;\n /**\n * Which display role this slot fills.\n *\n * Load-bearing for the computed case. Without a property there is nothing to\n * infer from, and \"render it as text\" is right for a title and wrong for an\n * image: a resolver that returned a URL had that URL printed inside the card's\n * image frame. The role is the one thing that distinguishes them, so it\n * travels with the slot rather than being re-derived at each call site.\n */\n role?: EntityDisplayRole;\n}\n\n/**\n * Date slot extends the base with a pre-formatted string.\n */\nexport interface DatePreviewSlot extends PreviewSlot {\n formatted: string;\n}\n\n/**\n * A single resolved relation chip — one item to render as a compact chip.\n * For cardinality:\"one\" relations there will be one chip.\n * For cardinality:\"many\" there can be several (capped for layout stability).\n */\nexport interface RelationChipItem {\n /** Human-readable display text for the chip */\n displayName: string;\n /** Relation ID */\n id: string | number;\n}\n\n/**\n * A resolved relation slot — groups all chips for one relation property.\n */\nexport interface RelationChipSlot {\n /** The relation property definition */\n property: RelationProperty;\n /** The property key on this entity (e.g. \"author\", \"tags\") */\n propertyKey: string;\n /** The relation property's user-facing name (e.g. \"Author\", \"Tags\") */\n label: string;\n /** Resolved chip items (display names extracted from eagerly-loaded data) */\n items: RelationChipItem[];\n /** Total count (for \"many\" relations that exceed the chip cap) */\n totalCount: number;\n /** Deterministic color for this relation property */\n colorScheme: ChipColorScheme;\n}\n\n/**\n * Fixed set of preview slots resolved from any entity + collection.\n *\n * Every view (list, card, board) consumes these same slots and decides\n * which ones to render and how. This eliminates duplicated inference\n * logic across view components.\n */\nexport interface EntityPreviewSlots {\n /** MEDIA — image thumbnail or `undefined` (view falls back to icon) */\n image: PreviewSlot | undefined;\n /** PRIMARY — title / name field */\n title: PreviewSlot | undefined;\n /** SECONDARY — subtitle or short description (first non-title text field) */\n subtitle: PreviewSlot | undefined;\n /** RELATIONS — compact chips for all relation properties (one + many) */\n relations: RelationChipSlot[];\n /** STATUS — enum chip (first enum field that isn't the title) */\n status: PreviewSlot | undefined;\n /** META — date / timestamp */\n date: DatePreviewSlot | undefined;\n /**\n * TAGS — free chips beside the status.\n *\n * Declared only. Every other role has an inference ladder behind it, and\n * this one deliberately does not: there is no \"first enum\" or \"looks like a\n * timestamp\" that means *labels*, so guessing would scatter arbitrary chips\n * across every row of every panel that never asked for them.\n *\n * The role existed on `EntityDisplay` and in `useEntityDisplay` before this\n * field did, which is why a declared `display.tags` resolved correctly and\n * then had nowhere to go.\n */\n tags: PreviewSlot | undefined;\n /** Entity ID (always available) */\n entityId: string | number;\n}\n\n// ── Collection-level slot resolution (entity-independent) ─────────────\n\n/**\n * Resolved property keys per slot. This is the expensive part (walks\n * all properties) so we memoize it at the collection level, not per entity.\n */\nexport interface CollectionSlotKeys {\n titleKey: string | undefined;\n /** Every property that could act as the title, best first (see `getTitlePropertyCandidates`) */\n titleKeyCandidates: string[];\n imageKey: string | undefined;\n subtitleKey: string | undefined;\n relationKeys: string[];\n statusKey: string | undefined;\n dateKey: string | undefined;\n /** Declared only — see {@link EntityPreviewSlots.tags}. */\n tagsKey: string | undefined;\n}\n\n/**\n * Resolve which property key fills each slot for a given collection.\n * Pure function — call inside `useMemo`.\n */\nexport function resolveCollectionSlotKeys(\n collection: AdminCollection<Record<string, unknown>>,\n authController: AuthController,\n propertyConfigs: Record<string, PropertyConfig>\n): CollectionSlotKeys {\n // One row per entity: when the collection leads with a relation and holds no\n // name of its own, that relation *is* what the row is called. See\n // `getLeadingRelationTitleKey` — the general ranking keeps relations last,\n // which is right for a detail header but leaves a junction row titleless.\n const rankedCandidates = getTitlePropertyCandidates(collection);\n const leadingRelationKey = getLeadingRelationTitleKey(collection);\n const titleKeyCandidates = leadingRelationKey\n ? [leadingRelationKey, ...rankedCandidates.filter(key => key !== leadingRelationKey)]\n : rankedCandidates;\n const titleKey = titleKeyCandidates[0];\n // `getEntityImagePreviewPropertyKey` prefers `display.image` itself, so\n // every caller of it — this, the reference card, the board — agrees.\n const imageKey = getEntityImagePreviewPropertyKey(collection);\n\n // Status: declared, else the first string-enum that isn't the title.\n //\n // Everything below this line is inference — \"the first enum\", \"a key that\n // looks like a timestamp\", \"the longest remaining string\". It is a good\n // guess and it is only a guess, so a collection that states the role wins\n // outright and the ladder is skipped. That is the whole point of\n // `admin.display`: the heuristics stay for the collections that never say\n // anything, and stop overruling the ones that do.\n let statusKey: string | undefined = getDisplayPropertyKey(collection, \"status\");\n\n // 1. Explicitly defined in previewProperties\n if (!statusKey && collection.previewProperties) {\n for (const key of collection.previewProperties) {\n const p = collection.properties[key] as Property | undefined;\n if (p?.type === \"string\" && \"enum\" in p && p.enum && key !== titleKey) {\n statusKey = key;\n break;\n }\n }\n }\n\n // 2. Explicitly defined in propertiesOrder\n if (!statusKey && collection.propertiesOrder) {\n for (const key of collection.propertiesOrder) {\n if (typeof key === \"string\" && !key.startsWith(\"subcollection:\")) {\n const p = collection.properties[key] as Property | undefined;\n if (p?.type === \"string\" && \"enum\" in p && p.enum && key !== titleKey) {\n statusKey = key;\n break;\n }\n }\n }\n }\n\n // 3. Default automatic inference\n if (!statusKey) {\n for (const [key, prop] of Object.entries(collection.properties)) {\n const p = prop as Property;\n if (p.type === \"string\" && \"enum\" in p && p.enum && key !== titleKey) {\n statusKey = key;\n break;\n }\n }\n }\n\n // Date: declared, else a well-known timestamp field, else any date\n let dateKey: string | undefined = getDisplayPropertyKey(collection, \"date\");\n const dateCandidates = [\"updated_at\", \"updatedAt\", \"modified_at\", \"modifiedAt\", \"created_at\", \"createdAt\"];\n if (!dateKey) {\n for (const candidate of dateCandidates) {\n if (collection.properties[candidate]) {\n dateKey = candidate;\n break;\n }\n }\n }\n if (!dateKey) {\n for (const [key, prop] of Object.entries(collection.properties)) {\n const p = prop as Property;\n if (p.type === \"date\") {\n dateKey = key;\n break;\n }\n }\n }\n\n // Relations: collect relation property keys for chip rendering.\n // When propertiesOrder is explicitly set, skip this — relations will\n // be shown in the developer-defined order, not as separate chips.\n const hasExplicitOrder = !!(collection.propertiesOrder as string[] | undefined);\n const relationKeys: string[] = [];\n if (!hasExplicitOrder) {\n for (const [key, prop] of Object.entries(collection.properties)) {\n const p = prop as Property;\n // The relation filling the title slot is already the row's headline;\n // repeating it as a chip below says the same thing twice.\n if (p.type === \"relation\" && key !== titleKey) {\n relationKeys.push(key);\n }\n }\n }\n\n // Subtitle: first preview key that isn't title/image/status/date/id.\n // When propertiesOrder is not set, also exclude relation keys (they render as chips).\n // Prefer string fields (especially multiline/description-like) over numbers.\n const excludeKeys = new Set([titleKey, imageKey, statusKey, dateKey, ...relationKeys]);\n const previewKeys = getEntityPreviewKeys(authController, collection, propertyConfigs, undefined, 10)\n .filter(k => !excludeKeys.has(k) && k !== \"id\");\n\n // When propertiesOrder is set, respect the developer-defined order (no re-sorting).\n // When not set, sort: strings first (prefer multiline → good description candidate).\n const sortedPreviewKeys = hasExplicitOrder\n ? previewKeys\n : [...previewKeys].sort((a, b) => {\n const propA = collection.properties[a] as Property | undefined;\n const propB = collection.properties[b] as Property | undefined;\n const scoreA = propA?.type === \"string\" ? (propA.admin?.multiline ? 2 : 1) : 0;\n const scoreB = propB?.type === \"string\" ? (propB.admin?.multiline ? 2 : 1) : 0;\n return scoreB - scoreA;\n });\n const subtitleKey = getDisplayPropertyKey(collection, \"subtitle\")\n ?? (sortedPreviewKeys.length > 0 ? sortedPreviewKeys[0] : undefined);\n\n return { titleKey,\ntitleKeyCandidates,\nimageKey,\nsubtitleKey,\nrelationKeys,\nstatusKey,\ndateKey,\ntagsKey: getDisplayPropertyKey(collection, \"tags\") };\n}\n\n// ── Image place ───────────────────────────────────────────────────────\n\n/**\n * Whether a list row, a card or a kanban card keeps its image place where no\n * property fills it, drawing the collection's icon there. A view given\n * `fields` that leaves every image out keeps none.\n *\n * @internal Provided by the collection view; read through {@link useImagePlace}.\n */\nexport const EmptyImagePlaceContext = React.createContext(true);\n\n/**\n * Whether the rows of the collection view around draw an image place: a\n * property fills it (`imageKey`, from {@link useCollectionSlotKeys}), or the\n * view keeps an empty one with the collection's icon. A view given `fields`\n * that leaves every image out keeps none, so the place takes no room — a copy\n * of a card or a row honours `fields` by drawing its thumbnail only when this\n * says so.\n *\n * @group Components\n */\nexport function useImagePlace(imageKey: string | undefined): boolean {\n return React.useContext(EmptyImagePlaceContext) || imageKey !== undefined;\n}\n\n// ── Image unwrapping helper ───────────────────────────────────────────\n\n/**\n * Unwrap image property + value from potential array-of-images.\n * Returns `{ property, value }` where property is the *inner* property\n * and value is the first element (for arrays) or the raw value.\n */\nfunction resolveImageSlot(\n collection: AdminCollection<Record<string, unknown>>,\n imageKey: string,\n entity: Entity<Record<string, unknown>>\n): PreviewSlot | undefined {\n const imageProperty = collection.properties[imageKey];\n if (!imageProperty) return undefined;\n\n const ofProp = \"of\" in imageProperty ? imageProperty.of : undefined;\n const resolvedProperty = ofProp\n ? (Array.isArray(ofProp) ? ofProp[0] : ofProp)\n : imageProperty;\n\n const rawValue = getValueInPath(entity.values, imageKey);\n const resolvedValue = ofProp\n ? (((rawValue as unknown[]) ?? []).length > 0 ? (rawValue as unknown[])[0] : undefined)\n : rawValue;\n\n if (resolvedValue === undefined || resolvedValue === null) return undefined;\n\n return {\n role: \"image\",\n property: resolvedProperty as Property,\n propertyKey: imageKey,\n value: resolvedValue\n };\n}\n\n// ── Title resolution (entity-level) ───────────────────────────────────\n\n/**\n * Walk the collection's ranked title candidates and return the first one that\n * holds something a person can read for this entity. Candidates are already\n * ordered and free of identifier properties; this only rejects values —\n * empties, and strings that turn out to be an id at runtime.\n */\nfunction resolveEntityTitleKey(\n entity: Entity<Record<string, unknown>>,\n candidates: string[]\n): string | undefined {\n for (const key of candidates) {\n const value = getValueInPath(entity.values, key);\n if (value === undefined || value === null || value === \"\") continue;\n if (typeof value === \"string\") {\n if (looksLikeIdentifierValue(value)) continue;\n if (value === String(entity.id)) continue;\n }\n return key;\n }\n return candidates[0];\n}\n\n// ── Hook: collection-level slot keys ──────────────────────────────────\n\n/**\n * Resolves which property key fills each preview slot for a collection.\n * Memoized — only recomputes when the collection definition changes.\n *\n * Use this in the parent list/grid component, then pass the result to\n * `resolveEntitySlots` for each entity row.\n */\nexport function useCollectionSlotKeys(\n collection: AdminCollection<Record<string, unknown>>,\n authController: AuthController,\n propertyConfigs: Record<string, PropertyConfig>\n): CollectionSlotKeys {\n return useMemo(\n () => resolveCollectionSlotKeys(collection, authController, propertyConfigs),\n [collection, authController, propertyConfigs]\n );\n}\n\n// ── Pure function: entity-level slot resolution ───────────────────────\n\n/**\n * Resolve concrete slot values for a single entity.\n * This is a pure function (no hooks) so it can be called inside\n * `React.memo` render functions or loops without violating hook rules.\n */\nexport function resolveEntitySlots(\n entity: Entity<Record<string, unknown>>,\n collection: AdminCollection<Record<string, unknown>>,\n slotKeys: CollectionSlotKeys,\n /** How the date slot is written: the relative phrases' language, say. */\n dateOptions?: FormatCollectionDateOptions\n): EntityPreviewSlots {\n const { titleKey, titleKeyCandidates, imageKey, subtitleKey, relationKeys, statusKey, dateKey, tagsKey } = slotKeys;\n\n // Image\n const image = imageKey ? resolveImageSlot(collection, imageKey, entity) : undefined;\n\n // Title — the best-ranked candidate that carries a readable value for THIS\n // entity, so a row whose name is empty (or whose column happens to hold a\n // UUID) falls through to the next candidate instead of showing an id.\n const resolvedTitleKey = resolveEntityTitleKey(entity, titleKeyCandidates ?? (titleKey ? [titleKey] : []));\n let title: PreviewSlot | undefined;\n if (resolvedTitleKey) {\n const prop = collection.properties[resolvedTitleKey] as Property | undefined;\n const val = getValueInPath(entity.values, resolvedTitleKey);\n if (prop) title = { role: \"title\",\nproperty: prop,\npropertyKey: resolvedTitleKey,\nvalue: val };\n }\n\n // Subtitle\n let subtitle: PreviewSlot | undefined;\n if (subtitleKey && subtitleKey !== resolvedTitleKey) {\n const prop = collection.properties[subtitleKey] as Property | undefined;\n const val = getValueInPath(entity.values, subtitleKey);\n if (prop && val !== undefined && val !== null && val !== \"\") {\n subtitle = { role: \"subtitle\",\nproperty: prop,\npropertyKey: subtitleKey,\nvalue: val };\n }\n }\n\n // Relations — resolve chip items for every relation property\n const relations: RelationChipSlot[] = [];\n const MAX_CHIPS_PER_RELATION = 3;\n\n for (const relKey of relationKeys) {\n const prop = collection.properties[relKey] as RelationProperty | undefined;\n if (!prop || prop.type !== \"relation\") continue;\n\n const val = getValueInPath(entity.values, relKey);\n if (val === undefined || val === null) continue;\n\n const items: RelationChipItem[] = [];\n let totalCount = 0;\n\n const isMany = relationCardinality(prop.relation) === \"many\";\n\n if (isMany && Array.isArray(val)) {\n // cardinality:\"many\" → array of EntityRelation\n totalCount = val.length;\n for (let i = 0; i < Math.min(val.length, MAX_CHIPS_PER_RELATION); i++) {\n const rel = val[i];\n if (rel && typeof rel === \"object\") {\n const displayName = resolveRelationDisplayName(rel as EntityRelation, prop);\n const id = (rel as EntityRelation).id ?? i;\n if (displayName) {\n items.push({ displayName,\nid });\n }\n }\n }\n } else if (!isMany && val && typeof val === \"object\") {\n // cardinality:\"one\" → single EntityRelation\n const obj = val as Record<string, unknown>;\n const isRelation = (\"__type\" in obj && obj.__type === \"relation\")\n || (typeof obj.isEntityRelation === \"function\"\n && (obj.isEntityRelation as () => boolean)());\n if (isRelation) {\n const relation = obj as unknown as EntityRelation;\n const displayName = resolveRelationDisplayName(relation, prop);\n totalCount = 1;\n if (displayName) {\n items.push({ displayName,\nid: relation.id });\n }\n }\n }\n\n if (items.length > 0) {\n const relIndex = relationKeys.indexOf(relKey);\n // Walking the seed keys rather than `Object.values`: the table also\n // holds a bare-hue alias per hue, so raw values would hand the first\n // two relations the same scheme.\n const colorScheme = CHIP_COLORS[CHIP_SEED_KEYS[relIndex % CHIP_SEED_KEYS.length]];\n relations.push({\n property: prop,\n propertyKey: relKey,\n label: prop.name || relKey,\n items,\n totalCount,\n colorScheme\n });\n }\n }\n\n // Status\n let status: PreviewSlot | undefined;\n if (statusKey) {\n const prop = collection.properties[statusKey] as Property | undefined;\n const val = getValueInPath(entity.values, statusKey);\n if (prop && val !== undefined && val !== null) {\n status = { role: \"status\",\nproperty: prop,\npropertyKey: statusKey,\nvalue: val };\n }\n }\n\n // Date\n let date: DatePreviewSlot | undefined;\n if (dateKey) {\n const prop = collection.properties[dateKey] as Property | undefined;\n const val = getValueInPath(entity.values, dateKey);\n if (prop && val !== undefined && val !== null) {\n date = {\n role: \"date\",\n property: prop,\n propertyKey: dateKey,\n value: val,\n formatted: formatCollectionDate(val, prop, dateOptions) ?? String(val)\n };\n }\n }\n\n // Tags — declared only, and empty means absent: an empty array is \"this\n // record has no labels\", which must render as nothing rather than as an\n // empty chip row that shifts every other slot down.\n let tags: PreviewSlot | undefined;\n if (tagsKey) {\n const prop = collection.properties[tagsKey] as Property | undefined;\n const val = getValueInPath(entity.values, tagsKey);\n const empty = val === undefined || val === null || val === \"\"\n || (Array.isArray(val) && val.length === 0);\n if (prop && !empty) {\n tags = { role: \"tags\",\nproperty: prop,\npropertyKey: tagsKey,\nvalue: val };\n }\n }\n\n return {\n image,\n title,\n subtitle,\n relations,\n status,\n date,\n tags,\n entityId: entity.id\n };\n}\n\n// ── Relation display name resolution ─────────────────────────────────\n\n/**\n * Extract a human-readable display name from an eagerly-loaded EntityRelation.\n * Uses the target collection's title property when available, otherwise\n * walks the entity values for the first short string.\n */\nfunction resolveRelationDisplayName(\n relation: EntityRelation | Record<string, unknown>,\n prop: RelationProperty\n): string | undefined {\n // Support both EntityRelation instances and plain objects\n const data = \"data\" in relation ? (relation as EntityRelation).data : undefined;\n\n // Resolve target collection from either `prop.relation.target()` or `prop.relation?.target()` (inline API)\n let targetCollection: AdminCollection | undefined;\n try {\n const resolved = prop.relation?.target?.() ?? (typeof prop.relation?.target === \"function\" ? prop.relation?.target() : undefined);\n if (resolved && typeof resolved === \"object\") {\n targetCollection = resolved as AdminCollection;\n }\n } catch {\n // Target collection may not be resolvable\n }\n\n // Helper: extract display name from entity values using the target collection\n //\n // This used to carry a ranking of its own — priority keys `name/title/label/\n // displayName`, then the first visible non-id string — which is a *seventh*\n // answer to \"what is this record called\", and one that disagreed with the\n // shared one: it read `titleProperty` with a flat lookup (so a dotted path\n // was ignored), never saw `display.title`, and ranked by key name where the\n // shared ranking excludes identifiers structurally. A chip and the record it\n // points at could therefore be labelled differently on the same screen.\n //\n // What is left here is the part that is genuinely local: a relation carries\n // *eagerly loaded* values, not an entity, so a resolver cannot run against\n // it — a computed title falls back to the ranked property, which is the same\n // thing the list row shows while its own resolver is in flight.\n const extractDisplayName = (values: Record<string, unknown>): string | undefined => {\n if (targetCollection) {\n for (const key of getTitlePropertyCandidates(targetCollection)) {\n const value = getValueInPath(values, key);\n if (value === undefined || value === null || value === \"\") continue;\n if (typeof value === \"string\" && looksLikeIdentifierValue(value)) continue;\n return String(value);\n }\n }\n // Generic fallback: walk entity values for any short string.\n for (const [, v] of Object.entries(values)) {\n if (typeof v === \"string\" && v.length > 0 && v.length < 200) {\n return v;\n }\n }\n return undefined;\n };\n\n // 1. Try eagerly-loaded data on the relation object\n if (data && data.values) {\n const result = extractDisplayName(data.values as Record<string, unknown>);\n if (result) return result;\n }\n\n const id = \"id\" in relation ? relation.id : undefined;\n\n // 2. Try the entity cache (sessionStorage) as a fallback\n if (id !== undefined && targetCollection) {\n try {\n const slug = targetCollection.slug ?? (\"table\" in targetCollection ? targetCollection.table : undefined);\n if (slug) {\n const cacheKey = `${slug}/${id}`;\n const cached = getEntityFromCache(cacheKey) as { values?: Record<string, unknown> } | undefined;\n if (cached?.values) {\n const result = extractDisplayName(cached.values);\n if (result) return result;\n }\n }\n } catch {\n // Cache lookup failed — fall through\n }\n }\n\n // 3. Final fallback: show the ID\n return id !== undefined ? String(id) : undefined;\n}\n\n/**\n * The slots for one record, with `admin.display` resolvers applied.\n *\n * {@link resolveEntitySlots} answers the question from values already in hand —\n * which is everything a slot filled by a property needs, and nothing a slot\n * filled by a *resolver* can use. A computed title may have to be fetched, so it\n * arrives after the first render; this hook is where the two meet.\n *\n * Until a resolver lands, the derived slot shows. That is deliberate: a list of\n * fifty rows must not blank its titles for a beat while fifty promises settle,\n * and the derived answer — the best-ranked property carrying a readable value —\n * is a reasonable thing to be looking at meanwhile. When the resolved value\n * arrives it replaces the slot outright, property and all, because there is no\n * property behind a computed value (see {@link PreviewSlot}).\n *\n * Every role is hooked unconditionally, so the hook order is fixed regardless of\n * what a given collection declares.\n */\nexport function useEntitySlots(\n entity: Entity<Record<string, unknown>>,\n collection: AdminCollection<Record<string, unknown>>,\n slotKeys: CollectionSlotKeys\n): EntityPreviewSlots {\n\n const relativeTimeLabels = useUiLabels().relativeTime;\n const derived = useMemo(\n () => resolveEntitySlots(entity, collection, slotKeys, { relativeTimeLabels }),\n [entity, collection, slotKeys, relativeTimeLabels]\n );\n\n const params = { collection,\nentity };\n const title = useEntityDisplay<string>(\"title\", params);\n const subtitle = useEntityDisplay<string>(\"subtitle\", params);\n const image = useEntityDisplay<string>(\"image\", params);\n const status = useEntityDisplay<string>(\"status\", params);\n const date = useEntityDisplay<Date | string | number>(\"date\", params);\n const tags = useEntityDisplay<string[] | string>(\"tags\", params);\n\n return useMemo(() => {\n // `source` is set only when the value came from a property, so its\n // absence is exactly the \"this was computed\" signal — no second flag to\n // keep in step with the first.\n // The role travels with the computed slot too. It is the only thing left\n // to say about a value with no property behind it, and `SlotValue` needs\n // it to tell a computed image from a computed title.\n const computed = (\n role: EntityDisplayRole,\n resolved: { value: unknown, source?: unknown }\n ): PreviewSlot | undefined =>\n resolved.value !== undefined && resolved.source === undefined\n ? { role,\nvalue: resolved.value }\n : undefined;\n\n const computedDate = computed(\"date\", date);\n\n return {\n ...derived,\n title: computed(\"title\", title) ?? derived.title,\n subtitle: computed(\"subtitle\", subtitle) ?? derived.subtitle,\n image: computed(\"image\", image) ?? derived.image,\n status: computed(\"status\", status) ?? derived.status,\n date: computedDate\n ? { ...computedDate,\nformatted: formatCollectionDate(computedDate.value, undefined, { relativeTimeLabels }) ?? String(computedDate.value) }\n : derived.date,\n tags: computed(\"tags\", tags) ?? derived.tags\n };\n }, [derived, title, subtitle, image, status, date, tags, relativeTimeLabels]);\n}\n"],"mappings":";;;;;;;;;AAgBA,SAAS,oBAAoB,UAA2F;CACpH,IAAI,CAAC,UAAU,OAAO,KAAA;CACtB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AAoBA,SAAgB,eACZ,QACA,YACA,UACkB;CAElB,MAAM,qBAAqB,YAAY,CAAC,CAAC;CACzC,MAAM,UAAU,cACN,mBAAmB,QAAQ,YAAY,UAAU,EAAE,mBAAmB,CAAC,GAC7E;EAAC;EAAQ;EAAY;EAAU;CAAkB,CACrD;CAEA,MAAM,SAAS;EAAE;EACrB;CAAO;CACH,MAAM,QAAQ,iBAAyB,SAAS,MAAM;CACtD,MAAM,WAAW,iBAAyB,YAAY,MAAM;CAC5D,MAAM,QAAQ,iBAAyB,SAAS,MAAM;CACtD,MAAM,SAAS,iBAAyB,UAAU,MAAM;CACxD,MAAM,OAAO,iBAAyC,QAAQ,MAAM;CACpE,MAAM,OAAO,iBAAoC,QAAQ,MAAM;CAE/D,OAAO,cAAc;EAOjB,MAAM,YACF,MACA,aAEA,SAAS,UAAU,KAAA,KAAa,SAAS,WAAW,KAAA,IAC9C;GAAE;GACpB,OAAO,SAAS;EAAM,IACJ,KAAA;EAEV,MAAM,eAAe,SAAS,QAAQ,IAAI;EAE1C,OAAO;GACH,GAAG;GACH,OAAO,SAAS,SAAS,KAAK,KAAK,QAAQ;GAC3C,UAAU,SAAS,YAAY,QAAQ,KAAK,QAAQ;GACpD,OAAO,SAAS,SAAS,KAAK,KAAK,QAAQ;GAC3C,QAAQ,SAAS,UAAU,MAAM,KAAK,QAAQ;GAC9C,MAAM,eACA;IAAE,GAAG;IACvB,WAAW,qBAAqB,aAAa,OAAO,KAAA,GAAW,EAAE,mBAAmB,CAAC,KAAK,OAAO,aAAa,KAAK;GAAE,IACnG,QAAQ;GACd,MAAM,SAAS,QAAQ,IAAI,KAAK,QAAQ;EAC5C;CACJ,GAAG;EAAC;EAAS;EAAO;EAAU;EAAO;EAAQ;EAAM;EAAM;CAAkB,CAAC;AAChF"}
1
+ {"version":3,"file":"usePreviewSlots.js","names":[],"sources":["../../../src/components/CollectionViewBinding/usePreviewSlots.ts"],"sourcesContent":["import React, { useMemo } from \"react\";\nimport type { Property, RelationProperty } from \"@rebasepro/types\";\nimport type { Entity, EntityRelation } from \"@rebasepro/types\";\nimport type { PropertyConfig, AdminCollection, EntityDisplayRole } from \"@rebasepro/cms-types\";\nimport { getEntityImagePreviewPropertyKey } from \"@rebasepro/app\";\nimport { getDisplayPropertyKey } from \"@rebasepro/app\";\nimport { getLeadingRelationTitleKey, getTitlePropertyCandidates, looksLikeIdentifierValue } from \"@rebasepro/app\";\nimport { getEntityFromCache } from \"@rebasepro/app\";\nimport { getEntityPreviewKeys } from \"../../util/previews\";\nimport { getValueInPath } from \"@rebasepro/utils\";\nimport { formatCollectionDate, type FormatCollectionDateOptions } from \"../../util/format_collection_date\";\nimport type { AuthController } from \"@rebasepro/cms-types\";\nimport { ChipColorScheme, CHIP_COLORS, CHIP_SEED_KEYS, useUiLabels } from \"@rebasepro/ui\";\nimport { useEntityDisplay } from \"../../hooks/useEntityDisplay\";\n\n/** Whether an authored relation yields many rows. Derived from its kind. */\nexport function relationCardinality(relation: { kind?: string; cardinality?: string } | undefined): \"one\" | \"many\" | undefined {\n if (!relation) return undefined;\n if (relation.kind === \"via\") return relation.cardinality as \"one\" | \"many\" | undefined;\n if (relation.kind === \"hasMany\" || relation.kind === \"manyToMany\") return \"many\";\n if (relation.kind === \"belongsTo\" || relation.kind === \"hasOne\") return \"one\";\n return relation.cardinality as \"one\" | \"many\" | undefined;\n}\n\n\n// ── Slot types ────────────────────────────────────────────────────────\n\n/**\n * A resolved \"slot\": what fills one display role for one record.\n *\n * `property` and `propertyKey` are set when the value was read off the record,\n * and absent when a `display` resolver computed it — a computed title has no\n * column behind it, so there is nothing to render it *as*. Renderers must go\n * through {@link SlotValue}, which makes that choice once: a property renders\n * with its own preview (an enum keeps its coloured chip, a date its format), a\n * computed value renders as text.\n */\nexport interface PreviewSlot {\n property?: Property;\n propertyKey?: string;\n value: unknown;\n /**\n * Which display role this slot fills.\n *\n * Load-bearing for the computed case. Without a property there is nothing to\n * infer from, and \"render it as text\" is right for a title and wrong for an\n * image: a resolver that returned a URL had that URL printed inside the card's\n * image frame. The role is the one thing that distinguishes them, so it\n * travels with the slot rather than being re-derived at each call site.\n */\n role?: EntityDisplayRole;\n}\n\n/**\n * Date slot extends the base with a pre-formatted string.\n */\nexport interface DatePreviewSlot extends PreviewSlot {\n formatted: string;\n}\n\n/**\n * A single resolved relation chip — one item to render as a compact chip.\n * For cardinality:\"one\" relations there will be one chip.\n * For cardinality:\"many\" there can be several (capped for layout stability).\n */\nexport interface RelationChipItem {\n /** Human-readable display text for the chip */\n displayName: string;\n /** Relation ID */\n id: string | number;\n}\n\n/**\n * A resolved relation slot — groups all chips for one relation property.\n */\nexport interface RelationChipSlot {\n /** The relation property definition */\n property: RelationProperty;\n /** The property key on this entity (e.g. \"author\", \"tags\") */\n propertyKey: string;\n /** The relation property's user-facing name (e.g. \"Author\", \"Tags\") */\n label: string;\n /** Resolved chip items (display names extracted from eagerly-loaded data) */\n items: RelationChipItem[];\n /** Total count (for \"many\" relations that exceed the chip cap) */\n totalCount: number;\n /** Deterministic color for this relation property */\n colorScheme: ChipColorScheme;\n}\n\n/**\n * Fixed set of preview slots resolved from any entity + collection.\n *\n * Every view (list, card, board) consumes these same slots and decides\n * which ones to render and how. This eliminates duplicated inference\n * logic across view components.\n */\nexport interface EntityPreviewSlots {\n /** MEDIA — image thumbnail or `undefined` (view falls back to icon) */\n image: PreviewSlot | undefined;\n /** PRIMARY — title / name field */\n title: PreviewSlot | undefined;\n /** SECONDARY — subtitle or short description (first non-title text field) */\n subtitle: PreviewSlot | undefined;\n /** RELATIONS — compact chips for all relation properties (one + many) */\n relations: RelationChipSlot[];\n /** STATUS — enum chip (first enum field that isn't the title) */\n status: PreviewSlot | undefined;\n /** META — date / timestamp */\n date: DatePreviewSlot | undefined;\n /**\n * TAGS — free chips beside the status.\n *\n * Declared only. Every other role has an inference ladder behind it, and\n * this one deliberately does not: there is no \"first enum\" or \"looks like a\n * timestamp\" that means *labels*, so guessing would scatter arbitrary chips\n * across every row of every panel that never asked for them.\n *\n * The role existed on `EntityDisplay` and in `useEntityDisplay` before this\n * field did, which is why a declared `display.tags` resolved correctly and\n * then had nowhere to go.\n */\n tags: PreviewSlot | undefined;\n /** Entity ID (always available) */\n entityId: string | number;\n}\n\n// ── Collection-level slot resolution (entity-independent) ─────────────\n\n/**\n * Resolved property keys per slot. This is the expensive part (walks\n * all properties) so we memoize it at the collection level, not per entity.\n */\nexport interface CollectionSlotKeys {\n titleKey: string | undefined;\n /** Every property that could act as the title, best first (see `getTitlePropertyCandidates`) */\n titleKeyCandidates: string[];\n imageKey: string | undefined;\n subtitleKey: string | undefined;\n relationKeys: string[];\n statusKey: string | undefined;\n dateKey: string | undefined;\n /** Declared only — see {@link EntityPreviewSlots.tags}. */\n tagsKey: string | undefined;\n}\n\n/**\n * Resolve which property key fills each slot for a given collection.\n * Pure function — call inside `useMemo`.\n */\nexport function resolveCollectionSlotKeys(\n collection: AdminCollection<Record<string, unknown>>,\n authController: AuthController,\n propertyConfigs: Record<string, PropertyConfig>\n): CollectionSlotKeys {\n // One row per entity: when the collection leads with a relation and holds no\n // name of its own, that relation *is* what the row is called. See\n // `getLeadingRelationTitleKey` — the general ranking keeps relations last,\n // which is right for a detail header but leaves a junction row titleless.\n const rankedCandidates = getTitlePropertyCandidates(collection);\n const leadingRelationKey = getLeadingRelationTitleKey(collection);\n const titleKeyCandidates = leadingRelationKey\n ? [leadingRelationKey, ...rankedCandidates.filter(key => key !== leadingRelationKey)]\n : rankedCandidates;\n const titleKey = titleKeyCandidates[0];\n // `getEntityImagePreviewPropertyKey` prefers `display.image` itself, so\n // every caller of it — this, the reference card, the board — agrees.\n const imageKey = getEntityImagePreviewPropertyKey(collection);\n\n // Status: declared, else the first string-enum that isn't the title.\n //\n // Everything below this line is inference — \"the first enum\", \"a key that\n // looks like a timestamp\", \"the longest remaining string\". It is a good\n // guess and it is only a guess, so a collection that states the role wins\n // outright and the ladder is skipped. That is the whole point of\n // `admin.display`: the heuristics stay for the collections that never say\n // anything, and stop overruling the ones that do.\n let statusKey: string | undefined = getDisplayPropertyKey(collection, \"status\");\n\n // 1. Explicitly defined in previewProperties\n if (!statusKey && collection.previewProperties) {\n for (const key of collection.previewProperties) {\n const p = collection.properties[key] as Property | undefined;\n if (p?.type === \"string\" && \"enum\" in p && p.enum && key !== titleKey) {\n statusKey = key;\n break;\n }\n }\n }\n\n // 2. Explicitly defined in propertiesOrder\n if (!statusKey && collection.propertiesOrder) {\n for (const key of collection.propertiesOrder) {\n if (typeof key === \"string\" && !key.startsWith(\"subcollection:\")) {\n const p = collection.properties[key] as Property | undefined;\n if (p?.type === \"string\" && \"enum\" in p && p.enum && key !== titleKey) {\n statusKey = key;\n break;\n }\n }\n }\n }\n\n // 3. Default automatic inference\n if (!statusKey) {\n for (const [key, prop] of Object.entries(collection.properties)) {\n const p = prop as Property;\n if (p.type === \"string\" && \"enum\" in p && p.enum && key !== titleKey) {\n statusKey = key;\n break;\n }\n }\n }\n\n // Date: declared, else a well-known timestamp field, else any date\n let dateKey: string | undefined = getDisplayPropertyKey(collection, \"date\");\n const dateCandidates = [\"updated_at\", \"updatedAt\", \"modified_at\", \"modifiedAt\", \"created_at\", \"createdAt\"];\n if (!dateKey) {\n for (const candidate of dateCandidates) {\n if (collection.properties[candidate]) {\n dateKey = candidate;\n break;\n }\n }\n }\n if (!dateKey) {\n for (const [key, prop] of Object.entries(collection.properties)) {\n const p = prop as Property;\n if (p.type === \"date\") {\n dateKey = key;\n break;\n }\n }\n }\n\n // Relations: collect relation property keys for chip rendering.\n // When propertiesOrder is explicitly set, skip this — relations will\n // be shown in the developer-defined order, not as separate chips.\n const hasExplicitOrder = !!(collection.propertiesOrder as string[] | undefined);\n const relationKeys: string[] = [];\n if (!hasExplicitOrder) {\n for (const [key, prop] of Object.entries(collection.properties)) {\n const p = prop as Property;\n // The relation filling the title slot is already the row's headline;\n // repeating it as a chip below says the same thing twice.\n if (p.type === \"relation\" && key !== titleKey) {\n relationKeys.push(key);\n }\n }\n }\n\n // Subtitle: first preview key that isn't title/image/status/date/id.\n // When propertiesOrder is not set, also exclude relation keys (they render as chips).\n // Prefer string fields (especially multiline/description-like) over numbers.\n const excludeKeys = new Set([titleKey, imageKey, statusKey, dateKey, ...relationKeys]);\n const previewKeys = getEntityPreviewKeys(authController, collection, propertyConfigs, undefined, 10)\n .filter(k => !excludeKeys.has(k) && k !== \"id\");\n\n // When propertiesOrder is set, respect the developer-defined order (no re-sorting).\n // When not set, sort: strings first (prefer multiline → good description candidate).\n const sortedPreviewKeys = hasExplicitOrder\n ? previewKeys\n : [...previewKeys].sort((a, b) => {\n const propA = collection.properties[a] as Property | undefined;\n const propB = collection.properties[b] as Property | undefined;\n const scoreA = propA?.type === \"string\" ? (propA.admin?.multiline ? 2 : 1) : 0;\n const scoreB = propB?.type === \"string\" ? (propB.admin?.multiline ? 2 : 1) : 0;\n return scoreB - scoreA;\n });\n const subtitleKey = getDisplayPropertyKey(collection, \"subtitle\")\n ?? (sortedPreviewKeys.length > 0 ? sortedPreviewKeys[0] : undefined);\n\n return { titleKey,\ntitleKeyCandidates,\nimageKey,\nsubtitleKey,\nrelationKeys,\nstatusKey,\ndateKey,\ntagsKey: getDisplayPropertyKey(collection, \"tags\") };\n}\n\n// ── Image place ───────────────────────────────────────────────────────\n\n/**\n * Whether a list row, a card or a kanban card keeps its image place where no\n * property fills it, drawing the collection's icon there. A view given\n * `fields` that leaves every image out keeps none.\n *\n * @internal Provided by the collection view; read through {@link useImagePlace}.\n */\nexport const EmptyImagePlaceContext = React.createContext(true);\n\n/**\n * Whether the rows of the collection view around draw an image place: a\n * property fills it (`imageKey`, from {@link useCollectionSlotKeys}), or the\n * view keeps an empty one with the collection's icon. A view given `fields`\n * that leaves every image out keeps none, so the place takes no room — a copy\n * of a card or a row honours `fields` by drawing its thumbnail only when this\n * says so.\n *\n * @group Components\n */\nexport function useImagePlace(imageKey: string | undefined): boolean {\n return React.useContext(EmptyImagePlaceContext) || imageKey !== undefined;\n}\n\n// ── Image unwrapping helper ───────────────────────────────────────────\n\n/**\n * Unwrap image property + value from potential array-of-images.\n * Returns `{ property, value }` where property is the *inner* property\n * and value is the first element (for arrays) or the raw value.\n */\nfunction resolveImageSlot(\n collection: AdminCollection<Record<string, unknown>>,\n imageKey: string,\n entity: Entity<Record<string, unknown>>\n): PreviewSlot | undefined {\n const imageProperty = collection.properties[imageKey];\n if (!imageProperty) return undefined;\n\n const ofProp = \"of\" in imageProperty ? imageProperty.of : undefined;\n const resolvedProperty = ofProp\n ? (Array.isArray(ofProp) ? ofProp[0] : ofProp)\n : imageProperty;\n\n const rawValue = getValueInPath(entity.values, imageKey);\n const resolvedValue = ofProp\n ? (((rawValue as unknown[]) ?? []).length > 0 ? (rawValue as unknown[])[0] : undefined)\n : rawValue;\n\n if (resolvedValue === undefined || resolvedValue === null) return undefined;\n\n return {\n role: \"image\",\n property: resolvedProperty as Property,\n propertyKey: imageKey,\n value: resolvedValue\n };\n}\n\n// ── Title resolution (entity-level) ───────────────────────────────────\n\n/**\n * Walk the collection's ranked title candidates and return the first one that\n * holds something a person can read for this entity. Candidates are already\n * ordered and free of identifier properties; this only rejects values —\n * empties, and strings that turn out to be an id at runtime.\n */\nfunction resolveEntityTitleKey(\n entity: Entity<Record<string, unknown>>,\n candidates: string[]\n): string | undefined {\n for (const key of candidates) {\n const value = getValueInPath(entity.values, key);\n if (value === undefined || value === null || value === \"\") continue;\n if (typeof value === \"string\") {\n if (looksLikeIdentifierValue(value)) continue;\n if (value === String(entity.id)) continue;\n }\n return key;\n }\n return candidates[0];\n}\n\n// ── Hook: collection-level slot keys ──────────────────────────────────\n\n/**\n * Resolves which property key fills each preview slot for a collection.\n * Memoized — only recomputes when the collection definition changes.\n *\n * Use this in the parent list/grid component, then pass the result to\n * `resolveEntitySlots` for each entity row.\n */\nexport function useCollectionSlotKeys(\n collection: AdminCollection<Record<string, unknown>>,\n authController: AuthController,\n propertyConfigs: Record<string, PropertyConfig>\n): CollectionSlotKeys {\n return useMemo(\n () => resolveCollectionSlotKeys(collection, authController, propertyConfigs),\n [collection, authController, propertyConfigs]\n );\n}\n\n// ── Pure function: entity-level slot resolution ───────────────────────\n\n/**\n * Resolve concrete slot values for a single entity.\n * This is a pure function (no hooks) so it can be called inside\n * `React.memo` render functions or loops without violating hook rules.\n */\nexport function resolveEntitySlots(\n entity: Entity<Record<string, unknown>>,\n collection: AdminCollection<Record<string, unknown>>,\n slotKeys: CollectionSlotKeys,\n /** How the date slot is written: the relative phrases' language, say. */\n dateOptions?: FormatCollectionDateOptions\n): EntityPreviewSlots {\n const { titleKey, titleKeyCandidates, imageKey, subtitleKey, relationKeys, statusKey, dateKey, tagsKey } = slotKeys;\n\n // Image\n const image = imageKey ? resolveImageSlot(collection, imageKey, entity) : undefined;\n\n // Title — the best-ranked candidate that carries a readable value for THIS\n // entity, so a row whose name is empty (or whose column happens to hold a\n // UUID) falls through to the next candidate instead of showing an id.\n const resolvedTitleKey = resolveEntityTitleKey(entity, titleKeyCandidates ?? (titleKey ? [titleKey] : []));\n let title: PreviewSlot | undefined;\n if (resolvedTitleKey) {\n const prop = collection.properties[resolvedTitleKey] as Property | undefined;\n const val = getValueInPath(entity.values, resolvedTitleKey);\n if (prop) title = { role: \"title\",\nproperty: prop,\npropertyKey: resolvedTitleKey,\nvalue: val };\n }\n\n // Subtitle\n let subtitle: PreviewSlot | undefined;\n if (subtitleKey && subtitleKey !== resolvedTitleKey) {\n const prop = collection.properties[subtitleKey] as Property | undefined;\n const val = getValueInPath(entity.values, subtitleKey);\n if (prop && val !== undefined && val !== null && val !== \"\") {\n subtitle = { role: \"subtitle\",\nproperty: prop,\npropertyKey: subtitleKey,\nvalue: val };\n }\n }\n\n // Relations — resolve chip items for every relation property\n const relations: RelationChipSlot[] = [];\n const MAX_CHIPS_PER_RELATION = 3;\n\n for (const relKey of relationKeys) {\n const prop = collection.properties[relKey] as RelationProperty | undefined;\n if (!prop || prop.type !== \"relation\") continue;\n\n const val = getValueInPath(entity.values, relKey);\n if (val === undefined || val === null) continue;\n\n const items: RelationChipItem[] = [];\n let totalCount = 0;\n\n const isMany = relationCardinality(prop.relation) === \"many\";\n\n if (isMany && Array.isArray(val)) {\n // cardinality:\"many\" → array of EntityRelation\n totalCount = val.length;\n for (let i = 0; i < Math.min(val.length, MAX_CHIPS_PER_RELATION); i++) {\n const rel = val[i];\n if (rel && typeof rel === \"object\") {\n const displayName = resolveRelationDisplayName(rel as EntityRelation, prop);\n const id = (rel as EntityRelation).id ?? i;\n if (displayName) {\n items.push({ displayName,\nid });\n }\n }\n }\n } else if (!isMany && val && typeof val === \"object\") {\n // cardinality:\"one\" → single EntityRelation\n const obj = val as Record<string, unknown>;\n const isRelation = (\"__type\" in obj && obj.__type === \"relation\")\n || (typeof obj.isEntityRelation === \"function\"\n && (obj.isEntityRelation as () => boolean)());\n if (isRelation) {\n const displayName = resolveRelationDisplayName(obj, prop);\n totalCount = 1;\n // An `EntityRelation`'s id, or the wire ref's: a string or a number either way.\n const id = obj.id;\n if (displayName && (typeof id === \"string\" || typeof id === \"number\")) {\n items.push({ displayName,\nid });\n }\n }\n }\n\n if (items.length > 0) {\n const relIndex = relationKeys.indexOf(relKey);\n // Walking the seed keys rather than `Object.values`: the table also\n // holds a bare-hue alias per hue, so raw values would hand the first\n // two relations the same scheme.\n const colorScheme = CHIP_COLORS[CHIP_SEED_KEYS[relIndex % CHIP_SEED_KEYS.length]];\n relations.push({\n property: prop,\n propertyKey: relKey,\n label: prop.name || relKey,\n items,\n totalCount,\n colorScheme\n });\n }\n }\n\n // Status\n let status: PreviewSlot | undefined;\n if (statusKey) {\n const prop = collection.properties[statusKey] as Property | undefined;\n const val = getValueInPath(entity.values, statusKey);\n if (prop && val !== undefined && val !== null) {\n status = { role: \"status\",\nproperty: prop,\npropertyKey: statusKey,\nvalue: val };\n }\n }\n\n // Date\n let date: DatePreviewSlot | undefined;\n if (dateKey) {\n const prop = collection.properties[dateKey] as Property | undefined;\n const val = getValueInPath(entity.values, dateKey);\n if (prop && val !== undefined && val !== null) {\n date = {\n role: \"date\",\n property: prop,\n propertyKey: dateKey,\n value: val,\n formatted: formatCollectionDate(val, prop, dateOptions) ?? String(val)\n };\n }\n }\n\n // Tags — declared only, and empty means absent: an empty array is \"this\n // record has no labels\", which must render as nothing rather than as an\n // empty chip row that shifts every other slot down.\n let tags: PreviewSlot | undefined;\n if (tagsKey) {\n const prop = collection.properties[tagsKey] as Property | undefined;\n const val = getValueInPath(entity.values, tagsKey);\n const empty = val === undefined || val === null || val === \"\"\n || (Array.isArray(val) && val.length === 0);\n if (prop && !empty) {\n tags = { role: \"tags\",\nproperty: prop,\npropertyKey: tagsKey,\nvalue: val };\n }\n }\n\n return {\n image,\n title,\n subtitle,\n relations,\n status,\n date,\n tags,\n entityId: entity.id\n };\n}\n\n// ── Relation display name resolution ─────────────────────────────────\n\n/**\n * Extract a human-readable display name from an eagerly-loaded EntityRelation.\n * Uses the target collection's title property when available, otherwise\n * walks the entity values for the first short string; with neither, the id.\n */\nexport function resolveRelationDisplayName(\n relation: EntityRelation | Record<string, unknown>,\n prop: RelationProperty\n): string | undefined {\n const name = loadedRelationName(relation, prop);\n if (name !== undefined) return name;\n const id = \"id\" in relation ? relation.id : undefined;\n return id !== undefined ? String(id) : undefined;\n}\n\n/**\n * The related row's name from what is already on hand — values loaded with\n * the relation, or the entity cache — and nothing else: no id. A bare\n * foreign key has neither, and its caller fetches the row instead of\n * printing the key as though it were the name.\n */\nexport function loadedRelationName(\n relation: EntityRelation | Record<string, unknown>,\n prop: RelationProperty\n): string | undefined {\n // Support both EntityRelation instances and plain objects\n const data = \"data\" in relation ? (relation as EntityRelation).data : undefined;\n\n // Resolve target collection from either `prop.relation.target()` or `prop.relation?.target()` (inline API)\n let targetCollection: AdminCollection | undefined;\n try {\n const resolved = prop.relation?.target?.() ?? (typeof prop.relation?.target === \"function\" ? prop.relation?.target() : undefined);\n if (resolved && typeof resolved === \"object\") {\n targetCollection = resolved as AdminCollection;\n }\n } catch {\n // Target collection may not be resolvable\n }\n\n // Helper: extract display name from entity values using the target collection\n //\n // This used to carry a ranking of its own — priority keys `name/title/label/\n // displayName`, then the first visible non-id string — which is a *seventh*\n // answer to \"what is this record called\", and one that disagreed with the\n // shared one: it read `titleProperty` with a flat lookup (so a dotted path\n // was ignored), never saw `display.title`, and ranked by key name where the\n // shared ranking excludes identifiers structurally. A chip and the record it\n // points at could therefore be labelled differently on the same screen.\n //\n // What is left here is the part that is genuinely local: a relation carries\n // *eagerly loaded* values, not an entity, so a resolver cannot run against\n // it — a computed title falls back to the ranked property, which is the same\n // thing the list row shows while its own resolver is in flight.\n const extractDisplayName = (values: Record<string, unknown>): string | undefined => {\n if (targetCollection) {\n for (const key of getTitlePropertyCandidates(targetCollection)) {\n const value = getValueInPath(values, key);\n if (value === undefined || value === null || value === \"\") continue;\n if (typeof value === \"string\" && looksLikeIdentifierValue(value)) continue;\n return String(value);\n }\n }\n // Generic fallback: walk entity values for any short string.\n for (const [, v] of Object.entries(values)) {\n if (typeof v === \"string\" && v.length > 0 && v.length < 200) {\n return v;\n }\n }\n return undefined;\n };\n\n // 1. Try eagerly-loaded data on the relation object\n if (data && data.values) {\n const result = extractDisplayName(data.values as Record<string, unknown>);\n if (result) return result;\n }\n\n const id = \"id\" in relation ? relation.id : undefined;\n\n // 2. Try the entity cache (sessionStorage) as a fallback\n if (id !== undefined && targetCollection) {\n try {\n const slug = targetCollection.slug ?? (\"table\" in targetCollection ? targetCollection.table : undefined);\n if (slug) {\n const cacheKey = `${slug}/${id}`;\n const cached = getEntityFromCache(cacheKey) as { values?: Record<string, unknown> } | undefined;\n if (cached?.values) {\n const result = extractDisplayName(cached.values);\n if (result) return result;\n }\n }\n } catch {\n // Cache lookup failed — fall through\n }\n }\n\n return undefined;\n}\n\n/**\n * The slots for one record, with `admin.display` resolvers applied.\n *\n * {@link resolveEntitySlots} answers the question from values already in hand —\n * which is everything a slot filled by a property needs, and nothing a slot\n * filled by a *resolver* can use. A computed title may have to be fetched, so it\n * arrives after the first render; this hook is where the two meet.\n *\n * Until a resolver lands, the derived slot shows. That is deliberate: a list of\n * fifty rows must not blank its titles for a beat while fifty promises settle,\n * and the derived answer — the best-ranked property carrying a readable value —\n * is a reasonable thing to be looking at meanwhile. When the resolved value\n * arrives it replaces the slot outright, property and all, because there is no\n * property behind a computed value (see {@link PreviewSlot}).\n *\n * Every role is hooked unconditionally, so the hook order is fixed regardless of\n * what a given collection declares.\n */\nexport function useEntitySlots(\n entity: Entity<Record<string, unknown>>,\n collection: AdminCollection<Record<string, unknown>>,\n slotKeys: CollectionSlotKeys\n): EntityPreviewSlots {\n\n const relativeTimeLabels = useUiLabels().relativeTime;\n const derived = useMemo(\n () => resolveEntitySlots(entity, collection, slotKeys, { relativeTimeLabels }),\n [entity, collection, slotKeys, relativeTimeLabels]\n );\n\n const params = { collection,\nentity };\n const title = useEntityDisplay<string>(\"title\", params);\n const subtitle = useEntityDisplay<string>(\"subtitle\", params);\n const image = useEntityDisplay<string>(\"image\", params);\n const status = useEntityDisplay<string>(\"status\", params);\n const date = useEntityDisplay<Date | string | number>(\"date\", params);\n const tags = useEntityDisplay<string[] | string>(\"tags\", params);\n\n return useMemo(() => {\n // `source` is set only when the value came from a property, so its\n // absence is exactly the \"this was computed\" signal — no second flag to\n // keep in step with the first.\n // The role travels with the computed slot too. It is the only thing left\n // to say about a value with no property behind it, and `SlotValue` needs\n // it to tell a computed image from a computed title.\n const computed = (\n role: EntityDisplayRole,\n resolved: { value: unknown, source?: unknown }\n ): PreviewSlot | undefined =>\n resolved.value !== undefined && resolved.source === undefined\n ? { role,\nvalue: resolved.value }\n : undefined;\n\n const computedDate = computed(\"date\", date);\n\n return {\n ...derived,\n title: computed(\"title\", title) ?? derived.title,\n subtitle: computed(\"subtitle\", subtitle) ?? derived.subtitle,\n image: computed(\"image\", image) ?? derived.image,\n status: computed(\"status\", status) ?? derived.status,\n date: computedDate\n ? { ...computedDate,\nformatted: formatCollectionDate(computedDate.value, undefined, { relativeTimeLabels }) ?? String(computedDate.value) }\n : derived.date,\n tags: computed(\"tags\", tags) ?? derived.tags\n };\n }, [derived, title, subtitle, image, status, date, tags, relativeTimeLabels]);\n}\n"],"mappings":";;;;;;;;;AAgBA,SAAgB,oBAAoB,UAA2F;CAC3H,IAAI,CAAC,UAAU,OAAO,KAAA;CACtB,IAAI,SAAS,SAAS,OAAO,OAAO,SAAS;CAC7C,IAAI,SAAS,SAAS,aAAa,SAAS,SAAS,cAAc,OAAO;CAC1E,IAAI,SAAS,SAAS,eAAe,SAAS,SAAS,UAAU,OAAO;CACxE,OAAO,SAAS;AACpB;;;;;AAgIA,SAAgB,0BACZ,YACA,gBACA,iBACkB;CAKlB,MAAM,mBAAmB,2BAA2B,UAAU;CAC9D,MAAM,qBAAqB,2BAA2B,UAAU;CAChE,MAAM,qBAAqB,qBACrB,CAAC,oBAAoB,GAAG,iBAAiB,QAAO,QAAO,QAAQ,kBAAkB,CAAC,IAClF;CACN,MAAM,WAAW,mBAAmB;CAGpC,MAAM,WAAW,iCAAiC,UAAU;CAU5D,IAAI,YAAgC,sBAAsB,YAAY,QAAQ;CAG9E,IAAI,CAAC,aAAa,WAAW,mBACzB,KAAK,MAAM,OAAO,WAAW,mBAAmB;EAC5C,MAAM,IAAI,WAAW,WAAW;EAChC,IAAI,GAAG,SAAS,YAAY,UAAU,KAAK,EAAE,QAAQ,QAAQ,UAAU;GACnE,YAAY;GACZ;EACJ;CACJ;CAIJ,IAAI,CAAC,aAAa,WAAW;OACpB,MAAM,OAAO,WAAW,iBACzB,IAAI,OAAO,QAAQ,YAAY,CAAC,IAAI,WAAW,gBAAgB,GAAG;GAC9D,MAAM,IAAI,WAAW,WAAW;GAChC,IAAI,GAAG,SAAS,YAAY,UAAU,KAAK,EAAE,QAAQ,QAAQ,UAAU;IACnE,YAAY;IACZ;GACJ;EACJ;;CAKR,IAAI,CAAC,WACD,KAAK,MAAM,CAAC,KAAK,SAAS,OAAO,QAAQ,WAAW,UAAU,GAAG;EAC7D,MAAM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KAAK,QAAQ;GAC9C,MAAM,eACA;IAAE,GAAG;IACvB,WAAW,qBAAqB,aAAa,OAAO,KAAA,GAAW,EAAE,mBAAmB,CAAC,KAAK,OAAO,aAAa,KAAK;GAAE,IACnG,QAAQ;GACd,MAAM,SAAS,QAAQ,IAAI,KAAK,QAAQ;EAC5C;CACJ,GAAG;EAAC;EAAS;EAAO;EAAU;EAAO;EAAQ;EAAM;EAAM;CAAkB,CAAC;AAChF"}
@@ -41,6 +41,26 @@ export type EntityPreviewBindingDataProps = {
41
41
  * without any container wrapper. Used internally by EntityPreviewBinding.
42
42
  */
43
43
  export declare function EntityPreviewBindingData({ actions, collection: collectionProp, previewKeys, size, includeId, onSidePanelClick, includeTitle, includeEntityLink, includeImage, layout, entity }: EntityPreviewBindingDataProps): React.JSX.Element;
44
+ /**
45
+ * A card that has not loaded yet, drawn as the card it will be: the image
46
+ * slot, a title, one placeholder per line the card will show and the open
47
+ * button's room. A single bar in a 48px box grew to the full card when the
48
+ * record arrived and pushed everything under it down.
49
+ *
50
+ * Which lines a card shows is known before its record is — they come from
51
+ * the collection, not the values — so the count is right whatever the
52
+ * collection declares. Each placeholder sits in the line's own wrapper with
53
+ * the line's own type, and an enum's is a chip, so a line is as tall
54
+ * loading as loaded without any height written down here.
55
+ */
56
+ export declare function EntityPreviewBindingSkeleton({ collection, previewKeys, size, includeTitle, includeImage, includeEntityLink }: {
57
+ collection: AdminCollection;
58
+ previewKeys?: string[];
59
+ size?: "smallest" | "small" | "medium" | "large";
60
+ includeTitle?: boolean;
61
+ includeImage?: boolean;
62
+ includeEntityLink?: boolean;
63
+ }): React.JSX.Element;
44
64
  export declare function EntityPreviewBindingWithId({ entityId, path, ...props }: Omit<EntityPreviewBindingProps, "entity"> & {
45
65
  entityId: string | number;
46
66
  path: string;