@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,287 @@
1
+ import { jsxs as r, jsx as a, Fragment as _ } from "react/jsx-runtime";
2
+ import { useQueryClient as H } from "@tanstack/react-query";
3
+ import { Loader2 as N, Upload as J, Download as M, Shuffle as z, Plus as G, Minus as V, Pencil as X } from "lucide-react";
4
+ import { useRef as Y, useState as i } from "react";
5
+ import { toast as q } from "sonner";
6
+ import { useNivaroClient as Z } from "../../../context.js";
7
+ import { cn as d } from "../../../lib/utils.js";
8
+ import { apiFailure as w } from "../overview/overview-api.js";
9
+ import { layoutDraftKeys as D } from "../useLayoutDraft.js";
10
+ import { usePromoteSources as ee, downloadLayout as te, previewPromotion as ae, trimUploadedFile as re, applyPromotion as ne } from "./ops-api.js";
11
+ const C = "inline-flex h-7 items-center gap-1 whitespace-nowrap rounded-full border px-2.5 text-[12px] font-medium transition-colors disabled:cursor-not-allowed disabled:opacity-50", $ = "border-slate-200 bg-white text-slate-700 hover:border-slate-300 dark:border-border dark:bg-card dark:text-foreground dark:hover:bg-muted", E = "border-nvr-cyan/60 bg-nvr-cyan/10 text-nvr-navy dark:text-nvr-cyan", oe = "inline-flex h-7 items-center gap-1 whitespace-nowrap rounded-md border border-slate-200 bg-white px-2 text-[12px] font-medium text-slate-700 transition-colors hover:bg-slate-50 disabled:opacity-50 dark:border-border dark:bg-card dark:text-foreground dark:hover:bg-muted", I = "inline-flex h-7 items-center gap-1 whitespace-nowrap rounded-md bg-nvr-cyan px-2.5 text-[12px] font-semibold text-white hover:opacity-90 disabled:opacity-50", se = {
12
+ setting: "Settings",
13
+ section: "Sections and tabs",
14
+ field: "Fields",
15
+ order: "Order"
16
+ };
17
+ function le({ c: s }) {
18
+ const l = "mt-[3px] h-3 w-3 shrink-0";
19
+ return s.kind === "order" ? /* @__PURE__ */ a(z, { className: l }) : s.action === "add" ? /* @__PURE__ */ a(G, { className: d(l, "text-emerald-600 dark:text-emerald-400") }) : s.action === "remove" ? /* @__PURE__ */ a(V, { className: d(l, "text-red-600 dark:text-red-400") }) : /* @__PURE__ */ a(X, { className: l });
20
+ }
21
+ const O = (s) => s == null || s === "" ? "empty" : typeof s == "object" ? JSON.stringify(s).slice(0, 60) : String(s);
22
+ function be({
23
+ layoutId: s,
24
+ layoutName: l,
25
+ onApplied: g,
26
+ className: Q
27
+ }) {
28
+ var L;
29
+ const b = Z(), y = H(), h = ee(), P = Y(null), [o, S] = i(null), [R, U] = i(null), [n, k] = i(null), [c, f] = i(null), [F, m] = i(null), [T, p] = i(!1), x = async (e, t) => {
30
+ S(e), U(t ?? null), k(null), p(!1), m(null), f("preview");
31
+ try {
32
+ k(await ae(b, s, e.body, t ?? null));
33
+ } catch (v) {
34
+ m(w(v, "Could not compare").message);
35
+ } finally {
36
+ f(null);
37
+ }
38
+ }, W = async (e) => {
39
+ if (e)
40
+ try {
41
+ const t = re(await e.text());
42
+ x({ key: `file:${e.name}`, body: { file: t }, label: e.name });
43
+ } catch (t) {
44
+ m(t.message);
45
+ }
46
+ }, A = async () => {
47
+ if (!(!o || !n)) {
48
+ f("apply"), m(null);
49
+ try {
50
+ const e = await ne(b, s, o.body, n.base_rev, R);
51
+ q.success(
52
+ e.applied ? `Brought over from ${n.source.label}. History has the version from before.` : "Already the same"
53
+ ), y.invalidateQueries({ queryKey: D.bundle(s) }), y.invalidateQueries({ queryKey: D.versions(s) }), y.invalidateQueries({ queryKey: ["layout-editor", "overview"] }), p(!1), k(null), S(null), g == null || g();
54
+ } catch (e) {
55
+ const t = w(e, "Could not apply");
56
+ m(t.message), p(!1);
57
+ } finally {
58
+ f(null);
59
+ }
60
+ }
61
+ }, j = ((L = n == null ? void 0 : n.plan) == null ? void 0 : L.changes) ?? [], u = j.filter((e) => e.action !== "skip"), K = j.filter((e) => e.action === "skip"), B = ["setting", "section", "field", "order"].map((e) => ({ k: e, list: u.filter((t) => t.kind === e) })).filter((e) => e.list.length);
62
+ return /* @__PURE__ */ r("div", { className: d("space-y-3 text-[12.5px]", Q), "data-promote-panel": s, children: [
63
+ /* @__PURE__ */ r("div", { children: [
64
+ /* @__PURE__ */ a("p", { className: "font-semibold text-slate-900 dark:text-foreground", children: "Compare with another environment" }),
65
+ /* @__PURE__ */ a("p", { className: "mt-0.5 text-[12px] text-slate-500 dark:text-muted-foreground", children: "Reads that environment’s copy of this layout and shows what would change here. Nothing is sent from here." })
66
+ ] }),
67
+ /* @__PURE__ */ r("div", { className: "flex flex-wrap items-center gap-1.5", "data-promote-sources": !0, children: [
68
+ h.isLoading && /* @__PURE__ */ a(N, { className: "h-3.5 w-3.5 animate-spin text-slate-400" }),
69
+ (h.data ?? []).map((e) => {
70
+ const t = `env:${e.id}`;
71
+ return /* @__PURE__ */ a(
72
+ "button",
73
+ {
74
+ type: "button",
75
+ disabled: !e.has_token || c != null,
76
+ "data-tip": e.has_token ? void 0 : "Add an API token to this component on Environments",
77
+ "data-promote-source": e.id,
78
+ "aria-pressed": (o == null ? void 0 : o.key) === t,
79
+ onClick: () => void x({
80
+ key: t,
81
+ body: { component_id: e.id },
82
+ label: `${e.environment ?? "Environment"} · ${e.name}`
83
+ }),
84
+ className: d(C, (o == null ? void 0 : o.key) === t ? E : $),
85
+ children: e.environment ? `${e.environment} · ${e.name}` : e.name
86
+ },
87
+ e.id
88
+ );
89
+ }),
90
+ /* @__PURE__ */ r(
91
+ "button",
92
+ {
93
+ type: "button",
94
+ className: d(C, o != null && o.key.startsWith("file:") ? E : $),
95
+ disabled: c != null,
96
+ onClick: () => {
97
+ var e;
98
+ return (e = P.current) == null ? void 0 : e.click();
99
+ },
100
+ "data-promote-upload": !0,
101
+ children: [
102
+ /* @__PURE__ */ a(J, { className: "h-3 w-3" }),
103
+ o != null && o.key.startsWith("file:") ? o.label : "Upload a file…"
104
+ ]
105
+ }
106
+ ),
107
+ /* @__PURE__ */ a(
108
+ "input",
109
+ {
110
+ ref: P,
111
+ type: "file",
112
+ accept: ".json,application/json",
113
+ className: "hidden",
114
+ onChange: (e) => {
115
+ var t;
116
+ W((t = e.target.files) == null ? void 0 : t[0]), e.target.value = "";
117
+ }
118
+ }
119
+ )
120
+ ] }),
121
+ !h.isLoading && (h.data ?? []).length === 0 && /* @__PURE__ */ a("p", { className: "text-[11.5px] text-slate-500 dark:text-muted-foreground", children: "No other environment is registered with an API address. Upload a form file or a Config Diff snapshot instead." }),
122
+ /* @__PURE__ */ r("p", { className: "text-[11.5px] text-slate-500 dark:text-muted-foreground", children: [
123
+ "For an environment that cannot reach this one:",
124
+ " ",
125
+ /* @__PURE__ */ r(
126
+ "button",
127
+ {
128
+ type: "button",
129
+ className: "inline-flex items-center gap-1 font-medium text-[#0089ad] hover:underline dark:text-nvr-cyan",
130
+ onClick: () => void te(b, s, l).catch(
131
+ (e) => q.error(w(e, "Could not download").message)
132
+ ),
133
+ "data-promote-download": !0,
134
+ children: [
135
+ /* @__PURE__ */ a(M, { className: "h-3 w-3" }),
136
+ "download this form"
137
+ ]
138
+ }
139
+ ),
140
+ " ",
141
+ "and upload it there."
142
+ ] }),
143
+ c === "preview" && /* @__PURE__ */ r("p", { className: "flex items-center gap-1.5 text-slate-500 dark:text-muted-foreground", children: [
144
+ /* @__PURE__ */ a(N, { className: "h-3.5 w-3.5 animate-spin" }),
145
+ "Comparing…"
146
+ ] }),
147
+ F && /* @__PURE__ */ a("p", { className: "text-[12px] text-red-600 dark:text-red-400", role: "alert", children: F }),
148
+ n && !n.theirs && o && /* @__PURE__ */ r("div", { "data-promote-nomatch": !0, className: "space-y-1.5", children: [
149
+ /* @__PURE__ */ r("p", { className: "text-slate-700 dark:text-foreground", children: [
150
+ n.source.label,
151
+ " has no layout with this link name or name. Pick the one to compare with:"
152
+ ] }),
153
+ /* @__PURE__ */ r("div", { className: "flex flex-wrap gap-1.5", children: [
154
+ n.candidates.length === 0 && /* @__PURE__ */ a("span", { className: "text-slate-500 dark:text-muted-foreground", children: "It has no layouts for this collection." }),
155
+ n.candidates.map((e) => /* @__PURE__ */ a(
156
+ "button",
157
+ {
158
+ type: "button",
159
+ className: d(C, $),
160
+ onClick: () => void x(o, e.id),
161
+ children: e.name
162
+ },
163
+ e.id
164
+ ))
165
+ ] })
166
+ ] }),
167
+ (n == null ? void 0 : n.theirs) && n.plan && /* @__PURE__ */ r(
168
+ "div",
169
+ {
170
+ className: "space-y-2 rounded-lg border border-slate-200 bg-slate-50 p-3 dark:border-border dark:bg-background",
171
+ "data-promote-diff": !0,
172
+ children: [
173
+ /* @__PURE__ */ r("p", { className: "text-slate-700 dark:text-foreground", children: [
174
+ /* @__PURE__ */ r("span", { className: "font-semibold", children: [
175
+ "“",
176
+ n.theirs.name,
177
+ "”"
178
+ ] }),
179
+ " in ",
180
+ n.source.label,
181
+ n.source.version ? ` (${n.source.version})` : "",
182
+ n.candidates.length > 1 && /* @__PURE__ */ r(_, { children: [
183
+ " · ",
184
+ /* @__PURE__ */ a("span", { className: "text-slate-500 dark:text-muted-foreground", children: "compare with " }),
185
+ n.candidates.filter((e) => {
186
+ var t;
187
+ return e.id !== ((t = n.theirs) == null ? void 0 : t.id);
188
+ }).slice(0, 6).map((e, t) => /* @__PURE__ */ r("span", { children: [
189
+ t > 0 ? ", " : "",
190
+ /* @__PURE__ */ a(
191
+ "button",
192
+ {
193
+ type: "button",
194
+ className: "text-[#0089ad] hover:underline dark:text-nvr-cyan",
195
+ onClick: () => o && void x(o, e.id),
196
+ children: e.name
197
+ }
198
+ )
199
+ ] }, e.id))
200
+ ] })
201
+ ] }),
202
+ u.length === 0 ? /* @__PURE__ */ a("p", { className: "text-slate-600 dark:text-muted-foreground", "data-promote-same": !0, children: "The same as here — nothing to bring over." }) : B.map((e) => /* @__PURE__ */ r("div", { children: [
203
+ /* @__PURE__ */ r("p", { className: "mb-0.5 text-[11.5px] font-medium text-slate-500 dark:text-muted-foreground", children: [
204
+ se[e.k],
205
+ " · ",
206
+ e.list.length
207
+ ] }),
208
+ /* @__PURE__ */ r("ul", { className: "space-y-0.5", children: [
209
+ e.list.slice(0, 40).map((t, v) => /* @__PURE__ */ r(
210
+ "li",
211
+ {
212
+ className: "flex items-start gap-1.5 text-slate-700 dark:text-foreground",
213
+ children: [
214
+ /* @__PURE__ */ a(le, { c: t }),
215
+ /* @__PURE__ */ a("span", { className: "min-w-0 break-words", children: t.kind === "setting" ? /* @__PURE__ */ r(_, { children: [
216
+ /* @__PURE__ */ a("code", { className: "font-mono text-[11.5px]", children: t.target }),
217
+ ":",
218
+ " ",
219
+ /* @__PURE__ */ a("span", { className: "text-slate-500 dark:text-muted-foreground", children: O(t.from) }),
220
+ " → ",
221
+ O(t.to)
222
+ ] }) : t.text })
223
+ ]
224
+ },
225
+ `${t.kind}:${t.target}:${t.where ?? ""}:${v}`
226
+ )),
227
+ e.list.length > 40 && /* @__PURE__ */ r("li", { className: "text-slate-500 dark:text-muted-foreground", children: [
228
+ "and ",
229
+ e.list.length - 40,
230
+ " more"
231
+ ] })
232
+ ] })
233
+ ] }, e.k)),
234
+ K.length > 0 && /* @__PURE__ */ a(
235
+ "div",
236
+ {
237
+ className: "rounded-md border border-amber-300 bg-amber-50 p-2 text-[12px] text-amber-900 dark:border-amber-400/30 dark:bg-amber-400/10 dark:text-amber-200",
238
+ "data-promote-skipped": !0,
239
+ children: K.map((e, t) => /* @__PURE__ */ r("p", { children: [
240
+ e.kind === "setting" ? /* @__PURE__ */ a("code", { className: "font-mono", children: e.target }) : null,
241
+ e.kind === "setting" ? " — " : "",
242
+ e.text
243
+ ] }, `${e.target}:${t}`))
244
+ }
245
+ ),
246
+ /* @__PURE__ */ a("p", { className: "text-[11.5px] text-slate-500 dark:text-muted-foreground", children: "Which layout is the default, and its place in the list, stay as they are here." }),
247
+ u.length > 0 && (T ? /* @__PURE__ */ r("div", { className: "flex flex-wrap items-center gap-2", "data-promote-confirm": !0, children: [
248
+ /* @__PURE__ */ r("span", { className: "text-slate-700 dark:text-foreground", children: [
249
+ "Save a version of this layout, then apply ",
250
+ u.length,
251
+ " ",
252
+ u.length === 1 ? "change" : "changes",
253
+ "? History → Restore undoes it."
254
+ ] }),
255
+ /* @__PURE__ */ r(
256
+ "button",
257
+ {
258
+ type: "button",
259
+ className: I,
260
+ disabled: c != null,
261
+ onClick: () => void A(),
262
+ "data-promote-apply-confirm": !0,
263
+ children: [
264
+ c === "apply" && /* @__PURE__ */ a(N, { className: "h-3 w-3 animate-spin" }),
265
+ "Apply here"
266
+ ]
267
+ }
268
+ ),
269
+ /* @__PURE__ */ a("button", { type: "button", className: oe, onClick: () => p(!1), children: "Cancel" })
270
+ ] }) : /* @__PURE__ */ a(
271
+ "button",
272
+ {
273
+ type: "button",
274
+ className: I,
275
+ onClick: () => p(!0),
276
+ "data-promote-apply": !0,
277
+ children: "Apply here…"
278
+ }
279
+ ))
280
+ ]
281
+ }
282
+ )
283
+ ] });
284
+ }
285
+ export {
286
+ be as PromotePanel
287
+ };
@@ -0,0 +1,122 @@
1
+ import { useQuery as l } from "@tanstack/react-query";
2
+ import { useNivaroClient as y } from "../../../context.js";
3
+ import { get as i, post as c } from "../../../lib/commands.js";
4
+ const p = {
5
+ deps: (e) => ["layout-editor", "dependencies", e],
6
+ sources: () => ["layout-editor", "promote-sources"],
7
+ requests: (e) => ["layout-editor", "change-requests", e]
8
+ }, s = (e) => {
9
+ const o = e;
10
+ return o && typeof o == "object" && "data" in o ? o.data : e;
11
+ };
12
+ function q(e, o = !0) {
13
+ const r = y();
14
+ return l({
15
+ queryKey: p.deps(e ?? 0),
16
+ queryFn: async () => {
17
+ const t = s(
18
+ await r.request(i(`/collection-layouts/${e}/dependencies`))
19
+ );
20
+ if (!t || typeof t != "object" || !t.layout || !Array.isArray(t.nodes))
21
+ throw new Error("No dependency data");
22
+ return {
23
+ ...t,
24
+ groups: Array.isArray(t.groups) ? t.groups : [],
25
+ extensions: t.extensions ?? { declaring: 0, note: "" }
26
+ };
27
+ },
28
+ enabled: o && e != null,
29
+ staleTime: 15e3
30
+ });
31
+ }
32
+ function b(e = !0) {
33
+ const o = y();
34
+ return l({
35
+ queryKey: p.sources(),
36
+ queryFn: async () => {
37
+ const r = s(
38
+ await o.request(i("/collection-layouts/promote/sources"))
39
+ );
40
+ return Array.isArray(r) ? r : [];
41
+ },
42
+ enabled: e,
43
+ staleTime: 6e4
44
+ });
45
+ }
46
+ async function w(e, o, r, t) {
47
+ return s(
48
+ await e.request(
49
+ c(`/collection-layouts/${o}/promote/preview`, {
50
+ ...r,
51
+ ...t != null ? { remote_layout_id: t } : {}
52
+ })
53
+ )
54
+ );
55
+ }
56
+ async function g(e, o, r, t, a) {
57
+ return s(
58
+ await e.request(
59
+ c(`/collection-layouts/${o}/promote/apply`, {
60
+ ...r,
61
+ base_rev: t,
62
+ ...a != null ? { remote_layout_id: a } : {}
63
+ })
64
+ )
65
+ );
66
+ }
67
+ async function h(e, o, r) {
68
+ const t = await e.request(i(`/collection-layouts/${o}/export`)), a = new Blob([JSON.stringify(t, null, 2)], { type: "application/json" }), n = URL.createObjectURL(a), u = document.createElement("a");
69
+ u.href = n, u.download = `layout-${r.toLowerCase().replace(/[^a-z0-9_-]+/g, "-") || o}.json`, document.body.appendChild(u), u.click(), u.remove(), setTimeout(() => URL.revokeObjectURL(n), 1e3);
70
+ }
71
+ function _(e) {
72
+ let o;
73
+ try {
74
+ o = JSON.parse(e);
75
+ } catch {
76
+ throw new Error("That file is not JSON");
77
+ }
78
+ const r = (o == null ? void 0 : o.data) ?? o, t = r;
79
+ return t && t.format === 1 && t.tables && typeof t.tables == "object" ? {
80
+ ...t,
81
+ classification: void 0,
82
+ tables: Object.fromEntries([
83
+ "nivaro_collection_layouts",
84
+ "nivaro_field_groups",
85
+ "nivaro_layout_field_assignments"
86
+ ].filter((n) => n in t.tables).map((n) => [n, t.tables[n]]))
87
+ } : r;
88
+ }
89
+ function v(e, o = !0) {
90
+ const r = y();
91
+ return l({
92
+ queryKey: p.requests(e),
93
+ queryFn: async () => {
94
+ const t = s(
95
+ await r.request(i("/layout-change-requests", { collection: e }))
96
+ );
97
+ return Array.isArray(t) ? t : [];
98
+ },
99
+ enabled: o && !!e,
100
+ staleTime: 3e4
101
+ });
102
+ }
103
+ async function j(e, o, r, t) {
104
+ return e.request(c(`/layout-change-requests/${o}/resolve`, { decision: r, note: t }));
105
+ }
106
+ async function A(e, o) {
107
+ return s(
108
+ await e.request(c("/layout-change-requests", o))
109
+ );
110
+ }
111
+ export {
112
+ g as applyPromotion,
113
+ h as downloadLayout,
114
+ p as opsKeys,
115
+ w as previewPromotion,
116
+ j as resolveChangeRequest,
117
+ A as sendChangeRequest,
118
+ _ as trimUploadedFile,
119
+ v as useChangeRequests,
120
+ q as useLayoutDependencies,
121
+ b as usePromoteSources
122
+ };
@@ -0,0 +1,254 @@
1
+ import { jsxs as o, jsx as e, Fragment as R } from "react/jsx-runtime";
2
+ import { FileOutput as T, ArrowLeft as H, FileSpreadsheet as M, Download as U, Printer as _, Upload as q, Loader2 as I } from "lucide-react";
3
+ import { useState as u, useRef as W, useMemo as j } from "react";
4
+ import { useApiFetchConfig as Y } from "../../../context.js";
5
+ import { cn as x } from "../../../lib/utils.js";
6
+ import { Checkbox as z } from "../../ui/checkbox.js";
7
+ import { Popover as G, PopoverContent as J } from "../../ui/popover.js";
8
+ import { useCollectionMeta as K } from "../inspector/field-context.js";
9
+ import { effectText as g } from "../panel-style.js";
10
+ import { ToolButton as Q } from "../toolbar-kit.js";
11
+ import { helpSheetPlan as V, propWord as X, diffHelpSheet as Z, helpSheetRows as ee } from "./help-sheet.js";
12
+ import { parseHelpSheetFile as te, saveFile as k, downloadTemplate as ae, downloadRecords as ne, downloadBlankForm as oe, downloadHelpSheet as se } from "./output-api.js";
13
+ const re = "mt-0.5 h-4 w-4 shrink-0 rounded border-slate-300 data-[state=checked]:border-nvr-cyan data-[state=checked]:bg-nvr-cyan data-[state=checked]:text-white dark:border-slate-600 [&_svg]:h-3 [&_svg]:w-3", le = "group flex w-full items-start gap-2.5 rounded-md px-2 py-1.5 text-left transition-colors hover:bg-muted focus-visible:bg-muted focus-visible:outline-none disabled:pointer-events-none disabled:opacity-60";
14
+ function f({
15
+ icon: s,
16
+ title: d,
17
+ effect: i,
18
+ busy: n,
19
+ onClick: c,
20
+ data: w
21
+ }) {
22
+ return /* @__PURE__ */ o("button", { type: "button", className: le, disabled: n, onClick: c, "data-output": w, children: [
23
+ /* @__PURE__ */ e("span", { className: "mt-0.5 text-slate-500 dark:text-muted-foreground", children: n ? /* @__PURE__ */ e(I, { className: "h-4 w-4 animate-spin" }) : s }),
24
+ /* @__PURE__ */ o("span", { className: "min-w-0 flex-1", children: [
25
+ /* @__PURE__ */ e("span", { className: "block text-[13px] font-medium text-slate-900 dark:text-foreground", children: d }),
26
+ /* @__PURE__ */ e("span", { className: x(g, "block"), children: i })
27
+ ] })
28
+ ] });
29
+ }
30
+ function de({
31
+ diff: s,
32
+ skip: d,
33
+ toggle: i
34
+ }) {
35
+ return /* @__PURE__ */ e(
36
+ "div",
37
+ {
38
+ "data-help-changes": "",
39
+ className: "mt-2 max-h-[320px] overflow-y-auto border-t border-slate-100 pt-1 dark:border-border",
40
+ children: s.changes.map((n) => (
41
+ // biome-ignore lint/a11y/noLabelWithoutControl: the Radix checkbox is the control
42
+ /* @__PURE__ */ o(
43
+ "label",
44
+ {
45
+ "data-help-change": n.prop,
46
+ className: "flex cursor-pointer items-start gap-2 rounded px-1 py-1.5 hover:bg-muted",
47
+ children: [
48
+ /* @__PURE__ */ e(
49
+ z,
50
+ {
51
+ checked: !d.has(n.id),
52
+ onCheckedChange: () => i(n.id),
53
+ className: re
54
+ }
55
+ ),
56
+ /* @__PURE__ */ o("span", { className: "min-w-0 flex-1 text-[12.5px] leading-snug", children: [
57
+ /* @__PURE__ */ o("span", { className: "block truncate text-[11.5px] text-slate-500 dark:text-muted-foreground", children: [
58
+ X(n.prop),
59
+ " · ",
60
+ n.where
61
+ ] }),
62
+ /* @__PURE__ */ e("span", { className: "block whitespace-pre-wrap break-words text-slate-500 line-through decoration-slate-300 dark:text-muted-foreground", children: n.before || "Empty" }),
63
+ /* @__PURE__ */ e("span", { className: "block whitespace-pre-wrap break-words text-slate-900 dark:text-foreground", children: n.after || "Removed (the field’s own text shows)" })
64
+ ] })
65
+ ]
66
+ },
67
+ n.id
68
+ )
69
+ ))
70
+ }
71
+ );
72
+ }
73
+ function ye({
74
+ bundle: s,
75
+ apply: d,
76
+ collection: i
77
+ }) {
78
+ const n = Y(), c = Number(s.layout.id), w = String(s.layout.name ?? "form"), [S, F] = u(!1), [p, B] = u(null), [E, y] = u(null), [a, N] = u(null), [v, O] = u(/* @__PURE__ */ new Set()), $ = W(null), { data: C } = K(S ? i : null), A = C == null ? void 0 : C.fields, h = j(() => ((a == null ? void 0 : a.changes) ?? []).filter((t) => !v.has(t.id)), [a, v]), b = j(() => V(s, h), [s, h]), m = async (t, r) => {
79
+ B(t), y(null);
80
+ try {
81
+ await r();
82
+ } catch (l) {
83
+ y(l.message || "Something went wrong");
84
+ } finally {
85
+ B(null);
86
+ }
87
+ }, D = (t) => {
88
+ t && m("upload", async () => {
89
+ const r = await te(n, t), l = Z(s, A ?? [], r);
90
+ O(/* @__PURE__ */ new Set()), N(l);
91
+ });
92
+ }, L = (t) => O((r) => {
93
+ const l = new Set(r);
94
+ return l.has(t) ? l.delete(t) : l.add(t), l;
95
+ }), P = (t) => {
96
+ F(t), t || (N(null), y(null));
97
+ };
98
+ return /* @__PURE__ */ o(G, { open: S, onOpenChange: P, children: [
99
+ /* @__PURE__ */ e(
100
+ Q,
101
+ {
102
+ popover: !0,
103
+ onOpen: () => F(!0),
104
+ label: "Outputs",
105
+ icon: /* @__PURE__ */ e(T, { className: "h-3.5 w-3.5 shrink-0" }),
106
+ tip: "Excel template and export, blank printable form, help text sheet",
107
+ hint: "Spreadsheet, print and help text",
108
+ data: { "data-outputs-open": "" }
109
+ }
110
+ ),
111
+ /* @__PURE__ */ e(J, { align: "end", className: "w-[420px] p-3", "data-outputs": "", children: a ? /* @__PURE__ */ o(R, { children: [
112
+ /* @__PURE__ */ o(
113
+ "button",
114
+ {
115
+ type: "button",
116
+ onClick: () => N(null),
117
+ className: "mb-1 inline-flex items-center gap-1 text-[12px] font-medium text-sky-700 hover:underline dark:text-nvr-cyan",
118
+ children: [
119
+ /* @__PURE__ */ e(H, { className: "h-3 w-3" }),
120
+ " Back"
121
+ ]
122
+ }
123
+ ),
124
+ /* @__PURE__ */ e("p", { className: "text-[13px] font-semibold text-slate-900 dark:text-foreground", children: a.changes.length === 0 ? "Nothing differs from the form" : `${a.changes.length} ${a.changes.length === 1 ? "change" : "changes"} in the sheet` }),
125
+ /* @__PURE__ */ e("p", { className: x(g, "mt-0.5"), children: "Untick any you do not want. Applying is one step; Undo puts every one back." }),
126
+ /* @__PURE__ */ e(de, { diff: a, skip: v, toggle: L }),
127
+ (a.unknown > 0 || a.skipped.length > 0) && /* @__PURE__ */ o("p", { className: x(g, "mt-2"), children: [
128
+ a.unknown > 0 && `${a.unknown} ${a.unknown === 1 ? "row" : "rows"} match nothing on this form and ${a.unknown === 1 ? "is" : "are"} left out. `,
129
+ a.skipped.join(". ")
130
+ ] }),
131
+ /* @__PURE__ */ o("div", { className: "mt-2 flex items-center justify-end gap-2 border-t border-slate-100 pt-2.5 dark:border-border", children: [
132
+ /* @__PURE__ */ e("span", { className: x(g, "mr-auto"), children: a.changes.length > 0 && `${h.length} of ${a.changes.length} ticked` }),
133
+ /* @__PURE__ */ o(
134
+ "button",
135
+ {
136
+ type: "button",
137
+ "data-help-apply": "",
138
+ disabled: !b.ok,
139
+ onClick: () => {
140
+ b.ok && (d(b.ops, { label: b.label }), P(!1));
141
+ },
142
+ className: "inline-flex h-7 items-center rounded-md bg-nvr-cyan px-3 text-[12px] font-medium text-white transition-opacity hover:opacity-90 disabled:pointer-events-none disabled:opacity-40",
143
+ children: [
144
+ "Apply ",
145
+ h.length > 0 ? h.length : ""
146
+ ]
147
+ }
148
+ )
149
+ ] })
150
+ ] }) : /* @__PURE__ */ o(R, { children: [
151
+ /* @__PURE__ */ e("p", { className: "px-2 text-[13px] font-semibold text-slate-900 dark:text-foreground", children: "Outputs" }),
152
+ /* @__PURE__ */ e("p", { className: x(g, "mt-0.5 px-2"), children: "The form as a file. Spreadsheets and print follow the saved form." }),
153
+ /* @__PURE__ */ o("div", { className: "mt-2 space-y-0.5", children: [
154
+ /* @__PURE__ */ e(
155
+ f,
156
+ {
157
+ data: "template",
158
+ icon: /* @__PURE__ */ e(M, { className: "h-4 w-4" }),
159
+ title: "Excel import template",
160
+ effect: "Columns in this form’s order; choices are dropdowns and required columns are amber.",
161
+ busy: p === "template",
162
+ onClick: () => m("template", async () => k(await ae(n, c)))
163
+ }
164
+ ),
165
+ /* @__PURE__ */ e(
166
+ f,
167
+ {
168
+ data: "records",
169
+ icon: /* @__PURE__ */ e(U, { className: "h-4 w-4" }),
170
+ title: "Export records to Excel",
171
+ effect: "Up to 5,000 records in the same columns, limited to what you may read.",
172
+ busy: p === "records",
173
+ onClick: () => m("records", async () => k(await ne(n, c)))
174
+ }
175
+ ),
176
+ /* @__PURE__ */ e(
177
+ f,
178
+ {
179
+ data: "blank",
180
+ icon: /* @__PURE__ */ e(_, { className: "h-4 w-4" }),
181
+ title: "Blank printable form",
182
+ effect: "A PDF with lines and checkboxes for filling in on paper.",
183
+ busy: p === "blank",
184
+ onClick: () => m("blank", async () => k(await oe(n, c)))
185
+ }
186
+ )
187
+ ] }),
188
+ /* @__PURE__ */ o("div", { className: "mt-2 border-t border-slate-100 pt-2 dark:border-border", children: [
189
+ /* @__PURE__ */ e("p", { className: "px-2 text-[12.5px] font-semibold text-slate-900 dark:text-foreground", children: "Labels and help text" }),
190
+ /* @__PURE__ */ o("div", { className: "mt-1 space-y-0.5", children: [
191
+ /* @__PURE__ */ e(
192
+ f,
193
+ {
194
+ data: "help-download",
195
+ icon: /* @__PURE__ */ e(U, { className: "h-4 w-4" }),
196
+ title: "Download as a sheet",
197
+ effect: "Every label, help text and placeholder on this form, including unsaved edits.",
198
+ busy: p === "help",
199
+ onClick: () => m(
200
+ "help",
201
+ async () => k(
202
+ await se(
203
+ n,
204
+ ee(s, A ?? []),
205
+ w
206
+ )
207
+ )
208
+ )
209
+ }
210
+ ),
211
+ /* @__PURE__ */ e(
212
+ f,
213
+ {
214
+ data: "help-upload",
215
+ icon: /* @__PURE__ */ e(q, { className: "h-4 w-4" }),
216
+ title: "Upload the edited sheet",
217
+ effect: "You see every difference before anything changes.",
218
+ busy: p === "upload",
219
+ onClick: () => {
220
+ var t;
221
+ return (t = $.current) == null ? void 0 : t.click();
222
+ }
223
+ }
224
+ ),
225
+ /* @__PURE__ */ e(
226
+ "input",
227
+ {
228
+ ref: $,
229
+ type: "file",
230
+ accept: ".xlsx",
231
+ className: "hidden",
232
+ "data-help-file": "",
233
+ onChange: (t) => {
234
+ var r;
235
+ D((r = t.target.files) == null ? void 0 : r[0]), t.target.value = "";
236
+ }
237
+ }
238
+ )
239
+ ] })
240
+ ] }),
241
+ E && /* @__PURE__ */ e(
242
+ "p",
243
+ {
244
+ role: "alert",
245
+ className: "mt-2 text-[12px] leading-snug text-red-600 dark:text-red-400",
246
+ children: E
247
+ }
248
+ )
249
+ ] }) })
250
+ ] });
251
+ }
252
+ export {
253
+ ye as OutputsButton
254
+ };