@nivaro/react 0.2.53 → 0.2.55

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 (294) hide show
  1. package/dist/full.css +1 -1
  2. package/dist/hooks/useSessionRecorder.js +99 -98
  3. package/dist/index.d.ts +452 -4
  4. package/dist/index.js +644 -618
  5. package/dist/layout-editor.d.ts +252 -2
  6. package/dist/shared/components/BackgroundRunOffer.js +117 -0
  7. package/dist/shared/components/BroadcastView.js +214 -213
  8. package/dist/shared/components/CollectionBrowserView.js +2592 -2695
  9. package/dist/shared/components/FormWhatsNew.js +60 -0
  10. package/dist/shared/components/ItemEditForm.js +3968 -3618
  11. package/dist/shared/components/JobsTray.js +100 -55
  12. package/dist/shared/components/MyWorkView.js +91 -89
  13. package/dist/shared/components/NotificationBell.js +80 -79
  14. package/dist/shared/components/ProfileView.js +568 -520
  15. package/dist/shared/components/RecordCompare.js +254 -0
  16. package/dist/shared/components/RecordReadView.js +598 -543
  17. package/dist/shared/components/ReportView.js +578 -543
  18. package/dist/shared/components/RowPresence.js +91 -0
  19. package/dist/shared/components/TipLayer.js +27 -27
  20. package/dist/shared/components/WidgetSlot.js +474 -458
  21. package/dist/shared/components/ai/AiAnalyticsView.js +16 -6
  22. package/dist/shared/components/ai/AskPanel.js +139 -119
  23. package/dist/shared/components/ai/FirstWeekCard.js +126 -0
  24. package/dist/shared/components/bulk/BulkFieldUpdate.js +289 -0
  25. package/dist/shared/components/bulk/bulk-field-options.js +45 -0
  26. package/dist/shared/components/charts/CumulativeFlowChart.js +176 -0
  27. package/dist/shared/components/chat/ChannelArchive.js +326 -0
  28. package/dist/shared/components/chat/ChannelExtras.js +141 -121
  29. package/dist/shared/components/chat/ChatAnalyticsView.js +112 -110
  30. package/dist/shared/components/chat/ChatPanel.js +1695 -1733
  31. package/dist/shared/components/chat/Composer.js +357 -303
  32. package/dist/shared/components/chat/MessageActions.js +92 -0
  33. package/dist/shared/components/chat/MessageFormat.js +290 -264
  34. package/dist/shared/components/chat/OutboxBubbles.js +146 -0
  35. package/dist/shared/components/chat/RequestIdCard.js +135 -0
  36. package/dist/shared/components/chat/RoomHeaderMenu.js +202 -0
  37. package/dist/shared/components/chat/RoomParts.js +213 -274
  38. package/dist/shared/components/chat/ScreenClip.js +184 -0
  39. package/dist/shared/components/chat/chat-core.js +402 -483
  40. package/dist/shared/components/chat/chat-drafts.js +59 -0
  41. package/dist/shared/components/chat/chat-emoji.js +348 -0
  42. package/dist/shared/components/chat/chat-local-time.js +41 -0
  43. package/dist/shared/components/chat/chat-outbox.js +303 -0
  44. package/dist/shared/components/chat/chat-window.js +163 -0
  45. package/dist/shared/components/chat/huddle/HuddleControls.js +143 -0
  46. package/dist/shared/components/chat/huddle/HuddleStage.js +164 -0
  47. package/dist/shared/components/chat/huddle/huddle-store.js +342 -0
  48. package/dist/shared/components/chat/huddle/useHuddle.js +58 -0
  49. package/dist/shared/components/help-videos/api.js +80 -67
  50. package/dist/shared/components/help-videos/editor/DetailsTab.js +147 -130
  51. package/dist/shared/components/item-edit/CatalogPickerField.js +113 -112
  52. package/dist/shared/components/item-edit/ChangeReasonDialog.js +13 -13
  53. package/dist/shared/components/item-edit/FieldAffordances.js +9 -8
  54. package/dist/shared/components/item-edit/FieldRenderer.js +248 -245
  55. package/dist/shared/components/item-edit/FieldRow.js +382 -320
  56. package/dist/shared/components/item-edit/FormHelpVideoButton.js +59 -0
  57. package/dist/shared/components/item-edit/GroupSection.js +786 -639
  58. package/dist/shared/components/item-edit/HeaderTools.js +59 -56
  59. package/dist/shared/components/item-edit/InlineTableField.js +3 -1
  60. package/dist/shared/components/item-edit/LayoutContentBlock.js +47 -24
  61. package/dist/shared/components/item-edit/RelationCombobox.js +186 -176
  62. package/dist/shared/components/item-edit/entry/EntryStrip.js +54 -0
  63. package/dist/shared/components/item-edit/entry/entry-keys.js +27 -0
  64. package/dist/shared/components/item-edit/entry/useEntryKeyboard.js +70 -0
  65. package/dist/shared/components/item-edit/entry/useEntryMode.js +59 -0
  66. package/dist/shared/components/item-edit/form-structure-ui.js +105 -0
  67. package/dist/shared/components/item-edit/lazy-sections.js +36 -0
  68. package/dist/shared/components/item-edit/lock-why.js +94 -0
  69. package/dist/shared/components/item-edit/picker-miss.js +26 -0
  70. package/dist/shared/components/item-edit/placement-behaviour.js +196 -0
  71. package/dist/shared/components/item-edit/useFormUsageBeacon.js +65 -0
  72. package/dist/shared/components/layout-editor/AddPanel.js +226 -151
  73. package/dist/shared/components/layout-editor/ArrangeButton.js +34 -0
  74. package/dist/shared/components/layout-editor/AutoArrange.js +86 -0
  75. package/dist/shared/components/layout-editor/CanvasCompare.js +79 -0
  76. package/dist/shared/components/layout-editor/ChangeNote.js +147 -0
  77. package/dist/shared/components/layout-editor/CollabParts.js +175 -0
  78. package/dist/shared/components/layout-editor/DesignNode.js +311 -116
  79. package/dist/shared/components/layout-editor/EditorCanvas.js +30 -26
  80. package/dist/shared/components/layout-editor/EditorTopBar.js +463 -175
  81. package/dist/shared/components/layout-editor/FindReplace.js +188 -0
  82. package/dist/shared/components/layout-editor/FormMapButton.js +141 -0
  83. package/dist/shared/components/layout-editor/HistoryPanel.js +250 -109
  84. package/dist/shared/components/layout-editor/LayoutEditor.js +1196 -305
  85. package/dist/shared/components/layout-editor/LayoutsRail.js +94 -67
  86. package/dist/shared/components/layout-editor/NoteMarker.js +38 -0
  87. package/dist/shared/components/layout-editor/PlacementsTable.js +187 -0
  88. package/dist/shared/components/layout-editor/RestorePiece.js +143 -0
  89. package/dist/shared/components/layout-editor/ScheduleChange.js +106 -0
  90. package/dist/shared/components/layout-editor/SessionHistory.js +84 -0
  91. package/dist/shared/components/layout-editor/StagedChip.js +22 -0
  92. package/dist/shared/components/layout-editor/StructureMenu.js +464 -0
  93. package/dist/shared/components/layout-editor/UnsavedConfirm.js +103 -0
  94. package/dist/shared/components/layout-editor/ai/AiToolsButton.js +625 -0
  95. package/dist/shared/components/layout-editor/ai/ChangeCheck.js +153 -0
  96. package/dist/shared/components/layout-editor/ai/ai-tools-api.js +80 -0
  97. package/dist/shared/components/layout-editor/ai/assist-ops.js +38 -0
  98. package/dist/shared/components/layout-editor/ai/autofill-ops.js +73 -0
  99. package/dist/shared/components/layout-editor/ai/canvas-capture.js +41 -0
  100. package/dist/shared/components/layout-editor/ai-forms/AiComposer.js +271 -0
  101. package/dist/shared/components/layout-editor/ai-forms/AiFormsButton.js +182 -0
  102. package/dist/shared/components/layout-editor/ai-forms/MeaningSuggestions.js +109 -0
  103. package/dist/shared/components/layout-editor/ai-forms/SlimPanel.js +170 -0
  104. package/dist/shared/components/layout-editor/ai-forms/ai-forms-api.js +40 -0
  105. package/dist/shared/components/layout-editor/ai-forms/pending.js +25 -0
  106. package/dist/shared/components/layout-editor/ai-forms/plan.js +263 -0
  107. package/dist/shared/components/layout-editor/ai-rules/AiAskPopover.js +160 -0
  108. package/dist/shared/components/layout-editor/ai-rules/CascadeWriter.js +175 -0
  109. package/dist/shared/components/layout-editor/ai-rules/FieldRuleWriter.js +97 -0
  110. package/dist/shared/components/layout-editor/ai-rules/RuleWriter.js +94 -0
  111. package/dist/shared/components/layout-editor/ai-rules/ValidationSuggest.js +153 -0
  112. package/dist/shared/components/layout-editor/ai-rules/api.js +6 -0
  113. package/dist/shared/components/layout-editor/ai-text/AiTextTools.js +383 -0
  114. package/dist/shared/components/layout-editor/ai-text/text-ops.js +125 -0
  115. package/dist/shared/components/layout-editor/assist/AskPanel.js +278 -0
  116. package/dist/shared/components/layout-editor/assist/ExplainDiff.js +93 -0
  117. package/dist/shared/components/layout-editor/assist/ProposalsButton.js +150 -0
  118. package/dist/shared/components/layout-editor/assist/assist-api.js +63 -0
  119. package/dist/shared/components/layout-editor/assist/jump.js +142 -0
  120. package/dist/shared/components/layout-editor/assist/settings-index.js +118 -0
  121. package/dist/shared/components/layout-editor/auto-arrange.js +101 -0
  122. package/dist/shared/components/layout-editor/bulk/BulkChangesButton.js +221 -0
  123. package/dist/shared/components/layout-editor/bulk/BulkRun.js +237 -0
  124. package/dist/shared/components/layout-editor/bulk/MacrosPanel.js +230 -0
  125. package/dist/shared/components/layout-editor/bulk/bulk-api.js +65 -0
  126. package/dist/shared/components/layout-editor/bulk/field-labels.js +22 -0
  127. package/dist/shared/components/layout-editor/bulk/macro-record.js +142 -0
  128. package/dist/shared/components/layout-editor/bulk/useMacroRecorder.js +65 -0
  129. package/dist/shared/components/layout-editor/bundle-to-active.js +1 -0
  130. package/dist/shared/components/layout-editor/canvas-diff.js +157 -0
  131. package/dist/shared/components/layout-editor/collab/FormFollowShare.js +388 -0
  132. package/dist/shared/components/layout-editor/collab/collab-api.js +80 -0
  133. package/dist/shared/components/layout-editor/commands/CommandPalette.js +221 -0
  134. package/dist/shared/components/layout-editor/commands/intents.js +214 -0
  135. package/dist/shared/components/layout-editor/commands/parse.js +242 -0
  136. package/dist/shared/components/layout-editor/design-context.js +26 -6
  137. package/dist/shared/components/layout-editor/dnd/LayoutDndProvider.js +181 -164
  138. package/dist/shared/components/layout-editor/dnd/collision.js +25 -23
  139. package/dist/shared/components/layout-editor/dnd/node.js +69 -57
  140. package/dist/shared/components/layout-editor/dnd/rail-drop.js +56 -0
  141. package/dist/shared/components/layout-editor/draft-recovery.js +131 -0
  142. package/dist/shared/components/layout-editor/editor-notes.js +78 -0
  143. package/dist/shared/components/layout-editor/editors/swap-config.js +1 -0
  144. package/dist/shared/components/layout-editor/entry/PlacementPresets.js +149 -0
  145. package/dist/shared/components/layout-editor/entry/entry-editor-context.js +10 -0
  146. package/dist/shared/components/layout-editor/entry/presets.js +71 -0
  147. package/dist/shared/components/layout-editor/entry/tab-order.js +110 -0
  148. package/dist/shared/components/layout-editor/entry/theme-preview.js +37 -0
  149. package/dist/shared/components/layout-editor/explain/CanvasRules.js +142 -0
  150. package/dist/shared/components/layout-editor/explain/default-ghosts.js +81 -0
  151. package/dist/shared/components/layout-editor/explain/driver-hover.js +62 -0
  152. package/dist/shared/components/layout-editor/explain/field-sources.js +246 -0
  153. package/dist/shared/components/layout-editor/explain/rule-graph.js +215 -0
  154. package/dist/shared/components/layout-editor/explain/use-explain.js +132 -0
  155. package/dist/shared/components/layout-editor/field-zones.js +116 -0
  156. package/dist/shared/components/layout-editor/form-map.js +138 -0
  157. package/dist/shared/components/layout-editor/grid-guides.js +142 -0
  158. package/dist/shared/components/layout-editor/history-api.js +87 -0
  159. package/dist/shared/components/layout-editor/inheritance.js +55 -0
  160. package/dist/shared/components/layout-editor/inspect/inspect-api.js +66 -0
  161. package/dist/shared/components/layout-editor/inspect/picker-preview.js +48 -0
  162. package/dist/shared/components/layout-editor/inspect/width-fit.js +87 -0
  163. package/dist/shared/components/layout-editor/inspector/AiFillSetting.js +85 -0
  164. package/dist/shared/components/layout-editor/inspector/BehaviourSettings.js +402 -0
  165. package/dist/shared/components/layout-editor/inspector/Breadcrumb.js +36 -0
  166. package/dist/shared/components/layout-editor/inspector/BulkInspector.js +179 -0
  167. package/dist/shared/components/layout-editor/inspector/ColumnFit.js +112 -0
  168. package/dist/shared/components/layout-editor/inspector/GroupInspector.js +291 -141
  169. package/dist/shared/components/layout-editor/inspector/HelpTab.js +174 -0
  170. package/dist/shared/components/layout-editor/inspector/Inspector.js +282 -180
  171. package/dist/shared/components/layout-editor/inspector/LookTab.js +166 -109
  172. package/dist/shared/components/layout-editor/inspector/OverrideNotice.js +61 -0
  173. package/dist/shared/components/layout-editor/inspector/PickerMisses.js +129 -0
  174. package/dist/shared/components/layout-editor/inspector/PickerPreview.js +134 -0
  175. package/dist/shared/components/layout-editor/inspector/PickerTab.js +146 -118
  176. package/dist/shared/components/layout-editor/inspector/RulesTab.js +162 -111
  177. package/dist/shared/components/layout-editor/inspector/Translations.js +156 -0
  178. package/dist/shared/components/layout-editor/inspector/kit.js +71 -70
  179. package/dist/shared/components/layout-editor/inspector/tab-request.js +21 -0
  180. package/dist/shared/components/layout-editor/is-typing.js +9 -0
  181. package/dist/shared/components/layout-editor/keyboard-move.js +66 -0
  182. package/dist/shared/components/layout-editor/lint/LintPanel.js +190 -0
  183. package/dist/shared/components/layout-editor/lint/lint-api.js +52 -0
  184. package/dist/shared/components/layout-editor/load-error.js +37 -0
  185. package/dist/shared/components/layout-editor/matrix/FieldStateMatrix.js +305 -0
  186. package/dist/shared/components/layout-editor/matrix/MatrixGrid.js +181 -0
  187. package/dist/shared/components/layout-editor/matrix/RoleSectionMatrix.js +147 -0
  188. package/dist/shared/components/layout-editor/matrix/matrix-api.js +48 -0
  189. package/dist/shared/components/layout-editor/matrix/role-matrix.js +36 -0
  190. package/dist/shared/components/layout-editor/matrix/state-matrix.js +145 -0
  191. package/dist/shared/components/layout-editor/nav/FindPanel.js +109 -0
  192. package/dist/shared/components/layout-editor/nav/NavTools.js +114 -0
  193. package/dist/shared/components/layout-editor/nav/OutlinePanel.js +228 -0
  194. package/dist/shared/components/layout-editor/nav/ShortcutSheet.js +31 -0
  195. package/dist/shared/components/layout-editor/nav/find.js +20 -0
  196. package/dist/shared/components/layout-editor/nav/tree.js +142 -0
  197. package/dist/shared/components/layout-editor/nav/useEditorNav.js +101 -0
  198. package/dist/shared/components/layout-editor/nav/view-prefs.js +34 -0
  199. package/dist/shared/components/layout-editor/ops/ChangeRequestsPanel.js +143 -0
  200. package/dist/shared/components/layout-editor/ops/DependencyDiagram.js +179 -0
  201. package/dist/shared/components/layout-editor/ops/LayoutOpsBlocks.js +92 -0
  202. package/dist/shared/components/layout-editor/ops/PromotePanel.js +287 -0
  203. package/dist/shared/components/layout-editor/ops/ops-api.js +122 -0
  204. package/dist/shared/components/layout-editor/outputs/OutputsButton.js +254 -0
  205. package/dist/shared/components/layout-editor/outputs/help-sheet.js +154 -0
  206. package/dist/shared/components/layout-editor/outputs/output-api.js +61 -0
  207. package/dist/shared/components/layout-editor/overview/OverviewActions.js +15 -3
  208. package/dist/shared/components/layout-editor/overview/describe-conditions.js +24 -14
  209. package/dist/shared/components/layout-editor/overview/overview-api.js +105 -88
  210. package/dist/shared/components/layout-editor/overview/purpose.js +15 -13
  211. package/dist/shared/components/layout-editor/panel-style.js +8 -7
  212. package/dist/shared/components/layout-editor/parity-keys.json.js +4 -0
  213. package/dist/shared/components/layout-editor/pin.js +25 -0
  214. package/dist/shared/components/layout-editor/presence.js +111 -0
  215. package/dist/shared/components/layout-editor/preview/PreviewModes.js +224 -0
  216. package/dist/shared/components/layout-editor/preview/PreviewPanes.js +262 -0
  217. package/dist/shared/components/layout-editor/preview/preview-api.js +57 -0
  218. package/dist/shared/components/layout-editor/preview/preview-model.js +157 -0
  219. package/dist/shared/components/layout-editor/restore-piece.js +192 -0
  220. package/dist/shared/components/layout-editor/reuse/FieldMapStep.js +70 -0
  221. package/dist/shared/components/layout-editor/reuse/FormMoreMenu.js +127 -0
  222. package/dist/shared/components/layout-editor/reuse/LibraryRows.js +150 -0
  223. package/dist/shared/components/layout-editor/reuse/NewFormStart.js +20 -0
  224. package/dist/shared/components/layout-editor/reuse/SectionReuseActions.js +291 -0
  225. package/dist/shared/components/layout-editor/reuse/field-match.js +77 -0
  226. package/dist/shared/components/layout-editor/reuse/reuse-api.js +73 -0
  227. package/dist/shared/components/layout-editor/reuse/seed.js +13 -0
  228. package/dist/shared/components/layout-editor/reuse/useFormFromRecord.js +43 -0
  229. package/dist/shared/components/layout-editor/reuse/useRailCopy.js +34 -0
  230. package/dist/shared/components/layout-editor/section-structure.js +241 -0
  231. package/dist/shared/components/layout-editor/settings/EntrySection.js +296 -0
  232. package/dist/shared/components/layout-editor/settings/FormSettings.js +125 -103
  233. package/dist/shared/components/layout-editor/settings/InheritanceSection.js +1 -1
  234. package/dist/shared/components/layout-editor/settings/ResolveSettings.js +255 -0
  235. package/dist/shared/components/layout-editor/settings/ToolsSection.js +215 -105
  236. package/dist/shared/components/layout-editor/settings/WhoSection.js +139 -100
  237. package/dist/shared/components/layout-editor/settings/controls.js +8 -8
  238. package/dist/shared/components/layout-editor/settings/settings-registry.js +142 -21
  239. package/dist/shared/components/layout-editor/shortcuts.js +88 -0
  240. package/dist/shared/components/layout-editor/show-when.js +35 -0
  241. package/dist/shared/components/layout-editor/slot-names.js +4 -3
  242. package/dist/shared/components/layout-editor/staged-api.js +64 -0
  243. package/dist/shared/components/layout-editor/structure-ops.js +403 -0
  244. package/dist/shared/components/layout-editor/testing/CostLimitSetting.js +42 -0
  245. package/dist/shared/components/layout-editor/testing/TestingPanels.js +556 -0
  246. package/dist/shared/components/layout-editor/testing/testing-api.js +67 -0
  247. package/dist/shared/components/layout-editor/testing/testing-model.js +406 -0
  248. package/dist/shared/components/layout-editor/testing/use-record-check.js +44 -0
  249. package/dist/shared/components/layout-editor/toolbar-kit.js +242 -0
  250. package/dist/shared/components/layout-editor/unsaved-marks.js +72 -0
  251. package/dist/shared/components/layout-editor/usage/AbTestSection.js +355 -0
  252. package/dist/shared/components/layout-editor/usage/FillChip.js +27 -0
  253. package/dist/shared/components/layout-editor/usage/UsagePanel.js +232 -0
  254. package/dist/shared/components/layout-editor/usage/ab-api.js +86 -0
  255. package/dist/shared/components/layout-editor/usage/suggest-collapse.js +32 -0
  256. package/dist/shared/components/layout-editor/usage/suggest-sections.js +55 -0
  257. package/dist/shared/components/layout-editor/usage/usage-api.js +104 -0
  258. package/dist/shared/components/layout-editor/useLayoutDraft.js +573 -306
  259. package/dist/shared/components/notifications/NotificationAnalyticsView.js +148 -77
  260. package/dist/shared/components/panels/ErpFailureBanner.js +18 -17
  261. package/dist/shared/components/panels/ExternalRequestsChip.js +63 -62
  262. package/dist/shared/components/pipeline/PipelineEditorView.js +106 -104
  263. package/dist/shared/components/profile/AgentsPanel.js +479 -0
  264. package/dist/shared/components/queue/QueueWorklist.js +1026 -1040
  265. package/dist/shared/components/support/SuggestFormChange.js +143 -0
  266. package/dist/shared/components/support/SupportAnalytics.js +171 -0
  267. package/dist/shared/components/support/SupportView.js +75 -73
  268. package/dist/shared/lib/ai-fill.js +37 -0
  269. package/dist/shared/lib/background-runs.js +150 -0
  270. package/dist/shared/lib/delivery-ack.js +9 -0
  271. package/dist/shared/lib/entry-badge-style.js +13 -0
  272. package/dist/shared/lib/entry-config.js +71 -0
  273. package/dist/shared/lib/form-sections.js +64 -0
  274. package/dist/shared/lib/form-structure.js +99 -0
  275. package/dist/shared/lib/form-usage-beacon.js +133 -0
  276. package/dist/shared/lib/jobs-tray.js +25 -23
  277. package/dist/shared/lib/keyset-pager.js +37 -0
  278. package/dist/shared/lib/layout-i18n.js +66 -0
  279. package/dist/shared/lib/layout-lint.js +490 -0
  280. package/dist/shared/lib/layout-ops.js +116 -110
  281. package/dist/shared/lib/layout-resolve.js +113 -0
  282. package/dist/shared/lib/placement-behaviour.js +144 -0
  283. package/dist/shared/lib/prefetch.js +149 -0
  284. package/dist/shared/lib/presence-hooks.js +199 -0
  285. package/dist/shared/lib/record-outbox.js +82 -81
  286. package/dist/shared/lib/replay-socket.js +93 -0
  287. package/dist/shared/lib/request-gate.js +51 -50
  288. package/dist/shared/lib/room-gaps.js +96 -0
  289. package/dist/shared/lib/screenshot.js +54 -28
  290. package/dist/shared/lib/search-log.js +27 -0
  291. package/dist/shared/lib/socket-realtime.js +101 -80
  292. package/dist/shared/lib/visible-when.js +34 -0
  293. package/dist/shared/lib/worker-socket.js +200 -0
  294. package/package.json +1 -1
@@ -0,0 +1,388 @@
1
+ import { jsxs as r, jsx as e } from "react/jsx-runtime";
2
+ import { useQuery as D } from "@tanstack/react-query";
3
+ import { MessageSquare as P, Share2 as R, BellRing as W, Bell as B, Link2 as T, Copy as $, Crosshair as q, X as A } from "lucide-react";
4
+ import { useState as p } from "react";
5
+ import { toast as k } from "sonner";
6
+ import { useNivaroClient as j } from "../../../context.js";
7
+ import { get as E } from "../../../lib/commands.js";
8
+ import { cn as y } from "../../../lib/utils.js";
9
+ import { Popover as F, PopoverContent as U } from "../../ui/popover.js";
10
+ import { SimpleSelect as L } from "../../ui/SimpleSelect.js";
11
+ import { apiFailure as K } from "../overview/overview-api.js";
12
+ import { ToolButton as _ } from "../toolbar-kit.js";
13
+ import { useLayoutCollab as S, usePreviewComments as M, useCollabActions as v, usePreviewLinks as H, previewUrl as C } from "./collab-api.js";
14
+ const f = "inline-flex h-7 items-center gap-1 rounded-md px-2 text-[12px] text-slate-600 transition-colors hover:bg-muted hover:text-slate-900 disabled:opacity-40 dark:text-muted-foreground dark:hover:text-foreground", g = "text-[12px] font-semibold text-slate-700 dark:text-foreground", x = "text-[11.5px] leading-snug text-slate-500 dark:text-muted-foreground", O = (o) => o ? new Date(o).toLocaleDateString(void 0, { month: "short", day: "numeric" }) : "";
15
+ function w(o, n) {
16
+ k.error(K(o, n).message);
17
+ }
18
+ function le({ layoutId: o }) {
19
+ const { data: n } = S(o), m = v(o), [d, c] = p(!1), t = !!(n != null && n.watching);
20
+ return /* @__PURE__ */ e(
21
+ _,
22
+ {
23
+ label: "Watch this form",
24
+ ariaLabel: t ? "Stop watching this form" : "Watch this form",
25
+ icon: t ? /* @__PURE__ */ e(W, { className: "h-4 w-4" }) : /* @__PURE__ */ e(B, { className: "h-4 w-4" }),
26
+ hint: "Hear when someone saves a change",
27
+ iconOnly: !0,
28
+ checked: t,
29
+ disabled: d,
30
+ className: y(t && "text-[#0089ad] dark:text-nvr-cyan"),
31
+ tip: t ? "Watching: you hear when someone saves a change. Click to stop" : "Watch: hear when someone saves a change to this form",
32
+ data: { "data-form-watch": "" },
33
+ onClick: async () => {
34
+ c(!0);
35
+ try {
36
+ await m.setWatch(!t);
37
+ } catch (i) {
38
+ w(i, "Could not change the watch");
39
+ } finally {
40
+ c(!1);
41
+ }
42
+ }
43
+ }
44
+ );
45
+ }
46
+ function Q({ layoutId: o, owner: n }) {
47
+ const m = j(), d = v(o), [c, t] = p(!1), [i, h] = p(""), { data: u = [] } = D({
48
+ queryKey: ["layout-editor", "collab", "people", i],
49
+ queryFn: () => m.request(E("/users", { search: i, limit: 6, people: "1" })).then((s) => s.data ?? []),
50
+ enabled: c && i.trim().length > 1
51
+ }), l = async (s) => {
52
+ try {
53
+ await d.setOwner(s), t(!1), h("");
54
+ } catch (a) {
55
+ w(a, "Could not change the owner");
56
+ }
57
+ };
58
+ return c ? /* @__PURE__ */ r("div", { children: [
59
+ /* @__PURE__ */ e(
60
+ "input",
61
+ {
62
+ autoFocus: !0,
63
+ "aria-label": "Find a person",
64
+ value: i,
65
+ onChange: (s) => h(s.target.value),
66
+ onKeyDown: (s) => s.key === "Escape" && t(!1),
67
+ placeholder: "Type a name or email",
68
+ className: "h-8 w-full rounded-md border border-slate-200 bg-white px-2.5 text-[12.5px] outline-none placeholder:text-slate-400 focus:border-nvr-cyan dark:border-border dark:bg-background dark:text-foreground dark:placeholder:text-muted-foreground"
69
+ }
70
+ ),
71
+ i.trim().length > 1 && /* @__PURE__ */ e("div", { className: "mt-1 overflow-hidden rounded-md border border-slate-200 dark:border-border", children: u.length === 0 ? /* @__PURE__ */ e("div", { className: y(x, "px-2.5 py-1.5"), children: "No one matches" }) : u.map((s) => {
72
+ const a = `${s.first_name ?? ""} ${s.last_name ?? ""}`.trim() || s.email;
73
+ return /* @__PURE__ */ r(
74
+ "button",
75
+ {
76
+ type: "button",
77
+ onClick: () => void l(s.id),
78
+ className: "block w-full px-2.5 py-1.5 text-left text-[12.5px] text-slate-700 hover:bg-muted dark:text-foreground",
79
+ children: [
80
+ a,
81
+ /* @__PURE__ */ e("span", { className: "ml-1.5 text-[11px] text-slate-400 dark:text-muted-foreground", children: s.email })
82
+ ]
83
+ },
84
+ s.id
85
+ );
86
+ }) }),
87
+ /* @__PURE__ */ e("button", { type: "button", className: y(f, "mt-1"), onClick: () => t(!1), children: "Cancel" })
88
+ ] }) : /* @__PURE__ */ r("div", { className: "flex items-center gap-2", children: [
89
+ /* @__PURE__ */ e(
90
+ "span",
91
+ {
92
+ "data-form-owner": "",
93
+ className: y(
94
+ "min-w-0 flex-1 truncate text-[12.5px]",
95
+ n ? "text-slate-800 dark:text-foreground" : "text-slate-400 dark:text-muted-foreground"
96
+ ),
97
+ children: (n == null ? void 0 : n.name) ?? "No owner yet"
98
+ }
99
+ ),
100
+ /* @__PURE__ */ e("button", { type: "button", className: f, onClick: () => t(!0), children: n ? "Change" : "Name an owner" }),
101
+ n && /* @__PURE__ */ e("button", { type: "button", className: f, onClick: () => void l(null), children: "Clear" })
102
+ ] });
103
+ }
104
+ const N = "default";
105
+ function V({
106
+ layoutId: o,
107
+ review: n,
108
+ hasOwner: m
109
+ }) {
110
+ const d = v(o), [c, t] = p(!1), i = (a) => a === 1 ? "1 month" : `${a} months`, h = n.months == null ? N : String(n.months), u = [
111
+ {
112
+ value: N,
113
+ label: n.default_months > 0 ? `After ${i(n.default_months)} (default)` : "Never (default)"
114
+ },
115
+ ...[3, 6, 12].filter((a) => a !== n.default_months).map((a) => ({ value: String(a), label: `After ${i(a)}` })),
116
+ ...n.default_months > 0 ? [{ value: "0", label: "Never" }] : []
117
+ ], l = n.next_at ? new Date(n.next_at) : null, s = (a) => a.toLocaleDateString(void 0, { month: "short", day: "numeric", year: "numeric" });
118
+ return /* @__PURE__ */ r("div", { className: "space-y-1.5", children: [
119
+ /* @__PURE__ */ e(
120
+ L,
121
+ {
122
+ value: h,
123
+ disabled: c,
124
+ onChange: async (a) => {
125
+ t(!0);
126
+ try {
127
+ await d.setReviewMonths(a === N ? null : Number(a));
128
+ } catch (b) {
129
+ w(b, "Could not change the reminder");
130
+ } finally {
131
+ t(!1);
132
+ }
133
+ },
134
+ ariaLabel: "Remind the owner to review this form",
135
+ className: "h-8 w-full text-[12.5px]",
136
+ triggerProps: { "data-form-review": "" },
137
+ options: u
138
+ }
139
+ ),
140
+ /* @__PURE__ */ r("p", { className: x, children: [
141
+ m ? n.effective_months === 0 ? "The owner is never reminded." : l && l > /* @__PURE__ */ new Date() ? `If it stays unchanged, the owner is reminded on ${s(l)} with its health score and how much it was used.` : `It has been unchanged that long: the owner is reminded on a weekday morning, then every ${i(n.effective_months)} while it stays unchanged.` : "Name an owner first: the reminder goes to them, with the form’s health score and how much it was used.",
142
+ n.last_changed_at ? ` Last changed ${s(new Date(n.last_changed_at))}.` : ""
143
+ ] })
144
+ ] });
145
+ }
146
+ function X({ layoutId: o, open: n }) {
147
+ const { data: m = [] } = H(o, n), d = v(o), [c, t] = p("14"), [i, h] = p(!1), [u, l] = p(null), s = async (a) => {
148
+ try {
149
+ await navigator.clipboard.writeText(C(a)), k.success("Link copied");
150
+ } catch {
151
+ k.error("Could not copy — select the link and copy it");
152
+ }
153
+ };
154
+ return /* @__PURE__ */ r("div", { className: "space-y-2", children: [
155
+ /* @__PURE__ */ e("p", { className: x, children: "Anyone with the link can read this form’s layout (never record data) and comment on its fields. It shows the last saved version, as you see it." }),
156
+ /* @__PURE__ */ r("div", { className: "flex items-center gap-2", children: [
157
+ /* @__PURE__ */ e(
158
+ L,
159
+ {
160
+ value: c,
161
+ onChange: t,
162
+ ariaLabel: "Link lasts",
163
+ className: "h-8 w-[120px] text-[12.5px]",
164
+ options: [
165
+ { value: "7", label: "7 days" },
166
+ { value: "14", label: "14 days" },
167
+ { value: "30", label: "30 days" },
168
+ { value: "90", label: "90 days" }
169
+ ]
170
+ }
171
+ ),
172
+ /* @__PURE__ */ r(
173
+ "button",
174
+ {
175
+ type: "button",
176
+ disabled: i,
177
+ className: "inline-flex h-8 items-center gap-1.5 rounded-md bg-nvr-cyan px-3 text-[12.5px] font-medium text-white transition-opacity hover:opacity-90 disabled:opacity-50",
178
+ onClick: async () => {
179
+ h(!0);
180
+ try {
181
+ const a = await d.createLink(Number(c));
182
+ a != null && a.path && await s(a.path);
183
+ } catch (a) {
184
+ w(a, "Could not create the link");
185
+ } finally {
186
+ h(!1);
187
+ }
188
+ },
189
+ children: [
190
+ /* @__PURE__ */ e(T, { className: "h-3.5 w-3.5" }),
191
+ "Create link"
192
+ ]
193
+ }
194
+ )
195
+ ] }),
196
+ m.map((a) => /* @__PURE__ */ r(
197
+ "div",
198
+ {
199
+ "data-preview-link": a.id,
200
+ className: "rounded-md border border-slate-200 px-2.5 py-1.5 dark:border-border",
201
+ children: [
202
+ /* @__PURE__ */ e("div", { className: "truncate font-mono text-[11.5px] text-slate-600 dark:text-muted-foreground", children: C(a.path) }),
203
+ /* @__PURE__ */ r("div", { className: "mt-1 flex flex-wrap items-center gap-x-2 text-[11.5px] text-slate-500 dark:text-muted-foreground", children: [
204
+ /* @__PURE__ */ r("span", { children: [
205
+ "until ",
206
+ O(a.expires_at)
207
+ ] }),
208
+ /* @__PURE__ */ r("span", { children: [
209
+ "· ",
210
+ a.view_count,
211
+ " ",
212
+ a.view_count === 1 ? "view" : "views"
213
+ ] }),
214
+ /* @__PURE__ */ r("span", { children: [
215
+ "· ",
216
+ a.comments,
217
+ " ",
218
+ a.comments === 1 ? "comment" : "comments"
219
+ ] }),
220
+ /* @__PURE__ */ e("span", { className: "flex-1" }),
221
+ /* @__PURE__ */ r("button", { type: "button", className: f, onClick: () => void s(a.path), children: [
222
+ /* @__PURE__ */ e($, { className: "h-3 w-3" }),
223
+ "Copy"
224
+ ] }),
225
+ u === a.id ? /* @__PURE__ */ e(
226
+ "button",
227
+ {
228
+ type: "button",
229
+ className: y(f, "text-red-600 dark:text-red-400"),
230
+ onClick: async () => {
231
+ try {
232
+ await d.revokeLink(a.id);
233
+ } catch (b) {
234
+ w(b, "Could not turn the link off");
235
+ }
236
+ l(null);
237
+ },
238
+ children: "Turn off for everyone"
239
+ }
240
+ ) : /* @__PURE__ */ e("button", { type: "button", className: f, onClick: () => l(a.id), children: "Turn off" })
241
+ ] })
242
+ ]
243
+ },
244
+ a.id
245
+ ))
246
+ ] });
247
+ }
248
+ function z({
249
+ layoutId: o,
250
+ comments: n,
251
+ fieldLabel: m,
252
+ onSelectField: d
253
+ }) {
254
+ const c = v(o);
255
+ return n.length === 0 ? /* @__PURE__ */ e("p", { className: x, children: "No comments yet. People with a preview link leave them here." }) : /* @__PURE__ */ e("ul", { className: "space-y-1.5", children: n.map((t) => /* @__PURE__ */ r(
256
+ "li",
257
+ {
258
+ "data-preview-comment": t.id,
259
+ className: "rounded-md bg-slate-50 px-2.5 py-1.5 dark:bg-muted/40",
260
+ children: [
261
+ /* @__PURE__ */ r("div", { className: "flex items-center gap-1.5 text-[11.5px] text-slate-500 dark:text-muted-foreground", children: [
262
+ /* @__PURE__ */ e("span", { className: "min-w-0 truncate font-semibold text-slate-700 dark:text-foreground", children: t.field ? m(t.field) : "Whole form" }),
263
+ /* @__PURE__ */ r("span", { className: "shrink-0", children: [
264
+ "· ",
265
+ t.name,
266
+ " · ",
267
+ O(t.at)
268
+ ] }),
269
+ /* @__PURE__ */ e("span", { className: "flex-1" }),
270
+ t.field && d && /* @__PURE__ */ e(
271
+ "button",
272
+ {
273
+ type: "button",
274
+ "aria-label": "Select this field",
275
+ "data-tip": "Select this field on the canvas",
276
+ className: f,
277
+ onClick: () => d(t.field),
278
+ children: /* @__PURE__ */ e(q, { className: "h-3 w-3" })
279
+ }
280
+ ),
281
+ /* @__PURE__ */ e(
282
+ "button",
283
+ {
284
+ type: "button",
285
+ "aria-label": "Resolve comment",
286
+ "data-tip": "Resolve: remove the comment",
287
+ className: f,
288
+ onClick: async () => {
289
+ try {
290
+ await c.resolveComment(t.id);
291
+ } catch (i) {
292
+ w(i, "Could not resolve the comment");
293
+ }
294
+ },
295
+ children: /* @__PURE__ */ e(A, { className: "h-3 w-3" })
296
+ }
297
+ )
298
+ ] }),
299
+ /* @__PURE__ */ e("p", { className: "mt-0.5 whitespace-pre-wrap break-words text-[12.5px] text-slate-800 dark:text-foreground", children: t.text })
300
+ ]
301
+ },
302
+ t.id
303
+ )) });
304
+ }
305
+ function ce({
306
+ layoutId: o,
307
+ fields: n,
308
+ onSelectField: m
309
+ }) {
310
+ const [d, c] = p(!1), { data: t } = S(o), { data: i = [] } = M(o), h = (l) => {
311
+ var s;
312
+ return ((s = n.find((a) => a.field === l)) == null ? void 0 : s.label) || l;
313
+ }, u = ((t == null ? void 0 : t.watchers) ?? []).filter((l) => {
314
+ var s;
315
+ return l.id !== ((s = t == null ? void 0 : t.owner) == null ? void 0 : s.id);
316
+ });
317
+ return /* @__PURE__ */ r(F, { open: d, onOpenChange: c, children: [
318
+ /* @__PURE__ */ e(
319
+ _,
320
+ {
321
+ popover: !0,
322
+ onOpen: () => c(!0),
323
+ label: "Share & watchers",
324
+ ariaLabel: "Share",
325
+ icon: /* @__PURE__ */ e(R, { className: "h-3.5 w-3.5" }),
326
+ tip: "Owner, watchers, preview links and comments",
327
+ hint: "Owner, watchers, preview links, comments",
328
+ badge: i.length || void 0,
329
+ data: { "data-form-share": "" },
330
+ trailing: i.length > 0 && /* @__PURE__ */ r(
331
+ "span",
332
+ {
333
+ "data-preview-comment-count": "",
334
+ className: "inline-flex h-4 min-w-4 items-center justify-center gap-0.5 rounded-full bg-nvr-cyan/15 px-1 text-[10.5px] font-semibold text-[#0089ad] dark:text-nvr-cyan",
335
+ children: [
336
+ /* @__PURE__ */ e(P, { className: "h-2.5 w-2.5" }),
337
+ i.length
338
+ ]
339
+ }
340
+ )
341
+ }
342
+ ),
343
+ /* @__PURE__ */ r(
344
+ U,
345
+ {
346
+ align: "end",
347
+ className: "max-h-[min(75vh,620px)] w-[400px] space-y-4 overflow-y-auto overscroll-contain p-3",
348
+ children: [
349
+ /* @__PURE__ */ r("section", { className: "space-y-1.5", children: [
350
+ /* @__PURE__ */ e("h3", { className: g, children: "Owner" }),
351
+ /* @__PURE__ */ e(Q, { layoutId: o, owner: (t == null ? void 0 : t.owner) ?? null }),
352
+ /* @__PURE__ */ e("p", { className: x, children: "The business owner hears first about change requests and every saved change." })
353
+ ] }),
354
+ (t == null ? void 0 : t.review) && /* @__PURE__ */ r("section", { className: "space-y-1.5", "data-form-review-section": "", children: [
355
+ /* @__PURE__ */ e("h3", { className: g, children: "Review reminder" }),
356
+ /* @__PURE__ */ e(V, { layoutId: o, review: t.review, hasOwner: !!t.owner })
357
+ ] }),
358
+ /* @__PURE__ */ r("section", { className: "space-y-1", children: [
359
+ /* @__PURE__ */ e("h3", { className: g, children: "Watching" }),
360
+ /* @__PURE__ */ e("p", { className: x, children: u.length === 0 ? "No one else watches this form. Use the bell to watch it yourself." : u.map((l) => l.name).join(", ") })
361
+ ] }),
362
+ /* @__PURE__ */ r("section", { className: "space-y-1.5", children: [
363
+ /* @__PURE__ */ e("h3", { className: g, children: "Preview link" }),
364
+ /* @__PURE__ */ e(X, { layoutId: o, open: d })
365
+ ] }),
366
+ /* @__PURE__ */ r("section", { className: "space-y-1.5", children: [
367
+ /* @__PURE__ */ e("h3", { className: g, children: "Comments from previews" }),
368
+ /* @__PURE__ */ e(
369
+ z,
370
+ {
371
+ layoutId: o,
372
+ comments: i,
373
+ fieldLabel: h,
374
+ onSelectField: m ? (l) => {
375
+ m(l), c(!1);
376
+ } : void 0
377
+ }
378
+ )
379
+ ] })
380
+ ]
381
+ }
382
+ )
383
+ ] });
384
+ }
385
+ export {
386
+ ce as ShareButton,
387
+ le as WatchButton
388
+ };
@@ -0,0 +1,80 @@
1
+ import { useQuery as s, useQueryClient as m } from "@tanstack/react-query";
2
+ import { useCallback as b } from "react";
3
+ import { useNivaroClient as i } from "../../../context.js";
4
+ import { get as c, del as w, post as q, put as l } from "../../../lib/commands.js";
5
+ const u = {
6
+ one: (e) => ["layout-editor", "collab", e],
7
+ owners: () => ["layout-editor", "collab", "owners"],
8
+ links: (e) => ["layout-editor", "collab", e, "links"],
9
+ comments: (e) => ["layout-editor", "collab", e, "comments"]
10
+ }, r = (e, t) => (e == null ? void 0 : e.data) ?? t;
11
+ function $(e) {
12
+ const t = i();
13
+ return s({
14
+ queryKey: u.one(e),
15
+ queryFn: async () => r(await t.request(c(`/layout-collab/${e}`)), {
16
+ owner: null,
17
+ watching: !1,
18
+ watchers: []
19
+ }),
20
+ staleTime: 3e4
21
+ });
22
+ }
23
+ function d(e, t) {
24
+ const o = i();
25
+ return s({
26
+ queryKey: u.links(e),
27
+ queryFn: async () => r(await o.request(c(`/layout-collab/${e}/preview-links`)), []),
28
+ enabled: t,
29
+ staleTime: 15e3
30
+ });
31
+ }
32
+ function C(e) {
33
+ const t = i();
34
+ return s({
35
+ queryKey: u.comments(e),
36
+ queryFn: async () => r(await t.request(c(`/layout-collab/${e}/preview-comments`)), []),
37
+ staleTime: 3e4,
38
+ refetchOnWindowFocus: !0
39
+ });
40
+ }
41
+ function h(e) {
42
+ const t = i(), o = m(), a = b(
43
+ () => o.invalidateQueries({ queryKey: ["layout-editor", "collab"] }),
44
+ [o]
45
+ );
46
+ return {
47
+ setWatch: async (n) => {
48
+ await t.request(l(`/layout-collab/${e}/watch`, { on: n })), await a();
49
+ },
50
+ setOwner: async (n) => {
51
+ await t.request(l(`/layout-collab/${e}/owner`, { user_id: n })), await a();
52
+ },
53
+ setReviewMonths: async (n) => {
54
+ await t.request(l(`/layout-collab/${e}/review`, { months: n })), await a();
55
+ },
56
+ createLink: async (n) => {
57
+ const y = await t.request(
58
+ q(`/layout-collab/${e}/preview-links`, { days: n })
59
+ );
60
+ return await a(), r(y, null);
61
+ },
62
+ revokeLink: async (n) => {
63
+ await t.request(w(`/layout-collab/preview-links/${n}`)), await a();
64
+ },
65
+ resolveComment: async (n) => {
66
+ await t.request(w(`/layout-collab/${e}/preview-comments/${n}`)), await a();
67
+ }
68
+ };
69
+ }
70
+ function K(e) {
71
+ return typeof window > "u" ? e : new URL(e, window.location.origin).toString();
72
+ }
73
+ export {
74
+ u as collabKeys,
75
+ K as previewUrl,
76
+ h as useCollabActions,
77
+ $ as useLayoutCollab,
78
+ C as usePreviewComments,
79
+ d as usePreviewLinks
80
+ };