@delmaredigital/payload-experiments 0.2.0-rc.6 → 0.3.0-rc.1

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 (291) hide show
  1. package/README.md +129 -11
  2. package/dist/admin/PreviewLinks.d.ts +2 -1
  3. package/dist/admin/PreviewLinks.js +24 -16
  4. package/dist/admin/actions/ConfirmDialog.d.ts +7 -4
  5. package/dist/admin/actions/ConfirmDialog.js +37 -82
  6. package/dist/admin/actions/DecideDialog.d.ts +3 -1
  7. package/dist/admin/actions/DecideDialog.js +30 -13
  8. package/dist/admin/actions/MakeContentResult.d.ts +13 -2
  9. package/dist/admin/actions/MakeContentResult.js +115 -16
  10. package/dist/admin/actions/actions.model.d.ts +2 -4
  11. package/dist/admin/actions/actions.model.js +2 -3
  12. package/dist/admin/allocation.model.js +3 -5
  13. package/dist/admin/api.d.ts +10 -4
  14. package/dist/admin/api.js +11 -7
  15. package/dist/admin/copy/actions.d.ts +39 -3
  16. package/dist/admin/copy/actions.js +40 -4
  17. package/dist/admin/copy/armSelect.js +5 -5
  18. package/dist/admin/copy/arms.d.ts +1 -7
  19. package/dist/admin/copy/arms.js +1 -7
  20. package/dist/admin/copy/audience.d.ts +2 -1
  21. package/dist/admin/copy/audience.js +3 -2
  22. package/dist/admin/copy/common.d.ts +13 -6
  23. package/dist/admin/copy/common.js +14 -8
  24. package/dist/admin/copy/goals.d.ts +21 -6
  25. package/dist/admin/copy/goals.js +27 -6
  26. package/dist/admin/copy/readiness.d.ts +19 -0
  27. package/dist/admin/copy/readiness.js +19 -0
  28. package/dist/admin/copy/recommendation.d.ts +0 -3
  29. package/dist/admin/copy/recommendation.js +0 -3
  30. package/dist/admin/copy/results.d.ts +41 -2
  31. package/dist/admin/copy/results.js +42 -3
  32. package/dist/admin/copy/review.d.ts +1 -1
  33. package/dist/admin/copy/review.js +1 -1
  34. package/dist/admin/copy/setting.d.ts +2 -0
  35. package/dist/admin/copy/setting.js +2 -0
  36. package/dist/admin/copy/surface.d.ts +7 -4
  37. package/dist/admin/copy/surface.js +9 -4
  38. package/dist/admin/copy/testPage.d.ts +12 -0
  39. package/dist/admin/copy/testPage.js +12 -0
  40. package/dist/admin/format/date.d.ts +2 -0
  41. package/dist/admin/format/date.js +10 -0
  42. package/dist/admin/labels.d.ts +2 -7
  43. package/dist/admin/labels.js +2 -7
  44. package/dist/admin/previewLinks.model.d.ts +2 -2
  45. package/dist/admin/previewLinks.model.js +5 -7
  46. package/dist/admin/results/CiChart.js +11 -21
  47. package/dist/admin/results/DataQualityPanel.d.ts +4 -2
  48. package/dist/admin/results/DataQualityPanel.js +30 -17
  49. package/dist/admin/results/DataTable.d.ts +16 -0
  50. package/dist/admin/results/DataTable.js +152 -0
  51. package/dist/admin/results/StatTile.d.ts +7 -0
  52. package/dist/admin/results/StatTile.js +22 -0
  53. package/dist/admin/results/VerdictHero.d.ts +13 -0
  54. package/dist/admin/results/{VerdictCard.js → VerdictHero.js} +15 -12
  55. package/dist/admin/results/releasePages.model.d.ts +17 -0
  56. package/dist/admin/results/releasePages.model.js +10 -0
  57. package/dist/admin/results/results.css +64 -0
  58. package/dist/admin/results/results.model.d.ts +6 -2
  59. package/dist/admin/results/results.model.js +12 -5
  60. package/dist/admin/surface/ResultsRoute.d.ts +1 -1
  61. package/dist/admin/surface/ResultsRoute.js +60 -31
  62. package/dist/admin/surface/SurfaceShell.d.ts +11 -2
  63. package/dist/admin/surface/SurfaceShell.js +49 -14
  64. package/dist/admin/surface/TestsHome.d.ts +6 -1
  65. package/dist/admin/surface/TestsHome.js +183 -112
  66. package/dist/admin/surface/TestsSurface.js +56 -16
  67. package/dist/admin/surface/contracts.d.ts +1 -0
  68. package/dist/admin/surface/goals/GoalForm.js +341 -308
  69. package/dist/admin/surface/goals/GoalsList.js +123 -89
  70. package/dist/admin/surface/goals/data.d.ts +8 -2
  71. package/dist/admin/surface/goals/data.js +11 -3
  72. package/dist/admin/surface/goals/goals.css +10 -13
  73. package/dist/admin/surface/home.model.d.ts +7 -8
  74. package/dist/admin/surface/home.model.js +23 -12
  75. package/dist/admin/surface/newTest/NewTest.js +5 -5
  76. package/dist/admin/surface/pageBlock/parts.js +31 -26
  77. package/dist/admin/surface/readiness/ActionDialogs.js +43 -14
  78. package/dist/admin/surface/readiness/Banner.d.ts +3 -0
  79. package/dist/admin/surface/readiness/Banner.js +63 -36
  80. package/dist/admin/surface/readiness/SaveStatus.d.ts +1 -0
  81. package/dist/admin/surface/readiness/SaveStatus.js +6 -3
  82. package/dist/admin/surface/readiness/readiness.model.d.ts +2 -0
  83. package/dist/admin/surface/readiness/readiness.model.js +18 -9
  84. package/dist/admin/surface/readiness/useTransition.d.ts +1 -0
  85. package/dist/admin/surface/readiness/useTransition.js +2 -1
  86. package/dist/admin/surface/results/ReleasePages.d.ts +14 -0
  87. package/dist/admin/surface/results/ReleasePages.js +116 -0
  88. package/dist/admin/surface/results/ResultsBody.d.ts +15 -2
  89. package/dist/admin/surface/results/ResultsBody.js +281 -107
  90. package/dist/admin/surface/results/ResultsHeader.d.ts +10 -0
  91. package/dist/admin/surface/results/ResultsHeader.js +177 -0
  92. package/dist/admin/surface/results/recommendation.model.js +2 -6
  93. package/dist/admin/surface/results/useResults.d.ts +21 -3
  94. package/dist/admin/surface/results/useResults.js +2 -1
  95. package/dist/admin/surface/setting/parts.js +75 -88
  96. package/dist/admin/surface/setting/setting.css +3 -15
  97. package/dist/admin/surface/surface.css +62 -47
  98. package/dist/admin/surface/test/AdvancedSection.js +55 -48
  99. package/dist/admin/surface/test/GoalSection.js +39 -32
  100. package/dist/admin/surface/test/LengthSection.js +46 -34
  101. package/dist/admin/surface/test/Rail.d.ts +4 -0
  102. package/dist/admin/surface/test/Rail.js +83 -0
  103. package/dist/admin/surface/test/ReadinessBar.d.ts +5 -0
  104. package/dist/admin/surface/test/ReadinessBar.js +33 -0
  105. package/dist/admin/surface/test/Section.d.ts +1 -1
  106. package/dist/admin/surface/test/Section.js +36 -16
  107. package/dist/admin/surface/test/TargetingSection.js +168 -142
  108. package/dist/admin/surface/test/TestPage.d.ts +2 -1
  109. package/dist/admin/surface/test/TestPage.js +146 -59
  110. package/dist/admin/surface/test/VersionsSection.js +151 -120
  111. package/dist/admin/surface/test/fields.d.ts +11 -4
  112. package/dist/admin/surface/test/fields.js +84 -85
  113. package/dist/admin/surface/test/jumpToSection.d.ts +3 -0
  114. package/dist/admin/surface/test/jumpToSection.js +10 -0
  115. package/dist/admin/surface/test/pageParts.js +9 -3
  116. package/dist/admin/surface/test/testPage.css +81 -14
  117. package/dist/admin/surface/useTestDocument.d.ts +1 -0
  118. package/dist/admin/surface/useTestDocument.js +40 -9
  119. package/dist/admin/targeting/targeting.model.d.ts +1 -3
  120. package/dist/admin/targeting/targeting.model.js +3 -8
  121. package/dist/admin/theme.css +115 -36
  122. package/dist/admin/theme.d.ts +38 -0
  123. package/dist/admin/theme.js +38 -1
  124. package/dist/admin/useApi.d.ts +17 -2
  125. package/dist/admin/views/ExperimentsRootView.js +12 -2
  126. package/dist/collections/experiments/config.js +44 -1
  127. package/dist/collections/experiments/lockHook.js +16 -2
  128. package/dist/collections/identities.js +6 -1
  129. package/dist/collections/metrics.js +7 -0
  130. package/dist/collections/metricsGuards.d.ts +9 -0
  131. package/dist/collections/metricsGuards.js +33 -0
  132. package/dist/constants.d.ts +1 -0
  133. package/dist/constants.js +1 -0
  134. package/dist/contentDone.d.ts +4 -0
  135. package/dist/contentDone.js +5 -0
  136. package/dist/db/identities.d.ts +8 -7
  137. package/dist/db/identities.js +9 -6
  138. package/dist/db/metricUsage.d.ts +19 -0
  139. package/dist/db/metricUsage.js +54 -0
  140. package/dist/db/names.d.ts +5 -0
  141. package/dist/db/names.js +5 -0
  142. package/dist/db/publishedContent.d.ts +10 -0
  143. package/dist/db/publishedContent.js +43 -0
  144. package/dist/db/results.d.ts +2 -0
  145. package/dist/db/results.js +6 -2
  146. package/dist/db/snapshots.d.ts +18 -6
  147. package/dist/db/snapshots.js +23 -7
  148. package/dist/db/staleEdit.d.ts +6 -0
  149. package/dist/db/staleEdit.js +10 -0
  150. package/dist/db/sweep.js +11 -6
  151. package/dist/endpoints/events.js +3 -3
  152. package/dist/endpoints/index.js +19 -1
  153. package/dist/endpoints/recompute.js +2 -1
  154. package/dist/endpoints/results.js +5 -0
  155. package/dist/endpoints/sanitizeReadinessDetail.d.ts +1 -0
  156. package/dist/endpoints/sanitizeReadinessDetail.js +2 -0
  157. package/dist/endpoints/summary.js +20 -2
  158. package/dist/endpoints/transitions.d.ts +15 -0
  159. package/dist/endpoints/transitions.js +36 -0
  160. package/dist/errors.d.ts +8 -0
  161. package/dist/errors.js +28 -0
  162. package/dist/exports/adminClient.d.ts +1 -0
  163. package/dist/exports/adminClient.js +1 -0
  164. package/dist/exports/index.d.ts +2 -1
  165. package/dist/exports/index.js +1 -0
  166. package/dist/exports/puckEditor.d.ts +1 -0
  167. package/dist/exports/puckEditor.js +1 -0
  168. package/dist/exports/rsc.d.ts +5 -1
  169. package/dist/exports/rsc.js +2 -0
  170. package/dist/hooks/hostHook.js +3 -2
  171. package/dist/hooks/pageGuard.d.ts +5 -0
  172. package/dist/hooks/pageGuard.js +121 -0
  173. package/dist/labels/arms.d.ts +7 -0
  174. package/dist/labels/arms.js +7 -0
  175. package/dist/log.d.ts +7 -0
  176. package/dist/log.js +38 -0
  177. package/dist/manifest/compile.d.ts +5 -0
  178. package/dist/manifest/compile.js +5 -1
  179. package/dist/options.js +23 -0
  180. package/dist/plugin.js +26 -2
  181. package/dist/puck/copy.d.ts +1 -1
  182. package/dist/puck/copy.js +6 -6
  183. package/dist/puck/editor/editor.chrome.css +235 -0
  184. package/dist/puck/editor/editor.css +241 -43
  185. package/dist/results/aggregate.js +4 -3
  186. package/dist/results/analyse.d.ts +4 -1
  187. package/dist/results/analyse.js +27 -11
  188. package/dist/results/cuped.js +3 -2
  189. package/dist/results/identityCredit.d.ts +15 -7
  190. package/dist/results/identityCredit.js +32 -33
  191. package/dist/results/rolloutUnits.js +2 -1
  192. package/dist/results/snapshot.js +8 -2
  193. package/dist/results/srm.js +2 -1
  194. package/dist/results/verdict.d.ts +2 -0
  195. package/dist/results/verdict.js +18 -1
  196. package/dist/sanitizeReadinessDetail.d.ts +7 -0
  197. package/dist/sanitizeReadinessDetail.js +54 -0
  198. package/dist/server/linkIdentity.d.ts +10 -1
  199. package/dist/server/linkIdentity.js +20 -18
  200. package/dist/server/metadata.d.ts +5 -0
  201. package/dist/server/metadata.js +9 -1
  202. package/dist/server/recordContentChange.js +2 -1
  203. package/dist/server/recordExposures.js +3 -3
  204. package/dist/server/runResults.d.ts +3 -2
  205. package/dist/server/runResults.js +125 -34
  206. package/dist/server/trackConversion.js +5 -6
  207. package/dist/targeting/values.d.ts +4 -0
  208. package/dist/targeting/values.js +10 -0
  209. package/dist/transitions/addMetric.js +8 -0
  210. package/dist/transitions/archive.js +2 -3
  211. package/dist/transitions/checkStart.d.ts +6 -3
  212. package/dist/transitions/checkStart.js +15 -0
  213. package/dist/transitions/contentFields.d.ts +7 -0
  214. package/dist/transitions/contentFields.js +20 -0
  215. package/dist/transitions/decide.js +6 -1
  216. package/dist/transitions/deleteExperiment.js +2 -1
  217. package/dist/transitions/dismissContentEntry.d.ts +8 -0
  218. package/dist/transitions/dismissContentEntry.js +45 -0
  219. package/dist/transitions/makeContent.d.ts +5 -2
  220. package/dist/transitions/makeContent.js +217 -118
  221. package/dist/transitions/phaseRecord.d.ts +8 -2
  222. package/dist/transitions/placements.d.ts +1 -0
  223. package/dist/transitions/placements.js +4 -0
  224. package/dist/transitions/preflightData.d.ts +1 -1
  225. package/dist/transitions/preflightData.js +42 -4
  226. package/dist/transitions/releasePages.d.ts +8 -0
  227. package/dist/transitions/releasePages.js +26 -0
  228. package/dist/transitions/restoreContentEntry.d.ts +8 -0
  229. package/dist/transitions/restoreContentEntry.js +47 -0
  230. package/dist/transitions/start.js +30 -5
  231. package/dist/types/contracts.d.ts +14 -0
  232. package/dist/types/endpoints.d.ts +34 -3
  233. package/dist/types/index.d.ts +1 -0
  234. package/dist/types/index.js +1 -0
  235. package/dist/types/reasons.d.ts +3 -0
  236. package/dist/types/reasons.js +1 -0
  237. package/dist/types/snapshot.d.ts +6 -1
  238. package/dist/ui/Banner.d.ts +2 -0
  239. package/dist/ui/Banner.js +2 -0
  240. package/dist/ui/Breadcrumb.d.ts +7 -0
  241. package/dist/ui/Breadcrumb.js +25 -0
  242. package/dist/ui/Button.d.ts +15 -0
  243. package/dist/ui/Button.js +32 -0
  244. package/dist/ui/Card.d.ts +12 -0
  245. package/dist/ui/Card.js +40 -0
  246. package/dist/ui/Checkbox.d.ts +2 -0
  247. package/dist/ui/Checkbox.js +2 -0
  248. package/dist/{admin/components → ui}/ChipsInput.d.ts +4 -3
  249. package/dist/{admin/components → ui}/ChipsInput.js +20 -12
  250. package/dist/ui/Dialog.d.ts +13 -0
  251. package/dist/ui/Dialog.js +85 -0
  252. package/dist/ui/EmptyState.d.ts +2 -0
  253. package/dist/ui/EmptyState.js +2 -0
  254. package/dist/ui/Feedback.d.ts +24 -0
  255. package/dist/ui/Feedback.js +40 -0
  256. package/dist/ui/Inputs.d.ts +34 -0
  257. package/dist/ui/Inputs.js +225 -0
  258. package/dist/ui/NumberInput.d.ts +2 -0
  259. package/dist/ui/NumberInput.js +2 -0
  260. package/dist/ui/Range.d.ts +2 -0
  261. package/dist/ui/Range.js +2 -0
  262. package/dist/ui/SearchInput.d.ts +2 -0
  263. package/dist/ui/SearchInput.js +2 -0
  264. package/dist/ui/SectionCard.d.ts +2 -0
  265. package/dist/ui/SectionCard.js +2 -0
  266. package/dist/ui/Select.d.ts +2 -0
  267. package/dist/ui/Select.js +2 -0
  268. package/dist/ui/StatusChip.d.ts +2 -0
  269. package/dist/ui/StatusChip.js +2 -0
  270. package/dist/ui/Tabs.d.ts +14 -0
  271. package/dist/ui/Tabs.js +54 -0
  272. package/dist/ui/TextInput.d.ts +2 -0
  273. package/dist/ui/TextInput.js +2 -0
  274. package/dist/ui/Textarea.d.ts +2 -0
  275. package/dist/ui/Textarea.js +2 -0
  276. package/dist/ui/Toggle.d.ts +2 -0
  277. package/dist/ui/Toggle.js +2 -0
  278. package/dist/ui/accent.d.ts +21 -0
  279. package/dist/ui/accent.js +81 -0
  280. package/dist/ui/index.d.ts +9 -0
  281. package/dist/ui/index.js +9 -0
  282. package/dist/ui/ui.css +92 -0
  283. package/package.json +1 -1
  284. package/dist/admin/components/chipsInput.css +0 -11
  285. package/dist/admin/results/ArmTable.d.ts +0 -8
  286. package/dist/admin/results/ArmTable.js +0 -113
  287. package/dist/admin/results/VerdictCard.d.ts +0 -9
  288. package/dist/admin/surface/goals/GoalsBreadcrumb.d.ts +0 -5
  289. package/dist/admin/surface/goals/GoalsBreadcrumb.js +0 -47
  290. package/dist/admin/surface/test/TestHeader.d.ts +0 -4
  291. package/dist/admin/surface/test/TestHeader.js +0 -69
@@ -1,7 +1,8 @@
1
1
  'use client';
2
2
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
3
+ import { Button } from '../../../ui/Button.js';
3
4
  import { useId, useState } from 'react';
4
- import { ChipsInput } from '../../components/ChipsInput.js';
5
+ import { ChipsInput } from '../../../ui/ChipsInput.js';
5
6
  import { AUDIENCE_COPY } from '../../copy/audience.js';
6
7
  import { coerceValue, emptyListHint, humaniseAttribute, opLabel, opsFor, readListValue, readTargetingRules, valueInput } from '../../targeting/targeting.model.js';
7
8
  import { TEST_PAGE as C, NUMBER_COMPARISONS } from '../../copy/testPage.js';
@@ -17,145 +18,170 @@ export function TargetingSection({ test, surface }) {
17
18
  const update = (transform)=>save(test, 'targeting', ()=>({
18
19
  targeting: transform(readTargetingRules(test.doc.targeting ?? []))
19
20
  }));
20
- const keys = Object.keys(surface.attributeKeys);
21
- return /*#__PURE__*/ _jsx(Section, {
21
+ // Page block tests are scoped by their page; path rules belong to setting and flag tests (ruling Nov 3).
22
+ const blockPath = (key)=>test.doc.kind === 'block' && key === 'path';
23
+ const keys = Object.keys(surface.attributeKeys).filter((key)=>!blockPath(key));
24
+ return /*#__PURE__*/ _jsxs(Section, {
22
25
  test: test,
23
26
  sectionId: "who",
24
- children: /*#__PURE__*/ _jsxs("details", {
25
- children: [
26
- /*#__PURE__*/ _jsx("summary", {
27
- children: rules.length ? C.rulesSummary : C.everyone
28
- }),
29
- rules.map((rule, index)=>{
30
- const attribute = surface.attributeKeys[rule.attribute];
31
- const input = valueInput(attribute, rule.op);
32
- const setRule = (partial)=>update((current)=>current.map((row, i)=>i === index ? {
33
- ...row,
34
- ...partial
35
- } : row));
36
- const hint = emptyListHint(rule.op, rule.value);
37
- const changeValue = (raw)=>{
38
- const current = test.doc.targeting?.[index];
39
- const schema = current && surface.attributeKeys[current.attribute];
40
- if (!current || !schema) return;
41
- const value = coerceValue(schema.type, current.op, raw);
42
- if (value !== null) setRule({
43
- value
44
- });
45
- };
46
- return /*#__PURE__*/ _jsxs("div", {
47
- className: "xp-targeting-row",
48
- children: [
49
- /*#__PURE__*/ _jsx(SelectEdit, {
50
- label: C.attribute,
51
- reason: reason,
52
- value: rule.attribute,
53
- options: [
54
- ...keys,
55
- ...!attribute ? [
56
- rule.attribute
57
- ] : []
58
- ].map((key)=>({
59
- value: key,
60
- label: humaniseAttribute(key)
61
- })),
62
- onCommit: (value)=>{
63
- const key = String(value);
64
- const type = surface.attributeKeys[key].type;
65
- setRule({
66
- attribute: key,
67
- op: 'eq',
68
- value: type === 'boolean' ? false : type === 'number' ? 0 : ''
69
- });
70
- }
71
- }),
72
- /*#__PURE__*/ _jsx(SelectEdit, {
73
- label: C.comparison,
74
- reason: reason,
75
- value: rule.op,
76
- options: opsFor(attribute?.type).map((op)=>({
77
- value: op,
78
- label: attribute?.type === 'number' ? NUMBER_COMPARISONS[op] : opLabel(attribute.type, op)
79
- })),
80
- onCommit: (value)=>{
81
- const op = value;
82
- const current = readTargetingRules(test.doc.targeting ?? [])[index];
83
- setRule({
84
- op,
85
- value: coerceValue(attribute.type, op, current?.value) ?? ''
86
- });
87
- }
88
- }),
89
- input.kind === 'multiselect' ? /*#__PURE__*/ _jsx(CheckboxList, {
90
- label: C.value,
91
- reason: reason,
92
- value: readListValue(rule.value),
93
- options: input.options ?? [],
94
- onToggle: (value, checked)=>{
95
- const values = readListValue(test.doc.targeting?.[index]?.value);
96
- changeValue(checked ? [
97
- ...new Set([
98
- ...values,
99
- value
100
- ])
101
- ] : values.filter((saved)=>saved !== value));
102
- }
103
- }) : input.kind === 'chips' ? /*#__PURE__*/ _jsx(ChipsInput, {
104
- id: `${id}-${index}-value`,
105
- label: C.value,
106
- value: readListValue(rule.value),
107
- disabled: Boolean(reason),
108
- description: reason ?? AUDIENCE_COPY.listDescription,
109
- placeholder: AUDIENCE_COPY.listPlaceholder,
110
- onChange: changeValue
111
- }, `${rule.attribute}-${rule.op}`) : input.kind === 'select' ? /*#__PURE__*/ _jsx(SelectEdit, {
112
- label: C.value,
113
- reason: reason,
114
- value: String(rule.value),
115
- options: input.options ?? [],
116
- onCommit: changeValue
117
- }) : input.kind === 'boolean' ? /*#__PURE__*/ _jsx(SelectEdit, {
118
- label: C.value,
119
- reason: reason,
120
- value: String(rule.value),
121
- options: [
122
- {
123
- value: 'true',
124
- label: C.yes
125
- },
126
- {
127
- value: 'false',
128
- label: C.no
129
- }
130
- ],
131
- onCommit: changeValue
132
- }) : /*#__PURE__*/ _jsx(TextEdit, {
133
- label: C.value,
134
- reason: reason,
135
- value: Array.isArray(rule.value) ? rule.value.join(', ') : String(rule.value),
136
- type: input.kind === 'number' ? 'number' : 'text',
137
- onCommit: changeValue
138
- }),
139
- hint ? /*#__PURE__*/ _jsx("p", {
140
- children: hint
141
- }) : null,
142
- /*#__PURE__*/ _jsx(FieldErrors, {
143
- test: test,
144
- path: `targeting.${index}`
145
- }),
146
- !reason ? /*#__PURE__*/ _jsx("button", {
147
- type: "button",
148
- onClick: ()=>{
149
- setRowsRevision((revision)=>revision + 1);
150
- update((current)=>current.filter((_, i)=>i !== index));
27
+ children: [
28
+ /*#__PURE__*/ _jsx("p", {
29
+ children: rules.length ? C.rulesSummary : C.everyone
30
+ }),
31
+ rules.map((rule, index)=>{
32
+ const remove = ()=>{
33
+ setRowsRevision((revision)=>revision + 1);
34
+ update((current)=>current.filter((_, i)=>i !== index));
35
+ };
36
+ if (blockPath(rule.attribute)) return /*#__PURE__*/ _jsxs("div", {
37
+ className: "xp-targeting-row",
38
+ children: [
39
+ /*#__PURE__*/ _jsx("p", {
40
+ className: "xp-ui-help",
41
+ children: C.blockPathRule
42
+ }),
43
+ !reason ? /*#__PURE__*/ _jsx("div", {
44
+ className: "xp-ui-button-group",
45
+ children: /*#__PURE__*/ _jsx(Button, {
46
+ variant: "link",
47
+ size: "sm",
48
+ onClick: remove,
49
+ children: C.removeRule
50
+ })
51
+ }) : null
52
+ ]
53
+ }, `${rowsRevision}-${index}`);
54
+ const attribute = surface.attributeKeys[rule.attribute];
55
+ const input = valueInput(attribute, rule.op);
56
+ const setRule = (partial)=>update((current)=>current.map((row, i)=>i === index ? {
57
+ ...row,
58
+ ...partial
59
+ } : row));
60
+ const hint = emptyListHint(rule.op, rule.value);
61
+ const changeValue = (raw)=>{
62
+ const current = test.doc.targeting?.[index];
63
+ const schema = current && surface.attributeKeys[current.attribute];
64
+ if (!current || !schema) return;
65
+ const value = coerceValue(schema.type, current.op, raw);
66
+ if (value !== null) setRule({
67
+ value
68
+ });
69
+ };
70
+ return /*#__PURE__*/ _jsxs("div", {
71
+ className: "xp-targeting-row",
72
+ children: [
73
+ /*#__PURE__*/ _jsx(SelectEdit, {
74
+ label: C.attribute,
75
+ reason: reason,
76
+ value: rule.attribute,
77
+ options: [
78
+ ...keys,
79
+ ...!attribute ? [
80
+ rule.attribute
81
+ ] : []
82
+ ].map((key)=>({
83
+ value: key,
84
+ label: humaniseAttribute(key)
85
+ })),
86
+ onCommit: (value)=>{
87
+ const key = String(value);
88
+ const type = surface.attributeKeys[key].type;
89
+ setRule({
90
+ attribute: key,
91
+ op: 'eq',
92
+ value: type === 'boolean' ? false : type === 'number' ? 0 : ''
93
+ });
94
+ }
95
+ }),
96
+ /*#__PURE__*/ _jsx(SelectEdit, {
97
+ label: C.comparison,
98
+ reason: reason,
99
+ value: rule.op,
100
+ options: opsFor(attribute?.type).map((op)=>({
101
+ value: op,
102
+ label: attribute?.type === 'number' ? NUMBER_COMPARISONS[op] : opLabel(attribute.type, op)
103
+ })),
104
+ onCommit: (value)=>{
105
+ const op = value;
106
+ const current = readTargetingRules(test.doc.targeting ?? [])[index];
107
+ setRule({
108
+ op,
109
+ value: coerceValue(attribute.type, op, current?.value) ?? ''
110
+ });
111
+ }
112
+ }),
113
+ input.kind === 'multiselect' ? /*#__PURE__*/ _jsx(CheckboxList, {
114
+ label: C.value,
115
+ reason: reason,
116
+ value: readListValue(rule.value),
117
+ options: input.options ?? [],
118
+ onToggle: (value, checked)=>{
119
+ const values = readListValue(test.doc.targeting?.[index]?.value);
120
+ changeValue(checked ? [
121
+ ...new Set([
122
+ ...values,
123
+ value
124
+ ])
125
+ ] : values.filter((saved)=>saved !== value));
126
+ }
127
+ }) : input.kind === 'chips' ? /*#__PURE__*/ _jsx(ChipsInput, {
128
+ id: `${id}-${index}-value`,
129
+ label: C.value,
130
+ value: readListValue(rule.value),
131
+ disabled: Boolean(reason),
132
+ description: reason ?? AUDIENCE_COPY.listDescription,
133
+ placeholder: AUDIENCE_COPY.listPlaceholder,
134
+ onChange: changeValue
135
+ }, `${rule.attribute}-${rule.op}`) : input.kind === 'select' ? /*#__PURE__*/ _jsx(SelectEdit, {
136
+ label: C.value,
137
+ reason: reason,
138
+ value: String(rule.value),
139
+ options: input.options ?? [],
140
+ onCommit: changeValue
141
+ }) : input.kind === 'boolean' ? /*#__PURE__*/ _jsx(SelectEdit, {
142
+ label: C.value,
143
+ reason: reason,
144
+ value: String(rule.value),
145
+ options: [
146
+ {
147
+ value: 'true',
148
+ label: C.yes
151
149
  },
150
+ {
151
+ value: 'false',
152
+ label: C.no
153
+ }
154
+ ],
155
+ onCommit: changeValue
156
+ }) : /*#__PURE__*/ _jsx(TextEdit, {
157
+ label: C.value,
158
+ reason: reason,
159
+ value: Array.isArray(rule.value) ? rule.value.join(', ') : String(rule.value),
160
+ type: input.kind === 'number' ? 'number' : 'text',
161
+ onCommit: changeValue
162
+ }),
163
+ hint ? /*#__PURE__*/ _jsx("p", {
164
+ children: hint
165
+ }) : null,
166
+ /*#__PURE__*/ _jsx(FieldErrors, {
167
+ test: test,
168
+ path: `targeting.${index}`
169
+ }),
170
+ !reason ? /*#__PURE__*/ _jsx("div", {
171
+ className: "xp-ui-button-group",
172
+ children: /*#__PURE__*/ _jsx(Button, {
173
+ variant: "link",
174
+ size: "sm",
175
+ onClick: remove,
152
176
  children: C.removeRule
153
- }) : null
154
- ]
155
- }, `${rowsRevision}-${index}`);
156
- }),
157
- !reason ? /*#__PURE__*/ _jsx("button", {
158
- type: "button",
177
+ })
178
+ }) : null
179
+ ]
180
+ }, `${rowsRevision}-${index}`);
181
+ }),
182
+ !reason ? /*#__PURE__*/ _jsx("div", {
183
+ className: "xp-ui-button-group",
184
+ children: /*#__PURE__*/ _jsx(Button, {
159
185
  disabled: !keys.length,
160
186
  onClick: ()=>{
161
187
  const attribute = keys[0];
@@ -170,12 +196,12 @@ export function TargetingSection({ test, surface }) {
170
196
  ]);
171
197
  },
172
198
  children: C.addRule
173
- }) : null,
174
- /*#__PURE__*/ _jsx(FieldErrors, {
175
- test: test,
176
- path: "targeting"
177
199
  })
178
- ]
179
- })
200
+ }) : null,
201
+ /*#__PURE__*/ _jsx(FieldErrors, {
202
+ test: test,
203
+ path: "targeting"
204
+ })
205
+ ]
180
206
  });
181
207
  }
@@ -1,7 +1,8 @@
1
1
  import type { DocId } from '../../../types/contracts.js';
2
2
  import type { SurfaceProps } from '../contracts.js';
3
3
  import './testPage.css';
4
- export declare function TestPage({ id, surface }: {
4
+ export declare function TestPage({ id, surface, onTitleChange }: {
5
5
  id: DocId;
6
6
  surface: SurfaceProps;
7
+ onTitleChange?: (title: string) => void;
7
8
  }): import("react").JSX.Element;
@@ -1,84 +1,171 @@
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 { useEffect, useState } from 'react';
4
+ import { formatAdminURL } from 'payload/shared';
3
5
  import { useTestDocument } from '../useTestDocument.js';
4
6
  import { TEST_PAGE as C } from '../../copy/testPage.js';
5
7
  import { pageBlockParts } from '../pageBlock/parts.js';
6
8
  import { settingParts } from '../setting/parts.js';
7
9
  import { pageParts } from './pageParts.js';
8
- import { TestHeader } from './TestHeader.js';
9
10
  import { Section } from './Section.js';
10
- import { Hypothesis } from './fields.js';
11
+ import { Hypothesis, TestName } from './fields.js';
11
12
  import { VersionsSection } from './VersionsSection.js';
12
13
  import { GoalSection } from './GoalSection.js';
13
14
  import { TargetingSection } from './TargetingSection.js';
14
15
  import { LengthSection } from './LengthSection.js';
15
16
  import { AdvancedSection } from './AdvancedSection.js';
17
+ import { SurfaceShell } from '../SurfaceShell.js';
18
+ import { Button } from '../../../ui/Button.js';
19
+ import { Banner, StatusChip } from '../../../ui/Feedback.js';
20
+ import { Rail } from './Rail.js';
21
+ import { ReadinessBar } from './ReadinessBar.js';
16
22
  import './testPage.css';
17
- export function TestPage({ id, surface }) {
23
+ export function TestPage({ id, surface, onTitleChange }) {
24
+ const [barHeight, setBarHeight] = useState();
18
25
  const test = useTestDocument(id, {
19
26
  apiRoute: surface.apiRoute
20
27
  });
21
- if (test.loadState !== 'ready' || !test.doc) return /*#__PURE__*/ _jsxs("div", {
22
- className: "xp-test-page",
23
- role: test.loadState === 'error' ? 'alert' : 'status',
24
- children: [
25
- /*#__PURE__*/ _jsx("p", {
26
- children: test.loadState === 'forbidden' ? C.forbidden : test.loadState === 'missing' ? C.missing : test.loadState === 'error' ? C.error : C.loading
27
- }),
28
- test.loadState === 'error' ? /*#__PURE__*/ _jsx("button", {
29
- type: "button",
30
- onClick: ()=>void test.reload(),
31
- children: C.retry
32
- }) : null
33
- ]
28
+ useEffect(()=>{
29
+ if (test.doc?.name) onTitleChange?.(test.doc.name);
30
+ }, [
31
+ test.doc?.name,
32
+ onTitleChange
33
+ ]);
34
+ if (test.loadState !== 'ready' || !test.doc) return /*#__PURE__*/ _jsx(SurfaceShell, {
35
+ adminRoute: surface.adminRoute,
36
+ title: C.test,
37
+ crumbs: [
38
+ {
39
+ label: C.tests,
40
+ href: formatAdminURL({
41
+ adminRoute: surface.adminRoute,
42
+ path: '/experiments'
43
+ })
44
+ },
45
+ {
46
+ label: C.test
47
+ }
48
+ ],
49
+ children: /*#__PURE__*/ _jsxs("div", {
50
+ className: "xp-test-page",
51
+ role: test.loadState === 'error' ? 'alert' : 'status',
52
+ children: [
53
+ /*#__PURE__*/ _jsx("p", {
54
+ children: test.loadState === 'forbidden' ? C.forbidden : test.loadState === 'missing' ? C.missing : test.loadState === 'error' ? C.error : C.loading
55
+ }),
56
+ test.loadState === 'error' ? /*#__PURE__*/ _jsx(Button, {
57
+ onClick: ()=>void test.reload(),
58
+ children: C.retry
59
+ }) : null
60
+ ]
61
+ })
34
62
  });
35
63
  const parts = test.doc.kind === 'block' ? pageBlockParts : test.doc.kind === 'page' ? pageParts : settingParts;
36
64
  const props = {
37
65
  test,
38
66
  surface
39
67
  };
40
- return /*#__PURE__*/ _jsxs("main", {
41
- className: "xp-test-page",
42
- children: [
43
- /*#__PURE__*/ _jsx(TestHeader, {
44
- ...props
45
- }),
46
- test.errors._section ? /*#__PURE__*/ _jsx("p", {
47
- role: "alert",
48
- children: test.errors._section
49
- }) : null,
50
- test.preflightError ? /*#__PURE__*/ _jsx("p", {
51
- role: "alert",
52
- children: test.preflightError
53
- }) : null,
54
- /*#__PURE__*/ _jsxs(Section, {
55
- test: test,
56
- sectionId: "what",
57
- children: [
58
- /*#__PURE__*/ _jsx(parts.Binding, {
59
- ...props
60
- }),
61
- /*#__PURE__*/ _jsx(Hypothesis, {
62
- ...props
63
- })
64
- ]
65
- }),
66
- /*#__PURE__*/ _jsx(VersionsSection, {
67
- ...props,
68
- parts: parts
69
- }),
70
- /*#__PURE__*/ _jsx(GoalSection, {
71
- ...props
72
- }),
73
- /*#__PURE__*/ _jsx(TargetingSection, {
74
- ...props
75
- }),
76
- /*#__PURE__*/ _jsx(LengthSection, {
77
- ...props
68
+ return /*#__PURE__*/ _jsx(SurfaceShell, {
69
+ adminRoute: surface.adminRoute,
70
+ title: test.doc.name,
71
+ crumbs: [
72
+ {
73
+ label: C.tests,
74
+ href: formatAdminURL({
75
+ adminRoute: surface.adminRoute,
76
+ path: '/experiments'
77
+ })
78
+ },
79
+ {
80
+ label: test.doc.name
81
+ }
82
+ ],
83
+ status: /*#__PURE__*/ _jsxs(_Fragment, {
84
+ children: [
85
+ /*#__PURE__*/ _jsx("span", {
86
+ className: "xp-tests-kind",
87
+ children: C.kinds[test.doc.kind]
88
+ }),
89
+ /*#__PURE__*/ _jsx(StatusChip, {
90
+ status: test.doc.status
91
+ })
92
+ ]
93
+ }),
94
+ actions: surface.canReadResults && [
95
+ 'running',
96
+ 'stopped',
97
+ 'decided'
98
+ ].includes(test.doc.status) ? /*#__PURE__*/ _jsx(Button, {
99
+ variant: "secondary",
100
+ href: formatAdminURL({
101
+ adminRoute: surface.adminRoute,
102
+ path: `/experiments/${encodeURIComponent(String(test.doc.id))}/results`
78
103
  }),
79
- /*#__PURE__*/ _jsx(AdvancedSection, {
80
- ...props
81
- })
82
- ]
104
+ children: C.results
105
+ }) : undefined,
106
+ children: /*#__PURE__*/ _jsxs("div", {
107
+ className: "xp-test-page xp-test-page--setup",
108
+ style: {
109
+ paddingBottom: barHeight === undefined ? undefined : `${barHeight}px`
110
+ },
111
+ children: [
112
+ /*#__PURE__*/ _jsxs("div", {
113
+ className: "xp-test-layout",
114
+ children: [
115
+ /*#__PURE__*/ _jsx(Rail, {
116
+ test: test
117
+ }),
118
+ /*#__PURE__*/ _jsxs("div", {
119
+ className: "xp-test-content",
120
+ children: [
121
+ test.errors._section ? /*#__PURE__*/ _jsx(Banner, {
122
+ tone: "error",
123
+ action: test.stale ? /*#__PURE__*/ _jsx(Button, {
124
+ onClick: ()=>void test.reload(),
125
+ children: C.reload
126
+ }) : undefined,
127
+ children: test.errors._section
128
+ }) : null,
129
+ /*#__PURE__*/ _jsxs(Section, {
130
+ test: test,
131
+ sectionId: "what",
132
+ children: [
133
+ /*#__PURE__*/ _jsx(TestName, {
134
+ ...props
135
+ }),
136
+ /*#__PURE__*/ _jsx(parts.Binding, {
137
+ ...props
138
+ }),
139
+ /*#__PURE__*/ _jsx(Hypothesis, {
140
+ ...props
141
+ })
142
+ ]
143
+ }),
144
+ /*#__PURE__*/ _jsx(VersionsSection, {
145
+ ...props,
146
+ parts: parts
147
+ }),
148
+ /*#__PURE__*/ _jsx(GoalSection, {
149
+ ...props
150
+ }),
151
+ /*#__PURE__*/ _jsx(TargetingSection, {
152
+ ...props
153
+ }),
154
+ /*#__PURE__*/ _jsx(LengthSection, {
155
+ ...props
156
+ }),
157
+ /*#__PURE__*/ _jsx(AdvancedSection, {
158
+ ...props
159
+ })
160
+ ]
161
+ })
162
+ ]
163
+ }),
164
+ /*#__PURE__*/ _jsx(ReadinessBar, {
165
+ ...props,
166
+ onHeightChange: setBarHeight
167
+ })
168
+ ]
169
+ })
83
170
  });
84
171
  }