@delmaredigital/payload-experiments 0.4.0-rc.4 → 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 (123) 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/ResultsRoute.js +2 -10
  4. package/dist/admin/surface/newTest/NewTest.js +16 -18
  5. package/dist/admin/surface/newTest/PageWizard.js +10 -12
  6. package/dist/admin/surface/newTest/newTest.css +3 -1
  7. package/dist/admin/surface/results/ResultsHeader.js +15 -8
  8. package/dist/blocks/bindings.js +6 -13
  9. package/dist/blocks/placementLocale.d.ts +2 -0
  10. package/dist/blocks/placementLocale.js +16 -12
  11. package/dist/goals/fairness.d.ts +1 -1
  12. package/dist/goals/fairness.js +9 -7
  13. package/dist/hooks/blockRemovalRule.d.ts +2 -1
  14. package/dist/hooks/blockRemovalRule.js +27 -5
  15. package/dist/hooks/pageGuard.js +2 -2
  16. package/dist/puck/ExperimentPicker.d.ts +2 -1
  17. package/dist/puck/ExperimentPicker.js +34 -30
  18. package/dist/puck/ExperimentSlot.js +3 -1
  19. package/dist/puck/copy.d.ts +1 -0
  20. package/dist/puck/copy.js +1 -0
  21. package/dist/puck/editor/ConfigureTestDrawer.js +2 -2
  22. package/dist/puck/editor/CreateExperimentDrawer.d.ts +2 -1
  23. package/dist/puck/editor/CreateExperimentDrawer.js +24 -16
  24. package/dist/puck/editor/EditorControls.d.ts +1 -1
  25. package/dist/puck/editor/EditorControls.js +1 -1
  26. package/dist/puck/editor/ExperimentSlotEditor.js +624 -299
  27. package/dist/puck/editor/LeftoverVersions.d.ts +15 -0
  28. package/dist/puck/editor/LeftoverVersions.js +97 -0
  29. package/dist/puck/editor/PlacementNotice.d.ts +8 -0
  30. package/dist/puck/editor/PlacementNotice.js +22 -0
  31. package/dist/puck/editor/QuickTestActions.d.ts +3 -0
  32. package/dist/puck/editor/QuickTestActions.js +50 -0
  33. package/dist/puck/editor/ResultsReadout.js +5 -0
  34. package/dist/puck/editor/VersionBuilder.d.ts +37 -12
  35. package/dist/puck/editor/VersionBuilder.js +273 -184
  36. package/dist/puck/editor/armWrites.d.ts +11 -2
  37. package/dist/puck/editor/armWrites.js +42 -3
  38. package/dist/puck/editor/armsCache.d.ts +1 -1
  39. package/dist/puck/editor/armsCache.js +2 -1
  40. package/dist/puck/editor/cloneSlot.d.ts +2 -0
  41. package/dist/puck/editor/cloneSlot.js +7 -0
  42. package/dist/puck/editor/copy.d.ts +35 -20
  43. package/dist/puck/editor/copy.js +35 -20
  44. package/dist/puck/editor/createTest.d.ts +3 -0
  45. package/dist/puck/editor/createTest.js +33 -0
  46. package/dist/puck/editor/editor.chrome.css +32 -14
  47. package/dist/puck/editor/editor.css +58 -17
  48. package/dist/puck/editor/editor.model.d.ts +1 -1
  49. package/dist/puck/editor/editor.model.js +2 -2
  50. package/dist/puck/editor/experimentOutlinePlugin.js +96 -28
  51. package/dist/puck/editor/localPlacements.d.ts +4 -2
  52. package/dist/puck/editor/localPlacements.js +20 -18
  53. package/dist/puck/editor/outlineVersion.d.ts +5 -0
  54. package/dist/puck/editor/outlineVersion.js +36 -0
  55. package/dist/puck/editor/placementsCache.d.ts +33 -2
  56. package/dist/puck/editor/placementsCache.js +208 -33
  57. package/dist/puck/editor/sidebar.d.ts +8 -0
  58. package/dist/puck/editor/sidebar.js +74 -0
  59. package/dist/puck/editor/usePlacementNotice.d.ts +3 -0
  60. package/dist/puck/editor/usePlacementNotice.js +14 -0
  61. package/dist/puck/visibility.d.ts +21 -0
  62. package/dist/puck/visibility.js +77 -0
  63. package/dist/server/recordContentChange.js +3 -1
  64. package/dist/server/resolveExperimentData.js +4 -1
  65. package/dist/testSurface/api.js +1 -1
  66. package/dist/testSurface/copy/common.d.ts +1 -1
  67. package/dist/testSurface/copy/common.js +3 -1
  68. package/dist/testSurface/copy/readiness.d.ts +18 -1
  69. package/dist/testSurface/copy/readiness.js +23 -1
  70. package/dist/testSurface/copy/testPage.d.ts +8 -6
  71. package/dist/testSurface/copy/testPage.js +8 -6
  72. package/dist/testSurface/readPreflight.d.ts +9 -0
  73. package/dist/testSurface/readPreflight.js +38 -0
  74. package/dist/testSurface/readinessRead.d.ts +50 -0
  75. package/dist/testSurface/readinessRead.js +46 -0
  76. package/dist/testSurface/results/results.css +1 -1
  77. package/dist/testSurface/results/results.model.d.ts +1 -1
  78. package/dist/testSurface/surface/contracts.d.ts +6 -2
  79. package/dist/testSurface/surface/editorPlacement.d.ts +21 -0
  80. package/dist/testSurface/surface/editorPlacement.js +60 -0
  81. package/dist/testSurface/surface/pageBlock/parts.js +13 -3
  82. package/dist/testSurface/surface/readiness/ActionDialogs.js +65 -41
  83. package/dist/testSurface/surface/readiness/Banner.d.ts +1 -4
  84. package/dist/testSurface/surface/readiness/Banner.js +106 -68
  85. package/dist/testSurface/surface/readiness/BlockerList.d.ts +11 -0
  86. package/dist/testSurface/surface/readiness/BlockerList.js +31 -0
  87. package/dist/testSurface/surface/readiness/SaveStatus.d.ts +6 -2
  88. package/dist/testSurface/surface/readiness/SaveStatus.js +35 -22
  89. package/dist/testSurface/surface/readiness/parts.js +0 -2
  90. package/dist/testSurface/surface/readiness/readiness.model.d.ts +13 -0
  91. package/dist/testSurface/surface/readiness/readiness.model.js +51 -36
  92. package/dist/testSurface/surface/readiness/useTransition.d.ts +5 -2
  93. package/dist/testSurface/surface/readiness/useTransition.js +69 -7
  94. package/dist/testSurface/surface/test/AdvancedSection.js +1 -0
  95. package/dist/testSurface/surface/test/GoalSection.js +102 -74
  96. package/dist/testSurface/surface/test/LengthSection.d.ts +1 -1
  97. package/dist/testSurface/surface/test/LengthSection.js +2 -1
  98. package/dist/testSurface/surface/test/Rail.js +7 -4
  99. package/dist/testSurface/surface/test/ReadinessBar.js +1 -2
  100. package/dist/testSurface/surface/test/Section.d.ts +3 -1
  101. package/dist/testSurface/surface/test/Section.js +38 -6
  102. package/dist/testSurface/surface/test/TargetingSection.js +5 -0
  103. package/dist/testSurface/surface/test/TestSurface.d.ts +2 -1
  104. package/dist/testSurface/surface/test/TestSurface.js +68 -7
  105. package/dist/testSurface/surface/test/VersionsSection.js +1 -0
  106. package/dist/testSurface/surface/test/fields.d.ts +1 -3
  107. package/dist/testSurface/surface/test/fields.js +5 -35
  108. package/dist/testSurface/surface/test/testPage.css +12 -0
  109. package/dist/testSurface/surface/useTestDocument.d.ts +5 -2
  110. package/dist/testSurface/surface/useTestDocument.js +61 -46
  111. package/dist/testSurface/useReadinessPolling.d.ts +3 -0
  112. package/dist/testSurface/useReadinessPolling.js +24 -0
  113. package/dist/transitions/makeContent.js +24 -5
  114. package/dist/transitions/placements.js +23 -34
  115. package/dist/transitions/preflightData.js +1 -1
  116. package/dist/types/puck.d.ts +1 -0
  117. package/dist/ui/Card.d.ts +2 -1
  118. package/dist/ui/Card.js +4 -4
  119. package/dist/ui/Inputs.js +8 -5
  120. package/dist/ui/Tabs.d.ts +2 -2
  121. package/dist/ui/Tabs.js +33 -32
  122. package/dist/ui/ui.css +26 -3
  123. package/package.json +1 -1
@@ -0,0 +1,15 @@
1
+ import type { ArmSlot } from '../../types/puck.js';
2
+ import type { EditorExperiment } from './editor.model.js';
3
+ import type { ArmWrites } from './VersionBuilder.js';
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, active, dragging }: {
6
+ active: ArmSlot;
7
+ dragging: boolean;
8
+ slots: ArmSlot[];
9
+ experiment: EditorExperiment;
10
+ writes: ArmWrites;
11
+ canManage: boolean;
12
+ countBlocks: (slot: ArmSlot) => number;
13
+ onDelete: (slot: ArmSlot) => void;
14
+ onSelect: (slot: ArmSlot) => void;
15
+ }): import("react").JSX.Element;
@@ -0,0 +1,97 @@
1
+ 'use client';
2
+ import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
3
+ import { useState } from 'react';
4
+ import { FieldGroup } from '@puckeditor/core';
5
+ import { Button } from '../../ui/Button.js';
6
+ import { Dialog } from '../../ui/Dialog.js';
7
+ import { slotLabels } from '../copy.js';
8
+ import { editorCopy as C } from './copy.js';
9
+ import { tabsFor } from './editor.model.js';
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 }) {
12
+ const [deleting, setDeleting] = useState(null);
13
+ const versions = new Intl.ListFormat('en', {
14
+ style: 'long',
15
+ type: 'conjunction'
16
+ }).format(tabsFor(experiment).map((tab)=>tab.label));
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,
25
+ children: [
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",
38
+ children: [
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
+ })
55
+ ]
56
+ })
57
+ ]
58
+ })
59
+ }, slot);
60
+ return /*#__PURE__*/ _jsxs(_Fragment, {
61
+ children: [
62
+ slots.map(notice),
63
+ deleting ? /*#__PURE__*/ _jsx(Dialog, {
64
+ open: true,
65
+ title: C.deleteContentTitle(slotLabels[deleting]),
66
+ initialFocus: "cancel",
67
+ onClose: ()=>setDeleting(null),
68
+ children: /*#__PURE__*/ _jsxs("div", {
69
+ className: "xp-slot-drawer",
70
+ children: [
71
+ /*#__PURE__*/ _jsx("p", {
72
+ children: C.deleteContentHelp(slotLabels[deleting], countBlocks(deleting))
73
+ }),
74
+ /*#__PURE__*/ _jsxs("div", {
75
+ className: "xp-ui-button-group",
76
+ children: [
77
+ /*#__PURE__*/ _jsx(Button, {
78
+ "data-dialog-cancel": true,
79
+ onClick: ()=>setDeleting(null),
80
+ children: C.cancel
81
+ }),
82
+ /*#__PURE__*/ _jsx(Button, {
83
+ variant: "danger",
84
+ onClick: ()=>{
85
+ onDelete(deleting);
86
+ setDeleting(null);
87
+ },
88
+ children: C.deleteContent
89
+ })
90
+ ]
91
+ })
92
+ ]
93
+ })
94
+ }) : null
95
+ ]
96
+ });
97
+ }
@@ -0,0 +1,8 @@
1
+ import type { ReadinessRead } from '../../testSurface/readinessRead.js';
2
+ /** Chrome and sidebar consume the settled read's sentence and recovery policy. */
3
+ export declare function PlacementNotice({ read, message, running, onRetry }: {
4
+ read?: ReadinessRead;
5
+ message?: string;
6
+ running: boolean;
7
+ onRetry(): void;
8
+ }): import("react").JSX.Element | null;
@@ -0,0 +1,22 @@
1
+ 'use client';
2
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
3
+ import { Banner } from '../../ui/Banner.js';
4
+ import { Button } from '../../ui/Button.js';
5
+ import { editorCopy } from './copy.js';
6
+ /** Chrome and sidebar consume the settled read's sentence and recovery policy. */ export function PlacementNotice({ read, message, running, onRetry }) {
7
+ const sentence = read?.message ?? message;
8
+ return sentence ? /*#__PURE__*/ _jsxs(Banner, {
9
+ tone: running && !read?.message ? 'warning' : 'error',
10
+ action: read?.retry ? /*#__PURE__*/ _jsx(Button, {
11
+ onClick: onRetry,
12
+ children: editorCopy.retrySetup
13
+ }) : undefined,
14
+ children: [
15
+ running && !read?.message ? /*#__PURE__*/ _jsx("span", {
16
+ "aria-hidden": "true",
17
+ children: "⚠ "
18
+ }) : null,
19
+ sentence
20
+ ]
21
+ }) : null;
22
+ }
@@ -0,0 +1,3 @@
1
+ import type { SectionProps } from '../../testSurface/surface/contracts.js';
2
+ /** Same transition runner and confirmation as the drawer; Decide stays there. */
3
+ export declare function QuickTestActions({ test, surface }: SectionProps): import("react").JSX.Element | null;
@@ -0,0 +1,50 @@
1
+ 'use client';
2
+ import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
3
+ import { READINESS_COPY } from '../../testSurface/copy/readiness.js';
4
+ import { canStartTest, readyToStart } from '../../testSurface/readinessRead.js';
5
+ import { useState } from 'react';
6
+ import { Button } from '../../ui/Button.js';
7
+ import { availableActions } from '../../testSurface/actions/actions.model.js';
8
+ import { ConfirmAction } from '../../testSurface/surface/readiness/ActionDialogs.js';
9
+ import { useTransition } from '../../testSurface/surface/readiness/useTransition.js';
10
+ import { createApi } from '../../testSurface/api.js';
11
+ /** Same transition runner and confirmation as the drawer; Decide stays there. */ export function QuickTestActions({ test, surface }) {
12
+ const [confirm, setConfirm] = useState(false);
13
+ const transition = useTransition(test, undefined, surface);
14
+ const doc = test.doc;
15
+ const action = availableActions({
16
+ ...doc,
17
+ canManage: surface.canManage
18
+ }).find((item)=>doc.status === 'draft' || doc.status === 'stopped' ? item.id === 'start' : doc.status === 'running' && item.id === 'stop');
19
+ if (!action) return null;
20
+ const ready = !transition.checking && canStartTest(test, surface.editorPlacementMessage);
21
+ const showAction = action.id !== 'start' || readyToStart(test, surface.editorPlacementMessage) && !test.hasUnsaved;
22
+ return /*#__PURE__*/ _jsxs(_Fragment, {
23
+ children: [
24
+ showAction && action.id === 'start' ? /*#__PURE__*/ _jsx("p", {
25
+ role: "status",
26
+ children: READINESS_COPY.ready
27
+ }) : null,
28
+ showAction ? /*#__PURE__*/ _jsx(Button, {
29
+ disabled: transition.busy || confirm || test.hasUnsaved || action.id === 'start' && !ready,
30
+ busy: transition.busy,
31
+ onClick: ()=>{
32
+ if (action.id === 'start' && doc.status !== 'stopped') void transition.run('start', ()=>createApi(surface.apiRoute).start(doc.id));
33
+ else setConfirm(true);
34
+ },
35
+ children: action.label
36
+ }) : null,
37
+ transition.error ? /*#__PURE__*/ _jsx("p", {
38
+ role: "alert",
39
+ children: transition.error
40
+ }) : null,
41
+ confirm ? /*#__PURE__*/ _jsx(ConfirmAction, {
42
+ test: test,
43
+ surface: surface,
44
+ action: action,
45
+ winnerLabel: "",
46
+ onClose: ()=>setConfirm(false)
47
+ }) : null
48
+ ]
49
+ });
50
+ }
@@ -81,6 +81,11 @@ export function ResultsReadout({ id, api, experiment }) {
81
81
  className: "xp-ui-help",
82
82
  children: C.loading
83
83
  }),
84
+ busy && data ? /*#__PURE__*/ _jsx("p", {
85
+ role: "status",
86
+ className: "xp-ui-help",
87
+ children: C.refreshing
88
+ }) : null,
84
89
  /*#__PURE__*/ _jsx(Button, {
85
90
  variant: "quiet",
86
91
  size: "sm",
@@ -1,10 +1,29 @@
1
- import type { Arm } from '../../types/contracts.js';
1
+ import { type Dispatch, type ReactNode, type RefObject, type SetStateAction } from 'react';
2
+ import type { Arm, ArmKey } from '../../types/contracts.js';
2
3
  import type { ArmSlot } from '../../types/puck.js';
3
4
  import type { EditorExperiment } from './editor.model.js';
4
- export declare function useArmWrites(url: string, publish: (doc: EditorExperiment) => void, isCurrent: () => boolean, onWrite: () => void): {
5
- write: (transform: (arms: Arm[]) => Arm[]) => Promise<Arm[] | undefined>;
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
+ }): {
15
+ write: (transform: (arms: Arm[]) => Arm[], options?: {
16
+ draftOnly?: boolean;
17
+ onError?: (message: string) => void;
18
+ queue?: boolean;
19
+ cancelled?: () => boolean;
20
+ onStart?: () => void;
21
+ errorKey?: string;
22
+ }) => Promise<Arm[] | undefined>;
6
23
  busy: boolean;
7
- error: string | null;
24
+ error: string;
25
+ errorFor: (key: string) => string | undefined;
26
+ clearError: (key: string) => void;
8
27
  };
9
28
  export type ArmWrites = ReturnType<typeof useArmWrites>;
10
29
  export declare function AddVariant({ experiment, writes, onSelect }: {
@@ -12,23 +31,29 @@ export declare function AddVariant({ experiment, writes, onSelect }: {
12
31
  writes: ArmWrites;
13
32
  onSelect: (slot: ArmSlot) => void;
14
33
  }): import("react").JSX.Element | null;
15
- export declare function VersionActions({ arm, writes, editable, open, onOpenChange, canCopy, onCopy, onRequestRemove }: {
34
+ /** Always-visible editor for the saved version name. */
35
+ export declare function VersionName({ arm, writes, editable }: {
16
36
  arm: EditorExperiment['arms'][number];
17
37
  writes: ArmWrites;
18
38
  editable: boolean;
19
- open: boolean;
20
- onOpenChange: (open: boolean) => void;
21
- canCopy: boolean;
22
- onCopy: (slot: ArmSlot) => void;
23
- onRequestRemove: () => void;
24
39
  }): import("react").JSX.Element;
25
- export declare function RemoveVersion({ arm, writes, onRemove, onClose }: {
40
+ export declare function RemoveVersion({ arm, writes, count, shared, onRemove, onClose }: {
26
41
  arm: EditorExperiment['arms'][number];
27
42
  writes: ArmWrites;
43
+ count: number;
44
+ shared: boolean | undefined;
28
45
  onRemove: (slot: ArmSlot) => void;
29
46
  onClose: () => void;
30
47
  }): import("react").JSX.Element;
31
- export declare function VersionWeights({ experiment, writes }: {
48
+ export type WeightEdits = Partial<Record<ArmKey, string>>;
49
+ export declare function VersionWeights({ experiment, writes, edits, setEdits, groupId, splitIntent, editable, beforeSplit, renderRow }: {
32
50
  experiment: EditorExperiment;
33
51
  writes: ArmWrites;
52
+ edits: WeightEdits;
53
+ setEdits: Dispatch<SetStateAction<WeightEdits>>;
54
+ groupId: string;
55
+ splitIntent: RefObject<boolean>;
56
+ editable?: boolean;
57
+ beforeSplit?: ReactNode;
58
+ renderRow?: (arm: EditorExperiment['arms'][number], input: ReactNode) => ReactNode;
34
59
  }): import("react").JSX.Element;