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

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 (65) hide show
  1. package/dist/admin/copy/newTest.d.ts +1 -1
  2. package/dist/admin/copy/newTest.js +1 -1
  3. package/dist/admin/surface/newTest/NewTest.js +16 -18
  4. package/dist/admin/surface/newTest/newTest.css +3 -1
  5. package/dist/blocks/bindings.js +6 -13
  6. package/dist/blocks/placementLocale.d.ts +2 -0
  7. package/dist/blocks/placementLocale.js +16 -12
  8. package/dist/goals/fairness.js +8 -6
  9. package/dist/hooks/blockRemovalRule.d.ts +2 -1
  10. package/dist/hooks/blockRemovalRule.js +27 -5
  11. package/dist/hooks/pageGuard.js +2 -2
  12. package/dist/puck/ExperimentPicker.d.ts +2 -1
  13. package/dist/puck/ExperimentPicker.js +34 -30
  14. package/dist/puck/ExperimentSlot.js +3 -1
  15. package/dist/puck/copy.d.ts +1 -0
  16. package/dist/puck/copy.js +1 -0
  17. package/dist/puck/editor/CreateExperimentDrawer.d.ts +2 -1
  18. package/dist/puck/editor/CreateExperimentDrawer.js +24 -20
  19. package/dist/puck/editor/EditorControls.d.ts +1 -1
  20. package/dist/puck/editor/EditorControls.js +1 -1
  21. package/dist/puck/editor/ExperimentSlotEditor.js +354 -374
  22. package/dist/puck/editor/LeftoverVersions.d.ts +3 -1
  23. package/dist/puck/editor/LeftoverVersions.js +45 -63
  24. package/dist/puck/editor/QuickTestActions.js +2 -2
  25. package/dist/puck/editor/VersionBuilder.d.ts +24 -13
  26. package/dist/puck/editor/VersionBuilder.js +264 -205
  27. package/dist/puck/editor/armWrites.d.ts +9 -2
  28. package/dist/puck/editor/armWrites.js +40 -2
  29. package/dist/puck/editor/armsCache.d.ts +1 -1
  30. package/dist/puck/editor/armsCache.js +2 -1
  31. package/dist/puck/editor/copy.d.ts +19 -25
  32. package/dist/puck/editor/copy.js +19 -25
  33. package/dist/puck/editor/createTest.d.ts +3 -0
  34. package/dist/puck/editor/createTest.js +33 -0
  35. package/dist/puck/editor/editor.chrome.css +24 -17
  36. package/dist/puck/editor/editor.css +33 -21
  37. package/dist/puck/editor/editor.model.d.ts +1 -1
  38. package/dist/puck/editor/editor.model.js +2 -2
  39. package/dist/puck/editor/experimentOutlinePlugin.js +1 -1
  40. package/dist/puck/editor/localPlacements.d.ts +4 -2
  41. package/dist/puck/editor/localPlacements.js +20 -18
  42. package/dist/puck/editor/sidebar.d.ts +2 -6
  43. package/dist/puck/editor/sidebar.js +3 -6
  44. package/dist/puck/visibility.d.ts +21 -0
  45. package/dist/puck/visibility.js +77 -0
  46. package/dist/server/recordContentChange.js +3 -1
  47. package/dist/server/resolveExperimentData.js +4 -1
  48. package/dist/testSurface/copy/readiness.d.ts +1 -0
  49. package/dist/testSurface/copy/readiness.js +1 -0
  50. package/dist/testSurface/copy/testPage.d.ts +7 -6
  51. package/dist/testSurface/copy/testPage.js +7 -6
  52. package/dist/testSurface/results/results.css +1 -1
  53. package/dist/testSurface/results/results.model.d.ts +1 -1
  54. package/dist/testSurface/surface/readiness/ActionDialogs.js +28 -34
  55. package/dist/testSurface/surface/test/GoalSection.js +101 -74
  56. package/dist/testSurface/surface/test/fields.d.ts +1 -3
  57. package/dist/testSurface/surface/test/fields.js +5 -35
  58. package/dist/transitions/makeContent.js +24 -5
  59. package/dist/transitions/placements.js +23 -34
  60. package/dist/types/puck.d.ts +1 -0
  61. package/dist/ui/Inputs.js +8 -5
  62. package/dist/ui/Tabs.d.ts +0 -1
  63. package/dist/ui/Tabs.js +28 -40
  64. package/dist/ui/ui.css +9 -4
  65. package/package.json +1 -1
@@ -1,10 +1,46 @@
1
1
  import { checkArms } from '../../collections/experiments/armInvariants.js';
2
2
  import { issueMessage } from '../../arms/copy.js';
3
- import { totalWeight, withSlotsFor } from '../../arms/model.js';
3
+ import { addVariant, balanceWeight, removeArm, splitEvenly, totalWeight, withSlotsFor } from '../../arms/model.js';
4
4
  import { XP_IF_UPDATED_AT_HEADER } from '../../constants.js';
5
+ import { slotLabels } from '../copy.js';
5
6
  import { editorCopy, writeRefusal } from './copy.js';
6
7
  export class ArmWriteError extends Error {
7
8
  }
9
+ /** Refuse obsolete intents before a no-op can become a successful PATCH. */ export function removeVersionArms(arms, key) {
10
+ if (!arms.some((arm)=>arm.key === key && arm.kind !== 'control')) throw new ArmWriteError(editorCopy.staleEdit);
11
+ return splitEvenly(removeArm(arms, key));
12
+ }
13
+ export function addVersionArms(arms) {
14
+ const next = addVariant(arms, 'block');
15
+ if (next.length === arms.length) throw new ArmWriteError(editorCopy.staleEdit);
16
+ return next;
17
+ }
18
+ export function setVersionTraffic(arms, key, weight) {
19
+ if (!arms.some((arm)=>arm.key === key) || arms.length < 2) throw new ArmWriteError(editorCopy.staleEdit);
20
+ return balanceWeight(arms, key, weight);
21
+ }
22
+ export function renameVersionArms(arms, key, label) {
23
+ if (!arms.some((arm)=>arm.key === key)) throw new ArmWriteError(editorCopy.staleEdit);
24
+ return arms.map((arm)=>arm.key === key ? {
25
+ ...arm,
26
+ label
27
+ } : arm);
28
+ }
29
+ export function addLeftoverArms(arms, slot) {
30
+ if (slot === 'control' || arms.some((arm)=>arm.key === slot) || !arms.some((arm)=>arm.kind === 'control') || arms.filter((arm)=>arm.kind === 'variant').length >= 3) throw new ArmWriteError(editorCopy.staleEdit);
31
+ const next = [
32
+ ...arms
33
+ ];
34
+ const holdout = next.findIndex((arm)=>arm.kind === 'holdout');
35
+ next.splice(holdout < 0 ? next.length : holdout, 0, {
36
+ key: slot,
37
+ slot,
38
+ kind: 'variant',
39
+ label: slotLabels[slot],
40
+ weight: 0
41
+ });
42
+ return next;
43
+ }
8
44
  export async function readExperiment(url, signal) {
9
45
  const response = await fetch(url, {
10
46
  credentials: 'include',
@@ -33,7 +69,9 @@ export async function readExperiment(url, signal) {
33
69
  }
34
70
  /** Each intent is applied to a fresh document, guarded by the collection's compare-and-set header. */ export async function writeArms(url, transform, publish, { draftOnly = false } = {}) {
35
71
  const fresh = await readExperiment(`${url}?depth=0`);
36
- publish(fresh);
72
+ const accepted = publish(fresh) ?? fresh;
73
+ // A later cache read can supersede this baseline before this GET finishes.
74
+ if (accepted.updatedAt !== fresh.updatedAt) throw new ArmWriteError(editorCopy.staleEdit);
37
75
  if (draftOnly && fresh.status !== 'draft') throw new ArmWriteError(editorCopy.draftOnly);
38
76
  if (fresh.status !== 'draft' && fresh.status !== 'stopped') throw new ArmWriteError(editorCopy.locked[fresh.status]);
39
77
  if (!fresh.updatedAt || !Array.isArray(fresh.arms)) throw new ArmWriteError(editorCopy.writeUnreadable);
@@ -9,7 +9,7 @@ export declare function acquireArms(testId: DocId): () => void;
9
9
  /** Share the request, but abort it only after its last mounted consumer leaves. */
10
10
  export declare function loadArms(testId: DocId, load: (signal: AbortSignal) => Promise<EditorExperiment>, signal: AbortSignal): Promise<EditorExperiment>;
11
11
  export declare function subscribe(listener: () => void): () => void;
12
- export declare function publishExperiment(testId: DocId, doc: EditorExperiment): void;
12
+ export declare function publishExperiment(testId: DocId, doc: EditorExperiment): EditorExperiment;
13
13
  /** undefined means unknown. */
14
14
  export declare function setArms(testId: DocId, arms: string[] | undefined): void;
15
15
  export declare function useArms(testId: DocId | undefined): Arms | undefined;
@@ -71,13 +71,14 @@ export function publishExperiment(testId, doc) {
71
71
  const previous = cache.get(String(testId))?.doc;
72
72
  // Surface reads and chrome writes share this producer too. A GET that began
73
73
  // before a save cannot overwrite its newer server timestamp when it finishes.
74
- if (previous?.updatedAt && doc.updatedAt && Date.parse(previous.updatedAt) > Date.parse(doc.updatedAt)) return;
74
+ if (previous?.updatedAt && doc.updatedAt && Date.parse(previous.updatedAt) > Date.parse(doc.updatedAt)) return previous;
75
75
  revisions.set(String(testId), (revisions.get(String(testId)) ?? 0) + 1);
76
76
  cache.set(String(testId), {
77
77
  arms: doc.arms.map((arm)=>arm.key),
78
78
  doc
79
79
  });
80
80
  for (const listener of listeners)listener();
81
+ return doc;
81
82
  }
82
83
  /** undefined means unknown. */ export function setArms(testId, arms) {
83
84
  revisions.set(String(testId), (revisions.get(String(testId)) ?? 0) + 1);
@@ -1,4 +1,6 @@
1
1
  export declare const editorCopy: {
2
+ readonly hidden: "This block is hidden, so visitors won't see this test here.";
3
+ readonly hiddenOn: (sizes: string) => string;
2
4
  readonly retrySetup: "Retry";
3
5
  readonly controlsUnavailable: "Test controls couldn't load.";
4
6
  readonly setupForbidden: "You don't have access to set up tests.";
@@ -14,29 +16,22 @@ export declare const editorCopy: {
14
16
  readonly openInTab: "Open in a new tab";
15
17
  readonly closeConfigure: "Close";
16
18
  readonly selectBlock: "Select this test block";
17
- readonly placementsError: "Couldn't check where this test is used. Try again.";
18
- readonly notSetUp: "Not set up";
19
- readonly unbound: "Choose or create a test to show different versions.";
20
- readonly draft: "This block shows the Original to everyone until the test starts.";
19
+ readonly deleted: "The test for this block was deleted.";
20
+ readonly unbound: "This Experiment block has no test yet.";
21
+ readonly draft: (label: string) => string;
21
22
  readonly running: "Changing this content mid-test mixes two versions in one result";
22
23
  readonly decided: (winner: string) => string;
23
24
  readonly archived: "This test is archived; the winning content is shown to everyone.";
24
- readonly copy: "Copy Original here";
25
- readonly copyEmpty: "Add content to the Original before copying it.";
25
+ readonly copy: (label?: string) => string;
26
+ readonly copyEmpty: (label?: string) => string;
26
27
  readonly enterName: "Enter a name to create the test.";
27
- readonly loadingBeforeNew: "Wait for this test to load before starting a new one.";
28
- readonly checkingRemoval: "Checking whether this test can be removed…";
29
- readonly dropZone: (slot: "control" | "variantA" | "variantB" | "variantC") => string;
30
- readonly replaceConfirm: (label: string) => string;
28
+ readonly dropZone: (label: string) => string;
29
+ readonly replaceConfirm: (label: string, original?: string) => string;
31
30
  readonly replace: "Replace";
32
- readonly createLabel: "Test this block";
33
- readonly newTest: "Start a new test from this block";
31
+ readonly pageFallback: "Page";
32
+ readonly createLabel: "Set up test";
33
+ readonly existingTest: "Use an existing test";
34
34
  readonly sharedTest: "This test is also used in another place. Changes here affect that test.";
35
- readonly detach: "Remove the test from this block";
36
- readonly detachTitle: "Remove the test from this block?";
37
- readonly detachHelp: "Show the Original on this page? All version content stays in this block. The test and its results are kept. Save the page to keep this change.";
38
- readonly stopToDetach: "Stop the test to remove it from this block.";
39
- readonly detachRunningHelp: "Show the Original here? The test keeps running in its other place. All version content stays in this block. Save the page to keep this change.";
40
35
  readonly createdUnbound: "The test was created, but this block changed or was removed. Open the test to continue.";
41
36
  readonly creating: "Creating…";
42
37
  readonly cancel: "Cancel";
@@ -53,20 +48,19 @@ export declare const editorCopy: {
53
48
  readonly deleteContent: "Delete its content";
54
49
  readonly deleteContentTitle: (label: string) => string;
55
50
  readonly deleteContentHelp: (label: string, count: number) => string;
56
- readonly draftOnly: "Only draft tests can add this version. Start a new test from this block to include it.";
57
- readonly leftovers: (labels: string) => string;
51
+ readonly draftOnly: "Only draft tests can add this version. Use a different test to include it.";
58
52
  readonly outsideTest: (label: string) => string;
59
53
  readonly tabs: "Test versions";
60
54
  readonly add: "Add variant";
61
- readonly menu: (label: string) => string;
62
55
  readonly testGroup: "Test";
63
56
  readonly versionsGroup: "Versions";
64
- readonly actionsGroup: "Actions";
65
- readonly options: "Options";
66
- readonly runningVersions: "Versions can't change while the test runs.";
57
+ readonly moreGroup: "More";
58
+ readonly differentTest: "Use a different test";
59
+ readonly createAnother: "Create a test";
60
+ readonly readOnlyVersions: "You don't have permission to change this test's versions.";
61
+ readonly traffic: "Traffic (%)";
62
+ readonly saved: "Saved";
67
63
  readonly removeVersion: "Remove version";
68
- readonly rename: "Rename";
69
- readonly renameLabel: "Version name";
70
64
  readonly emptyLabel: "Enter a name for this version.";
71
65
  readonly remove: "Remove";
72
66
  readonly removeTitle: (label: string) => string;
@@ -1,5 +1,7 @@
1
1
  import { ARM_LABELS } from '../../labels/arms.js';
2
2
  export const editorCopy = {
3
+ hidden: "This block is hidden, so visitors won't see this test here.",
4
+ hiddenOn: (sizes)=>`This block is hidden on ${sizes}. Visitors on ${sizes} are still counted in this test.`,
3
5
  retrySetup: 'Retry',
4
6
  controlsUnavailable: "Test controls couldn't load.",
5
7
  setupForbidden: "You don't have access to set up tests.",
@@ -9,29 +11,22 @@ export const editorCopy = {
9
11
  openInTab: 'Open in a new tab',
10
12
  closeConfigure: 'Close',
11
13
  selectBlock: 'Select this test block',
12
- placementsError: "Couldn't check where this test is used. Try again.",
13
- notSetUp: 'Not set up',
14
- unbound: 'Choose or create a test to show different versions.',
15
- draft: 'This block shows the Original to everyone until the test starts.',
14
+ deleted: 'The test for this block was deleted.',
15
+ unbound: 'This Experiment block has no test yet.',
16
+ draft: (label)=>`This block shows the ${label} to everyone until the test starts.`,
16
17
  running: 'Changing this content mid-test mixes two versions in one result',
17
18
  decided: (winner)=>`Decided: ${winner}. Use 'Make it the content' on the test to finish.`,
18
19
  archived: 'This test is archived; the winning content is shown to everyone.',
19
- copy: 'Copy Original here',
20
- copyEmpty: 'Add content to the Original before copying it.',
20
+ copy: (label = ARM_LABELS.control)=>`Copy ${label} here`,
21
+ copyEmpty: (label = ARM_LABELS.control)=>`Add content to the ${label} before copying it.`,
21
22
  enterName: 'Enter a name to create the test.',
22
- loadingBeforeNew: 'Wait for this test to load before starting a new one.',
23
- checkingRemoval: 'Checking whether this test can be removed…',
24
- dropZone: (slot)=>slot === 'control' ? 'Drop the original content here' : `Drop ${editorCopy.labels[slot]} content here`,
25
- replaceConfirm: (label)=>`${label} already has content. Replace it with a copy of the Original?`,
23
+ dropZone: (label)=>`Drop ${label} content here`,
24
+ replaceConfirm: (label, original = ARM_LABELS.control)=>`${label} already has content. Replace it with a copy of the ${original}?`,
26
25
  replace: 'Replace',
27
- createLabel: 'Test this block',
28
- newTest: 'Start a new test from this block',
26
+ pageFallback: 'Page',
27
+ createLabel: 'Set up test',
28
+ existingTest: 'Use an existing test',
29
29
  sharedTest: 'This test is also used in another place. Changes here affect that test.',
30
- detach: 'Remove the test from this block',
31
- detachTitle: 'Remove the test from this block?',
32
- detachHelp: 'Show the Original on this page? All version content stays in this block. The test and its results are kept. Save the page to keep this change.',
33
- stopToDetach: 'Stop the test to remove it from this block.',
34
- detachRunningHelp: 'Show the Original here? The test keeps running in its other place. All version content stays in this block. Save the page to keep this change.',
35
30
  createdUnbound: 'The test was created, but this block changed or was removed. Open the test to continue.',
36
31
  creating: 'Creating…',
37
32
  cancel: 'Cancel',
@@ -48,20 +43,19 @@ export const editorCopy = {
48
43
  deleteContent: 'Delete its content',
49
44
  deleteContentTitle: (label)=>`Delete ${label} content?`,
50
45
  deleteContentHelp: (label, count)=>`This deletes the ${count} ${count === 1 ? 'block' : 'blocks'} in ${label} from this page. Save the page to keep this change.`,
51
- draftOnly: 'Only draft tests can add this version. Start a new test from this block to include it.',
52
- leftovers: (labels)=>`3 versions have content outside this test: ${labels}. Visitors never see them.`,
46
+ draftOnly: 'Only draft tests can add this version. Use a different test to include it.',
53
47
  outsideTest: (label)=>`${label} · not in this test`,
54
48
  tabs: 'Test versions',
55
49
  add: 'Add variant',
56
- menu: (label)=>`Options for ${label}`,
57
50
  testGroup: 'Test',
58
51
  versionsGroup: 'Versions',
59
- actionsGroup: 'Actions',
60
- options: 'Options',
61
- runningVersions: "Versions can't change while the test runs.",
52
+ moreGroup: 'More',
53
+ differentTest: 'Use a different test',
54
+ createAnother: 'Create a test',
55
+ readOnlyVersions: "You don't have permission to change this test's versions.",
56
+ traffic: 'Traffic (%)',
57
+ saved: 'Saved',
62
58
  removeVersion: 'Remove version',
63
- rename: 'Rename',
64
- renameLabel: 'Version name',
65
59
  emptyLabel: 'Enter a name for this version.',
66
60
  remove: 'Remove',
67
61
  removeTitle: (label)=>`Remove ${label}?`,
@@ -5,3 +5,6 @@ export declare class CreateRefused extends Error {
5
5
  }
6
6
  /** Shared lookup, complete draft creation and one retry for a racing slug collision. */
7
7
  export declare function createTest(api: string, input: Omit<Parameters<typeof newTestBody>[0], 'slug'>): Promise<ExperimentRef>;
8
+ /** Choose a free display name before the existing slug/creation path. Called only by Set up test.
9
+ * Names are not unique: two editors may choose the same display name. Slugs are guarded separately. */
10
+ export declare function createBlockTest(api: string, pageTitle: string, arms: Parameters<typeof newTestBody>[0]['arms']): Promise<ExperimentRef>;
@@ -1,3 +1,4 @@
1
+ import { fetchAllDocs } from '../../lib/fetchAllDocs.js';
1
2
  import { editorCopy } from './copy.js';
2
3
  import { isSlugCollision, newTestBody, slugify, slugCandidate } from './editor.model.js';
3
4
  /** Only a server refusal may supply editor-facing error text. */ export class CreateRefused extends Error {
@@ -59,3 +60,35 @@ function refusalMessage(body) {
59
60
  };
60
61
  }
61
62
  }
63
+ // Keep generated names readable and bounded, including the numbered suffix.
64
+ const NAME_MAX_LENGTH = 200;
65
+ function blockTestName(title, index) {
66
+ const suffix = index === 1 ? ' test' : ` test ${index}`;
67
+ // Do not leave half a surrogate pair at the title boundary.
68
+ return title.slice(0, NAME_MAX_LENGTH - suffix.length).replace(/[\uD800-\uDBFF]$/, '').trimEnd() + suffix;
69
+ }
70
+ /** Choose a free display name before the existing slug/creation path. Called only by Set up test.
71
+ * Names are not unique: two editors may choose the same display name. Slugs are guarded separately. */ export async function createBlockTest(api, pageTitle, arms) {
72
+ const title = pageTitle.trim() || editorCopy.pageFallback;
73
+ const base = blockTestName(title, 1);
74
+ // A short common prefix also matches candidates whose title is trimmed for a number.
75
+ const query = new URLSearchParams({
76
+ depth: '0',
77
+ 'select[name]': 'true',
78
+ 'where[name][like]': base.slice(0, 64).replace(/[\uD800-\uDBFF]$/, '')
79
+ });
80
+ const response = await fetchAllDocs(`${api}/xp-experiments?${query}`, {
81
+ credentials: 'include'
82
+ });
83
+ if (!response.ok) throw new CreateRefused(refusalMessage(response.body));
84
+ const taken = new Set(response.docs.map((doc)=>doc.name));
85
+ for(let index = 1;; index++){
86
+ const name = blockTestName(title, index);
87
+ if (!taken.has(name)) return createTest(api, {
88
+ name,
89
+ kind: 'block',
90
+ unitType: 'visitor',
91
+ arms
92
+ });
93
+ }
94
+ }
@@ -18,7 +18,7 @@
18
18
 
19
19
  .xp-slot-header {
20
20
  display: flex;
21
- flex-wrap: wrap;
21
+ flex-wrap: nowrap;
22
22
  align-items: center;
23
23
  gap: var(--xp-space-2);
24
24
  cursor: pointer;
@@ -39,7 +39,11 @@
39
39
  color: var(--xp-text);
40
40
  font: inherit;
41
41
  font-weight: 600;
42
- overflow-wrap: anywhere;
42
+ min-width: 0;
43
+ flex: 1;
44
+ white-space: nowrap;
45
+ overflow: hidden;
46
+ text-overflow: ellipsis;
43
47
  }
44
48
 
45
49
  .xp-slot-editor > .xp-ui-tabs > .xp-ui-tabs-header {
@@ -94,7 +98,7 @@
94
98
  gap: var(--xp-space-4);
95
99
  }
96
100
 
97
- .xp-slot-confirm {
101
+ .xp-slot-copy-confirm {
98
102
  padding: var(--xp-space-2) var(--xp-space-3);
99
103
  border: 1px solid var(--xp-warning);
100
104
  border-radius: var(--xp-radius);
@@ -114,16 +118,6 @@
114
118
  }
115
119
 
116
120
  .xp-slot-editor .xp-ui-tabs-header { display: flex; flex-wrap: wrap; align-items: stretch; }
117
- .xp-slot-version-actions { display: contents; }
118
- .xp-slot-version-anchor { position: relative; display: flex; align-items: center; border-bottom: 1px solid var(--xp-border); }
119
- .xp-slot-version-rename { flex: 1 0 100%; min-width: 0; padding-top: var(--xp-space-2); }
120
- .xp-slot-version-menu {
121
- position: absolute; top: 100%; inset-inline-end: 0; z-index: 5;
122
- display: grid; min-width: 180px; padding: var(--xp-space-2);
123
- box-shadow: 0 8px 24px var(--xp-overlay);
124
- background: var(--xp-surface); border: 1px solid var(--xp-border); border-radius: var(--xp-radius);
125
- }
126
- .xp-slot-version-menu .xp-ui-button { justify-content: start; }
127
121
  .xp-slot-weight-inputs, .xp-slot-people { display: flex; flex-wrap: wrap; gap: var(--xp-space-3); }
128
122
  .xp-slot-weight-inputs { align-items: flex-start; }
129
123
  .xp-slot-weight-inputs .xp-ui-field { flex: 1 1 120px; max-width: 200px; }
@@ -138,7 +132,8 @@
138
132
  [class*="_PuckFields"] .xp-slot-root .xp-ui-error { color: var(--xp-error); }
139
133
  [class*="_PuckFields"] .xp-slot-root .xp-ui-help { color: var(--xp-text-2); }
140
134
  [class*="_PuckFields"] .xp-slot-root .xp-ui-field label { color: var(--xp-text); }
141
- [class*="_PuckFields"] .xp-puck-field .xp-ui-button:disabled {
135
+ [class*="_PuckFields"] .xp-puck-field .xp-ui-button:disabled,
136
+ [class*="_PuckFields"] .xp-puck-field .xp-ui-button[aria-disabled='true'] {
142
137
  opacity: 1;
143
138
  background: var(--xp-surface-3);
144
139
  border-color: var(--xp-border-strong);
@@ -169,11 +164,23 @@
169
164
 
170
165
  .xp-slot-editor .xp-ui-tabbar { flex: 1 1 auto; min-width: 0; }
171
166
 
172
- .xp-slot-weight-row { display: flex; flex-wrap: wrap; align-items: center; gap: var(--xp-space-2); }
173
167
  .xp-slot-sidebar { display: grid; gap: var(--xp-space-4); }
174
168
  .xp-slot-sidebar section, .xp-slot-sidebar section > div { display: grid; gap: var(--xp-space-3); }
175
- .xp-slot-sidebar h4 { margin: 0; font: inherit; font-weight: 600; }
176
169
  .xp-slot-sidebar .xp-slot-weight-inputs { display: grid; }
177
170
  .xp-slot-sidebar .xp-slot-weight-inputs .xp-ui-field { max-width: none; flex: 1 1 100%; }
178
171
 
179
- .xp-slot-sidebar .xp-slot-version-menu { inset-inline-start: 0; inset-inline-end: auto; }
172
+ /* Grid stretching must not turn a status chip into a full-width bar. */
173
+ .xp-slot-sidebar .xp-ui-status { justify-self: start; width: max-content; }
174
+ .xp-slot-sidebar fieldset { min-width: 0; }
175
+ .xp-slot-sidebar .xp-slot-version-group[data-active='true'] { border-inline-start: 3px solid var(--xp-focus); }
176
+ .xp-slot-sidebar .xp-slot-version-name { display: flex; align-items: end; gap: var(--xp-space-2); }
177
+ .xp-slot-sidebar .xp-slot-version-name > .xp-ui-field { flex: 1; min-width: 0; }
178
+
179
+ .xp-slot-header .xp-ui-status { flex: none; }
180
+
181
+ .xp-slot-title-sentence {
182
+ white-space: normal;
183
+ overflow: visible;
184
+ overflow-wrap: anywhere;
185
+ text-overflow: clip;
186
+ }
@@ -273,7 +273,7 @@
273
273
  .xp-ui-button--sm { height: 30px; padding: 0 10px; font-size: 13px; }
274
274
  .xp-ui-button--link { height: auto; min-height: 0; padding-inline: 0; color: var(--xp-accent-text); text-decoration: var(--xp-accent-text-decoration); }
275
275
  .xp-ui-button--link:hover { text-decoration: underline; }
276
- .xp-ui-button:disabled, .xp-ui-button[aria-disabled='true'], .xp-ui-input:disabled, .xp-ui-toggle:disabled { opacity: .5; cursor: not-allowed; }
276
+ .xp-ui-button:disabled, .xp-ui-button[aria-disabled='true'], .xp-ui-input:disabled, .xp-ui-input[aria-disabled='true'], .xp-ui-toggle:disabled { opacity: .5; cursor: not-allowed; }
277
277
  .xp-ui-button:focus-visible, .xp-ui-input:focus-visible, .xp-ui-toggle:focus-visible, .xp-ui-tab:focus-visible, .xp-ui-tabpanel:focus-visible, .xp-ui-breadcrumb a:focus-visible, .xp-ui-dialog:focus-visible { outline: 2px solid var(--xp-focus); outline-offset: 2px; }
278
278
  .xp-ui-field { min-width: 0; max-width: 100%; display: grid; gap: 6px; color: var(--xp-text); font: var(--xp-text-body); }
279
279
  .xp-ui-field > label { font-weight: 500; }
@@ -282,7 +282,10 @@
282
282
  .xp-ui-input:hover { border-color: var(--xp-text-3); }
283
283
  .xp-ui-input[aria-invalid='true'] { border-color: var(--xp-error); }
284
284
  .xp-ui-input--number { text-align: right; font-variant-numeric: tabular-nums; }
285
- .xp-ui-select { cursor: pointer; appearance: auto; }
285
+ /* The same token-based dropdown chrome in the admin and isolated editor. */
286
+ .xp-ui-select-wrap { display: block; position: relative; min-width: 0; }
287
+ .xp-ui-select-wrap::after { content: ''; position: absolute; inset-inline-end: 14px; top: 50%; width: 7px; height: 7px; border-right: 2px solid var(--xp-text-2); border-bottom: 2px solid var(--xp-text-2); transform: translateY(-70%) rotate(45deg); pointer-events: none; }
288
+ .xp-ui-select { cursor: pointer; appearance: none; padding-inline-end: 36px; }
286
289
  .xp-ui-help { margin: 0; color: var(--xp-text-2); font: var(--xp-text-small); }
287
290
  .xp-ui-error { margin: 0; color: var(--xp-error); font: var(--xp-text-small); }
288
291
  .xp-ui-toggle { appearance: none; display: inline-block; width: 32px; height: 20px; margin: 0; padding: 2px; border-radius: 20px; border: 1px solid var(--xp-border-strong); background: var(--xp-surface-3); cursor: pointer; transition: background-color var(--xp-motion); }
@@ -298,7 +301,7 @@
298
301
  .xp-ui-section-body { padding: 20px; }
299
302
  .xp-ui-tabs { color: var(--xp-text); font: var(--xp-text-body); }
300
303
  .xp-ui-tablist { display: flex; flex-wrap: wrap; gap: 4px; border-bottom: 1px solid var(--xp-border); }
301
- .xp-ui-tab { appearance: none; border: 0; border-bottom: 2px solid transparent; border-radius: 0; padding: 10px 12px; background: transparent; color: var(--xp-text-2); font: var(--xp-text-body); cursor: pointer; }
304
+ .xp-ui-tab { min-width: 0; max-width: 100%; overflow-wrap: anywhere; white-space: normal; appearance: none; border: 0; border-bottom: 2px solid transparent; border-radius: 0; padding: 10px 12px; background: transparent; color: var(--xp-text-2); font: var(--xp-text-body); cursor: pointer; }
302
305
  .xp-ui-tab[aria-selected='true'] { color: var(--xp-accent-text); text-decoration: var(--xp-accent-text-decoration); border-bottom-color: var(--xp-accent-text); font-weight: 600; }
303
306
  .xp-ui-tab:disabled { opacity: .5; cursor: not-allowed; }
304
307
  .xp-ui-tabpanel { padding-block: 16px; }
@@ -372,13 +375,15 @@
372
375
  /* Actions sit beside each tab visually and outside the tablist's owned roles. */
373
376
  .xp-ui-tabbar { display: flex; flex-wrap: wrap; align-items: stretch; gap: 4px; border-bottom: 1px solid var(--xp-border); }
374
377
  .xp-ui-tabbar > .xp-ui-tablist { display: contents; }
375
- .xp-ui-tab-actions { display: flex; align-items: center; flex-wrap: wrap; position: relative; }
376
378
 
377
379
  /* One blocker-list format in the admin footer and the Puck sidebar. */
378
380
  .xp-readiness__blockers, .xp-readiness__blockers a { color: var(--xp-error); }
379
381
  .xp-readiness__blockers ul { margin: 0; padding-inline-start: var(--xp-space-4); }
380
382
  .xp-readiness__blockers li { white-space: pre-line; }
381
383
 
384
+ .xp-other-goals summary { cursor: pointer; font-weight: 600; }
385
+ .xp-other-goal-list { display: grid; gap: var(--xp-space-3); padding-block: var(--xp-space-3); }
386
+
382
387
  /* Shared UI controls are assembled into editor.css for the isolated canvas. */
383
388
  .xp-slot-editor {
384
389
  min-width: 0;
@@ -399,7 +404,7 @@
399
404
 
400
405
  .xp-slot-header {
401
406
  display: flex;
402
- flex-wrap: wrap;
407
+ flex-wrap: nowrap;
403
408
  align-items: center;
404
409
  gap: var(--xp-space-2);
405
410
  cursor: pointer;
@@ -420,7 +425,11 @@
420
425
  color: var(--xp-text);
421
426
  font: inherit;
422
427
  font-weight: 600;
423
- overflow-wrap: anywhere;
428
+ min-width: 0;
429
+ flex: 1;
430
+ white-space: nowrap;
431
+ overflow: hidden;
432
+ text-overflow: ellipsis;
424
433
  }
425
434
 
426
435
  .xp-slot-editor > .xp-ui-tabs > .xp-ui-tabs-header {
@@ -475,7 +484,7 @@
475
484
  gap: var(--xp-space-4);
476
485
  }
477
486
 
478
- .xp-slot-confirm {
487
+ .xp-slot-copy-confirm {
479
488
  padding: var(--xp-space-2) var(--xp-space-3);
480
489
  border: 1px solid var(--xp-warning);
481
490
  border-radius: var(--xp-radius);
@@ -495,16 +504,6 @@
495
504
  }
496
505
 
497
506
  .xp-slot-editor .xp-ui-tabs-header { display: flex; flex-wrap: wrap; align-items: stretch; }
498
- .xp-slot-version-actions { display: contents; }
499
- .xp-slot-version-anchor { position: relative; display: flex; align-items: center; border-bottom: 1px solid var(--xp-border); }
500
- .xp-slot-version-rename { flex: 1 0 100%; min-width: 0; padding-top: var(--xp-space-2); }
501
- .xp-slot-version-menu {
502
- position: absolute; top: 100%; inset-inline-end: 0; z-index: 5;
503
- display: grid; min-width: 180px; padding: var(--xp-space-2);
504
- box-shadow: 0 8px 24px var(--xp-overlay);
505
- background: var(--xp-surface); border: 1px solid var(--xp-border); border-radius: var(--xp-radius);
506
- }
507
- .xp-slot-version-menu .xp-ui-button { justify-content: start; }
508
507
  .xp-slot-weight-inputs, .xp-slot-people { display: flex; flex-wrap: wrap; gap: var(--xp-space-3); }
509
508
  .xp-slot-weight-inputs { align-items: flex-start; }
510
509
  .xp-slot-weight-inputs .xp-ui-field { flex: 1 1 120px; max-width: 200px; }
@@ -519,7 +518,8 @@
519
518
  [class*="_PuckFields"] .xp-slot-root .xp-ui-error { color: var(--xp-error); }
520
519
  [class*="_PuckFields"] .xp-slot-root .xp-ui-help { color: var(--xp-text-2); }
521
520
  [class*="_PuckFields"] .xp-slot-root .xp-ui-field label { color: var(--xp-text); }
522
- [class*="_PuckFields"] .xp-puck-field .xp-ui-button:disabled {
521
+ [class*="_PuckFields"] .xp-puck-field .xp-ui-button:disabled,
522
+ [class*="_PuckFields"] .xp-puck-field .xp-ui-button[aria-disabled='true'] {
523
523
  opacity: 1;
524
524
  background: var(--xp-surface-3);
525
525
  border-color: var(--xp-border-strong);
@@ -550,11 +550,23 @@
550
550
 
551
551
  .xp-slot-editor .xp-ui-tabbar { flex: 1 1 auto; min-width: 0; }
552
552
 
553
- .xp-slot-weight-row { display: flex; flex-wrap: wrap; align-items: center; gap: var(--xp-space-2); }
554
553
  .xp-slot-sidebar { display: grid; gap: var(--xp-space-4); }
555
554
  .xp-slot-sidebar section, .xp-slot-sidebar section > div { display: grid; gap: var(--xp-space-3); }
556
- .xp-slot-sidebar h4 { margin: 0; font: inherit; font-weight: 600; }
557
555
  .xp-slot-sidebar .xp-slot-weight-inputs { display: grid; }
558
556
  .xp-slot-sidebar .xp-slot-weight-inputs .xp-ui-field { max-width: none; flex: 1 1 100%; }
559
557
 
560
- .xp-slot-sidebar .xp-slot-version-menu { inset-inline-start: 0; inset-inline-end: auto; }
558
+ /* Grid stretching must not turn a status chip into a full-width bar. */
559
+ .xp-slot-sidebar .xp-ui-status { justify-self: start; width: max-content; }
560
+ .xp-slot-sidebar fieldset { min-width: 0; }
561
+ .xp-slot-sidebar .xp-slot-version-group[data-active='true'] { border-inline-start: 3px solid var(--xp-focus); }
562
+ .xp-slot-sidebar .xp-slot-version-name { display: flex; align-items: end; gap: var(--xp-space-2); }
563
+ .xp-slot-sidebar .xp-slot-version-name > .xp-ui-field { flex: 1; min-width: 0; }
564
+
565
+ .xp-slot-header .xp-ui-status { flex: none; }
566
+
567
+ .xp-slot-title-sentence {
568
+ white-space: normal;
569
+ overflow: visible;
570
+ overflow-wrap: anywhere;
571
+ text-overflow: clip;
572
+ }
@@ -14,7 +14,7 @@ export declare function tabsFor(experiment?: Pick<EditorExperiment, 'arms'> | nu
14
14
  slot: ArmSlot;
15
15
  label: string;
16
16
  }>;
17
- export declare function bannerFor(status?: Status | null, winner?: string): string;
17
+ export declare function bannerFor(status?: Status | null, winner?: string, original?: string): string;
18
18
  /** Preserve the block's populated slots and the current test's versions, without carrying test settings. */
19
19
  export declare function armsFromBlock(experiment: Pick<EditorExperiment, 'arms'>, content: Partial<Record<ArmSlot, unknown>>): Arm[];
20
20
  /** The host's Payload Puck editor route identifies the saved document, including in an iframe. */
@@ -15,11 +15,11 @@ export function tabsFor(experiment) {
15
15
  }
16
16
  ]).sort((a, b)=>Number(b.slot === 'control') - Number(a.slot === 'control'));
17
17
  }
18
- export function bannerFor(status, winner = editorCopy.labels.control) {
18
+ export function bannerFor(status, winner = editorCopy.labels.control, original = editorCopy.labels.control) {
19
19
  switch(status){
20
20
  case 'draft':
21
21
  case 'stopped':
22
- return editorCopy.draft;
22
+ return editorCopy.draft(original);
23
23
  case 'running':
24
24
  return editorCopy.running;
25
25
  case 'decided':
@@ -52,7 +52,7 @@ const chain = (count)=>Array(count).fill(zone).join(' ~ ');
52
52
  // A drag's collision shapes were measured before it began. Never hide a
53
53
  // previously visible target mid-drag; apply the new tab after it finishes.
54
54
  if (!valid || unknown) fixedHidden.current = [];
55
- else if (!dragging) fixedHidden.current = slots.filter((slot, index)=>testId !== null && active ? slot !== active : slot !== active && slot !== 'control' && !known?.arms.includes(slot) && emptySlots[index]);
55
+ else if (!dragging) fixedHidden.current = slots.filter((slot, index)=>active ? slot !== active : slot !== active && slot !== 'control' && !known?.arms.includes(slot) && emptySlots[index]);
56
56
  const rules = !valid || unknown ? '' : slots.flatMap((slot, index)=>{
57
57
  // No canvas tab is mounted: retain the existing empty-unused-slot behavior.
58
58
  if (!fixedHidden.current.includes(slot)) return [];
@@ -1,2 +1,4 @@
1
- import { type Config, type Data } from '@puckeditor/core';
2
- export declare function localPlacements(data: Data, config: Config): Map<string, Set<string>>;
1
+ import { type BlockVisibility } from '../visibility.js';
2
+ import type { Data } from '@puckeditor/core';
3
+ export declare function localPlacements(data: Data): Map<string, Set<string>>;
4
+ export declare function localBlockVisibility(data: Data, id: string): BlockVisibility | undefined;
@@ -1,29 +1,31 @@
1
- import { walkTree } from '@puckeditor/core';
2
- // Puck data/config are immutable. Selection, hover and drag state reuse this
1
+ import { walkVisiblePuck } from '../visibility.js';
2
+ // Puck data is immutable. Selection, hover and drag state reuse this
3
3
  // result, and every block on the page shares a single traversal per data change.
4
4
  const pages = new WeakMap();
5
- export function localPlacements(data, config) {
6
- let configs = pages.get(data);
7
- if (!configs) {
8
- configs = new WeakMap();
9
- pages.set(data, configs);
10
- }
11
- let placements = configs.get(config);
5
+ export function localPlacements(data) {
6
+ let placements = pages.get(data);
12
7
  if (!placements) {
13
8
  placements = new Map();
14
- const collect = (content)=>{
15
- for (const item of content)if (item.type === 'ExperimentSlot' && item.props.experiment?.id !== undefined) {
16
- const key = String(item.props.experiment.id);
9
+ walkVisiblePuck(data, (item, visibility)=>{
10
+ const ref = item.props.experiment;
11
+ if (!visibility.hidden && item.type === 'ExperimentSlot' && ref && ref.id !== undefined) {
12
+ const key = String(ref.id);
17
13
  const ids = placements.get(key) ?? new Set();
18
- ids.add(item.props.id);
14
+ ids.add(String(item.props.id));
19
15
  placements.set(key, ids);
20
16
  }
21
- };
22
- walkTree(data, config, (content)=>{
23
- collect(content);
24
17
  });
25
- for (const content of Object.values(data.zones ?? {}))collect(content);
26
- configs.set(config, placements);
18
+ pages.set(data, placements);
27
19
  }
28
20
  return placements;
29
21
  }
22
+ const visibilityPages = new WeakMap();
23
+ export function localBlockVisibility(data, id) {
24
+ let blocks = visibilityPages.get(data);
25
+ if (!blocks) {
26
+ blocks = new Map();
27
+ walkVisiblePuck(data, (block, visibility)=>blocks.set(String(block.props.id), visibility));
28
+ visibilityPages.set(data, blocks);
29
+ }
30
+ return blocks.get(id);
31
+ }
@@ -1,12 +1,8 @@
1
- import type { ExperimentRef } from '../../types/puck.js';
2
1
  type Targets = {
3
2
  test: HTMLElement;
4
3
  controls: HTMLElement;
5
- onChange: (value: ExperimentRef | null) => void;
6
4
  };
7
5
  export declare function useSidebarTargets(id: string): Targets | undefined;
8
- /** The custom field owns only its portal destinations and binding callback, never another data reader. */
9
- export declare function TestSidebarField({ onChange }: {
10
- onChange: (value: ExperimentRef | null) => void;
11
- }): import("react").JSX.Element;
6
+ /** The custom field owns only its portal destinations never another data reader. */
7
+ export declare function TestSidebarField(): import("react").JSX.Element;
12
8
  export {};