@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.
- package/dist/admin/copy/newTest.d.ts +1 -1
- package/dist/admin/copy/newTest.js +1 -1
- package/dist/admin/surface/newTest/NewTest.js +16 -18
- package/dist/admin/surface/newTest/newTest.css +3 -1
- package/dist/blocks/bindings.js +6 -13
- package/dist/blocks/placementLocale.d.ts +2 -0
- package/dist/blocks/placementLocale.js +16 -12
- package/dist/goals/fairness.js +8 -6
- package/dist/hooks/blockRemovalRule.d.ts +2 -1
- package/dist/hooks/blockRemovalRule.js +27 -5
- package/dist/hooks/pageGuard.js +2 -2
- package/dist/puck/ExperimentPicker.d.ts +2 -1
- package/dist/puck/ExperimentPicker.js +34 -30
- package/dist/puck/ExperimentSlot.js +3 -1
- package/dist/puck/copy.d.ts +1 -0
- package/dist/puck/copy.js +1 -0
- package/dist/puck/editor/CreateExperimentDrawer.d.ts +2 -1
- package/dist/puck/editor/CreateExperimentDrawer.js +24 -20
- package/dist/puck/editor/EditorControls.d.ts +1 -1
- package/dist/puck/editor/EditorControls.js +1 -1
- package/dist/puck/editor/ExperimentSlotEditor.js +354 -374
- package/dist/puck/editor/LeftoverVersions.d.ts +3 -1
- package/dist/puck/editor/LeftoverVersions.js +45 -63
- package/dist/puck/editor/QuickTestActions.js +2 -2
- package/dist/puck/editor/VersionBuilder.d.ts +24 -13
- package/dist/puck/editor/VersionBuilder.js +264 -205
- package/dist/puck/editor/armWrites.d.ts +9 -2
- package/dist/puck/editor/armWrites.js +40 -2
- package/dist/puck/editor/armsCache.d.ts +1 -1
- package/dist/puck/editor/armsCache.js +2 -1
- package/dist/puck/editor/copy.d.ts +19 -25
- package/dist/puck/editor/copy.js +19 -25
- package/dist/puck/editor/createTest.d.ts +3 -0
- package/dist/puck/editor/createTest.js +33 -0
- package/dist/puck/editor/editor.chrome.css +24 -17
- package/dist/puck/editor/editor.css +33 -21
- package/dist/puck/editor/editor.model.d.ts +1 -1
- package/dist/puck/editor/editor.model.js +2 -2
- package/dist/puck/editor/experimentOutlinePlugin.js +1 -1
- package/dist/puck/editor/localPlacements.d.ts +4 -2
- package/dist/puck/editor/localPlacements.js +20 -18
- package/dist/puck/editor/sidebar.d.ts +2 -6
- package/dist/puck/editor/sidebar.js +3 -6
- package/dist/puck/visibility.d.ts +21 -0
- package/dist/puck/visibility.js +77 -0
- package/dist/server/recordContentChange.js +3 -1
- package/dist/server/resolveExperimentData.js +4 -1
- package/dist/testSurface/copy/readiness.d.ts +1 -0
- package/dist/testSurface/copy/readiness.js +1 -0
- package/dist/testSurface/copy/testPage.d.ts +7 -6
- package/dist/testSurface/copy/testPage.js +7 -6
- package/dist/testSurface/results/results.css +1 -1
- package/dist/testSurface/results/results.model.d.ts +1 -1
- package/dist/testSurface/surface/readiness/ActionDialogs.js +28 -34
- package/dist/testSurface/surface/test/GoalSection.js +101 -74
- package/dist/testSurface/surface/test/fields.d.ts +1 -3
- package/dist/testSurface/surface/test/fields.js +5 -35
- package/dist/transitions/makeContent.js +24 -5
- package/dist/transitions/placements.js +23 -34
- package/dist/types/puck.d.ts +1 -0
- package/dist/ui/Inputs.js +8 -5
- package/dist/ui/Tabs.d.ts +0 -1
- package/dist/ui/Tabs.js +28 -40
- package/dist/ui/ui.css +9 -4
- package/package.json +1 -1
|
@@ -2,7 +2,9 @@ import type { ArmSlot } from '../../types/puck.js';
|
|
|
2
2
|
import type { EditorExperiment } from './editor.model.js';
|
|
3
3
|
import type { ArmWrites } from './VersionBuilder.js';
|
|
4
4
|
/** Page content stays editable even when it does not belong to the selected test. */
|
|
5
|
-
export declare function LeftoverVersions({ slots, experiment, writes, canManage, countBlocks, onDelete, onSelect }: {
|
|
5
|
+
export declare function LeftoverVersions({ slots, experiment, writes, canManage, countBlocks, onDelete, onSelect, active, dragging }: {
|
|
6
|
+
active: ArmSlot;
|
|
7
|
+
dragging: boolean;
|
|
6
8
|
slots: ArmSlot[];
|
|
7
9
|
experiment: EditorExperiment;
|
|
8
10
|
writes: ArmWrites;
|
|
@@ -1,83 +1,65 @@
|
|
|
1
1
|
'use client';
|
|
2
2
|
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
3
3
|
import { useState } from 'react';
|
|
4
|
+
import { FieldGroup } from '@puckeditor/core';
|
|
4
5
|
import { Button } from '../../ui/Button.js';
|
|
5
6
|
import { Dialog } from '../../ui/Dialog.js';
|
|
6
7
|
import { slotLabels } from '../copy.js';
|
|
7
8
|
import { editorCopy as C } from './copy.js';
|
|
8
9
|
import { tabsFor } from './editor.model.js';
|
|
9
|
-
|
|
10
|
+
import { addLeftoverArms } from './armWrites.js';
|
|
11
|
+
/** Page content stays editable even when it does not belong to the selected test. */ export function LeftoverVersions({ slots, experiment, writes, canManage, countBlocks, onDelete, onSelect, active, dragging }) {
|
|
10
12
|
const [deleting, setDeleting] = useState(null);
|
|
11
13
|
const versions = new Intl.ListFormat('en', {
|
|
12
14
|
style: 'long',
|
|
13
15
|
type: 'conjunction'
|
|
14
16
|
}).format(tabsFor(experiment).map((tab)=>tab.label));
|
|
15
|
-
const notice = (slot)=>/*#__PURE__*/
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
canManage && experiment.status === 'draft' ? /*#__PURE__*/ _jsx(Button, {
|
|
24
|
-
disabled: writes.busy,
|
|
25
|
-
onClick: async ()=>{
|
|
26
|
-
const saved = await writes.write((arms)=>{
|
|
27
|
-
if (arms.some((arm)=>arm.key === slot)) return arms;
|
|
28
|
-
const next = [
|
|
29
|
-
...arms
|
|
30
|
-
];
|
|
31
|
-
const holdout = next.findIndex((arm)=>arm.kind === 'holdout');
|
|
32
|
-
next.splice(holdout < 0 ? next.length : holdout, 0, {
|
|
33
|
-
key: slot,
|
|
34
|
-
slot,
|
|
35
|
-
kind: 'variant',
|
|
36
|
-
label: slotLabels[slot],
|
|
37
|
-
weight: 0
|
|
38
|
-
});
|
|
39
|
-
return next;
|
|
40
|
-
}, {
|
|
41
|
-
draftOnly: true
|
|
42
|
-
});
|
|
43
|
-
if (saved) onSelect(slot);
|
|
44
|
-
},
|
|
45
|
-
children: C.addLeftover
|
|
46
|
-
}) : null,
|
|
47
|
-
/*#__PURE__*/ _jsx(Button, {
|
|
48
|
-
onClick: ()=>setDeleting(slot),
|
|
49
|
-
children: C.deleteContent
|
|
50
|
-
})
|
|
51
|
-
]
|
|
52
|
-
})
|
|
53
|
-
]
|
|
54
|
-
}, slot);
|
|
55
|
-
return /*#__PURE__*/ _jsxs(_Fragment, {
|
|
56
|
-
children: [
|
|
57
|
-
slots.length > 2 ? /*#__PURE__*/ _jsxs("details", {
|
|
58
|
-
className: "xp-ui-banner xp-ui-banner--warning xp-slot-leftovers",
|
|
17
|
+
const notice = (slot)=>/*#__PURE__*/ _jsx("div", {
|
|
18
|
+
className: "xp-slot-version-group",
|
|
19
|
+
"data-active": active === slot,
|
|
20
|
+
role: "group",
|
|
21
|
+
"aria-label": C.outsideTest(slotLabels[slot]),
|
|
22
|
+
children: /*#__PURE__*/ _jsxs(FieldGroup, {
|
|
23
|
+
variant: "card",
|
|
24
|
+
collapsible: false,
|
|
59
25
|
children: [
|
|
60
|
-
/*#__PURE__*/
|
|
26
|
+
/*#__PURE__*/ _jsx(Button, {
|
|
27
|
+
variant: "quiet",
|
|
28
|
+
"aria-pressed": active === slot,
|
|
29
|
+
disabled: dragging,
|
|
30
|
+
onClick: ()=>onSelect(slot),
|
|
31
|
+
children: C.outsideTest(slotLabels[slot])
|
|
32
|
+
}),
|
|
33
|
+
/*#__PURE__*/ _jsx("p", {
|
|
34
|
+
children: C.orphan(slotLabels[slot], versions)
|
|
35
|
+
}),
|
|
36
|
+
/*#__PURE__*/ _jsxs("div", {
|
|
37
|
+
className: "xp-ui-button-group",
|
|
61
38
|
children: [
|
|
62
|
-
/*#__PURE__*/ _jsx(
|
|
63
|
-
"aria-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
39
|
+
canManage && experiment.status === 'draft' ? /*#__PURE__*/ _jsx(Button, {
|
|
40
|
+
"aria-disabled": writes.busy || undefined,
|
|
41
|
+
onClick: async ()=>{
|
|
42
|
+
if (writes.busy) return;
|
|
43
|
+
const saved = await writes.write((arms)=>addLeftoverArms(arms, slot), {
|
|
44
|
+
draftOnly: true,
|
|
45
|
+
errorKey: `leftover:${slot}`
|
|
46
|
+
});
|
|
47
|
+
if (saved) onSelect(slot);
|
|
48
|
+
},
|
|
49
|
+
children: C.addLeftover
|
|
50
|
+
}) : null,
|
|
51
|
+
/*#__PURE__*/ _jsx(Button, {
|
|
52
|
+
onClick: ()=>setDeleting(slot),
|
|
53
|
+
children: C.deleteContent
|
|
54
|
+
})
|
|
67
55
|
]
|
|
68
|
-
})
|
|
69
|
-
slots.map(notice)
|
|
56
|
+
})
|
|
70
57
|
]
|
|
71
|
-
})
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
children: "⚠"
|
|
77
|
-
}),
|
|
78
|
-
notice(slot)
|
|
79
|
-
]
|
|
80
|
-
}, slot)),
|
|
58
|
+
})
|
|
59
|
+
}, slot);
|
|
60
|
+
return /*#__PURE__*/ _jsxs(_Fragment, {
|
|
61
|
+
children: [
|
|
62
|
+
slots.map(notice),
|
|
81
63
|
deleting ? /*#__PURE__*/ _jsx(Dialog, {
|
|
82
64
|
open: true,
|
|
83
65
|
title: C.deleteContentTitle(slotLabels[deleting]),
|
|
@@ -15,7 +15,7 @@ import { createApi } from '../../testSurface/api.js';
|
|
|
15
15
|
const action = availableActions({
|
|
16
16
|
...doc,
|
|
17
17
|
canManage: surface.canManage
|
|
18
|
-
}).find((item)=>doc.status === 'draft' ? item.id === 'start' : doc.status === 'running' && item.id === 'stop');
|
|
18
|
+
}).find((item)=>doc.status === 'draft' || doc.status === 'stopped' ? item.id === 'start' : doc.status === 'running' && item.id === 'stop');
|
|
19
19
|
if (!action) return null;
|
|
20
20
|
const ready = !transition.checking && canStartTest(test, surface.editorPlacementMessage);
|
|
21
21
|
const showAction = action.id !== 'start' || readyToStart(test, surface.editorPlacementMessage) && !test.hasUnsaved;
|
|
@@ -29,7 +29,7 @@ import { createApi } from '../../testSurface/api.js';
|
|
|
29
29
|
disabled: transition.busy || confirm || test.hasUnsaved || action.id === 'start' && !ready,
|
|
30
30
|
busy: transition.busy,
|
|
31
31
|
onClick: ()=>{
|
|
32
|
-
if (action.id === 'start') void transition.run('start', ()=>createApi(surface.apiRoute).start(doc.id));
|
|
32
|
+
if (action.id === 'start' && doc.status !== 'stopped') void transition.run('start', ()=>createApi(surface.apiRoute).start(doc.id));
|
|
33
33
|
else setConfirm(true);
|
|
34
34
|
},
|
|
35
35
|
children: action.label
|
|
@@ -1,13 +1,29 @@
|
|
|
1
|
-
import { type ReactNode, type RefObject } from 'react';
|
|
1
|
+
import { type Dispatch, type ReactNode, type RefObject, type SetStateAction } from 'react';
|
|
2
2
|
import type { Arm, ArmKey } from '../../types/contracts.js';
|
|
3
3
|
import type { ArmSlot } from '../../types/puck.js';
|
|
4
4
|
import type { EditorExperiment } from './editor.model.js';
|
|
5
|
-
export declare function useArmWrites(url
|
|
5
|
+
export declare function useArmWrites({ url, bindingKey, status, controlKeys, publish, isCurrent, onWrite, onSaved }: {
|
|
6
|
+
url: string;
|
|
7
|
+
bindingKey: string;
|
|
8
|
+
status?: EditorExperiment['status'];
|
|
9
|
+
controlKeys: string[];
|
|
10
|
+
publish: (doc: EditorExperiment) => EditorExperiment | void;
|
|
11
|
+
isCurrent: () => boolean;
|
|
12
|
+
onWrite: () => void;
|
|
13
|
+
onSaved?: () => void;
|
|
14
|
+
}): {
|
|
6
15
|
write: (transform: (arms: Arm[]) => Arm[], options?: {
|
|
7
16
|
draftOnly?: boolean;
|
|
17
|
+
onError?: (message: string) => void;
|
|
18
|
+
queue?: boolean;
|
|
19
|
+
cancelled?: () => boolean;
|
|
20
|
+
onStart?: () => void;
|
|
21
|
+
errorKey?: string;
|
|
8
22
|
}) => Promise<Arm[] | undefined>;
|
|
9
23
|
busy: boolean;
|
|
10
|
-
error: string
|
|
24
|
+
error: string;
|
|
25
|
+
errorFor: (key: string) => string | undefined;
|
|
26
|
+
clearError: (key: string) => void;
|
|
11
27
|
};
|
|
12
28
|
export type ArmWrites = ReturnType<typeof useArmWrites>;
|
|
13
29
|
export declare function AddVariant({ experiment, writes, onSelect }: {
|
|
@@ -15,16 +31,11 @@ export declare function AddVariant({ experiment, writes, onSelect }: {
|
|
|
15
31
|
writes: ArmWrites;
|
|
16
32
|
onSelect: (slot: ArmSlot) => void;
|
|
17
33
|
}): import("react").JSX.Element | null;
|
|
18
|
-
|
|
34
|
+
/** Always-visible editor for the saved version name. */
|
|
35
|
+
export declare function VersionName({ arm, writes, editable }: {
|
|
19
36
|
arm: EditorExperiment['arms'][number];
|
|
20
37
|
writes: ArmWrites;
|
|
21
38
|
editable: boolean;
|
|
22
|
-
running?: boolean;
|
|
23
|
-
open: boolean;
|
|
24
|
-
onOpenChange: (open: boolean) => void;
|
|
25
|
-
canCopy: boolean;
|
|
26
|
-
onCopy: (slot: ArmSlot) => void;
|
|
27
|
-
onRequestRemove: () => void;
|
|
28
39
|
}): import("react").JSX.Element;
|
|
29
40
|
export declare function RemoveVersion({ arm, writes, count, shared, onRemove, onClose }: {
|
|
30
41
|
arm: EditorExperiment['arms'][number];
|
|
@@ -35,14 +46,14 @@ export declare function RemoveVersion({ arm, writes, count, shared, onRemove, on
|
|
|
35
46
|
onClose: () => void;
|
|
36
47
|
}): import("react").JSX.Element;
|
|
37
48
|
export type WeightEdits = Partial<Record<ArmKey, string>>;
|
|
38
|
-
export declare function VersionWeights({ experiment, writes, edits, setEdits, groupId, splitIntent, editable, beforeSplit,
|
|
49
|
+
export declare function VersionWeights({ experiment, writes, edits, setEdits, groupId, splitIntent, editable, beforeSplit, renderRow }: {
|
|
39
50
|
experiment: EditorExperiment;
|
|
40
51
|
writes: ArmWrites;
|
|
41
52
|
edits: WeightEdits;
|
|
42
|
-
setEdits:
|
|
53
|
+
setEdits: Dispatch<SetStateAction<WeightEdits>>;
|
|
43
54
|
groupId: string;
|
|
44
55
|
splitIntent: RefObject<boolean>;
|
|
45
56
|
editable?: boolean;
|
|
46
57
|
beforeSplit?: ReactNode;
|
|
47
|
-
|
|
58
|
+
renderRow?: (arm: EditorExperiment['arms'][number], input: ReactNode) => ReactNode;
|
|
48
59
|
}): import("react").JSX.Element;
|