@delmaredigital/payload-experiments 0.4.0-rc.6 → 0.4.0-rc.9

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/README.md +12 -12
  2. package/dist/admin/blocks/BlockPanel.js +6 -4
  3. package/dist/admin/blocks/inject.js +1 -0
  4. package/dist/admin/blocks/model.d.ts +3 -2
  5. package/dist/admin/blocks/model.js +9 -5
  6. package/dist/admin/copy/blocks.d.ts +3 -2
  7. package/dist/admin/copy/blocks.js +8 -7
  8. package/dist/admin/surface/ResultsRoute.js +18 -11
  9. package/dist/admin/surface/TestsHome.d.ts +2 -1
  10. package/dist/admin/surface/TestsHome.js +131 -44
  11. package/dist/admin/surface/TestsSurface.js +3 -0
  12. package/dist/admin/surface/home.model.d.ts +2 -0
  13. package/dist/admin/surface/newTest/PageWizard.js +9 -2
  14. package/dist/admin/surface/newTest/newTest.css +1 -1
  15. package/dist/admin/surface/results/ResultsHeader.js +11 -6
  16. package/dist/admin/surface/test/TestPage.js +3 -3
  17. package/dist/admin/views/TestsSurfaceClient.d.ts +3 -0
  18. package/dist/admin/views/TestsSurfaceClient.js +11 -0
  19. package/dist/admin/views/buildSurfaceProps.js +10 -3
  20. package/dist/blocks/bindings.js +3 -2
  21. package/dist/blocks/formState.js +1 -1
  22. package/dist/blocks/placementLanguages.d.ts +7 -0
  23. package/dist/blocks/placementLanguages.js +27 -0
  24. package/dist/blocks/placementLocale.d.ts +21 -7
  25. package/dist/blocks/placementLocale.js +218 -67
  26. package/dist/collections/experiments/config.js +8 -3
  27. package/dist/collections/experiments/deleteGuard.js +2 -2
  28. package/dist/collections/experiments/lockHook.js +21 -2
  29. package/dist/collections/experiments/pickSlug.js +2 -0
  30. package/dist/collections/metricsGuards.js +2 -0
  31. package/dist/collections/serialize.js +5 -4
  32. package/dist/constants.d.ts +1 -0
  33. package/dist/constants.js +1 -0
  34. package/dist/db/adapter.d.ts +9 -1
  35. package/dist/db/adapter.js +77 -1
  36. package/dist/db/appends.d.ts +13 -0
  37. package/dist/db/appends.js +49 -0
  38. package/dist/db/bulkPlacementRemoval.js +8 -4
  39. package/dist/db/delete.d.ts +1 -1
  40. package/dist/db/delete.js +2 -4
  41. package/dist/db/events.d.ts +9 -0
  42. package/dist/db/events.js +42 -8
  43. package/dist/db/executor.d.ts +7 -1
  44. package/dist/db/executor.js +7 -3
  45. package/dist/db/results.d.ts +5 -1
  46. package/dist/db/results.js +21 -5
  47. package/dist/db/snapshots.d.ts +1 -0
  48. package/dist/endpoints/contentLocale.d.ts +6 -0
  49. package/dist/endpoints/contentLocale.js +15 -0
  50. package/dist/endpoints/deleteImpact.d.ts +6 -0
  51. package/dist/endpoints/deleteImpact.js +207 -0
  52. package/dist/endpoints/events.js +103 -39
  53. package/dist/endpoints/index.js +9 -8
  54. package/dist/endpoints/pages.js +7 -3
  55. package/dist/endpoints/placementStatus.js +13 -5
  56. package/dist/endpoints/preflight.d.ts +1 -1
  57. package/dist/endpoints/preflight.js +17 -2
  58. package/dist/endpoints/results.d.ts +1 -1
  59. package/dist/endpoints/results.js +6 -2
  60. package/dist/endpoints/routeId.d.ts +2 -2
  61. package/dist/endpoints/routeId.js +11 -5
  62. package/dist/endpoints/summary.js +46 -12
  63. package/dist/endpoints/transitions.js +37 -24
  64. package/dist/errors.d.ts +4 -0
  65. package/dist/errors.js +6 -0
  66. package/dist/events/request.d.ts +6 -2
  67. package/dist/events/request.js +35 -8
  68. package/dist/events/rows.d.ts +1 -1
  69. package/dist/events/rows.js +24 -8
  70. package/dist/events/writable.d.ts +9 -0
  71. package/dist/events/writable.js +13 -0
  72. package/dist/exports/adminClient.d.ts +1 -1
  73. package/dist/exports/adminClient.js +1 -1
  74. package/dist/exports/index.d.ts +1 -1
  75. package/dist/exports/rsc.d.ts +1 -0
  76. package/dist/exports/rsc.js +1 -0
  77. package/dist/goals/fairness.js +38 -31
  78. package/dist/hooks/blockRemovalRule.d.ts +2 -2
  79. package/dist/hooks/blockRemovalRule.js +16 -14
  80. package/dist/hooks/hostHook.js +6 -2
  81. package/dist/hooks/pageGuard.d.ts +3 -0
  82. package/dist/hooks/pageGuard.js +37 -23
  83. package/dist/hooks/puckNestedTests.d.ts +8 -0
  84. package/dist/hooks/puckNestedTests.js +36 -0
  85. package/dist/lib/fetchAllDocs.d.ts +1 -1
  86. package/dist/lib/placementPages.d.ts +2 -1
  87. package/dist/lib/placementPages.js +10 -2
  88. package/dist/manifest/compile.d.ts +2 -1
  89. package/dist/manifest/compile.js +13 -6
  90. package/dist/onInit.js +14 -0
  91. package/dist/options.js +5 -0
  92. package/dist/proxy/pageNavigation.d.ts +4 -0
  93. package/dist/proxy/pageNavigation.js +28 -0
  94. package/dist/proxy/resolve.js +52 -25
  95. package/dist/puck/ExperimentPicker.js +40 -37
  96. package/dist/puck/editor/ConfigureTestDrawer.d.ts +8 -4
  97. package/dist/puck/editor/ConfigureTestDrawer.js +5 -2
  98. package/dist/puck/editor/ExperimentSlotEditor.js +313 -158
  99. package/dist/puck/editor/LeftoverVersions.d.ts +1 -1
  100. package/dist/puck/editor/LeftoverVersions.js +40 -43
  101. package/dist/puck/editor/QuickTestActions.d.ts +5 -2
  102. package/dist/puck/editor/QuickTestActions.js +16 -4
  103. package/dist/puck/editor/ResultsReadout.d.ts +2 -1
  104. package/dist/puck/editor/ResultsReadout.js +2 -1
  105. package/dist/puck/editor/VersionBuilder.d.ts +31 -3
  106. package/dist/puck/editor/VersionBuilder.js +336 -74
  107. package/dist/puck/editor/armWrites.js +1 -1
  108. package/dist/puck/editor/armsCache.js +1 -3
  109. package/dist/puck/editor/blockClipboard.d.ts +16 -0
  110. package/dist/puck/editor/blockClipboard.js +20 -0
  111. package/dist/puck/editor/copy.d.ts +12 -2
  112. package/dist/puck/editor/copy.js +13 -2
  113. package/dist/puck/editor/editor.chrome.css +118 -3
  114. package/dist/puck/editor/editor.css +131 -8
  115. package/dist/puck/editor/editor.model.d.ts +3 -1
  116. package/dist/puck/editor/editor.model.js +2 -2
  117. package/dist/puck/editor/localPlacements.d.ts +1 -0
  118. package/dist/puck/editor/localPlacements.js +12 -0
  119. package/dist/puck/editor/placementsCache.d.ts +22 -12
  120. package/dist/puck/editor/placementsCache.js +62 -49
  121. package/dist/puck/editor/usePageSaveReadiness.d.ts +9 -0
  122. package/dist/puck/editor/usePageSaveReadiness.js +34 -0
  123. package/dist/puck/editor/usePlacementNotice.d.ts +2 -2
  124. package/dist/puck/editor/usePlacementNotice.js +6 -4
  125. package/dist/puck/experimentSlug.d.ts +2 -0
  126. package/dist/puck/experimentSlug.js +3 -0
  127. package/dist/puck/nestedTestCopy.d.ts +8 -0
  128. package/dist/puck/nestedTestCopy.js +22 -0
  129. package/dist/puck/nestedTests.d.ts +17 -0
  130. package/dist/puck/nestedTests.js +30 -0
  131. package/dist/puck/slotConfig.d.ts +1 -1
  132. package/dist/puck/slotConfig.js +17 -4
  133. package/dist/puck/visibility.d.ts +2 -3
  134. package/dist/puck/visibility.js +11 -7
  135. package/dist/results/aggregate.d.ts +6 -3
  136. package/dist/results/aggregate.js +9 -9
  137. package/dist/results/health.d.ts +8 -0
  138. package/dist/results/health.js +28 -0
  139. package/dist/results/identityCredit.d.ts +1 -0
  140. package/dist/results/identityCredit.js +4 -1
  141. package/dist/results/verdict.js +2 -1
  142. package/dist/runtime/cookie.d.ts +10 -2
  143. package/dist/runtime/cookie.js +38 -6
  144. package/dist/runtime/cookieOptions.d.ts +6 -0
  145. package/dist/runtime/cookieOptions.js +14 -0
  146. package/dist/runtime/proxyRuntime.d.ts +1 -0
  147. package/dist/runtime/proxyRuntime.js +18 -8
  148. package/dist/runtime/signing.d.ts +1 -0
  149. package/dist/runtime/signing.js +5 -0
  150. package/dist/sanitizeReadinessDetail.d.ts +2 -2
  151. package/dist/sanitizeReadinessDetail.js +20 -2
  152. package/dist/server/getAssignments.js +11 -10
  153. package/dist/server/recordContentChange.d.ts +1 -1
  154. package/dist/server/recordContentChange.js +45 -21
  155. package/dist/server/resolveExperimentBlocks.js +2 -4
  156. package/dist/server/resolveExperimentData.js +4 -7
  157. package/dist/server/runResults.js +52 -14
  158. package/dist/server/startExperiment.d.ts +20 -0
  159. package/dist/server/startExperiment.js +70 -0
  160. package/dist/server/trackConversion.js +10 -13
  161. package/dist/testSurface/PreviewLinks.js +6 -2
  162. package/dist/testSurface/actions/DecideDialog.d.ts +4 -1
  163. package/dist/testSurface/actions/DecideDialog.js +32 -14
  164. package/dist/testSurface/actions/MakeContentResult.d.ts +4 -3
  165. package/dist/testSurface/actions/MakeContentResult.js +9 -1
  166. package/dist/testSurface/api.d.ts +11 -8
  167. package/dist/testSurface/api.js +27 -11
  168. package/dist/testSurface/contentLocaleURL.d.ts +2 -0
  169. package/dist/testSurface/contentLocaleURL.js +3 -0
  170. package/dist/testSurface/copy/actions.d.ts +1 -0
  171. package/dist/testSurface/copy/actions.js +1 -0
  172. package/dist/testSurface/copy/common.d.ts +6 -0
  173. package/dist/testSurface/copy/common.js +11 -5
  174. package/dist/testSurface/copy/languages.d.ts +12 -0
  175. package/dist/testSurface/copy/languages.js +8 -0
  176. package/dist/testSurface/copy/metrics.d.ts +1 -0
  177. package/dist/testSurface/copy/metrics.js +1 -0
  178. package/dist/testSurface/copy/readiness.d.ts +13 -2
  179. package/dist/testSurface/copy/readiness.js +19 -2
  180. package/dist/testSurface/copy/results.d.ts +5 -2
  181. package/dist/testSurface/copy/results.js +5 -2
  182. package/dist/testSurface/copy/testPage.d.ts +40 -1
  183. package/dist/testSurface/copy/testPage.js +53 -1
  184. package/dist/testSurface/placementLabel.d.ts +8 -0
  185. package/dist/testSurface/placementLabel.js +24 -0
  186. package/dist/testSurface/placements/placementLabels.d.ts +2 -0
  187. package/dist/testSurface/placements/placementLabels.js +2 -1
  188. package/dist/testSurface/readPreflight.d.ts +5 -0
  189. package/dist/testSurface/readPreflight.js +7 -0
  190. package/dist/testSurface/readinessRead.d.ts +3 -0
  191. package/dist/testSurface/readinessRead.js +4 -0
  192. package/dist/testSurface/results/VerdictHero.d.ts +2 -1
  193. package/dist/testSurface/results/VerdictHero.js +5 -1
  194. package/dist/testSurface/results/results.css +1 -1
  195. package/dist/testSurface/results/results.model.d.ts +1 -1
  196. package/dist/testSurface/results/results.model.js +6 -2
  197. package/dist/testSurface/surface/contracts.d.ts +10 -1
  198. package/dist/testSurface/surface/editorPlacement.d.ts +7 -2
  199. package/dist/testSurface/surface/editorPlacement.js +19 -1
  200. package/dist/testSurface/surface/pageBlock/pageBlock.model.js +4 -3
  201. package/dist/testSurface/surface/pageBlock/parts.js +24 -6
  202. package/dist/testSurface/surface/pagePicker/PageCombobox.js +20 -6
  203. package/dist/testSurface/surface/readiness/ActionDialogs.d.ts +4 -2
  204. package/dist/testSurface/surface/readiness/ActionDialogs.js +39 -34
  205. package/dist/testSurface/surface/readiness/Banner.js +23 -12
  206. package/dist/testSurface/surface/readiness/SaveStatus.d.ts +4 -3
  207. package/dist/testSurface/surface/readiness/SaveStatus.js +15 -15
  208. package/dist/testSurface/surface/readiness/readiness.model.d.ts +6 -1
  209. package/dist/testSurface/surface/readiness/readiness.model.js +116 -12
  210. package/dist/testSurface/surface/readiness/useTransition.d.ts +4 -4
  211. package/dist/testSurface/surface/readiness/useTransition.js +12 -10
  212. package/dist/testSurface/surface/results/ReleasePages.d.ts +4 -2
  213. package/dist/testSurface/surface/results/ReleasePages.js +5 -4
  214. package/dist/testSurface/surface/results/ResultsBody.d.ts +4 -2
  215. package/dist/testSurface/surface/results/ResultsBody.js +86 -43
  216. package/dist/testSurface/surface/results/useResults.d.ts +11 -7
  217. package/dist/testSurface/surface/results/useResults.js +3 -2
  218. package/dist/testSurface/surface/setting/parts.js +58 -18
  219. package/dist/testSurface/surface/test/AdvancedSection.js +1 -0
  220. package/dist/testSurface/surface/test/DeleteTest.d.ts +19 -0
  221. package/dist/testSurface/surface/test/DeleteTest.js +262 -0
  222. package/dist/testSurface/surface/test/GoalSection.js +7 -3
  223. package/dist/testSurface/surface/test/LengthSection.js +3 -0
  224. package/dist/testSurface/surface/test/PageHoldout.js +4 -1
  225. package/dist/testSurface/surface/test/ReadinessBar.js +1 -1
  226. package/dist/testSurface/surface/test/TargetingSection.js +77 -12
  227. package/dist/testSurface/surface/test/TestSurface.js +97 -15
  228. package/dist/testSurface/surface/test/VersionsSection.js +56 -29
  229. package/dist/testSurface/surface/test/fields.d.ts +29 -4
  230. package/dist/testSurface/surface/test/fields.js +159 -39
  231. package/dist/testSurface/surface/test/pageParts.js +14 -5
  232. package/dist/testSurface/surface/test/testPage.model.d.ts +1 -0
  233. package/dist/testSurface/surface/test/testPage.model.js +6 -0
  234. package/dist/testSurface/surface/testDocument.model.d.ts +3 -0
  235. package/dist/testSurface/surface/testDocument.model.js +4 -1
  236. package/dist/testSurface/surface/useTestDocument.d.ts +23 -4
  237. package/dist/testSurface/surface/useTestDocument.js +425 -162
  238. package/dist/testSurface/useApi.d.ts +9 -6
  239. package/dist/testSurface/useOnTestReturn.d.ts +2 -0
  240. package/dist/testSurface/useOnTestReturn.js +27 -0
  241. package/dist/testSurface/useReadinessPolling.js +3 -1
  242. package/dist/transitions/addMetric.d.ts +1 -4
  243. package/dist/transitions/allocate.d.ts +2 -2
  244. package/dist/transitions/allocate.js +3 -1
  245. package/dist/transitions/archive.d.ts +1 -1
  246. package/dist/transitions/archive.js +3 -2
  247. package/dist/transitions/checkStart.d.ts +5 -1
  248. package/dist/transitions/checkStart.js +130 -16
  249. package/dist/transitions/contentFields.js +9 -5
  250. package/dist/transitions/decide.d.ts +1 -1
  251. package/dist/transitions/decide.js +5 -3
  252. package/dist/transitions/deleteExperiment.d.ts +2 -2
  253. package/dist/transitions/deleteExperiment.js +17 -7
  254. package/dist/transitions/kernel.d.ts +2 -0
  255. package/dist/transitions/kernel.js +9 -4
  256. package/dist/transitions/makeContent.d.ts +2 -1
  257. package/dist/transitions/makeContent.js +17 -12
  258. package/dist/transitions/nestedPlacementNames.d.ts +5 -0
  259. package/dist/transitions/nestedPlacementNames.js +32 -0
  260. package/dist/transitions/pageVersions.js +3 -1
  261. package/dist/transitions/phaseRecord.d.ts +2 -0
  262. package/dist/transitions/phaseRecord.js +5 -0
  263. package/dist/transitions/placementInteractions.d.ts +3 -3
  264. package/dist/transitions/placementInteractions.js +15 -11
  265. package/dist/transitions/placements.d.ts +28 -1
  266. package/dist/transitions/placements.js +223 -60
  267. package/dist/transitions/preflightData.d.ts +5 -3
  268. package/dist/transitions/preflightData.js +126 -37
  269. package/dist/transitions/releaseHoldout.d.ts +2 -1
  270. package/dist/transitions/releaseHoldout.js +3 -1
  271. package/dist/transitions/releasePages.d.ts +2 -1
  272. package/dist/transitions/releasePages.js +3 -1
  273. package/dist/transitions/resolveCaps.d.ts +2 -4
  274. package/dist/transitions/start.d.ts +6 -8
  275. package/dist/transitions/start.js +70 -34
  276. package/dist/transitions/startReads.d.ts +7 -0
  277. package/dist/transitions/startReads.js +28 -0
  278. package/dist/transitions/stop.d.ts +2 -1
  279. package/dist/transitions/stop.js +3 -2
  280. package/dist/types/contracts.d.ts +6 -3
  281. package/dist/types/endpoints.d.ts +86 -9
  282. package/dist/types/endpoints.js +1 -1
  283. package/dist/types/runtime.d.ts +15 -9
  284. package/dist/types/snapshot.d.ts +2 -0
  285. package/dist/types/surface.d.ts +2 -0
  286. package/dist/ui/Button.js +2 -2
  287. package/dist/ui/ChipsInput.d.ts +8 -1
  288. package/dist/ui/ChipsInput.js +17 -4
  289. package/dist/ui/Inputs.d.ts +4 -3
  290. package/dist/ui/Inputs.js +9 -9
  291. package/dist/ui/SelectControl.d.ts +33 -0
  292. package/dist/ui/SelectControl.js +504 -0
  293. package/dist/ui/ui.css +13 -5
  294. package/package.json +3 -2
@@ -1,9 +1,11 @@
1
1
  'use client';
2
- import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
3
+ import { DeleteTest } from './DeleteTest.js';
4
+ import { surfaceUrls } from '../../surfaceUrls.js';
3
5
  import { useEffect, useState, useRef } from 'react';
4
6
  import { useTestDocument } from '../useTestDocument.js';
5
7
  import { API_MESSAGES } from '../../copy/common.js';
6
- import { TEST_PAGE as C } from '../../copy/testPage.js';
8
+ import { DELETE_TEST, TEST_PAGE as C } from '../../copy/testPage.js';
7
9
  import { pageBlockParts } from '../pageBlock/parts.js';
8
10
  import { settingParts } from '../setting/parts.js';
9
11
  import { pageParts } from './pageParts.js';
@@ -28,7 +30,9 @@ export function TestSurface({ id, surface, onTitleChange, renderFrame, embedded
28
30
  const [barHeight, setBarHeight] = useState();
29
31
  const documentState = useTestDocument(id, {
30
32
  apiRoute: surface.apiRoute,
33
+ contentLocale: surface.contentLocale,
31
34
  refetchPreflightOnFocus: true,
35
+ refetchDocumentOnFocus: true,
32
36
  ...!surface.canManage ? {
33
37
  enabled: false
34
38
  } : {},
@@ -45,27 +49,39 @@ export function TestSurface({ id, surface, onTitleChange, renderFrame, embedded
45
49
  const [placementRead, setPlacementRead] = useState();
46
50
  const placementKey = JSON.stringify([
47
51
  surface.apiRoute,
48
- String(id)
52
+ String(id),
53
+ ...surface.contentLocale ? [
54
+ surface.contentLocale
55
+ ] : []
49
56
  ]);
50
57
  const watching = embedded && surface.canManage && documentState.loadState === 'ready';
51
58
  useEffect(()=>{
52
59
  if (!embedded || !surface.canManage) return;
53
60
  return subscribePlacements(surface.apiRoute, id, ()=>setPlacementRead({
54
61
  key: placementKey,
55
- preflight: cachedPreflight(surface.apiRoute, id),
56
- read: cachedReadinessRead(surface.apiRoute, id),
57
- pending: placementsPending(surface.apiRoute, id),
58
- blocking: placementsBlocking(surface.apiRoute, id),
59
- error: placementReadError(surface.apiRoute, id)
60
- }));
62
+ preflight: cachedPreflight(surface.apiRoute, id, surface.contentLocale),
63
+ read: cachedReadinessRead(surface.apiRoute, id, surface.contentLocale),
64
+ pending: placementsPending(surface.apiRoute, id, surface.contentLocale),
65
+ blocking: placementsBlocking(surface.apiRoute, id, surface.contentLocale),
66
+ error: placementReadError(surface.apiRoute, id, surface.contentLocale)
67
+ }), surface.contentLocale);
61
68
  }, [
62
69
  surface.apiRoute,
63
70
  id,
64
71
  embedded,
65
72
  surface.canManage,
66
- placementKey
73
+ placementKey,
74
+ surface.contentLocale
67
75
  ]);
68
76
  const currentRead = documentState.loadState === 'ready' && placementRead?.key === placementKey ? placementRead : undefined;
77
+ const answer = currentRead?.pending ? undefined : currentRead?.read;
78
+ const { syncDocument } = documentState;
79
+ useEffect(()=>{
80
+ syncDocument?.(answer);
81
+ }, [
82
+ answer,
83
+ syncDocument
84
+ ]);
69
85
  const preflight = currentRead ? currentRead.preflight ?? (currentRead.pending && !currentRead.error ? documentState.preflight : null) : documentState.preflight;
70
86
  const sharedDocument = currentRead ? {
71
87
  ...documentState,
@@ -88,7 +104,7 @@ export function TestSurface({ id, surface, onTitleChange, renderFrame, embedded
88
104
  editorPage,
89
105
  editorPlacementMessage: message
90
106
  };
91
- usePlacementNotice(surface.apiRoute, id, watching ? sharedDocument.preflightError ?? (placementFailed ? placementReadError(surface.apiRoute, id) : message) : undefined);
107
+ usePlacementNotice(surface.apiRoute, id, watching ? sharedDocument.preflightError ?? (placementFailed ? placementReadError(surface.apiRoute, id, surface.contentLocale) : message) : undefined, surface.contentLocale, watching);
92
108
  const setup = documentState.doc?.status === 'draft' || documentState.doc?.status === 'stopped';
93
109
  const test = setup ? {
94
110
  ...sharedDocument,
@@ -110,6 +126,23 @@ export function TestSurface({ id, surface, onTitleChange, renderFrame, embedded
110
126
  children
111
127
  }) : children;
112
128
  };
129
+ const detachedEdits = (test.detachedDrafts ?? []).map((key)=>{
130
+ const draft = test.fieldDrafts?.[key];
131
+ return draft && !draft.saving ? /*#__PURE__*/ _jsxs(Banner, {
132
+ tone: "warning",
133
+ action: /*#__PURE__*/ _jsx(Button, {
134
+ onClick: ()=>test.trackDraft(key, null),
135
+ children: C.discardEdit
136
+ }),
137
+ children: [
138
+ C.detachedEdit(draft.label),
139
+ " ",
140
+ /*#__PURE__*/ _jsx("strong", {
141
+ children: draft.value || C.emptyValue
142
+ })
143
+ ]
144
+ }, key) : null;
145
+ });
113
146
  // Results readers have no permission to load the manager-only test/preflight.
114
147
  if (!surface.canManage) return frame(/*#__PURE__*/ _jsx(ResultsBody, {
115
148
  id: id,
@@ -119,6 +152,20 @@ export function TestSurface({ id, surface, onTitleChange, renderFrame, embedded
119
152
  className: "xp-test-page",
120
153
  role: test.loadState === 'error' ? 'alert' : 'status',
121
154
  children: [
155
+ Object.entries(test.fieldDrafts ?? {}).map(([key, draft])=>/*#__PURE__*/ _jsxs(Banner, {
156
+ tone: "warning",
157
+ action: /*#__PURE__*/ _jsx(Button, {
158
+ onClick: ()=>test.trackDraft(key, null),
159
+ children: C.discardEdit
160
+ }),
161
+ children: [
162
+ C.detachedEdit(draft.label),
163
+ " ",
164
+ /*#__PURE__*/ _jsx("strong", {
165
+ children: draft.value || C.emptyValue
166
+ })
167
+ ]
168
+ }, key)),
122
169
  /*#__PURE__*/ _jsx("p", {
123
170
  children: test.preflightRead?.kind === 'signed-out' ? API_MESSAGES.unauthenticated : test.loadState === 'forbidden' ? C.forbidden : test.loadState === 'missing' ? C.missing : test.loadState === 'error' ? C.error : C.loading
124
171
  }),
@@ -148,14 +195,25 @@ export function TestSurface({ id, surface, onTitleChange, renderFrame, embedded
148
195
  /*#__PURE__*/ _jsxs("div", {
149
196
  className: "xp-test-content",
150
197
  children: [
151
- test.errors._section ? /*#__PURE__*/ _jsx(Banner, {
198
+ test.errors._section ? /*#__PURE__*/ _jsxs(Banner, {
152
199
  tone: "error",
153
200
  action: /*#__PURE__*/ _jsx(Button, {
154
- onClick: ()=>void test.reload(),
201
+ onClick: ()=>void test.reload({
202
+ discardDrafts: true
203
+ }),
155
204
  children: C.reload
156
205
  }),
157
- children: test.errors._section
206
+ children: [
207
+ test.errors._section,
208
+ test.stale ? null : /*#__PURE__*/ _jsxs(_Fragment, {
209
+ children: [
210
+ " ",
211
+ C.reloadAfterError
212
+ ]
213
+ })
214
+ ]
158
215
  }) : null,
216
+ detachedEdits,
159
217
  /*#__PURE__*/ _jsxs(Section, {
160
218
  surface: surface,
161
219
  test: test,
@@ -190,7 +248,31 @@ export function TestSurface({ id, surface, onTitleChange, renderFrame, embedded
190
248
  /*#__PURE__*/ _jsx(AdvancedSection, {
191
249
  ...props
192
250
  }),
251
+ !embedded ? /*#__PURE__*/ _jsxs("div", {
252
+ children: [
253
+ /*#__PURE__*/ _jsx(DeleteTest, {
254
+ test: test.doc,
255
+ canManage: surface.canManage && !test.statusReadPending,
256
+ apiRoute: surface.apiRoute,
257
+ contentLocale: surface.contentLocale,
258
+ onStatusChanged: ()=>{
259
+ void test.reload();
260
+ },
261
+ onDeleted: (outcome)=>{
262
+ window.location.assign(surfaceUrls.home(surface.adminRoute, {
263
+ deleted: outcome
264
+ }));
265
+ }
266
+ }, test.doc.id),
267
+ !test.statusReadPending && (test.doc.status === 'stopped' || test.doc.status === 'decided') ? /*#__PURE__*/ _jsx("p", {
268
+ children: DELETE_TEST.archiveFirst
269
+ }) : null
270
+ ]
271
+ }) : null,
193
272
  embedded && surface.canReadResults && test.doc.status !== 'draft' ? /*#__PURE__*/ _jsx(ResultsBody, {
273
+ documentVersion: `${test.doc.phase}/${test.doc.status}`,
274
+ liveDocument: test.doc,
275
+ statusReadPending: test.statusReadPending,
194
276
  id: id,
195
277
  surface: surface,
196
278
  onChanged: (doc)=>{
@@ -199,7 +281,7 @@ export function TestSurface({ id, surface, onTitleChange, renderFrame, embedded
199
281
  });
200
282
  void test.reload();
201
283
  }
202
- }, `${test.doc.id}/${test.doc.phase}/${test.doc.status}`) : null
284
+ }) : null
203
285
  ]
204
286
  })
205
287
  ]
@@ -1,15 +1,14 @@
1
1
  'use client';
2
2
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
3
- import { useId } from 'react';
3
+ import { useId, useState } from 'react';
4
4
  import { Button } from '../../../ui/Button.js';
5
5
  import { Range } from '../../../ui/Inputs.js';
6
- import { useEffect, useRef, useState } from 'react';
7
6
  import { TEST_PAGE as C } from '../../copy/testPage.js';
8
7
  import { ARMS_COPY, GROUP_LABELS, issueMessage } from '../../copy/arms.js';
9
8
  import { addHoldoutArm, addVariant, issuesByRow, removeArm, splitEvenly, totalWeight, withSlotsFor } from '../../arms/arms.model.js';
10
9
  import { allocationSentence } from '../../allocation.model.js';
11
- import { balanceWeight, orderedVersions, trafficShares } from './testPage.model.js';
12
- import { FieldErrors, ReadOnly, reasonFor, save, TextEdit } from './fields.js';
10
+ import { balanceWeight, orderedVersions, trafficShares, trafficSplit } from './testPage.model.js';
11
+ import { FieldErrors, ReadOnly, reasonFor, save, SavedValueChanged, TextEdit, useDraftAnnouncement, useFieldDraft } from './fields.js';
13
12
  import { PAGE_COPY } from '../../copy/pages.js';
14
13
  import { testPageCollection } from '../pagePicker/pagePicker.model.js';
15
14
  import { Section } from './Section.js';
@@ -24,28 +23,31 @@ export function VersionsSection({ test, surface, parts, contentOnCanvas = false
24
23
  const id = useId();
25
24
  const doc = test.doc;
26
25
  const [weightEdit, setWeightEdit] = useState(null);
27
- const releasedAllocation = useRef(null);
28
- const [allocation, setAllocation] = useState(doc.allocation);
29
- useEffect(()=>setWeightEdit(null), [
30
- doc.arms
31
- ]);
32
- useEffect(()=>setAllocation(doc.allocation), [
33
- doc.allocation
34
- ]);
26
+ const split = trafficSplit(doc.arms);
27
+ const allocationEdit = useFieldDraft(test, 'allocation', C.allocation, String(doc.allocation));
28
+ const [announcement, announce] = useDraftAnnouncement();
29
+ const allocation = Number(allocationEdit.value);
30
+ const allocationReason = reasonFor(test, 'allocation');
31
+ const allocationConflict = allocationEdit.dirty && !allocationEdit.saving && (allocationEdit.conflict || allocationEdit.retry || allocationReason) ? `${id}-new-value` : undefined;
32
+ if (weightEdit && (weightEdit.split !== split || test.mountDraft && !test.fieldDrafts?.[`share:${weightEdit.key}`])) setWeightEdit(null);
35
33
  const reason = reasonFor(test, 'arms');
36
- const live = weightEdit ? balanceWeight(doc.arms, weightEdit.key, weightEdit.weight) : doc.arms;
34
+ const live = weightEdit && !reason ? balanceWeight(doc.arms, weightEdit.key, weightEdit.weight) : doc.arms;
37
35
  const ordered = orderedVersions(live);
38
36
  const shares = trafficShares(ordered.map((row)=>row.arm));
39
- const issues = issuesByRow(live, doc.kind);
37
+ const issues = issuesByRow(doc.kind === 'block' ? withSlotsFor(live, 'block') : live, doc.kind);
40
38
  const update = (transform)=>save(test, 'arms', ()=>({
41
39
  arms: withSlotsFor(transform(test.doc.arms), test.doc.kind)
42
40
  }));
43
- const commitAllocation = ()=>{
44
- if (allocation === test.doc.allocation || releasedAllocation.current === allocation) return;
45
- releasedAllocation.current = allocation;
46
- save(test, 'allocation', ()=>({
47
- allocation
48
- }));
41
+ const commitAllocation = (confirmed = false)=>{
42
+ if (!allocationEdit.dirty || allocationEdit.saving) return;
43
+ if (allocationReason || test.stale || allocationConflict && !confirmed) {
44
+ announce();
45
+ return;
46
+ }
47
+ if (allocation === doc.allocation) allocationEdit.discard();
48
+ else allocationEdit.submit(()=>save(test, 'allocation', ()=>({
49
+ allocation
50
+ })));
49
51
  };
50
52
  return /*#__PURE__*/ _jsxs(Section, {
51
53
  surface: surface,
@@ -87,6 +89,7 @@ export function VersionsSection({ test, surface, parts, contentOnCanvas = false
87
89
  contentOnCanvas ? /*#__PURE__*/ _jsx("span", {
88
90
  children: arm.label
89
91
  }) : /*#__PURE__*/ _jsx(TextEdit, {
92
+ test: test,
90
93
  label: `${GROUP_LABELS[arm.key]}: ${C.label}`,
91
94
  value: arm.label,
92
95
  reason: reason,
@@ -98,17 +101,22 @@ export function VersionsSection({ test, surface, parts, contentOnCanvas = false
98
101
  } : current))
99
102
  }),
100
103
  /*#__PURE__*/ _jsx(TextEdit, {
104
+ test: test,
105
+ draftKey: `share:${arm.key}`,
101
106
  label: `${GROUP_LABELS[arm.key]}: ${C.weight}`,
102
107
  type: "number",
103
108
  min: 0,
104
109
  max: 100,
105
110
  value: doc.arms[index].weight,
111
+ preview: weightEdit?.key !== arm.key ? arm.weight : undefined,
112
+ scope: split,
106
113
  reason: reason,
107
114
  hideLabel: true,
108
115
  disabled: Boolean(reason),
109
116
  isValid: (raw)=>raw.trim() !== '' && Number.isInteger(Number(raw)) && Number(raw) >= 0 && Number(raw) <= 100,
110
117
  invalidMessage: C.invalidShare,
111
- onDraft: (value)=>setWeightEdit({
118
+ onDraft: (value)=>setWeightEdit(value === null ? null : {
119
+ split,
112
120
  key: arm.key,
113
121
  weight: Number(value)
114
122
  }),
@@ -207,10 +215,10 @@ export function VersionsSection({ test, surface, parts, contentOnCanvas = false
207
215
  className: "xp-ui-help",
208
216
  children: ARMS_COPY.holdout
209
217
  }) : null,
210
- reasonFor(test, 'allocation') ? /*#__PURE__*/ _jsx(ReadOnly, {
218
+ allocationReason && !allocationEdit.dirty ? /*#__PURE__*/ _jsx(ReadOnly, {
211
219
  label: C.allocation,
212
220
  value: `${doc.allocation}%`,
213
- reason: reasonFor(test, 'allocation')
221
+ reason: allocationReason
214
222
  }) : /*#__PURE__*/ _jsx(Range, {
215
223
  id: id,
216
224
  label: C.allocation,
@@ -218,11 +226,21 @@ export function VersionsSection({ test, surface, parts, contentOnCanvas = false
218
226
  min: 1,
219
227
  max: 100,
220
228
  value: allocation,
221
- onChange: (e)=>{
222
- releasedAllocation.current = null;
223
- setAllocation(Number(e.target.value));
229
+ "aria-describedby": allocationConflict,
230
+ disabled: Boolean(allocationReason || test.stale || allocationEdit.saving),
231
+ onChange: (e)=>allocationEdit.change(e.target.value),
232
+ onPointerUp: ()=>commitAllocation(),
233
+ onKeyDown: (e)=>{
234
+ if (e.key === 'Enter' && allocationConflict) {
235
+ e.preventDefault();
236
+ announce();
237
+ }
238
+ if (e.key === 'Escape' && allocationEdit.dirty && !allocationEdit.saving) {
239
+ e.preventDefault();
240
+ e.stopPropagation();
241
+ allocationEdit.discard();
242
+ }
224
243
  },
225
- onPointerUp: commitAllocation,
226
244
  onKeyUp: (e)=>{
227
245
  if ([
228
246
  'ArrowLeft',
@@ -235,11 +253,20 @@ export function VersionsSection({ test, surface, parts, contentOnCanvas = false
235
253
  'PageDown'
236
254
  ].includes(e.key)) commitAllocation();
237
255
  },
238
- onBlur: commitAllocation
256
+ onBlur: ()=>commitAllocation()
239
257
  }),
258
+ allocationConflict ? /*#__PURE__*/ _jsx(SavedValueChanged, {
259
+ id: allocationConflict,
260
+ value: `${doc.allocation}%`,
261
+ reason: allocationReason,
262
+ conflict: allocationEdit.conflict,
263
+ announce: announcement,
264
+ onKeep: !allocationReason && !test.stale ? ()=>commitAllocation(true) : undefined,
265
+ onDiscard: allocationEdit.discard
266
+ }) : null,
240
267
  /*#__PURE__*/ _jsx("p", {
241
268
  children: allocationSentence({
242
- allocation: reasonFor(test, 'allocation') ? doc.allocation : allocation,
269
+ allocation: allocationReason ? doc.allocation : allocation,
243
270
  unitType: doc.unitType,
244
271
  arms: live,
245
272
  status: doc.status
@@ -3,7 +3,7 @@ import type { SectionProps, TestDocApi } from '../contracts.js';
3
3
  import type { EditableField } from '../../../types/admin.js';
4
4
  import type { TestDocumentPatch } from '../testDocument.model.js';
5
5
  export declare function reasonFor(test: TestDocApi, field: string): string | null;
6
- export declare function save(test: TestDocApi, field: EditableField, patch: () => TestDocumentPatch): void;
6
+ export declare function save(test: TestDocApi, field: EditableField, patch: () => TestDocumentPatch): boolean;
7
7
  export declare function FieldErrors({ test, path }: {
8
8
  test: TestDocApi;
9
9
  path: string;
@@ -14,13 +14,38 @@ export declare function ReadOnly({ label, value, reason, labelAction }: {
14
14
  reason: string | null;
15
15
  labelAction?: ReactNode;
16
16
  }): import("react").JSX.Element;
17
+ export declare function useFieldDraft(test: TestDocApi, key: string, label: string, saved: string, scope?: string): {
18
+ value: string;
19
+ dirty: boolean;
20
+ saving: boolean;
21
+ retry: boolean;
22
+ conflict: boolean;
23
+ change(value: string): void;
24
+ submit(save: () => boolean | void): void;
25
+ discard(): void;
26
+ };
27
+ export declare function SavedValueChanged({ id, value, reason, conflict, announce, onKeep, onDiscard }: {
28
+ id: string;
29
+ value: string;
30
+ reason?: string | null;
31
+ conflict: boolean;
32
+ announce: number;
33
+ onKeep?: () => void;
34
+ onDiscard: () => void;
35
+ }): import("react").JSX.Element;
36
+ /** Announce the existing choices again when blur or Enter cannot commit. */
37
+ export declare function useDraftAnnouncement(): readonly [number, () => void];
17
38
  /** Local typing is intentionally separate from staging: build the current group on commit. */
18
- export declare function TextEdit({ label, value, onCommit, reason, multiline, placeholder, type, min, max, required, onDraft, isValid, invalidMessage, hideLabel, disabled, help }: {
39
+ export declare function TextEdit({ test, label, draftKey, value, preview, onCommit, reason, multiline, placeholder, type, min, max, required, onDraft, scope, isValid, invalidMessage, hideLabel, disabled, help }: {
40
+ test: TestDocApi;
19
41
  label: string;
42
+ draftKey?: string;
20
43
  value: string | number;
21
- onCommit: (value: string) => void;
44
+ onCommit: (value: string) => boolean | void;
22
45
  reason?: string | null;
23
- onDraft?: (value: string) => void;
46
+ onDraft?: (value: string | null) => void;
47
+ scope?: string;
48
+ preview?: number;
24
49
  multiline?: boolean;
25
50
  placeholder?: string;
26
51
  type?: 'text' | 'number';
@@ -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, {
@@ -45,55 +47,171 @@ export function ReadOnly({ label, value, reason, labelAction }) {
45
47
  ]
46
48
  });
47
49
  }
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 }) {
50
+ export function useFieldDraft(test, key, label, saved, scope) {
51
+ const { mountDraft, submitDraft, trackDraft } = test;
52
+ const [localEdit, setLocalEdit] = useState(null);
53
+ const edit = mountDraft ? test.fieldDrafts?.[key] : localEdit;
54
+ const conflict = Boolean(edit && !edit.saving && (edit.scope !== scope || edit.base !== saved && edit.value !== saved));
55
+ useLayoutEffect(()=>mountDraft?.(key), [
56
+ key,
57
+ mountDraft
58
+ ]);
59
+ const update = (draft)=>mountDraft ? trackDraft(key, draft) : setLocalEdit(draft);
60
+ return {
61
+ value: edit?.value ?? saved,
62
+ dirty: Boolean(edit),
63
+ saving: Boolean(edit?.saving),
64
+ retry: Boolean(edit?.retry),
65
+ conflict,
66
+ change (value) {
67
+ update(value === saved && !conflict ? null : {
68
+ label,
69
+ base: edit?.base ?? saved,
70
+ scope: edit ? edit.scope : scope,
71
+ value
72
+ });
73
+ },
74
+ submit (save) {
75
+ if (submitDraft) submitDraft(key, save);
76
+ else if (save() !== false) update(null);
77
+ },
78
+ discard () {
79
+ update(null);
80
+ }
81
+ };
82
+ }
83
+ export function SavedValueChanged({ id, value, reason, conflict, announce, onKeep, onDiscard }) {
84
+ return /*#__PURE__*/ _jsx("div", {
85
+ id: id,
86
+ className: "xp-field-draft-notice",
87
+ children: /*#__PURE__*/ _jsx(Banner, {
88
+ tone: "error",
89
+ action: /*#__PURE__*/ _jsxs("div", {
90
+ className: "xp-ui-button-group",
91
+ children: [
92
+ onKeep ? /*#__PURE__*/ _jsx(Button, {
93
+ size: "sm",
94
+ onClick: onKeep,
95
+ children: conflict ? C.keepEdit : C.retryEdit
96
+ }) : null,
97
+ /*#__PURE__*/ _jsx(Button, {
98
+ size: "sm",
99
+ variant: "quiet",
100
+ onClick: onDiscard,
101
+ children: C.useSavedValue
102
+ })
103
+ ]
104
+ }),
105
+ children: /*#__PURE__*/ _jsxs("span", {
106
+ children: [
107
+ reason ?? (conflict ? C.savedValueChanged : null),
108
+ ' ',
109
+ onKeep && conflict ? C.conflictChoice : C.draftNotSaved,
110
+ ' ',
111
+ C.savedValue,
112
+ " ",
113
+ /*#__PURE__*/ _jsx("strong", {
114
+ children: value || C.emptyValue
115
+ })
116
+ ]
117
+ }, announce)
118
+ })
119
+ });
120
+ }
121
+ /** Announce the existing choices again when blur or Enter cannot commit. */ export function useDraftAnnouncement() {
122
+ const [announcement, setAnnouncement] = useState(0);
123
+ return [
124
+ announcement,
125
+ ()=>setAnnouncement((count)=>count + 1)
126
+ ];
127
+ }
128
+ /** 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
129
  const id = useId();
50
- const [draft, setDraft] = useState(String(value));
130
+ const edit = useFieldDraft(test, draftKey, label, String(value), scope);
131
+ const [announcement, announce] = useDraftAnnouncement();
51
132
  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.
133
+ if (error && !edit.dirty) setError(null);
134
+ const discard = ()=>{
135
+ edit.discard();
136
+ onDraft?.(null);
137
+ setError(null);
138
+ };
139
+ const locked = Boolean(reason || disabled);
140
+ const choice = edit.dirty && !edit.saving && (edit.conflict || edit.retry || locked || Boolean(error));
141
+ const choiceId = choice ? `${id}-new-value` : undefined;
142
+ const commit = (confirmed = false)=>{
143
+ if (!edit.dirty || edit.saving) return;
144
+ if (locked || test.stale || choice && !confirmed) {
145
+ announce();
146
+ return;
147
+ }
148
+ const draft = edit.value;
149
+ if (draft === String(value)) {
150
+ discard();
151
+ return;
152
+ }
58
153
  if (isValid && !isValid(draft)) {
59
- setError(draft.trim() ? invalidMessage ?? null : null);
60
- setDraft(String(value));
61
- onDraft?.(String(value));
154
+ onDraft?.(null);
155
+ setError(invalidMessage ?? C.editInvalid);
62
156
  return;
63
157
  }
64
- onCommit(draft);
158
+ edit.submit(()=>onCommit(draft));
159
+ onDraft?.(null);
65
160
  };
66
- if (reason && !disabled) return /*#__PURE__*/ _jsx(ReadOnly, {
161
+ if (reason && !disabled && !edit.dirty) return /*#__PURE__*/ _jsx(ReadOnly, {
67
162
  label: label,
68
163
  value: value === '' && placeholder ? placeholder : value,
69
164
  reason: reason
70
165
  });
71
166
  const Input = multiline ? Textarea : type === 'number' ? NumberInput : TextInput;
72
- return /*#__PURE__*/ _jsx("div", {
167
+ return /*#__PURE__*/ _jsxs("div", {
73
168
  className: hideLabel ? 'xp-grid-field' : undefined,
74
169
  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
- })
170
+ children: [
171
+ /*#__PURE__*/ _jsx(Input, {
172
+ id: id,
173
+ label: label,
174
+ "aria-label": label,
175
+ value: edit.dirty ? edit.value : preview ?? edit.value,
176
+ disabled: disabled && !edit.dirty,
177
+ readOnly: locked || test.stale || edit.saving,
178
+ "aria-describedby": choiceId,
179
+ placeholder: placeholder,
180
+ min: min,
181
+ max: max,
182
+ required: required,
183
+ help: help,
184
+ error: error ?? undefined,
185
+ onChange: (e)=>{
186
+ if (locked || test.stale || edit.saving) return;
187
+ const draft = e.target.value;
188
+ setError(null);
189
+ edit.change(draft);
190
+ onDraft?.(draft === String(value) || edit.conflict ? null : draft);
191
+ },
192
+ onBlur: ()=>commit(),
193
+ onKeyDown: (e)=>{
194
+ if (e.key === 'Escape' && edit.dirty && !edit.saving) {
195
+ e.preventDefault();
196
+ e.stopPropagation();
197
+ discard();
198
+ }
199
+ if (e.key === 'Enter' && !e.nativeEvent.isComposing && (choice || !multiline)) {
200
+ e.preventDefault();
201
+ commit();
202
+ }
203
+ }
204
+ }),
205
+ choiceId ? /*#__PURE__*/ _jsx(SavedValueChanged, {
206
+ id: choiceId,
207
+ value: String(value),
208
+ reason: reason,
209
+ conflict: edit.conflict,
210
+ announce: announcement,
211
+ onKeep: !locked && !test.stale && !error ? ()=>commit(true) : undefined,
212
+ onDiscard: discard
213
+ }) : null
214
+ ]
97
215
  });
98
216
  }
99
217
  export const positiveInteger = (raw)=>raw.trim() !== '' && Number.isInteger(Number(raw)) && Number(raw) > 0;
@@ -150,6 +268,7 @@ export function TestName({ test }) {
150
268
  return /*#__PURE__*/ _jsxs(_Fragment, {
151
269
  children: [
152
270
  /*#__PURE__*/ _jsx(TextEdit, {
271
+ test: test,
153
272
  label: C.name,
154
273
  value: test.doc?.name ?? '',
155
274
  reason: reasonFor(test, 'name'),
@@ -168,6 +287,7 @@ export function Hypothesis({ test }) {
168
287
  return /*#__PURE__*/ _jsxs(_Fragment, {
169
288
  children: [
170
289
  /*#__PURE__*/ _jsx(TextEdit, {
290
+ test: test,
171
291
  label: C.hypothesis,
172
292
  value: test.doc?.hypothesis ?? '',
173
293
  multiline: true,