@lupinum/ginko-studio 0.0.0-stage → 0.18.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (338) hide show
  1. package/CHANGELOG.md +16 -0
  2. package/LICENSE +21 -0
  3. package/README.md +50 -2
  4. package/app/app.vue +22 -0
  5. package/app/assets/css/tailwind.css +170 -0
  6. package/app/assets/ui.css +59 -0
  7. package/app/components/AccountMenu.vue +57 -0
  8. package/app/components/AllNav.vue +55 -0
  9. package/app/components/AllShell.vue +37 -0
  10. package/app/components/AppToast.vue +14 -0
  11. package/app/components/ChangeDetail.vue +17 -0
  12. package/app/components/ChangeDiff.vue +190 -0
  13. package/app/components/ChangeRows.vue +333 -0
  14. package/app/components/CommandPalette.vue +212 -0
  15. package/app/components/ConflictPanel.vue +119 -0
  16. package/app/components/DeleteAccount.vue +62 -0
  17. package/app/components/DeleteSite.vue +44 -0
  18. package/app/components/EntryEditor.vue +956 -0
  19. package/app/components/EntryFields.vue +99 -0
  20. package/app/components/EntryGoneBanner.vue +45 -0
  21. package/app/components/EntryPublishPanel.vue +35 -0
  22. package/app/components/EntryRemoveDialog.vue +57 -0
  23. package/app/components/FactUses.vue +25 -0
  24. package/app/components/GinkoMark.vue +7 -0
  25. package/app/components/GrantsChecklist.vue +40 -0
  26. package/app/components/LanguageSwitch.vue +34 -0
  27. package/app/components/LocalDraftList.vue +77 -0
  28. package/app/components/LocalDraftOffer.vue +24 -0
  29. package/app/components/NavPlace.vue +56 -0
  30. package/app/components/NavTree.vue +595 -0
  31. package/app/components/OwnProposals.vue +96 -0
  32. package/app/components/PickSheet.vue +80 -0
  33. package/app/components/PreviewPane.vue +223 -0
  34. package/app/components/ProposalWithdraw.vue +26 -0
  35. package/app/components/RemovedList.vue +103 -0
  36. package/app/components/ReviewDecide.vue +90 -0
  37. package/app/components/ReviewItem.vue +101 -0
  38. package/app/components/ReviewPane.vue +93 -0
  39. package/app/components/ReviewRow.vue +106 -0
  40. package/app/components/SavedViews.vue +112 -0
  41. package/app/components/ScheduleField.vue +46 -0
  42. package/app/components/SignOut.vue +14 -0
  43. package/app/components/SiteBackup.vue +106 -0
  44. package/app/components/SiteConnect.vue +46 -0
  45. package/app/components/SiteDeleting.vue +40 -0
  46. package/app/components/SiteRail.vue +37 -0
  47. package/app/components/SiteTabBar.vue +52 -0
  48. package/app/components/SiteToken.vue +87 -0
  49. package/app/components/SiteZoneNote.vue +21 -0
  50. package/app/components/SplitHandle.vue +48 -0
  51. package/app/components/StorageNotice.vue +54 -0
  52. package/app/components/StudioPage.vue +28 -0
  53. package/app/components/TaskSheet.vue +545 -0
  54. package/app/components/TodayDrafts.vue +82 -0
  55. package/app/components/TranslationBadges.vue +16 -0
  56. package/app/components/TranslationList.vue +87 -0
  57. package/app/components/UsedInList.vue +25 -0
  58. package/app/components/WhyNotPublic.vue +38 -0
  59. package/app/components/editor/BlockMenu.vue +176 -0
  60. package/app/components/editor/ComponentSettings.vue +108 -0
  61. package/app/components/editor/ComponentView.vue +278 -0
  62. package/app/components/editor/EditorBubble.vue +64 -0
  63. package/app/components/editor/EditorToolbar.vue +208 -0
  64. package/app/components/editor/FactSettings.vue +98 -0
  65. package/app/components/editor/FindBar.vue +88 -0
  66. package/app/components/editor/ImageBubble.vue +144 -0
  67. package/app/components/editor/ImageDialog.vue +165 -0
  68. package/app/components/editor/InlineComponentView.vue +112 -0
  69. package/app/components/editor/LinkPopover.vue +119 -0
  70. package/app/components/editor/LinkTargetList.vue +54 -0
  71. package/app/components/editor/MarkdownEditor.vue +555 -0
  72. package/app/components/editor/PropField.vue +185 -0
  73. package/app/components/editor/SlashMenu.vue +69 -0
  74. package/app/components/editor/SourceToggle.vue +28 -0
  75. package/app/components/editor/TableBar.vue +115 -0
  76. package/app/components/editor/ToolToggle.vue +20 -0
  77. package/app/components/editor/context.ts +83 -0
  78. package/app/components/editor/dock.ts +30 -0
  79. package/app/components/editor/extensions.ts +398 -0
  80. package/app/components/editor/liveComponents.ts +21 -0
  81. package/app/components/editor/useImageUploads.ts +111 -0
  82. package/app/components/fields/FieldFrame.vue +77 -0
  83. package/app/components/fields/FocusPicker.vue +143 -0
  84. package/app/components/fields/FrameDialog.vue +28 -0
  85. package/app/components/fields/GinkoField.vue +205 -0
  86. package/app/components/fields/GinkoFieldChoice.vue +35 -0
  87. package/app/components/fields/GinkoFieldChoices.vue +42 -0
  88. package/app/components/fields/GinkoFieldDate.vue +52 -0
  89. package/app/components/fields/GinkoFieldDaterange.vue +32 -0
  90. package/app/components/fields/GinkoFieldFile.vue +97 -0
  91. package/app/components/fields/GinkoFieldImage.vue +228 -0
  92. package/app/components/fields/GinkoFieldList.vue +335 -0
  93. package/app/components/fields/GinkoFieldMoney.vue +67 -0
  94. package/app/components/fields/GinkoFieldNumber.vue +28 -0
  95. package/app/components/fields/GinkoFieldRef.vue +98 -0
  96. package/app/components/fields/ImageFrames.vue +70 -0
  97. package/app/components/fields/SlugChange.vue +75 -0
  98. package/app/components/fields/refs.ts +20 -0
  99. package/app/components/fields/sizes.ts +21 -0
  100. package/app/components/files/FileGrid.vue +128 -0
  101. package/app/components/files/FileInfoPanel.vue +172 -0
  102. package/app/components/files/FileRemoveDialog.vue +45 -0
  103. package/app/components/files/FilesBrowser.vue +510 -0
  104. package/app/components/files/FilesSidebar.vue +189 -0
  105. package/app/components/files/LibraryPicker.vue +30 -0
  106. package/app/components/files/LibraryPickerBody.vue +89 -0
  107. package/app/components/files/util.ts +27 -0
  108. package/app/components/today/TodayArea.vue +121 -0
  109. package/app/components/today/TodayCard.vue +43 -0
  110. package/app/components/today/TodayRows.vue +101 -0
  111. package/app/components/today/TodayVerdict.vue +53 -0
  112. package/app/components/today/TodayWaiting.vue +67 -0
  113. package/app/components/today/context.ts +31 -0
  114. package/app/components/ui/alert/Alert.vue +21 -0
  115. package/app/components/ui/alert/AlertDescription.vue +17 -0
  116. package/app/components/ui/alert/AlertTitle.vue +17 -0
  117. package/app/components/ui/alert/index.ts +24 -0
  118. package/app/components/ui/badge/Badge.vue +26 -0
  119. package/app/components/ui/badge/index.ts +31 -0
  120. package/app/components/ui/button/Button.vue +31 -0
  121. package/app/components/ui/button/index.ts +40 -0
  122. package/app/components/ui/calendar/Calendar.vue +162 -0
  123. package/app/components/ui/calendar/CalendarCell.vue +23 -0
  124. package/app/components/ui/calendar/CalendarCellTrigger.vue +39 -0
  125. package/app/components/ui/calendar/CalendarGrid.vue +23 -0
  126. package/app/components/ui/calendar/CalendarGridBody.vue +15 -0
  127. package/app/components/ui/calendar/CalendarGridHead.vue +16 -0
  128. package/app/components/ui/calendar/CalendarGridRow.vue +22 -0
  129. package/app/components/ui/calendar/CalendarHeadCell.vue +23 -0
  130. package/app/components/ui/calendar/CalendarHeader.vue +23 -0
  131. package/app/components/ui/calendar/CalendarHeading.vue +30 -0
  132. package/app/components/ui/calendar/CalendarNextButton.vue +31 -0
  133. package/app/components/ui/calendar/CalendarPrevButton.vue +31 -0
  134. package/app/components/ui/calendar/index.ts +14 -0
  135. package/app/components/ui/card/Card.vue +22 -0
  136. package/app/components/ui/card/CardAction.vue +17 -0
  137. package/app/components/ui/card/CardContent.vue +17 -0
  138. package/app/components/ui/card/CardDescription.vue +17 -0
  139. package/app/components/ui/card/CardFooter.vue +17 -0
  140. package/app/components/ui/card/CardHeader.vue +17 -0
  141. package/app/components/ui/card/CardTitle.vue +17 -0
  142. package/app/components/ui/card/index.ts +7 -0
  143. package/app/components/ui/checkbox/Checkbox.vue +35 -0
  144. package/app/components/ui/checkbox/index.ts +1 -0
  145. package/app/components/ui/collapsible/Collapsible.vue +19 -0
  146. package/app/components/ui/collapsible/CollapsibleContent.vue +15 -0
  147. package/app/components/ui/collapsible/CollapsibleTrigger.vue +15 -0
  148. package/app/components/ui/collapsible/index.ts +3 -0
  149. package/app/components/ui/command/Command.vue +93 -0
  150. package/app/components/ui/command/CommandDialog.vue +31 -0
  151. package/app/components/ui/command/CommandEmpty.vue +27 -0
  152. package/app/components/ui/command/CommandGroup.vue +45 -0
  153. package/app/components/ui/command/CommandInput.vue +39 -0
  154. package/app/components/ui/command/CommandItem.vue +76 -0
  155. package/app/components/ui/command/CommandList.vue +25 -0
  156. package/app/components/ui/command/CommandSeparator.vue +21 -0
  157. package/app/components/ui/command/CommandShortcut.vue +17 -0
  158. package/app/components/ui/command/index.ts +25 -0
  159. package/app/components/ui/dialog/Dialog.vue +19 -0
  160. package/app/components/ui/dialog/DialogClose.vue +15 -0
  161. package/app/components/ui/dialog/DialogContent.vue +55 -0
  162. package/app/components/ui/dialog/DialogDescription.vue +23 -0
  163. package/app/components/ui/dialog/DialogFooter.vue +27 -0
  164. package/app/components/ui/dialog/DialogHeader.vue +17 -0
  165. package/app/components/ui/dialog/DialogOverlay.vue +21 -0
  166. package/app/components/ui/dialog/DialogScrollContent.vue +61 -0
  167. package/app/components/ui/dialog/DialogTitle.vue +23 -0
  168. package/app/components/ui/dialog/DialogTrigger.vue +15 -0
  169. package/app/components/ui/dialog/index.ts +10 -0
  170. package/app/components/ui/dropdown-menu/DropdownMenu.vue +19 -0
  171. package/app/components/ui/dropdown-menu/DropdownMenuCheckboxItem.vue +39 -0
  172. package/app/components/ui/dropdown-menu/DropdownMenuContent.vue +39 -0
  173. package/app/components/ui/dropdown-menu/DropdownMenuGroup.vue +15 -0
  174. package/app/components/ui/dropdown-menu/DropdownMenuItem.vue +31 -0
  175. package/app/components/ui/dropdown-menu/DropdownMenuLabel.vue +23 -0
  176. package/app/components/ui/dropdown-menu/DropdownMenuRadioGroup.vue +21 -0
  177. package/app/components/ui/dropdown-menu/DropdownMenuRadioItem.vue +40 -0
  178. package/app/components/ui/dropdown-menu/DropdownMenuSeparator.vue +23 -0
  179. package/app/components/ui/dropdown-menu/DropdownMenuShortcut.vue +17 -0
  180. package/app/components/ui/dropdown-menu/DropdownMenuSub.vue +18 -0
  181. package/app/components/ui/dropdown-menu/DropdownMenuSubContent.vue +27 -0
  182. package/app/components/ui/dropdown-menu/DropdownMenuSubTrigger.vue +31 -0
  183. package/app/components/ui/dropdown-menu/DropdownMenuTrigger.vue +17 -0
  184. package/app/components/ui/dropdown-menu/index.ts +16 -0
  185. package/app/components/ui/input/Input.vue +33 -0
  186. package/app/components/ui/input/index.ts +1 -0
  187. package/app/components/ui/label/Label.vue +26 -0
  188. package/app/components/ui/label/index.ts +1 -0
  189. package/app/components/ui/native-select/NativeSelect.vue +50 -0
  190. package/app/components/ui/native-select/NativeSelectOptGroup.vue +12 -0
  191. package/app/components/ui/native-select/NativeSelectOption.vue +12 -0
  192. package/app/components/ui/native-select/index.ts +3 -0
  193. package/app/components/ui/number-field/NumberField.vue +20 -0
  194. package/app/components/ui/number-field/NumberFieldContent.vue +14 -0
  195. package/app/components/ui/number-field/NumberFieldDecrement.vue +22 -0
  196. package/app/components/ui/number-field/NumberFieldIncrement.vue +22 -0
  197. package/app/components/ui/number-field/NumberFieldInput.vue +16 -0
  198. package/app/components/ui/number-field/index.ts +5 -0
  199. package/app/components/ui/popover/Popover.vue +19 -0
  200. package/app/components/ui/popover/PopoverAnchor.vue +15 -0
  201. package/app/components/ui/popover/PopoverContent.vue +45 -0
  202. package/app/components/ui/popover/PopoverTrigger.vue +15 -0
  203. package/app/components/ui/popover/index.ts +4 -0
  204. package/app/components/ui/radio-group/RadioGroup.vue +25 -0
  205. package/app/components/ui/radio-group/RadioGroupItem.vue +40 -0
  206. package/app/components/ui/radio-group/index.ts +2 -0
  207. package/app/components/ui/scroll-area/ScrollArea.vue +33 -0
  208. package/app/components/ui/scroll-area/ScrollBar.vue +32 -0
  209. package/app/components/ui/scroll-area/index.ts +2 -0
  210. package/app/components/ui/select/Select.vue +19 -0
  211. package/app/components/ui/select/SelectContent.vue +51 -0
  212. package/app/components/ui/select/SelectGroup.vue +15 -0
  213. package/app/components/ui/select/SelectItem.vue +44 -0
  214. package/app/components/ui/select/SelectItemText.vue +15 -0
  215. package/app/components/ui/select/SelectLabel.vue +17 -0
  216. package/app/components/ui/select/SelectScrollDownButton.vue +26 -0
  217. package/app/components/ui/select/SelectScrollUpButton.vue +26 -0
  218. package/app/components/ui/select/SelectSeparator.vue +19 -0
  219. package/app/components/ui/select/SelectTrigger.vue +33 -0
  220. package/app/components/ui/select/SelectValue.vue +15 -0
  221. package/app/components/ui/select/index.ts +11 -0
  222. package/app/components/ui/separator/Separator.vue +29 -0
  223. package/app/components/ui/separator/index.ts +1 -0
  224. package/app/components/ui/sheet/Sheet.vue +19 -0
  225. package/app/components/ui/sheet/SheetClose.vue +15 -0
  226. package/app/components/ui/sheet/SheetContent.vue +64 -0
  227. package/app/components/ui/sheet/SheetDescription.vue +21 -0
  228. package/app/components/ui/sheet/SheetFooter.vue +16 -0
  229. package/app/components/ui/sheet/SheetHeader.vue +15 -0
  230. package/app/components/ui/sheet/SheetOverlay.vue +21 -0
  231. package/app/components/ui/sheet/SheetTitle.vue +21 -0
  232. package/app/components/ui/sheet/SheetTrigger.vue +15 -0
  233. package/app/components/ui/sheet/index.ts +8 -0
  234. package/app/components/ui/skeleton/Skeleton.vue +17 -0
  235. package/app/components/ui/skeleton/index.ts +1 -0
  236. package/app/components/ui/sonner/Sonner.vue +42 -0
  237. package/app/components/ui/sonner/index.ts +1 -0
  238. package/app/components/ui/switch/Switch.vue +38 -0
  239. package/app/components/ui/switch/index.ts +1 -0
  240. package/app/components/ui/tabs/Tabs.vue +24 -0
  241. package/app/components/ui/tabs/TabsContent.vue +21 -0
  242. package/app/components/ui/tabs/TabsList.vue +24 -0
  243. package/app/components/ui/tabs/TabsTrigger.vue +26 -0
  244. package/app/components/ui/tabs/index.ts +4 -0
  245. package/app/components/ui/tags-input/TagsInput.vue +26 -0
  246. package/app/components/ui/tags-input/TagsInputInput.vue +17 -0
  247. package/app/components/ui/tags-input/TagsInputItem.vue +20 -0
  248. package/app/components/ui/tags-input/TagsInputItemDelete.vue +22 -0
  249. package/app/components/ui/tags-input/TagsInputItemText.vue +19 -0
  250. package/app/components/ui/tags-input/index.ts +5 -0
  251. package/app/components/ui/textarea/Textarea.vue +28 -0
  252. package/app/components/ui/textarea/index.ts +1 -0
  253. package/app/components/ui/toggle/Toggle.vue +35 -0
  254. package/app/components/ui/toggle/index.ts +31 -0
  255. package/app/components/ui/toggle-group/ToggleGroup.vue +49 -0
  256. package/app/components/ui/toggle-group/ToggleGroupItem.vue +46 -0
  257. package/app/components/ui/toggle-group/index.ts +2 -0
  258. package/app/components/ui/tooltip/Tooltip.vue +19 -0
  259. package/app/components/ui/tooltip/TooltipContent.vue +34 -0
  260. package/app/components/ui/tooltip/TooltipProvider.vue +14 -0
  261. package/app/components/ui/tooltip/TooltipTrigger.vue +15 -0
  262. package/app/components/ui/tooltip/index.ts +4 -0
  263. package/app/composables/useAll.ts +39 -0
  264. package/app/composables/useAreaList.ts +18 -0
  265. package/app/composables/useBottomBar.ts +6 -0
  266. package/app/composables/useConvexGinkoAssets.ts +35 -0
  267. package/app/composables/useEntryForm.ts +448 -0
  268. package/app/composables/useFacts.ts +35 -0
  269. package/app/composables/useFilesLibrary.ts +201 -0
  270. package/app/composables/useKeptEntry.ts +15 -0
  271. package/app/composables/useLocalDraft.ts +173 -0
  272. package/app/composables/useLocalDraftRows.ts +47 -0
  273. package/app/composables/useOps.ts +365 -0
  274. package/app/composables/usePageHeader.ts +59 -0
  275. package/app/composables/useRecentEntries.ts +46 -0
  276. package/app/composables/useSignOut.ts +57 -0
  277. package/app/composables/useSiteData.ts +59 -0
  278. package/app/composables/useSiteRefs.ts +22 -0
  279. package/app/composables/useStillRight.ts +30 -0
  280. package/app/composables/useStudioLocale.ts +40 -0
  281. package/app/composables/useTextOf.ts +11 -0
  282. package/app/composables/useToast.ts +38 -0
  283. package/app/composables/useTodayAreas.ts +398 -0
  284. package/app/composables/useUpdateSite.ts +27 -0
  285. package/app/composables/useUpload.ts +59 -0
  286. package/app/convex-auth.ts +6 -0
  287. package/app/error.vue +32 -0
  288. package/app/layouts/default.vue +29 -0
  289. package/app/layouts/site.vue +222 -0
  290. package/app/lib/utils.ts +7 -0
  291. package/app/pages/account.vue +139 -0
  292. package/app/pages/connect.vue +118 -0
  293. package/app/pages/index.vue +114 -0
  294. package/app/pages/invite/[token].vue +92 -0
  295. package/app/pages/login.vue +106 -0
  296. package/app/pages/new.vue +114 -0
  297. package/app/pages/s/[site]/ai/index.vue +197 -0
  298. package/app/pages/s/[site]/all/[brick]/[entry].vue +86 -0
  299. package/app/pages/s/[site]/all/[brick]/index.vue +179 -0
  300. package/app/pages/s/[site]/all/index.vue +112 -0
  301. package/app/pages/s/[site]/files/index.vue +28 -0
  302. package/app/pages/s/[site]/history/index.vue +70 -0
  303. package/app/pages/s/[site]/index.vue +309 -0
  304. package/app/pages/s/[site]/review/index.vue +206 -0
  305. package/app/pages/s/[site]/team/index.vue +509 -0
  306. package/app/utils/backup.ts +51 -0
  307. package/app/utils/basics.ts +24 -0
  308. package/app/utils/content.ts +395 -0
  309. package/app/utils/facts.ts +26 -0
  310. package/app/utils/frames.ts +26 -0
  311. package/app/utils/groups.ts +28 -0
  312. package/app/utils/keys.ts +3 -0
  313. package/app/utils/labels.ts +37 -0
  314. package/app/utils/markdownDiff.ts +53 -0
  315. package/app/utils/messageOf.ts +17 -0
  316. package/app/utils/origin.ts +9 -0
  317. package/app/utils/paragraphDiff.ts +35 -0
  318. package/app/utils/previewPage.ts +49 -0
  319. package/app/utils/review.ts +9 -0
  320. package/app/utils/sheetDialog.ts +15 -0
  321. package/app/utils/shrunk.ts +41 -0
  322. package/app/utils/siteLinks.ts +16 -0
  323. package/app/utils/sites.ts +37 -0
  324. package/app/utils/size.ts +20 -0
  325. package/app/utils/slugChange.ts +15 -0
  326. package/app/utils/textOf.ts +65 -0
  327. package/app/utils/today.ts +118 -0
  328. package/app/utils/when.ts +86 -0
  329. package/app/utils/who.ts +30 -0
  330. package/i18n/de.json +1361 -0
  331. package/i18n/en.json +1361 -0
  332. package/i18n/es.json +1361 -0
  333. package/i18n/fr.json +1361 -0
  334. package/modules/server-api.ts +16 -0
  335. package/modules/server-messages.ts +14 -0
  336. package/nuxt.config.ts +102 -0
  337. package/package.json +71 -3
  338. package/server/ginko-platform.ts +13 -0
@@ -0,0 +1,190 @@
1
+ <!-- What a change did, field by field (UI.md 10.5): "Before" and "After" in the words of the list
2
+ (displayValue). Long text shows only the changed paragraphs, a rich text its changed blocks formatted (a heading
3
+ as a heading, a bullet as a bullet, a picture as a thumbnail), each with a visible − / + in front so the change
4
+ does not depend on colour. Shared by History and Review. -->
5
+ <script setup lang="ts">
6
+ import { api } from '#convex/api'
7
+ import { useI18n } from '#imports'
8
+ import type { Fields, Json, Locale } from '@lupinum/ginko'
9
+ import { fileRefOf, isShown, ordered } from '@lupinum/ginko/internal'
10
+ import { GinkoMarkdown } from '@lupinum/ginko/vue'
11
+ import { computedAsync } from '@vueuse/core'
12
+ import { computed, defineComponent, h } from 'vue'
13
+ import { displayValue, rowTitle } from '../utils/content'
14
+ import { markdownDiff, pictureIdsOf, type BlockChange } from '../utils/markdownDiff'
15
+ import { paragraphDiff } from '../utils/paragraphDiff'
16
+ import { useStudioSite } from '../utils/labels'
17
+ import type { DiffField } from '../utils/review'
18
+
19
+ /** `site`: for the thumbnails of pictures in rich texts; without it a picture shows its description only. `split`: a
20
+ * plain value shows Before and After side by side once the diff is wide enough, on an inset surface (Review). */
21
+ const props = defineProps<{ diff: readonly DiffField[]; fields?: Fields; locale: Locale; site?: string; split?: boolean }>()
22
+ const { t, format } = useI18n()
23
+ const { shown } = useStudioSite()
24
+
25
+ interface Unit { tag?: string; before: Json | null; after: Json | null }
26
+
27
+ const LONG = new Set(['longtext', 'markdown'])
28
+
29
+ const items = computed(() => props.diff.map((d) => {
30
+ const units: Unit[] = d.locales ? d.locales.map((l) => ({ tag: l.locale.toUpperCase(), before: l.before, after: l.after })) : [{ before: d.before, after: d.after }]
31
+ return { d, units: d.locales && d.locales.length === 1 && d.locales[0]!.locale === props.locale ? units.map((u) => ({ ...u, tag: undefined })) : units }
32
+ }))
33
+
34
+ /** A value like in the list; a field the schema no longer has shows plain text, or "changed" for anything bigger. */
35
+ function show(d: DiffField, value: Json | null): string {
36
+ const field = props.fields && Object.hasOwn(props.fields, d.field) ? props.fields[d.field] : undefined
37
+ if (field) return displayValue(field, value, props.locale, { t, format })
38
+ if (value === null || value === '') return t('ops.value.empty')
39
+ return typeof value === 'string' || typeof value === 'number' ? String(value) : t('ops.value.changed')
40
+ }
41
+
42
+ type RowDiff = NonNullable<DiffField['rows']>[number]
43
+ interface Cell { key: string; label: string; before?: string; after?: string; kept?: boolean }
44
+
45
+ function columnsOf(d: DiffField): Fields {
46
+ const field = props.fields && Object.hasOwn(props.fields, d.field) ? props.fields[d.field] : undefined
47
+ return field?.type === 'list' ? field.of : {}
48
+ }
49
+
50
+ const filled = (value: Json | undefined) => value !== undefined && value !== null && value !== ''
51
+
52
+ /** One cell value of a row; a column the schema no longer has shows plain text. */
53
+ function cellText(columns: Fields, key: string, value: Json | undefined): string {
54
+ if (Object.hasOwn(columns, key)) return displayValue(columns[key]!, value ?? null, props.locale, { t, format })
55
+ return value === undefined || value === null || value === '' ? t('ops.value.empty') : typeof value === 'string' || typeof value === 'number' ? String(value) : t('ops.value.changed')
56
+ }
57
+
58
+ /** A changed row by its name (first text column, else the item label): its changed cells as old → new, then its other
59
+ * shown, filled cells as they stay (the allergens next to a new dish). Added and removed rows list their filled cells. */
60
+ function rowView(d: DiffField, row: RowDiff) {
61
+ const columns = columnsOf(d)
62
+ const list = props.fields && Object.hasOwn(props.fields, d.field) ? props.fields[d.field] : undefined
63
+ const data = (row.after ?? row.before) as Record<string, Json> | null
64
+ const named = rowTitle(columns, row.before ?? row.after, props.locale, { t, format })
65
+ const title = named?.text || (list?.type === 'list' ? shown(list.itemLabel) : '')
66
+ const label = (key: string) => (Object.hasOwn(columns, key) ? shown(columns[key]!.label) : key)
67
+ const cells: Cell[] = row.change === 'changed' ? changedCells(columns, row, named?.key, label) : Object.keys(columns).filter((key) => key !== named?.key && data && filled(data[key])).map((key) => ({ key, label: label(key), after: cellText(columns, key, data![key]) }))
68
+ return { id: row.id, change: row.change, title, cells }
69
+ }
70
+
71
+ function changedCells(columns: Fields, row: RowDiff, titleKey: string | undefined, label: (key: string) => string): Cell[] {
72
+ const before = (row.before ?? {}) as Record<string, Json>
73
+ const after = (row.after ?? {}) as Record<string, Json>
74
+ const changed = new Set((row.fields ?? []).filter((k) => k !== '_id'))
75
+ const keys = [...ordered(columns).map(([k]) => k), ...[...changed].filter((k) => !Object.hasOwn(columns, k))]
76
+ return keys.flatMap((key): Cell[] => {
77
+ if (changed.has(key)) return [{ key, label: label(key), before: cellText(columns, key, before[key]), after: cellText(columns, key, after[key]) }]
78
+ const column = columns[key]
79
+ if (key === '_id' || key === titleKey || !column || column.retired || !isShown(column, after) || (!filled(before[key]) && !filled(after[key]))) return []
80
+ return [{ key, label: label(key), after: cellText(columns, key, after[key]), kept: true }]
81
+ })
82
+ }
83
+
84
+ const asText = (value: Json | null): string => (typeof value === 'string' ? value : '')
85
+ const isLong = (d: DiffField, u: Unit) => LONG.has(d.kind) && (typeof u.before === 'string' || u.before === null) && (typeof u.after === 'string' || u.after === null)
86
+ const isRich = (d: DiffField, u: Unit) => d.kind === 'markdown' && isLong(d, u)
87
+
88
+ // Rich texts: their changed blocks per field and language, parsed in the browser. Empty until parsed.
89
+ const blocks = computedAsync(async () => {
90
+ const out = new Map<string, BlockChange[]>()
91
+ for (const { d, units } of items.value) {
92
+ for (const [i, u] of units.entries()) if (isRich(d, u)) out.set(`${d.field}:${i}`, await markdownDiff(asText(u.before), asText(u.after)))
93
+ }
94
+ return out
95
+ }, new Map<string, BlockChange[]>())
96
+ const pictureIds = computed(() => [...new Set([...blocks.value.values()].flatMap(pictureIdsOf))])
97
+ const pictures = useConvexQuery(api.uploads.urls, () => (props.site && pictureIds.value.length ? { site: props.site, ids: pictureIds.value } : 'skip'))
98
+
99
+ /** A picture in a rich text: a small thumbnail of the library file and its description, never its file id. */
100
+ const DiffPicture = defineComponent({
101
+ props: { src: { type: String, default: '' }, alt: { type: String, default: '' } },
102
+ setup(p) {
103
+ return () => {
104
+ const id = fileRefOf(p.src)
105
+ const url = id ? pictures.data.value?.[id]?.url : undefined
106
+ return h('span', { class: 'inline-grid max-w-full gap-1 align-top' }, [
107
+ url ? h('img', { src: url, alt: '', class: 'h-24 w-auto max-w-full rounded-sm border object-cover' }) : null,
108
+ h('span', { class: 'text-xs text-muted-foreground' }, p.alt || t('review.diff.picture')),
109
+ ])
110
+ }
111
+ },
112
+ })
113
+ /** A link shows as underlined text: the history never navigates. */
114
+ const DiffLink = defineComponent({
115
+ props: { href: { type: String, default: '' } },
116
+ setup: (_, { slots }) => () => h('span', { class: 'underline underline-offset-2' }, slots.default?.()),
117
+ })
118
+ const richParts = { img: DiffPicture, a: DiffLink }
119
+ </script>
120
+
121
+ <template>
122
+ <div :class="['grid gap-3', split && '@container']">
123
+ <section v-for="{ d, units } in items" :key="d.field" class="grid gap-1.5">
124
+ <h4 class="font-semibold">{{ d.label }}</h4>
125
+ <template v-if="!d.rows">
126
+ <div v-for="(u, i) in units" :key="i" :class="['grid gap-1 rounded-md', !split ? 'border bg-card px-3 py-2' : isLong(d, u) ? '' : 'bg-muted/50 px-3 py-2']">
127
+ <p v-if="u.tag" class="text-sm font-medium text-muted-foreground">{{ u.tag }}</p>
128
+ <div v-if="isRich(d, u)" class="grid gap-1">
129
+ <template v-for="(b, n) in blocks.get(`${d.field}:${i}`) ?? []" :key="n">
130
+ <del v-if="b.kind === 'removed'" class="rich flex gap-2 rounded-sm bg-destructive/8 px-2 py-1">
131
+ <span class="shrink-0">−</span>
132
+ <Suspense><GinkoMarkdown class="min-w-0" :value="b.tree" :components="richParts" /></Suspense>
133
+ </del>
134
+ <ins v-else class="rich flex gap-2 rounded-sm bg-success/10 px-2 py-1 no-underline">
135
+ <span class="shrink-0">+</span>
136
+ <Suspense><GinkoMarkdown class="min-w-0" :value="b.tree" :components="richParts" /></Suspense>
137
+ </ins>
138
+ </template>
139
+ </div>
140
+ <div v-else-if="isLong(d, u)" class="grid gap-1">
141
+ <p v-for="(p, n) in paragraphDiff(asText(u.before), asText(u.after))" :key="n">
142
+ <del v-if="p.kind === 'removed'" class="block rounded-sm bg-destructive/8 px-2 py-1">− {{ p.text }}</del>
143
+ <ins v-else class="block rounded-sm bg-success/10 px-2 py-1 no-underline">+ {{ p.text }}</ins>
144
+ </p>
145
+ </div>
146
+ <dl v-else :class="['grid grid-cols-[auto_1fr] gap-x-3 gap-y-0.5', split && '@md:grid-flow-col @md:grid-cols-2 @md:grid-rows-[auto_auto] @md:max-w-md @md:gap-x-6']">
147
+ <dt :class="['text-muted-foreground', split && '@md:text-[13px]']">{{ t('review.diff.before') }}</dt>
148
+ <dd>{{ show(d, u.before) }}</dd>
149
+ <dt :class="['text-muted-foreground', split && '@md:text-[13px]']">{{ t('review.diff.after') }}</dt>
150
+ <dd class="font-medium">{{ show(d, u.after) }}</dd>
151
+ </dl>
152
+ </div>
153
+ </template>
154
+ <ul v-if="d.rows?.length || d.reordered" :class="['grid gap-1.5 rounded-md px-3 py-2 text-sm', split ? 'bg-muted/50' : 'border bg-card']">
155
+ <li v-for="r in d.rows?.map((row) => rowView(d, row))" :key="r.id" class="grid gap-0.5">
156
+ <p :class="r.change === 'removed' ? 'text-muted-foreground' : 'font-medium'">
157
+ <del v-if="r.change === 'removed'">− {{ r.title }}</del>
158
+ <template v-else>{{ r.change === 'added' ? '+ ' : '' }}{{ r.title }}</template>
159
+ </p>
160
+ <p v-for="c in r.cells" :key="c.key" class="flex min-w-0 flex-wrap gap-x-1 pl-3" :title="c.before !== undefined ? `${c.label}: ${c.before} → ${c.after}` : `${c.label}: ${c.after}`">
161
+ <span class="shrink-0 text-muted-foreground">{{ `${c.label}: ` }}</span>
162
+ <template v-if="c.before !== undefined">
163
+ <span class="max-w-full truncate text-muted-foreground line-through">{{ `${c.before} ` }}</span>
164
+ <span class="shrink-0">{{ `→ ` }}</span>
165
+ <span class="min-w-0 break-words font-medium">{{ c.after }}</span>
166
+ </template>
167
+ <span v-else :class="['truncate', c.kept && 'text-muted-foreground']">{{ c.after }}</span>
168
+ </p>
169
+ </li>
170
+ <li v-if="d.reordered">{{ t('review.diff.reordered') }}</li>
171
+ </ul>
172
+ </section>
173
+ </div>
174
+ </template>
175
+
176
+ <style scoped>
177
+ /* A rich text block in the diff: compact, like the list's text, with headings and lists that still read as such. */
178
+ .rich :deep(.comark-content > *) { margin: 0; }
179
+ .rich :deep(:is(h1, h2, h3, h4, h5, h6)) { font-weight: 600; }
180
+ .rich :deep(h1), .rich :deep(h2) { font-size: 1.125rem; line-height: 1.4; }
181
+ .rich :deep(h3) { font-size: 1rem; }
182
+ .rich :deep(:is(ul, ol)) { padding-left: 1.25rem; }
183
+ .rich :deep(ul) { list-style: disc; }
184
+ .rich :deep(ol) { list-style: decimal; }
185
+ .rich :deep(blockquote) { border-left: 2px solid var(--border); padding-left: 0.75rem; }
186
+ .rich :deep(code) { border-radius: 0.25rem; background: var(--muted); padding: 0 0.25rem; font-family: ui-monospace, monospace; font-size: 0.9em; }
187
+ .rich :deep(pre) { overflow-x: auto; white-space: pre-wrap; font-family: ui-monospace, monospace; font-size: 0.875rem; }
188
+ /* A removed block is struck through to its last line, also inside the rendered text. */
189
+ del.rich :deep(.comark-content) { text-decoration: line-through; }
190
+ </style>
@@ -0,0 +1,333 @@
1
+ <!-- The change log (UI.md 7), one paginated query: older pages load on demand and every loaded page
2
+ stays live, so an undo on an older page updates its row at once. Rückgängig shows only on saves that are not undone yet, and for
3
+ staff only when one of their granted edit tasks covers every field of the change, or when the change is of an entry
4
+ they created (`own`) and they still hold its create task (SPEC 2.7); undo only with such a task without approval
5
+ (with approval, going back to a version becomes a proposal instead). An approved change names the approver. A save the
6
+ server would refuse to undo (`undoBlocked`: saved again, removed, fields restructured) says why
7
+ instead. "Zurück zu dieser Version" shows what it changes before it saves.
8
+ Layout (design A): days (Today, Yesterday, dates), each a card whose rows share columns (time, what and who, then fixed
9
+ action slots); from 1280px "Show changes" opens the diff in a sticky right column so the list keeps its place, below it
10
+ opens in the row. The revert question always stays in its row. The default slot sits above the log (OwnProposals). -->
11
+ <script setup lang="ts">
12
+ import { nextTick } from 'vue'
13
+ import { useMediaQuery } from '@vueuse/core'
14
+ import { EllipsisIcon, XIcon } from '@lucide/vue'
15
+ import { api } from '#convex/api'
16
+ import { labelOf, type Schema } from '@lupinum/ginko/internal'
17
+ import { opErrorOf } from '../composables/useOps'
18
+ import { useTextOf } from '../composables/useTextOf'
19
+ import { byText, whoText } from '../utils/who'
20
+ import { msToZoned, whenClock, whenFull } from '../utils/when'
21
+ import { Badge } from '@studio/components/ui/badge'
22
+ import { Button } from '@studio/components/ui/button'
23
+ import { DropdownMenu, DropdownMenuContent, DropdownMenuItem, DropdownMenuTrigger } from '@studio/components/ui/dropdown-menu'
24
+ import { Skeleton } from '@studio/components/ui/skeleton'
25
+
26
+ const props = defineProps<{
27
+ site: string
28
+ schema: Schema
29
+ manager: boolean
30
+ grants: ReadonlySet<string>
31
+ /** History filter (UI.md 10.5): `entry` is the list of that entry (see `entry`). */
32
+ filter?: 'all' | 'mine' | 'ai' | 'entry'
33
+ entry?: string
34
+ }>()
35
+ defineSlots<{ default?(): unknown }>()
36
+ const { t, format, locale } = useI18n()
37
+
38
+ const PAGE = 50
39
+ const by = (): 'me' | 'ai' | undefined => (props.filter === 'mine' ? 'me' : props.filter === 'ai' ? 'ai' : undefined)
40
+ // A new filter starts the list again by itself. Server rendering may start with a split first page; the list is then
41
+ // idle until the browser takes over, so the empty text waits for status 'success' (skeleton rows until then).
42
+ const list = useConvexPaginatedQuery(api.changes.list, () => ({ site: props.site, entry: props.filter === 'entry' ? props.entry : undefined, by: by() }), { initialNumItems: PAGE })
43
+ const ops = useOps(computed(() => props.site))
44
+
45
+ type Change = NonNullable<typeof list.data.value>[number]
46
+
47
+ const rows = computed<readonly Change[]>(() => list.data.value ?? [])
48
+ const loading = computed(() => !rows.value.length && list.status.value !== 'success' && !list.error.value)
49
+ // The detail column stays while a new filter or the first page loads, so the list keeps its width when rows arrive.
50
+ const asideShown = computed(() => wide.value && (rows.value.length > 0 || loading.value))
51
+
52
+ // Ticks so "Today" turns into "Yesterday" while the page stays open.
53
+ const now = ref(Date.now())
54
+ let timer: ReturnType<typeof setInterval> | undefined
55
+ onMounted(() => { timer = setInterval(() => { now.value = Date.now() }, 60_000) })
56
+ onUnmounted(() => clearInterval(timer))
57
+
58
+ const zone = () => props.schema.timeZone
59
+ const fullDate = (at: number) => whenFull(at, zone(), format)
60
+ const clock = (at: number) => whenClock(at, zone(), format)
61
+
62
+ /** The rows by day in the site's time zone (newest first, as the server sends them): Today, Yesterday, then dates. */
63
+ const days = computed(() => {
64
+ const today = msToZoned(now.value, zone()).slice(0, 10)
65
+ const [y, m, d] = today.split('-').map(Number)
66
+ const yesterday = new Date(Date.UTC(y!, m! - 1, d! - 1)).toISOString().slice(0, 10)
67
+ const groups: { key: string; label: string; rows: Change[] }[] = []
68
+ for (const change of rows.value) {
69
+ const key = msToZoned(change.at, zone()).slice(0, 10)
70
+ let group = groups.at(-1)
71
+ if (group?.key !== key) {
72
+ const label = key === today ? t('history.today') : key === yesterday ? t('history.yesterday')
73
+ : format.date(change.at, { timeZone: zone(), weekday: 'long', day: 'numeric', month: 'long', ...(key.slice(0, 4) === today.slice(0, 4) ? {} : { year: 'numeric' }) })
74
+ group = { key, label, rows: [] }
75
+ groups.push(group)
76
+ }
77
+ group.rows.push(change)
78
+ }
79
+ return groups
80
+ })
81
+
82
+ /** The line in the Studio's language, dates in the site's zone; rows from before `msg` show their German sentence. */
83
+ const textOf = useTextOf(() => ({ timeZone: props.schema.timeZone, main: props.schema.locales[0] }))
84
+ const sentenceOf = (change: Change) => textOf(change.msg, change.sentence)
85
+
86
+ /** Who made the change, and the AI key when one did. */
87
+ const actorName = (change: Change) => byText(change.who, change.via, change.agent, t)
88
+ const whoLine = (change: Change) => (change.approver ? `${actorName(change)} · ${t('history.approval', { who: whoText(change.approver, t) })}` : actorName(change))
89
+ /** The area of the change, as a chip; left out in the history of one entry, where it is always the same. */
90
+ const areaOf = (change: Change) => (props.filter !== 'entry' && Object.hasOwn(props.schema.bricks, change.brick) ? labelOf(props.schema.bricks[change.brick]!.label, locale.value, props.schema.locales[0]!) : undefined)
91
+
92
+ /**
93
+ * The task a staff member needs to go back on this save: one granted edit task that covers all its fields, else, for an
94
+ * entry they created, their create task of the brick (lib/access.ts `authorize`, the agent door's `taskFor`). `direct`
95
+ * asks for one without approval (undo writes at once, which the server refuses on such a task). Owners and admins need none.
96
+ */
97
+ function taskFor(change: Change, direct = false): string | undefined {
98
+ if (props.manager) return undefined
99
+ const fields = change.fields ?? []
100
+ const held = (props.schema.bricks[change.brick]?.tasks ?? [])
101
+ .filter((task) => props.grants.has(`${change.brick}.${task.id}`) && !(direct && task.needsApproval))
102
+ const found = held.find((task) => task.kind === 'edit' && fields.every((field) => task.fields.includes(field)))
103
+ ?? (change.own ? held.find((task) => task.kind === 'create') : undefined)
104
+ return found ? `${change.brick}.${found.id}` : undefined
105
+ }
106
+
107
+ function canUndo(change: Change): boolean {
108
+ return change.kind === 'save' && !change.undoneBy && (props.manager || taskFor(change, true) !== undefined)
109
+ }
110
+
111
+ /** Why the server would refuse an undo of this save (an undone one keeps its badge instead). */
112
+ function undoBlockedText(change: Change): string | undefined {
113
+ const block = change.undoBlocked
114
+ if (block === 'changed') return t('history.undoBlocked.changed')
115
+ if (block === 'removed') return t('history.undoBlocked.removed')
116
+ if (block === 'schema') return t('history.undoBlocked.schema')
117
+ return undefined
118
+ }
119
+
120
+ /** The change whose fields are shown: in the right column from 1280px, else under its row. One at a time. */
121
+ const wide = useMediaQuery('(min-width: 1280px)', { ssrWidth: 1024 })
122
+ const showing = ref<string | null>(null)
123
+ const toggleShow = (id: string) => { showing.value = showing.value === id ? null : id }
124
+ /** The shown change while it is in the list (a new filter can drop it). */
125
+ const shownRow = computed(() => rows.value.find((c) => c._id === showing.value))
126
+
127
+ const confirming = ref<string | null>(null)
128
+ /**
129
+ * Every row that wrote values can be gone back to: a save, an undo (it holds the state before a bad save) and the
130
+ * creation (the entry as it was made). A creation names no fields, so no staff task can be checked against it:
131
+ * owners and admins only.
132
+ */
133
+ function canRevert(change: Change): boolean {
134
+ if (!change.entry) return false
135
+ if (change.kind === 'create') return props.manager
136
+ return (change.kind === 'save' || change.kind === 'undo') && !!change.fields?.length && (props.manager || taskFor(change) !== undefined)
137
+ }
138
+ /**
139
+ * A save that cannot be undone says why; "Back to this version" is then the way out, so it sits in the Undo slot, not in
140
+ * the menu. Not for a removed entry: going back needs the entry, and the row says to restore it first.
141
+ */
142
+ const revertShown = (change: Change) => canRevert(change) && !!undoBlockedText(change) && change.undoBlocked !== 'removed' && confirming.value !== change._id
143
+ const hasMore = (change: Change) => (canRevert(change) && !undoBlockedText(change) && confirming.value !== change._id) || !!change.inTrash
144
+ // The question opens from the menu: focus goes into it instead of back to the menu button, and back to that button on Cancel.
145
+ let focusQuestion = false
146
+ function askRevert(id: string) {
147
+ confirming.value = id
148
+ focusQuestion = true
149
+ }
150
+ function askRevertHere(id: string) {
151
+ confirming.value = id
152
+ void nextTick(() => document.getElementById(`revert-${id}`)?.focus())
153
+ }
154
+ function menuClosed(event: Event, id: string) {
155
+ if (!focusQuestion) return
156
+ focusQuestion = false
157
+ event.preventDefault()
158
+ void nextTick(() => document.getElementById(`revert-${id}`)?.focus())
159
+ }
160
+ function cancelRevert(id: string) {
161
+ confirming.value = null
162
+ void nextTick(() => document.querySelector<HTMLElement>(`[data-more="${id}"]`)?.focus())
163
+ }
164
+ // What going back changes, read while the question is open (one row at a time). With the task the revert uses, so
165
+ // the preview leaves out what that task keeps (the week of the weekly task).
166
+ const version = useConvexQuery(api.entries.versionAt, () => {
167
+ const change = rows.value.find((c) => c._id === confirming.value)
168
+ if (!change?.entry) return 'skip'
169
+ const task = taskFor(change)
170
+ return { site: props.site, ...(task === undefined ? {} : { task }), entry: change.entry, change: change._id }
171
+ })
172
+ /** The answer for the open question; the one of the row asked before does not count. */
173
+ const versionShown = computed(() => (version.data.value?.change === confirming.value ? version.data.value : undefined))
174
+ const fieldsOf = (brick: string) => (Object.hasOwn(props.schema.bricks, brick) ? props.schema.bricks[brick]!.fields : undefined)
175
+ async function revert(change: Change) {
176
+ await whileBusy(change._id, async () => {
177
+ await ops.revertEntry(change.entry!, change._id, taskFor(change))
178
+ confirming.value = null
179
+ })
180
+ }
181
+
182
+ // One set for all loaded pages: each row stays disabled until its own undo or revert answered.
183
+ const busy = ref(new Set<string>())
184
+ async function whileBusy(id: string, run: () => Promise<unknown>) {
185
+ busy.value = new Set(busy.value).add(id)
186
+ try {
187
+ await run()
188
+ } finally {
189
+ const next = new Set(busy.value)
190
+ next.delete(id)
191
+ busy.value = next
192
+ }
193
+ }
194
+ async function undo(change: Change) {
195
+ await whileBusy(change._id, () => ops.undoChange(change._id, taskFor(change, true)))
196
+ }
197
+ </script>
198
+
199
+ <template>
200
+ <div :class="asideShown ? 'grid grid-cols-[minmax(0,1fr)_20rem] items-start gap-6' : ''">
201
+ <div class="grid min-w-0 gap-6">
202
+ <slot />
203
+ <p v-if="list.error.value" class="font-semibold text-destructive" role="alert">{{ t('history.loadFailed') }}</p>
204
+ <div v-if="loading" class="grid gap-2" aria-hidden="true">
205
+ <Skeleton class="h-4 w-24" />
206
+ <div class="divide-y rounded-xl border">
207
+ <div v-for="n in 4" :key="n" class="flex items-center gap-4 px-4 py-3.5">
208
+ <Skeleton class="h-3.5 w-10" />
209
+ <div class="grid flex-1 gap-2"><Skeleton class="h-4 w-2/3" /><Skeleton class="h-3 w-1/3" /></div>
210
+ </div>
211
+ </div>
212
+ </div>
213
+ <section v-for="day in days" :key="day.key" class="grid gap-2" :aria-labelledby="`day-${day.key}`">
214
+ <h2 :id="`day-${day.key}`" class="text-[13px] leading-5 font-medium text-muted-foreground">{{ day.label }}</h2>
215
+ <!-- From 640px the rows share the card's columns (subgrid): time, what and who, Show changes, Undo, more. -->
216
+ <ol class="m-0 list-none divide-y rounded-xl border bg-card p-0 min-[640px]:grid min-[640px]:grid-cols-[auto_minmax(0,1fr)_auto_auto_auto]">
217
+ <li
218
+ v-for="change in day.rows"
219
+ :key="change._id"
220
+ :class="['grid grid-cols-1 gap-y-2 px-4 py-3 min-[640px]:col-span-full min-[640px]:grid-cols-subgrid min-[640px]:gap-x-2 min-[640px]:py-2.5',
221
+ wide && showing === change._id ? 'bg-foreground/[0.03]' : '']"
222
+ >
223
+ <time :datetime="new Date(change.at).toISOString()" :title="fullDate(change.at)" class="hidden text-[13px] tabular-nums text-muted-foreground min-[640px]:block min-[640px]:row-start-1 min-[640px]:pr-2 min-[640px]:pt-[7px]">{{ clock(change.at) }}</time>
224
+ <div class="grid min-w-0 content-center gap-0.5 min-[640px]:col-start-2 min-[640px]:row-start-1 min-[640px]:min-h-9">
225
+ <p class="text-base font-medium [overflow-wrap:anywhere] min-[900px]:text-sm">
226
+ {{ sentenceOf(change) }}
227
+ <Badge v-if="areaOf(change)" as="span" variant="soft" class="ml-1 align-[1px] font-normal text-muted-foreground max-[639px]:hidden">{{ areaOf(change) }}</Badge>
228
+ <Badge v-if="change.undoneBy" as="span" variant="soft" class="ml-1 align-[1px]">{{ t('entry.changes.undone') }}</Badge>
229
+ </p>
230
+ <div class="flex flex-wrap items-center gap-x-1 text-[13px] text-muted-foreground">
231
+ <p class="text-[13px] [overflow-wrap:anywhere]">{{ whoLine(change) }}</p>
232
+ <!-- Phones have no time column: the time follows the name. -->
233
+ <span class="tabular-nums min-[640px]:hidden" :title="fullDate(change.at)">· {{ clock(change.at) }}</span>
234
+ <!-- Below 640px the area chip joins this line, so a row does not grow a short line of its own. -->
235
+ <Badge v-if="areaOf(change)" as="span" variant="soft" class="font-normal text-muted-foreground min-[640px]:hidden">{{ areaOf(change) }}</Badge>
236
+ </div>
237
+ <p v-if="canUndo(change) && undoBlockedText(change)" class="text-[13px] text-muted-foreground">{{ undoBlockedText(change) }}</p>
238
+ </div>
239
+ <div v-if="change.fields?.length || (canUndo(change) && !undoBlockedText(change)) || revertShown(change) || hasMore(change)" :class="['flex flex-wrap items-center gap-1 min-[640px]:contents', change.fields?.length ? '-ml-3' : '']">
240
+ <Button
241
+ v-if="change.fields?.length"
242
+ type="button"
243
+ variant="ghost" size="sm"
244
+ class="min-[640px]:col-start-3 min-[640px]:row-start-1 min-[640px]:self-start"
245
+ :aria-expanded="showing === change._id"
246
+ @click="toggleShow(change._id)"
247
+ >{{ showing === change._id ? t('history.hideChanges') : t('history.showChanges') }}</Button>
248
+ <Button
249
+ v-if="canUndo(change) && !undoBlockedText(change)"
250
+ type="button"
251
+ variant="outline"
252
+ size="sm"
253
+ class="min-[640px]:col-start-4 min-[640px]:row-start-1 min-[640px]:self-start min-[640px]:justify-self-start"
254
+ :disabled="busy.has(change._id)"
255
+ @click="undo(change)"
256
+ >{{ t('entry.changes.undo') }}</Button>
257
+ <Button
258
+ v-else-if="revertShown(change)"
259
+ :data-more="change._id"
260
+ type="button"
261
+ variant="outline"
262
+ size="sm"
263
+ class="min-[640px]:col-start-4 min-[640px]:row-start-1 min-[640px]:self-start min-[640px]:justify-self-start"
264
+ :disabled="busy.has(change._id)"
265
+ @click="askRevertHere(change._id)"
266
+ >{{ t('history.revert') }}</Button>
267
+ <DropdownMenu v-if="hasMore(change)">
268
+ <DropdownMenuTrigger as-child>
269
+ <Button :data-more="change._id" type="button" variant="ghost" size="icon-sm" class="min-[640px]:col-start-5 min-[640px]:row-start-1 min-[640px]:self-start" :aria-label="t('history.more')">
270
+ <EllipsisIcon class="size-4" aria-hidden="true" />
271
+ </Button>
272
+ </DropdownMenuTrigger>
273
+ <DropdownMenuContent align="end" @close-auto-focus="menuClosed($event, change._id)">
274
+ <DropdownMenuItem v-if="canRevert(change) && !undoBlockedText(change) && confirming !== change._id" class="min-h-9 pointer-coarse:min-h-11" @select="askRevert(change._id)">{{ t('history.revert') }}</DropdownMenuItem>
275
+ <DropdownMenuItem v-if="change.inTrash" as-child class="min-h-9 pointer-coarse:min-h-11">
276
+ <NuxtLink :to="`/s/${site}/all?removed`">{{ t('history.openTrash') }}</NuxtLink>
277
+ </DropdownMenuItem>
278
+ </DropdownMenuContent>
279
+ </DropdownMenu>
280
+ </div>
281
+ <div
282
+ v-if="confirming === change._id"
283
+ :id="`revert-${change._id}`"
284
+ tabindex="-1"
285
+ class="grid gap-3 rounded-lg text-sm min-[640px]:col-start-2 min-[640px]:col-end-[-1] outline-none focus-visible:ring-3 focus-visible:ring-ring/80"
286
+ role="group"
287
+ :aria-label="t('history.revert')"
288
+ >
289
+ <p v-if="versionShown && !versionShown.diff.length">{{ t('history.alreadyThere') }}</p>
290
+ <template v-else>
291
+ <p>{{ t('history.revertConfirm', { date: fullDate(change.at) }) }}</p>
292
+ <p v-if="version.error.value" class="font-medium text-destructive" role="alert">{{ opErrorOf(version.error.value).message }}</p>
293
+ <template v-else-if="versionShown">
294
+ <p class="font-medium">{{ t('history.revertChanges') }}</p>
295
+ <ChangeDiff :diff="versionShown.diff" :fields="fieldsOf(change.brick)" :locale="schema.locales[0]!" :site="site" split />
296
+ </template>
297
+ </template>
298
+ <div class="flex flex-wrap gap-2">
299
+ <Button v-if="versionShown?.diff.length" type="button" size="sm" :disabled="busy.has(change._id)" @click="revert(change)">{{ t('history.revert') }}</Button>
300
+ <Button type="button" variant="ghost" size="sm" @click="cancelRevert(change._id)">{{ t('entry.cancel') }}</Button>
301
+ </div>
302
+ </div>
303
+ <section v-if="!wide && showing === change._id" class="min-w-0 min-[640px]:col-start-2 min-[640px]:col-end-[-1] min-[900px]:text-sm" :aria-label="t('history.detail')">
304
+ <ChangeDetail :site="site" :change="change._id" :brick="change.brick" :schema="schema" />
305
+ </section>
306
+ </li>
307
+ </ol>
308
+ </section>
309
+ <p v-if="!rows.length && list.status.value === 'success'" class="rounded-xl border bg-card px-4 py-8 text-center text-muted-foreground min-[900px]:text-sm">{{ filter === 'entry' ? t('history.entryEmpty') : filter && filter !== 'all' ? t('history.noMatches') : t('entry.changes.empty') }}</p>
310
+ <div v-if="list.canLoadMore.value || list.isLoadingMore.value">
311
+ <Button type="button" variant="outline" :disabled="!list.canLoadMore.value" @click="list.loadMore(PAGE)">{{ t('site.history.loadOlder') }}</Button>
312
+ </div>
313
+ </div>
314
+ <aside v-if="asideShown" class="sticky top-[calc(var(--studio-header-height)+1.5rem)] grid max-h-[calc(100dvh-var(--studio-header-height)-3rem)] min-w-0 grid-rows-[auto_minmax(0,1fr)] gap-2">
315
+ <h2 id="change-detail" class="text-[13px] leading-5 font-medium text-muted-foreground">{{ t('history.detail') }}</h2>
316
+ <section v-if="shownRow" class="flex min-h-0 flex-col overflow-hidden rounded-xl border bg-card" aria-labelledby="change-detail">
317
+ <header class="flex items-start gap-2 border-b px-4 py-3">
318
+ <div class="grid min-w-0 flex-1 gap-0.5">
319
+ <h3 class="text-sm font-semibold [overflow-wrap:anywhere]">{{ sentenceOf(shownRow) }}</h3>
320
+ <p class="text-[13px] text-muted-foreground [overflow-wrap:anywhere]">{{ actorName(shownRow) }} · <span class="tabular-nums">{{ fullDate(shownRow.at) }}</span></p>
321
+ </div>
322
+ <Button type="button" variant="ghost" size="icon-sm" class="-mr-2" :aria-label="t('history.hideChanges')" @click="showing = null">
323
+ <XIcon class="size-4" aria-hidden="true" />
324
+ </Button>
325
+ </header>
326
+ <div class="min-h-0 overflow-y-auto p-4 text-sm">
327
+ <ChangeDetail :site="site" :change="shownRow._id" :brick="shownRow.brick" :schema="schema" />
328
+ </div>
329
+ </section>
330
+ <p v-else class="self-start rounded-xl border border-dashed px-4 py-6 text-[13px] text-muted-foreground">{{ t('history.detailEmpty') }}</p>
331
+ </aside>
332
+ </div>
333
+ </template>