@delmaredigital/payload-experiments 0.4.0-rc.7 → 0.4.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 (367) hide show
  1. package/README.md +9 -15
  2. package/dist/admin/MetricSourceSelect.js +10 -3
  3. package/dist/admin/armSelect/armSelect.model.d.ts +1 -1
  4. package/dist/admin/blocks/BlockPanel.d.ts +1 -0
  5. package/dist/admin/blocks/BlockPanel.js +75 -29
  6. package/dist/admin/blocks/model.js +7 -6
  7. package/dist/admin/copy/blocks.d.ts +14 -11
  8. package/dist/admin/copy/blocks.js +33 -22
  9. package/dist/admin/copy/goals.d.ts +15 -8
  10. package/dist/admin/copy/goals.js +18 -8
  11. package/dist/admin/copy/newTest.d.ts +10 -7
  12. package/dist/admin/copy/newTest.js +14 -7
  13. package/dist/admin/copy/status.d.ts +1 -1
  14. package/dist/admin/copy/status.js +2 -1
  15. package/dist/admin/pageCollections.d.ts +1 -0
  16. package/dist/admin/pageCollections.js +3 -0
  17. package/dist/admin/placementStatus.model.js +5 -3
  18. package/dist/admin/status.model.d.ts +1 -0
  19. package/dist/admin/status.model.js +2 -1
  20. package/dist/admin/surface/ResultsRoute.js +12 -10
  21. package/dist/admin/surface/SurfaceShell.d.ts +4 -2
  22. package/dist/admin/surface/SurfaceShell.js +28 -3
  23. package/dist/admin/surface/TestRowMenu.d.ts +13 -0
  24. package/dist/admin/surface/TestRowMenu.js +163 -0
  25. package/dist/admin/surface/TestsHome.d.ts +4 -3
  26. package/dist/admin/surface/TestsHome.js +224 -52
  27. package/dist/admin/surface/TestsSurface.js +2 -1
  28. package/dist/admin/surface/goals/DeleteGoalDialog.d.ts +7 -0
  29. package/dist/admin/surface/goals/DeleteGoalDialog.js +42 -0
  30. package/dist/admin/surface/goals/GoalForm.d.ts +1 -0
  31. package/dist/admin/surface/goals/GoalForm.js +280 -198
  32. package/dist/admin/surface/goals/GoalsList.js +102 -33
  33. package/dist/admin/surface/goals/data.d.ts +2 -0
  34. package/dist/admin/surface/goals/data.js +9 -0
  35. package/dist/admin/surface/goals/goals.css +3 -2
  36. package/dist/admin/surface/goals/goals.model.d.ts +2 -2
  37. package/dist/admin/surface/goals/goals.model.js +7 -12
  38. package/dist/admin/surface/home.model.d.ts +15 -8
  39. package/dist/admin/surface/home.model.js +22 -18
  40. package/dist/admin/surface/newTest/NewTest.d.ts +3 -3
  41. package/dist/admin/surface/newTest/NewTest.js +156 -96
  42. package/dist/admin/surface/newTest/PageWizard.d.ts +4 -1
  43. package/dist/admin/surface/newTest/PageWizard.js +99 -68
  44. package/dist/admin/surface/newTest/newTest.css +28 -11
  45. package/dist/admin/surface/results/ResultsHeader.d.ts +1 -1
  46. package/dist/admin/surface/results/ResultsHeader.js +98 -66
  47. package/dist/admin/surface/surface.css +29 -0
  48. package/dist/admin/surface/test/TestPage.js +46 -38
  49. package/dist/admin/surface/useXpStepNav.d.ts +11 -0
  50. package/dist/admin/surface/useXpStepNav.js +14 -0
  51. package/dist/admin/views/TestsSurfaceClient.js +27 -3
  52. package/dist/admin/views/buildSurfaceProps.js +18 -66
  53. package/dist/arms/copy.d.ts +13 -3
  54. package/dist/arms/copy.js +5 -4
  55. package/dist/blocks/createExperimentBlock.js +1 -1
  56. package/dist/blocks/formState.js +2 -2
  57. package/dist/collections/experiments/armInvariants.js +8 -5
  58. package/dist/collections/experiments/config.js +8 -3
  59. package/dist/collections/experiments/deleteGuard.js +2 -2
  60. package/dist/collections/experiments/lockHook.js +21 -2
  61. package/dist/collections/experiments/pickSlug.js +2 -0
  62. package/dist/collections/metrics.js +12 -5
  63. package/dist/collections/metricsGuards.js +2 -0
  64. package/dist/collections/serialize.js +8 -6
  65. package/dist/constants.d.ts +1 -0
  66. package/dist/constants.js +1 -0
  67. package/dist/db/adapter.d.ts +9 -1
  68. package/dist/db/adapter.js +77 -1
  69. package/dist/db/delete.d.ts +1 -1
  70. package/dist/db/delete.js +2 -4
  71. package/dist/db/events.d.ts +9 -0
  72. package/dist/db/events.js +42 -8
  73. package/dist/db/executor.d.ts +7 -1
  74. package/dist/db/executor.js +7 -3
  75. package/dist/db/pageCopies.d.ts +5 -0
  76. package/dist/db/pageCopies.js +31 -0
  77. package/dist/db/results.d.ts +5 -1
  78. package/dist/db/results.js +21 -5
  79. package/dist/db/snapshots.d.ts +2 -0
  80. package/dist/endpoints/deleteImpact.js +2 -1
  81. package/dist/endpoints/duplicateOriginal.d.ts +38 -0
  82. package/dist/endpoints/duplicateOriginal.js +414 -0
  83. package/dist/endpoints/editorSurface.js +1 -1
  84. package/dist/endpoints/events.js +103 -39
  85. package/dist/endpoints/index.js +22 -8
  86. package/dist/endpoints/pages.js +245 -66
  87. package/dist/endpoints/placementStatus.js +8 -4
  88. package/dist/endpoints/results.d.ts +1 -1
  89. package/dist/endpoints/results.js +9 -2
  90. package/dist/endpoints/routeId.d.ts +2 -2
  91. package/dist/endpoints/routeId.js +11 -5
  92. package/dist/endpoints/summary.js +46 -12
  93. package/dist/endpoints/testVersion.d.ts +2 -0
  94. package/dist/endpoints/testVersion.js +38 -0
  95. package/dist/endpoints/transitions.js +41 -29
  96. package/dist/errors.d.ts +4 -0
  97. package/dist/errors.js +6 -0
  98. package/dist/events/request.d.ts +6 -2
  99. package/dist/events/request.js +35 -8
  100. package/dist/events/rows.d.ts +1 -1
  101. package/dist/events/rows.js +24 -8
  102. package/dist/events/writable.d.ts +9 -0
  103. package/dist/events/writable.js +13 -0
  104. package/dist/exports/index.d.ts +1 -1
  105. package/dist/exports/rsc.d.ts +1 -0
  106. package/dist/exports/rsc.js +1 -0
  107. package/dist/goals/fairness.js +2 -2
  108. package/dist/goals/picker/copy.js +1 -1
  109. package/dist/goals/sourceLabel.d.ts +2 -0
  110. package/dist/goals/sourceLabel.js +4 -0
  111. package/dist/hooks/hostHook.js +6 -2
  112. package/dist/hooks/pageGuard.js +4 -0
  113. package/dist/hooks/trackPageCopies.d.ts +11 -0
  114. package/dist/hooks/trackPageCopies.js +7 -0
  115. package/dist/labels/arms.d.ts +3 -0
  116. package/dist/labels/arms.js +8 -0
  117. package/dist/lib/fetchAllDocs.d.ts +1 -1
  118. package/dist/manifest/compile.js +8 -5
  119. package/dist/onInit.js +14 -0
  120. package/dist/options.d.ts +2 -0
  121. package/dist/options.js +23 -2
  122. package/dist/plugin.js +56 -2
  123. package/dist/proxy/pageNavigation.d.ts +4 -0
  124. package/dist/proxy/pageNavigation.js +28 -0
  125. package/dist/proxy/resolve.js +52 -25
  126. package/dist/puck/editor/ConfigureTestDrawer.d.ts +7 -7
  127. package/dist/puck/editor/ConfigureTestDrawer.js +40 -29
  128. package/dist/puck/editor/ExperimentSlotEditor.d.ts +2 -1
  129. package/dist/puck/editor/ExperimentSlotEditor.js +376 -139
  130. package/dist/puck/editor/LeftoverVersions.js +17 -32
  131. package/dist/puck/editor/QuickTestActions.d.ts +6 -3
  132. package/dist/puck/editor/QuickTestActions.js +55 -33
  133. package/dist/puck/editor/ResultsReadout.d.ts +4 -1
  134. package/dist/puck/editor/ResultsReadout.js +28 -15
  135. package/dist/puck/editor/VersionBuilder.d.ts +17 -4
  136. package/dist/puck/editor/VersionBuilder.js +175 -112
  137. package/dist/puck/editor/armWrites.js +2 -2
  138. package/dist/puck/editor/armsCache.js +1 -3
  139. package/dist/puck/editor/copy.d.ts +14 -7
  140. package/dist/puck/editor/copy.js +26 -13
  141. package/dist/puck/editor/editor.chrome.css +10 -8
  142. package/dist/puck/editor/editor.css +15 -9
  143. package/dist/puck/editor/editor.model.d.ts +1 -0
  144. package/dist/puck/editor/placementsCache.d.ts +4 -0
  145. package/dist/puck/editor/usePageSaveReadiness.d.ts +6 -0
  146. package/dist/puck/editor/usePageSaveReadiness.js +31 -0
  147. package/dist/puck/nestedTestCopy.js +2 -2
  148. package/dist/puck/slotConfig.d.ts +1 -1
  149. package/dist/puck/slotConfig.js +1 -1
  150. package/dist/results/aggregate.d.ts +6 -3
  151. package/dist/results/aggregate.js +9 -9
  152. package/dist/results/analyse.d.ts +2 -0
  153. package/dist/results/analyse.js +2 -2
  154. package/dist/results/health.d.ts +8 -0
  155. package/dist/results/health.js +28 -0
  156. package/dist/results/identityCredit.d.ts +1 -0
  157. package/dist/results/identityCredit.js +4 -1
  158. package/dist/results/verdict.d.ts +4 -4
  159. package/dist/results/verdict.js +15 -11
  160. package/dist/runtime/cookie.d.ts +10 -2
  161. package/dist/runtime/cookie.js +38 -6
  162. package/dist/runtime/cookieOptions.d.ts +6 -0
  163. package/dist/runtime/cookieOptions.js +14 -0
  164. package/dist/runtime/proxyRuntime.d.ts +1 -0
  165. package/dist/runtime/proxyRuntime.js +18 -8
  166. package/dist/runtime/signing.d.ts +1 -0
  167. package/dist/runtime/signing.js +5 -0
  168. package/dist/sanitizeReadinessDetail.d.ts +2 -2
  169. package/dist/sanitizeReadinessDetail.js +20 -2
  170. package/dist/server/getAssignments.js +11 -10
  171. package/dist/server/recordContentChange.d.ts +1 -1
  172. package/dist/server/recordContentChange.js +11 -2
  173. package/dist/server/resolveExperimentBlocks.js +2 -4
  174. package/dist/server/resolveExperimentData.js +2 -5
  175. package/dist/server/runResults.js +54 -15
  176. package/dist/server/startExperiment.d.ts +20 -0
  177. package/dist/server/startExperiment.js +70 -0
  178. package/dist/server/trackConversion.js +10 -13
  179. package/dist/testSurface/PreviewLinks.d.ts +2 -1
  180. package/dist/testSurface/PreviewLinks.js +3 -3
  181. package/dist/testSurface/actions/DecideDialog.d.ts +10 -4
  182. package/dist/testSurface/actions/DecideDialog.js +93 -63
  183. package/dist/testSurface/actions/LifecycleAction.d.ts +17 -0
  184. package/dist/testSurface/actions/LifecycleAction.js +107 -0
  185. package/dist/testSurface/actions/MakeContentResult.d.ts +4 -3
  186. package/dist/testSurface/actions/MakeContentResult.js +10 -2
  187. package/dist/testSurface/actions/actions.model.d.ts +13 -5
  188. package/dist/testSurface/actions/actions.model.js +75 -22
  189. package/dist/testSurface/actions/decide.model.d.ts +1 -0
  190. package/dist/testSurface/actions/decide.model.js +1 -0
  191. package/dist/testSurface/allocation.model.js +6 -3
  192. package/dist/testSurface/api.d.ts +9 -6
  193. package/dist/testSurface/api.js +43 -23
  194. package/dist/testSurface/copy/actions.d.ts +37 -14
  195. package/dist/testSurface/copy/actions.js +40 -17
  196. package/dist/testSurface/copy/advanced.d.ts +10 -0
  197. package/dist/testSurface/copy/advanced.js +10 -0
  198. package/dist/testSurface/copy/arms.d.ts +1 -1
  199. package/dist/testSurface/copy/arms.js +1 -1
  200. package/dist/testSurface/copy/audience.d.ts +4 -3
  201. package/dist/testSurface/copy/audience.js +5 -4
  202. package/dist/testSurface/copy/common.d.ts +8 -6
  203. package/dist/testSurface/copy/common.js +8 -6
  204. package/dist/testSurface/copy/languages.d.ts +1 -0
  205. package/dist/testSurface/copy/languages.js +1 -0
  206. package/dist/testSurface/copy/metrics.d.ts +7 -0
  207. package/dist/testSurface/copy/metrics.js +9 -0
  208. package/dist/testSurface/copy/pages.d.ts +67 -7
  209. package/dist/testSurface/copy/pages.js +74 -7
  210. package/dist/testSurface/copy/readiness.d.ts +20 -7
  211. package/dist/testSurface/copy/readiness.js +36 -10
  212. package/dist/testSurface/copy/recommendation.d.ts +1 -22
  213. package/dist/testSurface/copy/recommendation.js +2 -22
  214. package/dist/testSurface/copy/results.d.ts +21 -12
  215. package/dist/testSurface/copy/results.js +24 -13
  216. package/dist/testSurface/copy/review.d.ts +13 -10
  217. package/dist/testSurface/copy/review.js +14 -10
  218. package/dist/testSurface/copy/setting.d.ts +1 -2
  219. package/dist/testSurface/copy/setting.js +1 -2
  220. package/dist/testSurface/copy/surface.d.ts +11 -2
  221. package/dist/testSurface/copy/surface.js +14 -11
  222. package/dist/testSurface/copy/testPage.d.ts +36 -12
  223. package/dist/testSurface/copy/testPage.js +53 -16
  224. package/dist/testSurface/format/date.d.ts +5 -2
  225. package/dist/testSurface/format/date.js +24 -8
  226. package/dist/testSurface/format/roundProgress.d.ts +6 -0
  227. package/dist/testSurface/format/roundProgress.js +15 -0
  228. package/dist/testSurface/format/useDateFormatter.d.ts +3 -0
  229. package/dist/testSurface/format/useDateFormatter.js +8 -0
  230. package/dist/testSurface/labels.d.ts +1 -2
  231. package/dist/testSurface/labels.js +2 -3
  232. package/dist/testSurface/lockedNotice.model.d.ts +2 -0
  233. package/dist/testSurface/lockedNotice.model.js +31 -0
  234. package/dist/testSurface/readPreflight.d.ts +4 -0
  235. package/dist/testSurface/readPreflight.js +6 -0
  236. package/dist/testSurface/readinessRead.d.ts +3 -0
  237. package/dist/testSurface/readinessRead.js +4 -0
  238. package/dist/testSurface/results/CiChart.js +2 -1
  239. package/dist/testSurface/results/DataTable.d.ts +1 -1
  240. package/dist/testSurface/results/DataTable.js +4 -3
  241. package/dist/testSurface/results/VerdictHero.d.ts +3 -2
  242. package/dist/testSurface/results/VerdictHero.js +5 -1
  243. package/dist/testSurface/results/legacy.d.ts +0 -5
  244. package/dist/testSurface/results/legacy.js +0 -14
  245. package/dist/testSurface/results/results.css +2 -2
  246. package/dist/testSurface/results/results.model.d.ts +9 -4
  247. package/dist/testSurface/results/results.model.js +31 -23
  248. package/dist/testSurface/results/snapshot.d.ts +2 -0
  249. package/dist/testSurface/results/snapshot.js +3 -0
  250. package/dist/testSurface/surface/contracts.d.ts +13 -1
  251. package/dist/testSurface/surface/editorPlacement.d.ts +3 -3
  252. package/dist/testSurface/surface/editorPlacement.js +2 -2
  253. package/dist/testSurface/surface/pageBlock/pageBlock.model.js +3 -3
  254. package/dist/testSurface/surface/pageBlock/parts.js +25 -12
  255. package/dist/testSurface/surface/pagePicker/CopyRoute.d.ts +8 -1
  256. package/dist/testSurface/surface/pagePicker/CopyRoute.js +243 -22
  257. package/dist/testSurface/surface/pagePicker/PageCombobox.d.ts +15 -4
  258. package/dist/testSurface/surface/pagePicker/PageCombobox.js +300 -197
  259. package/dist/testSurface/surface/pagePicker/pagePicker.css +73 -10
  260. package/dist/testSurface/surface/pagePicker/pagePicker.model.d.ts +5 -3
  261. package/dist/testSurface/surface/pagePicker/pagePicker.model.js +17 -2
  262. package/dist/testSurface/surface/readiness/ActionDialogs.d.ts +9 -5
  263. package/dist/testSurface/surface/readiness/ActionDialogs.js +241 -230
  264. package/dist/testSurface/surface/readiness/Banner.d.ts +5 -1
  265. package/dist/testSurface/surface/readiness/Banner.js +113 -141
  266. package/dist/testSurface/surface/readiness/SaveStatus.d.ts +8 -4
  267. package/dist/testSurface/surface/readiness/SaveStatus.js +23 -22
  268. package/dist/testSurface/surface/readiness/readiness.model.d.ts +20 -6
  269. package/dist/testSurface/surface/readiness/readiness.model.js +168 -21
  270. package/dist/testSurface/surface/readiness/useTransition.d.ts +6 -4
  271. package/dist/testSurface/surface/readiness/useTransition.js +57 -14
  272. package/dist/testSurface/surface/results/ReleasePages.d.ts +6 -3
  273. package/dist/testSurface/surface/results/ReleasePages.js +42 -41
  274. package/dist/testSurface/surface/results/ResultsBody.d.ts +11 -4
  275. package/dist/testSurface/surface/results/ResultsBody.js +221 -118
  276. package/dist/testSurface/surface/results/recommendation.model.d.ts +6 -9
  277. package/dist/testSurface/surface/results/recommendation.model.js +15 -59
  278. package/dist/testSurface/surface/results/useResults.d.ts +13 -8
  279. package/dist/testSurface/surface/results/useResults.js +3 -2
  280. package/dist/testSurface/surface/setting/parts.js +89 -46
  281. package/dist/testSurface/surface/setting/setting.css +2 -1
  282. package/dist/testSurface/surface/test/AdvancedSection.js +11 -4
  283. package/dist/testSurface/surface/test/DeleteTest.d.ts +10 -2
  284. package/dist/testSurface/surface/test/DeleteTest.js +173 -74
  285. package/dist/testSurface/surface/test/GoalSection.js +18 -14
  286. package/dist/testSurface/surface/test/LengthSection.js +24 -13
  287. package/dist/testSurface/surface/test/PageHoldout.d.ts +1 -1
  288. package/dist/testSurface/surface/test/PageHoldout.js +11 -8
  289. package/dist/testSurface/surface/test/ReadinessBar.d.ts +2 -1
  290. package/dist/testSurface/surface/test/ReadinessBar.js +4 -10
  291. package/dist/testSurface/surface/test/Section.js +8 -0
  292. package/dist/testSurface/surface/test/TargetingSection.js +82 -12
  293. package/dist/testSurface/surface/test/TestSurface.js +73 -37
  294. package/dist/testSurface/surface/test/VersionsSection.js +141 -91
  295. package/dist/testSurface/surface/test/fields.d.ts +32 -6
  296. package/dist/testSurface/surface/test/fields.js +166 -52
  297. package/dist/testSurface/surface/test/pageParts.js +27 -12
  298. package/dist/testSurface/surface/test/testPage.css +9 -2
  299. package/dist/testSurface/surface/test/testPage.model.d.ts +1 -0
  300. package/dist/testSurface/surface/test/testPage.model.js +6 -0
  301. package/dist/testSurface/surface/testDocument.model.d.ts +3 -0
  302. package/dist/testSurface/surface/testDocument.model.js +4 -1
  303. package/dist/testSurface/surface/useTestDocument.d.ts +21 -5
  304. package/dist/testSurface/surface/useTestDocument.js +472 -167
  305. package/dist/testSurface/surface/watchTestDocument.d.ts +15 -0
  306. package/dist/testSurface/surface/watchTestDocument.js +181 -0
  307. package/dist/testSurface/surfaceUrls.d.ts +1 -0
  308. package/dist/testSurface/surfaceUrls.js +4 -0
  309. package/dist/testSurface/useApi.d.ts +8 -5
  310. package/dist/testSurface/useOnTestReturn.d.ts +2 -0
  311. package/dist/testSurface/useOnTestReturn.js +27 -0
  312. package/dist/testSurface/useReadinessPolling.js +3 -1
  313. package/dist/transitions/addMetric.d.ts +2 -5
  314. package/dist/transitions/addMetric.js +5 -1
  315. package/dist/transitions/allocate.d.ts +2 -2
  316. package/dist/transitions/allocate.js +3 -1
  317. package/dist/transitions/archive.d.ts +1 -1
  318. package/dist/transitions/archive.js +3 -2
  319. package/dist/transitions/checkStart.d.ts +1 -0
  320. package/dist/transitions/checkStart.js +17 -6
  321. package/dist/transitions/decide.d.ts +1 -1
  322. package/dist/transitions/decide.js +5 -3
  323. package/dist/transitions/deleteExperiment.d.ts +2 -2
  324. package/dist/transitions/deleteExperiment.js +17 -7
  325. package/dist/transitions/kernel.d.ts +4 -0
  326. package/dist/transitions/kernel.js +9 -4
  327. package/dist/transitions/makeContent.d.ts +2 -1
  328. package/dist/transitions/makeContent.js +12 -8
  329. package/dist/transitions/nestedPlacementNames.d.ts +2 -2
  330. package/dist/transitions/nestedPlacementNames.js +4 -5
  331. package/dist/transitions/pageAddress.d.ts +6 -0
  332. package/dist/transitions/pageAddress.js +71 -0
  333. package/dist/transitions/pageVersions.d.ts +1 -1
  334. package/dist/transitions/phaseRecord.d.ts +2 -0
  335. package/dist/transitions/phaseRecord.js +5 -0
  336. package/dist/transitions/placementInteractions.d.ts +3 -3
  337. package/dist/transitions/placementInteractions.js +8 -7
  338. package/dist/transitions/placements.d.ts +2 -0
  339. package/dist/transitions/placements.js +5 -5
  340. package/dist/transitions/preflightData.d.ts +3 -2
  341. package/dist/transitions/preflightData.js +77 -43
  342. package/dist/transitions/releaseHoldout.d.ts +2 -1
  343. package/dist/transitions/releaseHoldout.js +3 -1
  344. package/dist/transitions/releasePages.d.ts +2 -1
  345. package/dist/transitions/releasePages.js +3 -1
  346. package/dist/transitions/resolveCaps.d.ts +2 -4
  347. package/dist/transitions/start.d.ts +7 -9
  348. package/dist/transitions/start.js +75 -39
  349. package/dist/transitions/startReads.d.ts +7 -0
  350. package/dist/transitions/startReads.js +28 -0
  351. package/dist/transitions/stop.d.ts +2 -1
  352. package/dist/transitions/stop.js +3 -2
  353. package/dist/types/armKey.d.ts +2 -0
  354. package/dist/types/armKey.js +1 -0
  355. package/dist/types/contracts.d.ts +17 -4
  356. package/dist/types/endpoints.d.ts +89 -17
  357. package/dist/types/endpoints.js +1 -1
  358. package/dist/types/runtime.d.ts +15 -9
  359. package/dist/types/snapshot.d.ts +2 -0
  360. package/dist/types/surface.d.ts +7 -9
  361. package/dist/ui/ChipsInput.d.ts +8 -1
  362. package/dist/ui/ChipsInput.js +17 -4
  363. package/dist/ui/Dialog.d.ts +21 -2
  364. package/dist/ui/Dialog.js +101 -4
  365. package/dist/ui/Inputs.js +0 -1
  366. package/dist/ui/ui.css +5 -1
  367. package/package.json +2 -2
@@ -1,7 +1,9 @@
1
1
  'use client';
2
2
  import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
3
- import { useEffect, useId, useState } from 'react';
3
+ import { useId, useLayoutEffect, useState } from 'react';
4
4
  import { TextInput, NumberInput, Textarea, Select, CheckboxList as UICheckboxList } from '../../../ui/Inputs.js';
5
+ import { Button } from '../../../ui/Button.js';
6
+ import { Banner } from '../../../ui/Feedback.js';
5
7
  import { TEST_PAGE as C } from '../../copy/testPage.js';
6
8
  import { EDITABLE_BY_STATUS } from '../../../collections/experiments/editability.js';
7
9
  import { lockedReason } from '../../lockedNotice.model.js';
@@ -9,9 +11,9 @@ export function reasonFor(test, field) {
9
11
  return test.doc ? lockedReason(test.doc.status, field, EDITABLE_BY_STATUS) : null;
10
12
  }
11
13
  export function save(test, field, patch) {
12
- if (!test.doc || reasonFor(test, field)) return;
13
- test.stage(patch());
14
+ if (!test.doc || reasonFor(test, field) || !test.stage(patch())) return false;
14
15
  void test.commit();
16
+ return true;
15
17
  }
16
18
  export function FieldErrors({ test, path }) {
17
19
  return /*#__PURE__*/ _jsx(_Fragment, {
@@ -22,12 +24,11 @@ export function FieldErrors({ test, path }) {
22
24
  }, key))
23
25
  });
24
26
  }
25
- export function ReadOnly({ label, value, reason, labelAction }) {
27
+ export function ReadOnly({ label, value, labelAction, hideLabel }) {
26
28
  return /*#__PURE__*/ _jsxs("div", {
27
29
  className: "xp-read-only",
28
- title: reason ?? undefined,
29
30
  children: [
30
- /*#__PURE__*/ _jsxs("div", {
31
+ !hideLabel ? /*#__PURE__*/ _jsxs("div", {
31
32
  className: "xp-ui-field-label",
32
33
  children: [
33
34
  /*#__PURE__*/ _jsx("strong", {
@@ -35,65 +36,178 @@ export function ReadOnly({ label, value, reason, labelAction }) {
35
36
  }),
36
37
  labelAction
37
38
  ]
38
- }),
39
+ }) : null,
39
40
  /*#__PURE__*/ _jsx("p", {
40
41
  children: value
41
- }),
42
- reason ? /*#__PURE__*/ _jsx("small", {
43
- children: reason
44
- }) : null
42
+ })
45
43
  ]
46
44
  });
47
45
  }
48
- /** Local typing is intentionally separate from staging: build the current group on commit. */ export function TextEdit({ label, value, onCommit, reason, multiline, placeholder, type = 'text', min, max, required, onDraft, isValid, invalidMessage, hideLabel = false, disabled = false, help }) {
46
+ export function useFieldDraft(test, key, label, saved, scope) {
47
+ const { mountDraft, submitDraft, trackDraft } = test;
48
+ const [localEdit, setLocalEdit] = useState(null);
49
+ const edit = mountDraft ? test.fieldDrafts?.[key] : localEdit;
50
+ const conflict = Boolean(edit && !edit.saving && (edit.scope !== scope || edit.base !== saved && edit.value !== saved));
51
+ useLayoutEffect(()=>mountDraft?.(key), [
52
+ key,
53
+ mountDraft
54
+ ]);
55
+ const update = (draft)=>mountDraft ? trackDraft(key, draft) : setLocalEdit(draft);
56
+ return {
57
+ value: edit?.value ?? saved,
58
+ dirty: Boolean(edit),
59
+ saving: Boolean(edit?.saving),
60
+ retry: Boolean(edit?.retry),
61
+ conflict,
62
+ change (value) {
63
+ update(value === saved && !conflict ? null : {
64
+ label,
65
+ base: edit?.base ?? saved,
66
+ scope: edit ? edit.scope : scope,
67
+ value
68
+ });
69
+ },
70
+ submit (save) {
71
+ if (submitDraft) submitDraft(key, save);
72
+ else if (save() !== false) update(null);
73
+ },
74
+ discard () {
75
+ update(null);
76
+ }
77
+ };
78
+ }
79
+ export function SavedValueChanged({ id, value, reason, showReason = true, conflict, announce, onKeep, onDiscard }) {
80
+ return /*#__PURE__*/ _jsx("div", {
81
+ id: id,
82
+ className: "xp-field-draft-notice",
83
+ children: /*#__PURE__*/ _jsx(Banner, {
84
+ tone: "error",
85
+ action: /*#__PURE__*/ _jsxs("div", {
86
+ className: "xp-ui-button-group",
87
+ children: [
88
+ onKeep ? /*#__PURE__*/ _jsx(Button, {
89
+ size: "sm",
90
+ onClick: onKeep,
91
+ children: conflict ? C.keepEdit : C.retryEdit
92
+ }) : null,
93
+ /*#__PURE__*/ _jsx(Button, {
94
+ size: "sm",
95
+ variant: "quiet",
96
+ onClick: onDiscard,
97
+ children: C.useSavedValue
98
+ })
99
+ ]
100
+ }),
101
+ children: /*#__PURE__*/ _jsxs("span", {
102
+ children: [
103
+ reason ? showReason ? reason : null : conflict ? C.savedValueChanged : null,
104
+ ' ',
105
+ onKeep && conflict ? C.conflictChoice : C.draftNotSaved,
106
+ ' ',
107
+ C.savedValue,
108
+ " ",
109
+ /*#__PURE__*/ _jsx("strong", {
110
+ children: value || C.emptyValue
111
+ })
112
+ ]
113
+ }, announce)
114
+ })
115
+ });
116
+ }
117
+ /** Announce the existing choices again when blur or Enter cannot commit. */ export function useDraftAnnouncement() {
118
+ const [announcement, setAnnouncement] = useState(0);
119
+ return [
120
+ announcement,
121
+ ()=>setAnnouncement((count)=>count + 1)
122
+ ];
123
+ }
124
+ /** Local typing is intentionally separate from staging: build the current group on commit. */ export function TextEdit({ test, label, draftKey = label, value, preview, onCommit, reason, multiline, placeholder, type = 'text', min, max, required, onDraft, scope, isValid, invalidMessage, hideLabel = false, disabled = false, help }) {
49
125
  const id = useId();
50
- const [draft, setDraft] = useState(String(value));
126
+ const edit = useFieldDraft(test, draftKey, label, String(value), scope);
127
+ const [announcement, announce] = useDraftAnnouncement();
51
128
  const [error, setError] = useState(null);
52
- useEffect(()=>setDraft(String(value)), [
53
- value
54
- ]);
55
- const commit = ()=>{
56
- if (draft === String(value)) return;
57
- // Named isValid, not validate: Payload 4's Local API has a validate method, which the access gate flags.
129
+ if (error && !edit.dirty) setError(null);
130
+ const discard = ()=>{
131
+ edit.discard();
132
+ onDraft?.(null);
133
+ setError(null);
134
+ };
135
+ const locked = Boolean(reason || disabled);
136
+ const choice = edit.dirty && !edit.saving && (edit.conflict || edit.retry || locked || Boolean(error));
137
+ const choiceId = choice ? `${id}-new-value` : undefined;
138
+ const commit = (confirmed = false)=>{
139
+ if (!edit.dirty || edit.saving) return;
140
+ if (locked || test.stale || choice && !confirmed) {
141
+ announce();
142
+ return;
143
+ }
144
+ const draft = edit.value;
145
+ if (draft === String(value)) {
146
+ discard();
147
+ return;
148
+ }
58
149
  if (isValid && !isValid(draft)) {
59
- setError(draft.trim() ? invalidMessage ?? null : null);
60
- setDraft(String(value));
61
- onDraft?.(String(value));
150
+ onDraft?.(null);
151
+ setError(invalidMessage ?? C.editInvalid);
62
152
  return;
63
153
  }
64
- onCommit(draft);
154
+ edit.submit(()=>onCommit(draft));
155
+ onDraft?.(null);
65
156
  };
66
- if (reason && !disabled) return /*#__PURE__*/ _jsx(ReadOnly, {
157
+ if (reason && !edit.dirty) return /*#__PURE__*/ _jsx(ReadOnly, {
67
158
  label: label,
68
- value: value === '' && placeholder ? placeholder : value,
69
- reason: reason
159
+ hideLabel: hideLabel,
160
+ value: value === '' && placeholder ? placeholder : value
70
161
  });
71
162
  const Input = multiline ? Textarea : type === 'number' ? NumberInput : TextInput;
72
- return /*#__PURE__*/ _jsx("div", {
163
+ return /*#__PURE__*/ _jsxs("div", {
73
164
  className: hideLabel ? 'xp-grid-field' : undefined,
74
- title: reason ?? undefined,
75
- children: /*#__PURE__*/ _jsx(Input, {
76
- id: id,
77
- label: label,
78
- "aria-label": label,
79
- value: draft,
80
- disabled: disabled,
81
- placeholder: placeholder,
82
- min: min,
83
- max: max,
84
- required: required,
85
- help: help,
86
- error: error ?? undefined,
87
- onChange: (e)=>{
88
- setError(null);
89
- setDraft(e.target.value);
90
- onDraft?.(e.target.value);
91
- },
92
- onBlur: commit,
93
- onKeyDown: (e)=>{
94
- if (!multiline && e.key === 'Enter') e.currentTarget.blur();
95
- }
96
- })
165
+ children: [
166
+ /*#__PURE__*/ _jsx(Input, {
167
+ id: id,
168
+ label: label,
169
+ "aria-label": label,
170
+ value: edit.dirty ? edit.value : preview ?? edit.value,
171
+ disabled: disabled && !edit.dirty,
172
+ readOnly: locked || test.stale || edit.saving,
173
+ "aria-describedby": choiceId,
174
+ placeholder: placeholder,
175
+ min: min,
176
+ max: max,
177
+ required: required,
178
+ help: help,
179
+ error: error ?? undefined,
180
+ onChange: (e)=>{
181
+ if (locked || test.stale || edit.saving) return;
182
+ const draft = e.target.value;
183
+ setError(null);
184
+ edit.change(draft);
185
+ onDraft?.(draft === String(value) || edit.conflict ? null : draft);
186
+ },
187
+ onBlur: ()=>commit(),
188
+ onKeyDown: (e)=>{
189
+ if (e.key === 'Escape' && edit.dirty && !edit.saving) {
190
+ e.preventDefault();
191
+ e.stopPropagation();
192
+ discard();
193
+ }
194
+ if (e.key === 'Enter' && !e.nativeEvent.isComposing && (choice || !multiline)) {
195
+ e.preventDefault();
196
+ commit();
197
+ }
198
+ }
199
+ }),
200
+ choiceId ? /*#__PURE__*/ _jsx(SavedValueChanged, {
201
+ id: choiceId,
202
+ value: String(value),
203
+ reason: reason,
204
+ showReason: false,
205
+ conflict: edit.conflict,
206
+ announce: announcement,
207
+ onKeep: !locked && !test.stale && !error ? ()=>commit(true) : undefined,
208
+ onDiscard: discard
209
+ }) : null
210
+ ]
97
211
  });
98
212
  }
99
213
  export const positiveInteger = (raw)=>raw.trim() !== '' && Number.isInteger(Number(raw)) && Number(raw) > 0;
@@ -102,7 +216,6 @@ export function SelectEdit({ label, value, options, groups, reason, onCommit, re
102
216
  if (reason) {
103
217
  return /*#__PURE__*/ _jsx(ReadOnly, {
104
218
  label: label,
105
- reason: reason,
106
219
  labelAction: labelAction,
107
220
  value: readOnlyValue ?? options.find((o)=>o.value === value)?.label ?? value
108
221
  });
@@ -132,7 +245,6 @@ export function CheckboxList({ label, value, options, reason, onToggle, readOnly
132
245
  const id = useId();
133
246
  if (reason) return /*#__PURE__*/ _jsx(ReadOnly, {
134
247
  label: label,
135
- reason: reason,
136
248
  value: readOnlyValue ?? value.map((v)=>options.find((o)=>o.value === v)?.label ?? v).join(', ')
137
249
  });
138
250
  return /*#__PURE__*/ _jsx(UICheckboxList, {
@@ -150,6 +262,7 @@ export function TestName({ test }) {
150
262
  return /*#__PURE__*/ _jsxs(_Fragment, {
151
263
  children: [
152
264
  /*#__PURE__*/ _jsx(TextEdit, {
265
+ test: test,
153
266
  label: C.name,
154
267
  value: test.doc?.name ?? '',
155
268
  reason: reasonFor(test, 'name'),
@@ -168,6 +281,7 @@ export function Hypothesis({ test }) {
168
281
  return /*#__PURE__*/ _jsxs(_Fragment, {
169
282
  children: [
170
283
  /*#__PURE__*/ _jsx(TextEdit, {
284
+ test: test,
171
285
  label: C.hypothesis,
172
286
  value: test.doc?.hypothesis ?? '',
173
287
  multiline: true,
@@ -1,5 +1,8 @@
1
1
  'use client';
2
2
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
3
+ import { useState } from 'react';
4
+ import { holdoutContent } from '../../copy/audience.js';
5
+ import { actionGroupLabel } from '../../actions/actions.model.js';
3
6
  import { TEST_PAGE as C } from '../../copy/testPage.js';
4
7
  import { pageTargetIssue, setPageTarget, showsPageTarget } from '../../arms/pageTarget.model.js';
5
8
  import { normalisePath } from '../../../runtime/normalisePath.js';
@@ -9,28 +12,35 @@ import { testPageCollection } from '../pagePicker/pagePicker.model.js';
9
12
  import { PAGE_COPY as P } from '../../copy/pages.js';
10
13
  import { FieldErrors, reasonFor, save, TextEdit } from './fields.js';
11
14
  export function VersionContent({ test, surface, armIndex }) {
12
- const arm = test.doc?.arms[armIndex];
13
- if (!arm || !test.doc) return null;
14
- if (!showsPageTarget(test.doc.kind, arm.kind)) return /*#__PURE__*/ _jsx("span", {
15
+ const doc = test.doc;
16
+ const arm = doc?.arms[armIndex];
17
+ const collection = doc && testPageCollection(surface.pageCollections, doc, test.preflight?.pagePlacements);
18
+ const usesAddress = !collection;
19
+ const [wasUsingAddress, setWasUsingAddress] = useState(usesAddress);
20
+ // Readiness can discover a page collection while someone is typing an address.
21
+ const addressKey = `page-address:${arm?.key}`;
22
+ if (!test.fieldDrafts?.[addressKey] && wasUsingAddress !== usesAddress) setWasUsingAddress(usesAddress);
23
+ if (!arm || !doc) return null;
24
+ if (!showsPageTarget(doc.kind, arm.kind)) return /*#__PURE__*/ _jsx("span", {
15
25
  className: "xp-content-chip",
16
- children: C.holdoutContent
26
+ children: holdoutContent(actionGroupLabel('control', test.doc?.arms.find((arm)=>arm.key === 'control')?.label))
17
27
  });
18
- const collection = testPageCollection(surface.pageCollections, test.doc, test.preflight?.pagePlacements);
19
28
  const placement = test.preflight?.pagePlacements?.find((entry)=>entry.arm === arm.key && entry.collection === collection?.slug && entry.id != null && arm.pageTarget && normalisePath(entry.path) === normalisePath(arm.pageTarget));
20
- if (collection) {
29
+ if (collection && !wasUsingAddress) {
21
30
  const picker = /*#__PURE__*/ _jsx(PageCombobox, {
22
31
  collection: collection,
23
32
  test: test,
24
33
  armKey: arm.key,
25
- apiRoute: surface.apiRoute
26
- });
34
+ apiRoute: surface.apiRoute,
35
+ contentLocale: surface.contentLocale
36
+ }, `${collection.slug}-${arm.key}`);
27
37
  return /*#__PURE__*/ _jsxs("div", {
28
38
  className: "xp-version-content xp-version-content--page",
29
39
  children: [
30
40
  /*#__PURE__*/ _jsx("strong", {
31
41
  children: P.where
32
42
  }),
33
- placement?.id != null ? /*#__PURE__*/ _jsxs("div", {
43
+ placement?.id != null && (arm.kind !== 'variant' || placement.published || doc.status !== 'draft' && doc.status !== 'stopped') ? /*#__PURE__*/ _jsxs("div", {
34
44
  children: [
35
45
  placement.editorUrl ? /*#__PURE__*/ _jsx("a", {
36
46
  href: placement.editorUrl,
@@ -48,9 +58,12 @@ export function VersionContent({ test, surface, armIndex }) {
48
58
  ]
49
59
  }) : null,
50
60
  arm.kind === 'variant' ? /*#__PURE__*/ _jsx(CopyRoute, {
51
- collection: collection
52
- }) : null,
53
- picker,
61
+ collection: collection,
62
+ arm: arm,
63
+ test: test,
64
+ surface: surface,
65
+ children: picker
66
+ }, `${collection.slug}/${arm.key}`) : picker,
54
67
  /*#__PURE__*/ _jsx(FieldErrors, {
55
68
  test: test,
56
69
  path: `arms.${armIndex}.pageTarget`
@@ -67,6 +80,8 @@ export function VersionContent({ test, surface, armIndex }) {
67
80
  children: issue ? C.addPageAddress : C.pageReady
68
81
  }),
69
82
  /*#__PURE__*/ _jsx(TextEdit, {
83
+ test: test,
84
+ draftKey: addressKey,
70
85
  label: `${arm.label}: ${C.pageAddress}`,
71
86
  value: arm.pageTarget ?? '',
72
87
  reason: reasonFor(test, 'arms'),
@@ -32,7 +32,11 @@
32
32
  :where(.xp-test-surface) .xp-ui-checkbox-list { display: flex; flex-wrap: wrap; gap: var(--xp-space-2) var(--xp-space-4); }
33
33
  :where(.xp-test-surface) .xp-duration-suggestion { align-items: center; margin-top: var(--xp-space-4); }
34
34
  :where(.xp-test-surface) .xp-read-only { padding-block: .5rem; }
35
- :where(.xp-test-surface) .xp-read-only p { margin-block: .5rem; }
35
+ :where(.xp-test-surface) .xp-read-only p { margin-block: .5rem; color: var(--xp-text); font: var(--xp-text-body); }
36
+ :where(.xp-test-surface) .xp-section-lock { margin-block: 0; }
37
+ :where(.xp-test-surface) .xp-page-binding-row { align-items: center; }
38
+ :where(.xp-test-surface) .xp-page-binding { margin-block-end: var(--xp-space-4); }
39
+ :where(.xp-test-surface) .xp-page-binding > .xp-ui-help { margin-block: var(--xp-space-2) 0; }
36
40
  :where(.xp-test-surface) .xp-field-error { color: var(--xp-error-text); }
37
41
 
38
42
  :where(.xp-test-surface) .xp-targeting-row { display: grid; grid-template-columns: var(--xp-targeting-attribute-width) var(--xp-targeting-comparison-width) minmax(0, 1fr); align-items: start; gap: var(--xp-space-3); border: 1px solid var(--xp-border); border-radius: var(--xp-radius-control); padding: var(--xp-space-4); margin-bottom: var(--xp-space-4); }
@@ -46,6 +50,10 @@
46
50
  :where(.xp-test-surface) .xp-targeting-row, :where(.xp-test-surface) .xp-field-grid { grid-template-columns: 1fr; }
47
51
  }
48
52
 
53
+ :where(.xp-test-surface) .xp-version-rows.xp-version-rows--setting { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); align-items: start; }
54
+ :where(.xp-test-surface) .xp-version-rows--setting .xp-version-row { align-items: start; }
55
+ :where(.xp-test-surface) .xp-version-rows--setting .xp-setting-values { grid-column: 2; min-width: 0; }
56
+
49
57
  :where(.xp-test-surface) .xp-test-layout { display: grid; grid-template-columns: 220px minmax(0, 1fr); align-items: start; gap: var(--xp-space-8); }
50
58
  :where(.xp-test-surface) .xp-test-content { display: grid; gap: var(--xp-space-8); min-width: 0; max-width: 760px; }
51
59
  :where(.xp-test-surface) .xp-test-rail { position: sticky; top: var(--xp-space-6); min-width: 0; }
@@ -98,7 +106,6 @@
98
106
 
99
107
  :where(.xp-test-surface) .xp-readiness--bar { grid-template-columns: minmax(0, 1fr); }
100
108
  :where(.xp-test-surface) .xp-readiness--bar > .xp-readiness__actions { grid-column: 1; grid-row: auto; justify-content: flex-start; }
101
- :where(.xp-test-surface) .xp-readiness-action-reason { display: block; }
102
109
 
103
110
  :where(.xp-test-surface) .xp-test-advanced.xp-ui-section--blocked { border-color: var(--xp-error-border); }
104
111
  :where(.xp-test-surface) .xp-test-rail-mark--blocked { display: grid; place-items: center; width: 20px; height: 20px; border: 1px solid var(--xp-error-border); border-radius: 50%; }
@@ -4,6 +4,7 @@ export declare function orderedVersions(arms: readonly Arm[]): Array<{
4
4
  arm: Arm;
5
5
  index: number;
6
6
  }>;
7
+ export declare function trafficSplit(arms: readonly Arm[]): string;
7
8
  /** Normalised visual shares only; invalid saved weights still surface as validation issues. */
8
9
  export declare function trafficShares(arms: readonly Arm[]): number[];
9
10
  export declare function durationSuggestion(preflight: PreflightResult | null, savedDays?: number | null): {
@@ -11,6 +11,12 @@ export function orderedVersions(arms) {
11
11
  index
12
12
  })).sort((a, b)=>ORDER.indexOf(a.arm.key) - ORDER.indexOf(b.arm.key));
13
13
  }
14
+ export function trafficSplit(arms) {
15
+ return JSON.stringify(arms.map((arm)=>[
16
+ arm.key,
17
+ arm.weight
18
+ ]));
19
+ }
14
20
  /** Normalised visual shares only; invalid saved weights still surface as validation issues. */ export function trafficShares(arms) {
15
21
  const weights = arms.map((arm)=>Number.isFinite(arm.weight) ? Math.max(0, arm.weight) : 0);
16
22
  const sum = weights.reduce((a, b)=>a + b, 0);
@@ -8,6 +8,8 @@ export interface TestDocument {
8
8
  status: Status;
9
9
  kind: ExperimentKind;
10
10
  unitType: UnitType;
11
+ phase?: number;
12
+ updatedAt?: string;
11
13
  hypothesis?: string | null;
12
14
  arms: Arm[];
13
15
  targeting?: TargetingRule[] | null;
@@ -34,6 +36,7 @@ export interface TestDocument {
34
36
  export type TestDocumentPatch = Partial<Pick<TestDocument, EditableField>>;
35
37
  /** Drop unknown and locked keys even when the caller is untyped. Groups replace whole groups. */
36
38
  export declare function editablePatch(status: Status, partial: TestDocumentPatch): TestDocumentPatch;
39
+ export declare function sameTestValue(left: unknown, right: unknown): boolean;
37
40
  /** Only changed top-level keys go on the wire; arrays and groups remain intact. */
38
41
  export declare function changedPatch(saved: TestDocument, staged: TestDocumentPatch): TestDocumentPatch;
39
42
  /** Payload validation details may be nested under errors[0].data or top-level data. */
@@ -28,8 +28,11 @@ function canonical(value) {
28
28
  ]));
29
29
  return value;
30
30
  }
31
+ export function sameTestValue(left, right) {
32
+ return left === right || JSON.stringify(canonical(left)) === JSON.stringify(canonical(right));
33
+ }
31
34
  /** Only changed top-level keys go on the wire; arrays and groups remain intact. */ export function changedPatch(saved, staged) {
32
- return Object.fromEntries(Object.entries(editablePatch(saved.status, staged)).filter(([key, value])=>JSON.stringify(canonical(saved[key])) !== JSON.stringify(canonical(value))));
35
+ return Object.fromEntries(Object.entries(editablePatch(saved.status, staged)).filter(([key, value])=>!sameTestValue(saved[key], value)));
33
36
  }
34
37
  const object = (value)=>value !== null && typeof value === 'object' && !Array.isArray(value) ? value : undefined;
35
38
  /** Payload validation details may be nested under errors[0].data or top-level data. */ export function payloadFieldErrors(envelope, section = '_section', fallback = "Couldn't save these changes. Try again.") {
@@ -2,19 +2,29 @@ import type { Arm, DocId } from '../../types/contracts.js';
2
2
  import type { PreflightResult } from '../../types/endpoints.js';
3
3
  import { type ReadinessRead } from '../readinessRead.js';
4
4
  import type { TestDocument, TestDocumentPatch } from './testDocument.model.js';
5
+ export type FieldDraft = {
6
+ label: string;
7
+ base: string;
8
+ scope?: string;
9
+ value: string;
10
+ saving?: boolean;
11
+ retry?: boolean;
12
+ };
5
13
  /** Section data only: staging never saves. Call commit on blur or a section action. */
6
- export declare function useTestDocument(id: DocId, { apiRoute, contentLocale, refetchPreflightOnFocus, enabled, onDocument, onPreflight, requestPreflight }: {
14
+ export declare function useTestDocument(id: DocId, { apiRoute, contentLocale, enabled, onDocument, onPreflight, requestPreflight }: {
7
15
  apiRoute: string;
8
16
  contentLocale?: string;
9
- refetchPreflightOnFocus?: boolean;
10
17
  enabled?: boolean;
11
18
  onDocument?: (doc: TestDocument) => void;
12
19
  onPreflight?: (preflight: PreflightResult) => void;
13
20
  requestPreflight?: (signal: AbortSignal, supersede?: boolean) => Promise<Response>;
14
21
  }): {
15
- stage: (partial: TestDocumentPatch) => void;
22
+ syncDocument: (read: ReadinessRead | undefined) => void;
23
+ stage: (partial: TestDocumentPatch) => boolean;
16
24
  commit: () => Promise<void>;
17
- reload: () => Promise<void>;
25
+ reload: ({ discardDrafts }?: {
26
+ discardDrafts?: boolean | undefined;
27
+ }) => Promise<void>;
18
28
  refreshPreflight: (supersede?: boolean) => Promise<void>;
19
29
  choosePage: (arm: Arm["key"], page: {
20
30
  id: DocId;
@@ -22,6 +32,9 @@ export declare function useTestDocument(id: DocId, { apiRoute, contentLocale, re
22
32
  title?: string;
23
33
  published?: boolean;
24
34
  }) => Promise<void>;
35
+ trackDraft: (id: string, draft: FieldDraft | null) => void;
36
+ mountDraft: (id: string) => (() => void) | undefined;
37
+ submitDraft: (id: string, submit: () => void) => void;
25
38
  chosenPages: Partial<Record<Arm["key"], {
26
39
  id: DocId;
27
40
  path: string;
@@ -33,8 +46,11 @@ export declare function useTestDocument(id: DocId, { apiRoute, contentLocale, re
33
46
  preflightRead?: ReadinessRead;
34
47
  preflightError: string | null;
35
48
  preflightPending: boolean;
36
- /** Includes staged edits and all queued or in-flight PATCHes. */
49
+ /** Includes field drafts, staged edits and all queued or in-flight PATCHes. */
37
50
  hasUnsaved: boolean;
51
+ fieldDrafts?: Readonly<Record<string, FieldDraft>>;
52
+ detachedDrafts?: string[];
53
+ statusReadPending?: boolean;
38
54
  loadState: "loading" | "ready" | "forbidden" | "missing" | "error";
39
55
  saving: "idle" | "saving" | "saved" | "error";
40
56
  stale: boolean;