@delmaredigital/payload-experiments 0.4.0-rc.6 → 0.4.0-rc.7
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/blocks/BlockPanel.js +6 -4
- package/dist/admin/blocks/inject.js +1 -0
- package/dist/admin/blocks/model.d.ts +3 -2
- package/dist/admin/blocks/model.js +8 -4
- package/dist/admin/copy/blocks.d.ts +3 -2
- package/dist/admin/copy/blocks.js +7 -6
- package/dist/admin/surface/ResultsRoute.js +2 -1
- package/dist/admin/surface/TestsHome.d.ts +2 -1
- package/dist/admin/surface/TestsHome.js +91 -37
- package/dist/admin/surface/TestsSurface.js +3 -0
- package/dist/admin/surface/home.model.d.ts +2 -0
- package/dist/admin/surface/newTest/PageWizard.js +1 -0
- package/dist/admin/surface/newTest/newTest.css +1 -1
- package/dist/admin/views/TestsSurfaceClient.d.ts +3 -0
- package/dist/admin/views/TestsSurfaceClient.js +11 -0
- package/dist/admin/views/buildSurfaceProps.js +10 -3
- package/dist/blocks/bindings.js +3 -2
- package/dist/blocks/placementLanguages.d.ts +7 -0
- package/dist/blocks/placementLanguages.js +27 -0
- package/dist/blocks/placementLocale.d.ts +21 -7
- package/dist/blocks/placementLocale.js +218 -67
- package/dist/db/appends.d.ts +13 -0
- package/dist/db/appends.js +49 -0
- package/dist/db/bulkPlacementRemoval.js +8 -4
- package/dist/endpoints/contentLocale.d.ts +6 -0
- package/dist/endpoints/contentLocale.js +15 -0
- package/dist/endpoints/deleteImpact.d.ts +6 -0
- package/dist/endpoints/deleteImpact.js +206 -0
- package/dist/endpoints/index.js +7 -0
- package/dist/endpoints/pages.js +7 -3
- package/dist/endpoints/placementStatus.js +6 -1
- package/dist/endpoints/preflight.d.ts +1 -1
- package/dist/endpoints/preflight.js +17 -2
- package/dist/exports/adminClient.d.ts +1 -1
- package/dist/exports/adminClient.js +1 -1
- package/dist/exports/index.d.ts +1 -1
- package/dist/goals/fairness.js +38 -31
- package/dist/hooks/blockRemovalRule.d.ts +2 -2
- package/dist/hooks/blockRemovalRule.js +16 -14
- package/dist/hooks/pageGuard.d.ts +3 -0
- package/dist/hooks/pageGuard.js +33 -23
- package/dist/hooks/puckNestedTests.d.ts +8 -0
- package/dist/hooks/puckNestedTests.js +36 -0
- package/dist/lib/placementPages.d.ts +2 -1
- package/dist/lib/placementPages.js +10 -2
- package/dist/manifest/compile.d.ts +2 -1
- package/dist/manifest/compile.js +5 -1
- package/dist/puck/ExperimentPicker.js +40 -37
- package/dist/puck/editor/ConfigureTestDrawer.d.ts +8 -4
- package/dist/puck/editor/ConfigureTestDrawer.js +4 -2
- package/dist/puck/editor/ExperimentSlotEditor.js +135 -104
- package/dist/puck/editor/LeftoverVersions.d.ts +1 -1
- package/dist/puck/editor/LeftoverVersions.js +40 -43
- package/dist/puck/editor/VersionBuilder.d.ts +18 -1
- package/dist/puck/editor/VersionBuilder.js +217 -39
- package/dist/puck/editor/blockClipboard.d.ts +16 -0
- package/dist/puck/editor/blockClipboard.js +20 -0
- package/dist/puck/editor/copy.d.ts +8 -1
- package/dist/puck/editor/copy.js +9 -1
- package/dist/puck/editor/editor.chrome.css +117 -3
- package/dist/puck/editor/editor.css +130 -8
- package/dist/puck/editor/editor.model.d.ts +2 -1
- package/dist/puck/editor/editor.model.js +2 -2
- package/dist/puck/editor/localPlacements.d.ts +1 -0
- package/dist/puck/editor/localPlacements.js +12 -0
- package/dist/puck/editor/placementsCache.d.ts +18 -12
- package/dist/puck/editor/placementsCache.js +52 -47
- package/dist/puck/editor/usePlacementNotice.d.ts +1 -1
- package/dist/puck/editor/usePlacementNotice.js +4 -3
- package/dist/puck/experimentSlug.d.ts +2 -0
- package/dist/puck/experimentSlug.js +3 -0
- package/dist/puck/nestedTestCopy.d.ts +8 -0
- package/dist/puck/nestedTestCopy.js +22 -0
- package/dist/puck/nestedTests.d.ts +17 -0
- package/dist/puck/nestedTests.js +30 -0
- package/dist/puck/slotConfig.d.ts +1 -1
- package/dist/puck/slotConfig.js +17 -4
- package/dist/puck/visibility.d.ts +2 -3
- package/dist/puck/visibility.js +11 -7
- package/dist/server/recordContentChange.js +34 -19
- package/dist/server/resolveExperimentData.js +2 -2
- package/dist/testSurface/PreviewLinks.js +6 -2
- package/dist/testSurface/api.d.ts +6 -3
- package/dist/testSurface/api.js +10 -6
- package/dist/testSurface/contentLocaleURL.d.ts +2 -0
- package/dist/testSurface/contentLocaleURL.js +3 -0
- package/dist/testSurface/copy/common.d.ts +4 -0
- package/dist/testSurface/copy/common.js +8 -4
- package/dist/testSurface/copy/languages.d.ts +11 -0
- package/dist/testSurface/copy/languages.js +7 -0
- package/dist/testSurface/copy/readiness.d.ts +1 -1
- package/dist/testSurface/copy/readiness.js +1 -1
- package/dist/testSurface/copy/testPage.d.ts +21 -0
- package/dist/testSurface/copy/testPage.js +21 -0
- package/dist/testSurface/placementLabel.d.ts +8 -0
- package/dist/testSurface/placementLabel.js +24 -0
- package/dist/testSurface/placements/placementLabels.d.ts +2 -0
- package/dist/testSurface/placements/placementLabels.js +2 -1
- package/dist/testSurface/results/results.css +1 -1
- package/dist/testSurface/surface/contracts.d.ts +2 -0
- package/dist/testSurface/surface/editorPlacement.d.ts +5 -0
- package/dist/testSurface/surface/editorPlacement.js +18 -0
- package/dist/testSurface/surface/pageBlock/pageBlock.model.js +2 -1
- package/dist/testSurface/surface/pageBlock/parts.js +24 -6
- package/dist/testSurface/surface/readiness/readiness.model.js +9 -2
- package/dist/testSurface/surface/results/useResults.d.ts +4 -1
- package/dist/testSurface/surface/test/DeleteTest.d.ts +15 -0
- package/dist/testSurface/surface/test/DeleteTest.js +171 -0
- package/dist/testSurface/surface/test/TestSurface.js +29 -9
- package/dist/testSurface/surface/useTestDocument.d.ts +2 -1
- package/dist/testSurface/surface/useTestDocument.js +20 -4
- package/dist/testSurface/useApi.d.ts +4 -1
- package/dist/transitions/checkStart.d.ts +4 -1
- package/dist/transitions/checkStart.js +117 -14
- package/dist/transitions/contentFields.js +9 -5
- package/dist/transitions/makeContent.js +5 -4
- package/dist/transitions/nestedPlacementNames.d.ts +5 -0
- package/dist/transitions/nestedPlacementNames.js +33 -0
- package/dist/transitions/pageVersions.js +3 -1
- package/dist/transitions/placementInteractions.js +7 -4
- package/dist/transitions/placements.d.ts +26 -1
- package/dist/transitions/placements.js +219 -56
- package/dist/transitions/preflightData.d.ts +2 -1
- package/dist/transitions/preflightData.js +66 -3
- package/dist/transitions/start.js +4 -1
- package/dist/types/endpoints.d.ts +35 -1
- package/dist/types/endpoints.js +1 -1
- package/dist/types/surface.d.ts +2 -0
- package/dist/ui/Button.js +2 -2
- package/dist/ui/Inputs.d.ts +4 -3
- package/dist/ui/Inputs.js +9 -9
- package/dist/ui/SelectControl.d.ts +33 -0
- package/dist/ui/SelectControl.js +504 -0
- package/dist/ui/ui.css +13 -5
- package/package.json +3 -2
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
'use client';
|
|
2
2
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
3
|
-
import { useEffect, useId, useRef, useState } from 'react';
|
|
3
|
+
import { createContext, useContext, useEffect, useId, useRef, useState } from 'react';
|
|
4
4
|
import { balanceWeight, splitEvenly, totalWeight, withSlotsFor } from '../../arms/model.js';
|
|
5
5
|
import { checkArms } from '../../collections/experiments/armInvariants.js';
|
|
6
6
|
import { issueMessage } from '../../arms/copy.js';
|
|
@@ -9,6 +9,154 @@ import { Dialog } from '../../ui/Dialog.js';
|
|
|
9
9
|
import { NumberInput, TextInput } from '../../ui/Inputs.js';
|
|
10
10
|
import { addVersionArms, ArmWriteError, removeVersionArms, renameVersionArms, setVersionTraffic, writeArms } from './armWrites.js';
|
|
11
11
|
import { editorCopy as C } from './copy.js';
|
|
12
|
+
const VersionLockContext = /*#__PURE__*/ createContext(undefined);
|
|
13
|
+
/** A pointer shortcut supplements the explicit, keyboard-accessible open marker. */ export function VersionCard({ label, openLabel = label, active, dragging, interactive = true, onSelect, children }) {
|
|
14
|
+
return /*#__PURE__*/ _jsx("div", {
|
|
15
|
+
className: "xp-slot-version-group",
|
|
16
|
+
"data-active": active,
|
|
17
|
+
role: "group",
|
|
18
|
+
"aria-label": label,
|
|
19
|
+
"aria-current": active ? 'true' : undefined,
|
|
20
|
+
onClick: (event)=>{
|
|
21
|
+
if (interactive && !dragging && event.currentTarget.ownerDocument.getSelection()?.isCollapsed !== false && !event.target.closest('button, input, label, select, textarea, a, [role="button"], [contenteditable="true"]')) onSelect();
|
|
22
|
+
},
|
|
23
|
+
children: /*#__PURE__*/ _jsxs("div", {
|
|
24
|
+
className: "xp-slot-version-row",
|
|
25
|
+
children: [
|
|
26
|
+
interactive ? /*#__PURE__*/ _jsx("button", {
|
|
27
|
+
type: "button",
|
|
28
|
+
className: "xp-slot-version-open",
|
|
29
|
+
"aria-label": C.showVersion(openLabel),
|
|
30
|
+
"aria-pressed": active,
|
|
31
|
+
disabled: dragging,
|
|
32
|
+
onClick: onSelect
|
|
33
|
+
}) : /*#__PURE__*/ _jsx("span", {
|
|
34
|
+
className: "xp-slot-version-open",
|
|
35
|
+
"aria-hidden": "true",
|
|
36
|
+
style: {
|
|
37
|
+
cursor: 'default'
|
|
38
|
+
}
|
|
39
|
+
}),
|
|
40
|
+
children
|
|
41
|
+
]
|
|
42
|
+
})
|
|
43
|
+
});
|
|
44
|
+
}
|
|
45
|
+
/** Keep unavailable controls reachable, and explain an attempted edit in place. */ export function VersionLock({ message, children }) {
|
|
46
|
+
const id = useId();
|
|
47
|
+
const controls = useRef(null);
|
|
48
|
+
const notice = useRef(null);
|
|
49
|
+
const timer = useRef(undefined);
|
|
50
|
+
const [attention, setAttention] = useState(false);
|
|
51
|
+
useEffect(()=>{
|
|
52
|
+
setAttention(false);
|
|
53
|
+
return ()=>{
|
|
54
|
+
clearTimeout(timer.current);
|
|
55
|
+
timer.current = undefined;
|
|
56
|
+
};
|
|
57
|
+
}, [
|
|
58
|
+
message
|
|
59
|
+
]);
|
|
60
|
+
const explain = ()=>{
|
|
61
|
+
if (timer.current !== undefined) return;
|
|
62
|
+
setAttention(true);
|
|
63
|
+
notice.current?.scrollIntoView?.({
|
|
64
|
+
block: 'nearest'
|
|
65
|
+
});
|
|
66
|
+
timer.current = setTimeout(()=>{
|
|
67
|
+
timer.current = undefined;
|
|
68
|
+
setAttention(false);
|
|
69
|
+
}, 2000);
|
|
70
|
+
};
|
|
71
|
+
useEffect(()=>{
|
|
72
|
+
const node = controls.current;
|
|
73
|
+
if (!message || !node) return;
|
|
74
|
+
const edit = (event)=>{
|
|
75
|
+
if (event.target.closest('input[aria-disabled="true"], textarea[aria-disabled="true"]')) {
|
|
76
|
+
event.preventDefault();
|
|
77
|
+
event.stopPropagation();
|
|
78
|
+
explain();
|
|
79
|
+
}
|
|
80
|
+
};
|
|
81
|
+
node.addEventListener('beforeinput', edit, true);
|
|
82
|
+
return ()=>node.removeEventListener('beforeinput', edit, true);
|
|
83
|
+
}, [
|
|
84
|
+
message
|
|
85
|
+
]);
|
|
86
|
+
return /*#__PURE__*/ _jsx(VersionLockContext.Provider, {
|
|
87
|
+
value: message ? id : undefined,
|
|
88
|
+
children: /*#__PURE__*/ _jsxs("div", {
|
|
89
|
+
ref: controls,
|
|
90
|
+
className: "xp-slot-version-controls",
|
|
91
|
+
onPasteCapture: (event)=>{
|
|
92
|
+
if (message && event.target.closest('input[aria-disabled="true"], textarea[aria-disabled="true"]')) {
|
|
93
|
+
event.preventDefault();
|
|
94
|
+
event.stopPropagation();
|
|
95
|
+
explain();
|
|
96
|
+
}
|
|
97
|
+
},
|
|
98
|
+
onCutCapture: (event)=>{
|
|
99
|
+
if (message && event.target.closest('input[aria-disabled="true"], textarea[aria-disabled="true"]')) {
|
|
100
|
+
event.preventDefault();
|
|
101
|
+
event.stopPropagation();
|
|
102
|
+
explain();
|
|
103
|
+
}
|
|
104
|
+
},
|
|
105
|
+
onClickCapture: (event)=>{
|
|
106
|
+
if (message && event.target.closest('button[aria-disabled="true"], [role="button"][aria-disabled="true"]')) {
|
|
107
|
+
event.preventDefault();
|
|
108
|
+
event.stopPropagation();
|
|
109
|
+
explain();
|
|
110
|
+
}
|
|
111
|
+
},
|
|
112
|
+
onKeyDownCapture: (event)=>{
|
|
113
|
+
// Leave Tab, caret navigation and copying available on read-only values.
|
|
114
|
+
const control = event.target.closest('[aria-disabled="true"]');
|
|
115
|
+
const stepping = control?.matches('input[type="number"]') && [
|
|
116
|
+
'ArrowUp',
|
|
117
|
+
'ArrowDown'
|
|
118
|
+
].includes(event.key);
|
|
119
|
+
const shortcut = (event.ctrlKey || event.metaKey) && [
|
|
120
|
+
'v',
|
|
121
|
+
'x'
|
|
122
|
+
].includes(event.key.toLowerCase()) || event.shiftKey && [
|
|
123
|
+
'Insert',
|
|
124
|
+
'Delete'
|
|
125
|
+
].includes(event.key);
|
|
126
|
+
const typing = !event.ctrlKey && !event.metaKey && !event.altKey && event.key.length === 1;
|
|
127
|
+
const deletion = [
|
|
128
|
+
'Backspace',
|
|
129
|
+
'Delete'
|
|
130
|
+
].includes(event.key);
|
|
131
|
+
const activation = control?.matches('button, [role="button"]') && [
|
|
132
|
+
'Enter',
|
|
133
|
+
' '
|
|
134
|
+
].includes(event.key);
|
|
135
|
+
const input = control?.matches('input, textarea');
|
|
136
|
+
if (message && control && (input && (shortcut || typing || deletion || stepping) || activation)) {
|
|
137
|
+
event.preventDefault();
|
|
138
|
+
event.stopPropagation();
|
|
139
|
+
explain();
|
|
140
|
+
}
|
|
141
|
+
},
|
|
142
|
+
children: [
|
|
143
|
+
message ? /*#__PURE__*/ _jsx("div", {
|
|
144
|
+
ref: notice,
|
|
145
|
+
id: id,
|
|
146
|
+
className: "xp-slot-lock-notice",
|
|
147
|
+
"data-attention": attention,
|
|
148
|
+
children: attention ? /*#__PURE__*/ _jsx("span", {
|
|
149
|
+
role: "alert",
|
|
150
|
+
children: message
|
|
151
|
+
}, "attention") : /*#__PURE__*/ _jsx("span", {
|
|
152
|
+
children: message
|
|
153
|
+
}, "rest")
|
|
154
|
+
}) : null,
|
|
155
|
+
children(message ? id : undefined)
|
|
156
|
+
]
|
|
157
|
+
})
|
|
158
|
+
});
|
|
159
|
+
}
|
|
12
160
|
export function useArmWrites({ url, bindingKey, status, controlKeys, publish, isCurrent, onWrite, onSaved }) {
|
|
13
161
|
const guard = useRef(false);
|
|
14
162
|
const running = useRef(Promise.resolve());
|
|
@@ -119,6 +267,7 @@ export function useArmWrites({ url, bindingKey, status, controlKeys, publish, is
|
|
|
119
267
|
export function AddVariant({ experiment, writes, onSelect }) {
|
|
120
268
|
if (experiment.arms.filter((arm)=>arm.kind === 'variant').length >= 3) return null;
|
|
121
269
|
return /*#__PURE__*/ _jsx(Button, {
|
|
270
|
+
size: "sm",
|
|
122
271
|
"aria-disabled": writes.busy || undefined,
|
|
123
272
|
onClick: async ()=>{
|
|
124
273
|
if (writes.busy) return;
|
|
@@ -135,6 +284,7 @@ export function AddVariant({ experiment, writes, onSelect }) {
|
|
|
135
284
|
}
|
|
136
285
|
/** Always-visible editor for the saved version name. */ export function VersionName({ arm, writes, editable }) {
|
|
137
286
|
const id = useId();
|
|
287
|
+
const lockId = useContext(VersionLockContext);
|
|
138
288
|
const [name, setName] = useState(arm.label);
|
|
139
289
|
const draft = useRef(arm.label);
|
|
140
290
|
const pending = useRef(null);
|
|
@@ -182,6 +332,7 @@ export function AddVariant({ experiment, writes, onSelect }) {
|
|
|
182
332
|
pending.current = null;
|
|
183
333
|
}
|
|
184
334
|
}
|
|
335
|
+
const message = invalid ? C.emptyLabel : error;
|
|
185
336
|
return /*#__PURE__*/ _jsxs("div", {
|
|
186
337
|
className: "xp-slot-version-name",
|
|
187
338
|
children: [
|
|
@@ -191,9 +342,15 @@ export function AddVariant({ experiment, writes, onSelect }) {
|
|
|
191
342
|
"aria-label": `${arm.label} ${C.name}`,
|
|
192
343
|
value: name,
|
|
193
344
|
readOnly: !editable || writes.busy,
|
|
194
|
-
"aria-disabled": writes.busy || undefined,
|
|
195
|
-
|
|
345
|
+
"aria-disabled": !editable || writes.busy || undefined,
|
|
346
|
+
"aria-describedby": [
|
|
347
|
+
lockId,
|
|
348
|
+
saved ? `${id}-saved` : undefined
|
|
349
|
+
].filter(Boolean).join(' ') || undefined,
|
|
350
|
+
"aria-errormessage": message ? `${id}-error` : undefined,
|
|
351
|
+
error: message,
|
|
196
352
|
onChange: (event)=>{
|
|
353
|
+
if (!editable || writes.busy) return;
|
|
197
354
|
draft.current = event.target.value;
|
|
198
355
|
setName(event.target.value);
|
|
199
356
|
setInvalid(false);
|
|
@@ -218,11 +375,12 @@ export function AddVariant({ experiment, writes, onSelect }) {
|
|
|
218
375
|
}
|
|
219
376
|
}
|
|
220
377
|
}),
|
|
221
|
-
|
|
378
|
+
/*#__PURE__*/ _jsx("span", {
|
|
379
|
+
id: `${id}-saved`,
|
|
222
380
|
role: "status",
|
|
223
|
-
className: "xp-ui-help",
|
|
224
|
-
children: C.saved
|
|
225
|
-
})
|
|
381
|
+
className: "xp-ui-help xp-slot-version-saved",
|
|
382
|
+
children: saved ? C.saved : ''
|
|
383
|
+
})
|
|
226
384
|
]
|
|
227
385
|
});
|
|
228
386
|
}
|
|
@@ -287,9 +445,9 @@ export function RemoveVersion({ arm, writes, count, shared, onRemove, onClose })
|
|
|
287
445
|
})
|
|
288
446
|
});
|
|
289
447
|
}
|
|
290
|
-
export function VersionWeights({ experiment, writes, edits, setEdits, groupId, splitIntent, editable = true, beforeSplit, renderRow }) {
|
|
448
|
+
export function VersionWeights({ experiment, writes, edits, setEdits, groupId, splitIntent, editable = true, showSplit = editable, beforeSplit, beforeActions, renderRow }) {
|
|
291
449
|
const id = useId();
|
|
292
|
-
const
|
|
450
|
+
const lockId = useContext(VersionLockContext);
|
|
293
451
|
const [errors, setErrors] = useState({});
|
|
294
452
|
const armKeys = experiment.arms.map((arm)=>arm.key).join(',');
|
|
295
453
|
useEffect(()=>{
|
|
@@ -306,7 +464,7 @@ export function VersionWeights({ experiment, writes, edits, setEdits, groupId, s
|
|
|
306
464
|
const live = withSlotsFor(keys.length === 1 && !invalidKeys.has(keys[0]) && !errors[keys[0]] ? apply(experiment.arms, keys[0]) : experiment.arms, 'block');
|
|
307
465
|
const issues = checkArms(live, 'block');
|
|
308
466
|
async function commit(key) {
|
|
309
|
-
if (writes.busy || edits[key] === undefined || invalidKeys.has(key)) return;
|
|
467
|
+
if (!editable || writes.busy || edits[key] === undefined || invalidKeys.has(key)) return;
|
|
310
468
|
clearErrors([
|
|
311
469
|
key
|
|
312
470
|
]);
|
|
@@ -333,9 +491,12 @@ export function VersionWeights({ experiment, writes, edits, setEdits, groupId, s
|
|
|
333
491
|
step: 1,
|
|
334
492
|
value: edits[arm.key] ?? live.find((current)=>current.key === arm.key)?.weight ?? '',
|
|
335
493
|
readOnly: !editable || writes.busy,
|
|
336
|
-
"aria-disabled": writes.busy || undefined,
|
|
494
|
+
"aria-disabled": !editable || writes.busy || undefined,
|
|
495
|
+
"aria-describedby": lockId,
|
|
337
496
|
error: invalidKeys.has(arm.key) ? C.invalidShare : errors[arm.key],
|
|
497
|
+
"aria-errormessage": invalidKeys.has(arm.key) || errors[arm.key] ? `${id}-${arm.key}-error` : undefined,
|
|
338
498
|
onChange: (event)=>{
|
|
499
|
+
if (!editable || writes.busy) return;
|
|
339
500
|
clearErrors([
|
|
340
501
|
arm.key
|
|
341
502
|
]);
|
|
@@ -364,7 +525,18 @@ export function VersionWeights({ experiment, writes, edits, setEdits, groupId, s
|
|
|
364
525
|
}
|
|
365
526
|
});
|
|
366
527
|
return /*#__PURE__*/ _jsx("div", {
|
|
367
|
-
|
|
528
|
+
className: "xp-slot-version-item",
|
|
529
|
+
children: renderRow ? renderRow(arm, /*#__PURE__*/ _jsxs("div", {
|
|
530
|
+
className: "xp-slot-version-traffic",
|
|
531
|
+
children: [
|
|
532
|
+
input,
|
|
533
|
+
/*#__PURE__*/ _jsx("span", {
|
|
534
|
+
className: "xp-slot-percent",
|
|
535
|
+
"aria-hidden": "true",
|
|
536
|
+
children: C.percent
|
|
537
|
+
})
|
|
538
|
+
]
|
|
539
|
+
})) : input
|
|
368
540
|
}, arm.key);
|
|
369
541
|
})
|
|
370
542
|
}),
|
|
@@ -373,33 +545,39 @@ export function VersionWeights({ experiment, writes, edits, setEdits, groupId, s
|
|
|
373
545
|
className: "xp-ui-error",
|
|
374
546
|
children: issueMessage(issue, totalWeight(live))
|
|
375
547
|
}, i)) : null,
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
548
|
+
beforeActions,
|
|
549
|
+
beforeSplit || showSplit ? /*#__PURE__*/ _jsxs("div", {
|
|
550
|
+
className: "xp-slot-version-actions",
|
|
551
|
+
children: [
|
|
552
|
+
beforeSplit,
|
|
553
|
+
showSplit ? /*#__PURE__*/ _jsx("div", {
|
|
554
|
+
"data-xp-split": groupId,
|
|
555
|
+
onPointerDownCapture: ()=>{
|
|
556
|
+
// Pointer intent reaches the destination before the source iframe loses focus.
|
|
557
|
+
if (!editable) return;
|
|
558
|
+
splitIntent.current = true;
|
|
559
|
+
setTimeout(()=>{
|
|
560
|
+
splitIntent.current = false;
|
|
561
|
+
}, 0);
|
|
562
|
+
},
|
|
563
|
+
children: /*#__PURE__*/ _jsx(Button, {
|
|
564
|
+
size: "sm",
|
|
565
|
+
"aria-describedby": lockId,
|
|
566
|
+
"aria-disabled": !editable || writes.busy || undefined,
|
|
567
|
+
onClick: async ()=>{
|
|
568
|
+
if (!editable || writes.busy) return;
|
|
569
|
+
const saved = await writes.write(splitEvenly, {
|
|
570
|
+
errorKey: 'split'
|
|
571
|
+
});
|
|
572
|
+
if (saved) {
|
|
573
|
+
setEdits(()=>({}));
|
|
574
|
+
setErrors({});
|
|
575
|
+
}
|
|
576
|
+
},
|
|
577
|
+
children: C.split
|
|
578
|
+
})
|
|
579
|
+
}) : null
|
|
580
|
+
]
|
|
403
581
|
}) : null
|
|
404
582
|
]
|
|
405
583
|
});
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import type { ComponentData } from '@puckeditor/core';
|
|
2
|
+
type PasteArgs = {
|
|
3
|
+
block: ComponentData;
|
|
4
|
+
destination: {
|
|
5
|
+
ancestors: readonly {
|
|
6
|
+
type: string;
|
|
7
|
+
}[];
|
|
8
|
+
};
|
|
9
|
+
};
|
|
10
|
+
export declare function canPasteExperiment({ block, destination }: PasteArgs): true | string;
|
|
11
|
+
export declare const experimentClipboard: {
|
|
12
|
+
blockClipboard: {
|
|
13
|
+
canPaste: typeof canPasteExperiment;
|
|
14
|
+
};
|
|
15
|
+
};
|
|
16
|
+
export {};
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { nestedTests } from '../nestedTests.js';
|
|
2
|
+
import { editorCopy } from './copy.js';
|
|
3
|
+
export function canPasteExperiment({ block, destination }) {
|
|
4
|
+
const ancestors = destination.ancestors.map((ancestor)=>({
|
|
5
|
+
type: ancestor.type,
|
|
6
|
+
props: {}
|
|
7
|
+
}));
|
|
8
|
+
if (nestedTests(block, {
|
|
9
|
+
includeHidden: true,
|
|
10
|
+
ancestors
|
|
11
|
+
}).length) return editorCopy.nestedPaste;
|
|
12
|
+
return true;
|
|
13
|
+
}
|
|
14
|
+
// Spread into the component config so older Puck typings and hosts accept the
|
|
15
|
+
// extra key. payload-puck 0.12.1 invokes it; 0.12.0 simply ignores it.
|
|
16
|
+
export const experimentClipboard = {
|
|
17
|
+
blockClipboard: {
|
|
18
|
+
canPaste: canPasteExperiment
|
|
19
|
+
}
|
|
20
|
+
};
|
|
@@ -1,4 +1,7 @@
|
|
|
1
1
|
export declare const editorCopy: {
|
|
2
|
+
readonly nested: (outer?: string, inner?: string) => string;
|
|
3
|
+
readonly nestedHidden: (outer?: string) => string;
|
|
4
|
+
readonly nestedPaste: "A test can't go inside another test's version.";
|
|
2
5
|
readonly hidden: "This block is hidden, so visitors won't see this test here.";
|
|
3
6
|
readonly hiddenOn: (sizes: string) => string;
|
|
4
7
|
readonly retrySetup: "Retry";
|
|
@@ -21,7 +24,8 @@ export declare const editorCopy: {
|
|
|
21
24
|
readonly draft: (label: string) => string;
|
|
22
25
|
readonly running: "Changing this content mid-test mixes two versions in one result";
|
|
23
26
|
readonly decided: (winner: string) => string;
|
|
24
|
-
readonly archived:
|
|
27
|
+
readonly archived: (winner: string) => string;
|
|
28
|
+
readonly archivedOriginal: (original: string, discarded: boolean) => string;
|
|
25
29
|
readonly copy: (label?: string) => string;
|
|
26
30
|
readonly copyEmpty: (label?: string) => string;
|
|
27
31
|
readonly enterName: "Enter a name to create the test.";
|
|
@@ -50,6 +54,7 @@ export declare const editorCopy: {
|
|
|
50
54
|
readonly deleteContentHelp: (label: string, count: number) => string;
|
|
51
55
|
readonly draftOnly: "Only draft tests can add this version. Use a different test to include it.";
|
|
52
56
|
readonly outsideTest: (label: string) => string;
|
|
57
|
+
readonly showVersion: (label: string) => string;
|
|
53
58
|
readonly tabs: "Test versions";
|
|
54
59
|
readonly add: "Add variant";
|
|
55
60
|
readonly testGroup: "Test";
|
|
@@ -59,6 +64,7 @@ export declare const editorCopy: {
|
|
|
59
64
|
readonly createAnother: "Create a test";
|
|
60
65
|
readonly readOnlyVersions: "You don't have permission to change this test's versions.";
|
|
61
66
|
readonly traffic: "Traffic (%)";
|
|
67
|
+
readonly percent: "%";
|
|
62
68
|
readonly saved: "Saved";
|
|
63
69
|
readonly removeVersion: "Remove version";
|
|
64
70
|
readonly emptyLabel: "Enter a name for this version.";
|
|
@@ -70,6 +76,7 @@ export declare const editorCopy: {
|
|
|
70
76
|
readonly removed: "Save the page to finish removing this version's content.";
|
|
71
77
|
readonly removeUncleared: "The version was removed from the test, but its content couldn't be cleared here. Delete it from the outline, then save the page.";
|
|
72
78
|
readonly lockedGeneric: "This test's versions can't change. View the test page for details.";
|
|
79
|
+
readonly holdoutContent: "Holdout visitors see the Original.";
|
|
73
80
|
readonly holdoutPeople: (label: string, count: string) => string;
|
|
74
81
|
readonly weight: (label: string) => string;
|
|
75
82
|
readonly invalidShare: "Use a whole number from 0 to 100.";
|
package/dist/puck/editor/copy.js
CHANGED
|
@@ -1,5 +1,9 @@
|
|
|
1
|
+
import { nestedTestCopy } from '../nestedTestCopy.js';
|
|
1
2
|
import { ARM_LABELS } from '../../labels/arms.js';
|
|
2
3
|
export const editorCopy = {
|
|
4
|
+
nested: nestedTestCopy.editor,
|
|
5
|
+
nestedHidden: nestedTestCopy.hidden,
|
|
6
|
+
nestedPaste: "A test can't go inside another test's version.",
|
|
3
7
|
hidden: "This block is hidden, so visitors won't see this test here.",
|
|
4
8
|
hiddenOn: (sizes)=>`This block is hidden on ${sizes}. Visitors on ${sizes} are still counted in this test.`,
|
|
5
9
|
retrySetup: 'Retry',
|
|
@@ -16,7 +20,8 @@ export const editorCopy = {
|
|
|
16
20
|
draft: (label)=>`This block shows the ${label} to everyone until the test starts.`,
|
|
17
21
|
running: 'Changing this content mid-test mixes two versions in one result',
|
|
18
22
|
decided: (winner)=>`Decided: ${winner}. Use 'Make it the content' on the test to finish.`,
|
|
19
|
-
archived:
|
|
23
|
+
archived: (winner)=>`Archived: this block serves ${winner}, or nothing if that version is empty. To keep the content without the test, move it out of this Experiment block on the canvas, then remove the Experiment block.`,
|
|
24
|
+
archivedOriginal: (original, discarded)=>`${discarded ? 'Winner discarded' : 'Archived without a winner'}: this block shows ${original}, or nothing if it is empty. To keep it without the test, move its content out on the canvas, then remove this Experiment block.`,
|
|
20
25
|
copy: (label = ARM_LABELS.control)=>`Copy ${label} here`,
|
|
21
26
|
copyEmpty: (label = ARM_LABELS.control)=>`Add content to the ${label} before copying it.`,
|
|
22
27
|
enterName: 'Enter a name to create the test.',
|
|
@@ -45,6 +50,7 @@ export const editorCopy = {
|
|
|
45
50
|
deleteContentHelp: (label, count)=>`This deletes the ${count} ${count === 1 ? 'block' : 'blocks'} in ${label} from this page. Save the page to keep this change.`,
|
|
46
51
|
draftOnly: 'Only draft tests can add this version. Use a different test to include it.',
|
|
47
52
|
outsideTest: (label)=>`${label} · not in this test`,
|
|
53
|
+
showVersion: (label)=>`Show ${label} on the page`,
|
|
48
54
|
tabs: 'Test versions',
|
|
49
55
|
add: 'Add variant',
|
|
50
56
|
testGroup: 'Test',
|
|
@@ -54,6 +60,7 @@ export const editorCopy = {
|
|
|
54
60
|
createAnother: 'Create a test',
|
|
55
61
|
readOnlyVersions: "You don't have permission to change this test's versions.",
|
|
56
62
|
traffic: 'Traffic (%)',
|
|
63
|
+
percent: '%',
|
|
57
64
|
saved: 'Saved',
|
|
58
65
|
removeVersion: 'Remove version',
|
|
59
66
|
emptyLabel: 'Enter a name for this version.',
|
|
@@ -65,6 +72,7 @@ export const editorCopy = {
|
|
|
65
72
|
removed: "Save the page to finish removing this version's content.",
|
|
66
73
|
removeUncleared: "The version was removed from the test, but its content couldn't be cleared here. Delete it from the outline, then save the page.",
|
|
67
74
|
lockedGeneric: "This test's versions can't change. View the test page for details.",
|
|
75
|
+
holdoutContent: 'Holdout visitors see the Original.',
|
|
68
76
|
holdoutPeople: (label, count)=>`${label}: ${count} people (not compared)`,
|
|
69
77
|
weight: (label)=>`${label} traffic (%)`,
|
|
70
78
|
invalidShare: 'Use a whole number from 0 to 100.',
|
|
@@ -132,6 +132,21 @@
|
|
|
132
132
|
[class*="_PuckFields"] .xp-slot-root .xp-ui-error { color: var(--xp-error); }
|
|
133
133
|
[class*="_PuckFields"] .xp-slot-root .xp-ui-help { color: var(--xp-text-2); }
|
|
134
134
|
[class*="_PuckFields"] .xp-slot-root .xp-ui-field label { color: var(--xp-text); }
|
|
135
|
+
/* Native popovers keep this ancestry in the top layer. The fallback portals to
|
|
136
|
+
the nearest open dialog or owner-document body, copying the trigger's --xp-*
|
|
137
|
+
tokens; outside the field subtree, shared ui.css supplies the menu colors. */
|
|
138
|
+
[class*="_PuckFields"] .xp-slot-root .xp-ui-combobox { color: var(--xp-text); background: var(--xp-surface); border-color: var(--xp-border-strong); }
|
|
139
|
+
[class*="_PuckFields"] .xp-slot-root .xp-ui-combobox:hover { border-color: var(--xp-text-3); }
|
|
140
|
+
[class*="_PuckFields"] .xp-slot-root .xp-ui-combobox:focus-visible { outline: 2px solid var(--xp-focus); }
|
|
141
|
+
[class*="_PuckFields"] .xp-slot-root .xp-ui-combobox[aria-invalid='true'] { border-color: var(--xp-error); }
|
|
142
|
+
[class*="_PuckFields"] .xp-slot-root .xp-ui-combobox:disabled { opacity: 1; color: var(--xp-text-2); background: var(--xp-surface-3); border-color: var(--xp-border-strong); }
|
|
143
|
+
[class*="_PuckFields"] .xp-slot-root .xp-ui-combobox > span:first-child { color: inherit; }
|
|
144
|
+
[class*="_PuckFields"] .xp-slot-root .xp-ui-combobox-chevron { border-right-color: var(--xp-text-2); border-bottom-color: var(--xp-text-2); }
|
|
145
|
+
[class*="_PuckFields"] .xp-slot-root .xp-ui-combobox-popup { color: var(--xp-text); background: var(--xp-surface); border-color: var(--xp-border-strong); }
|
|
146
|
+
[class*="_PuckFields"] .xp-slot-root .xp-ui-combobox-option { color: var(--xp-text); }
|
|
147
|
+
[class*="_PuckFields"] .xp-slot-root .xp-ui-combobox-option[data-active='true'] { color: var(--xp-text); background: var(--xp-surface-3); outline: 1px solid var(--xp-border-strong); }
|
|
148
|
+
[class*="_PuckFields"] .xp-slot-root .xp-ui-combobox-option[aria-disabled='true'] { color: var(--xp-text-3); }
|
|
149
|
+
[class*="_PuckFields"] .xp-slot-root .xp-ui-combobox-group { color: var(--xp-text-2); }
|
|
135
150
|
[class*="_PuckFields"] .xp-puck-field .xp-ui-button:disabled,
|
|
136
151
|
[class*="_PuckFields"] .xp-puck-field .xp-ui-button[aria-disabled='true'] {
|
|
137
152
|
opacity: 1;
|
|
@@ -172,9 +187,6 @@
|
|
|
172
187
|
/* Grid stretching must not turn a status chip into a full-width bar. */
|
|
173
188
|
.xp-slot-sidebar .xp-ui-status { justify-self: start; width: max-content; }
|
|
174
189
|
.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
190
|
|
|
179
191
|
.xp-slot-header .xp-ui-status { flex: none; }
|
|
180
192
|
|
|
@@ -184,3 +196,105 @@
|
|
|
184
196
|
overflow-wrap: anywhere;
|
|
185
197
|
text-overflow: clip;
|
|
186
198
|
}
|
|
199
|
+
|
|
200
|
+
/* Compact field cards fit the Puck sidebar and wrap by their own available width. */
|
|
201
|
+
.xp-slot-sidebar .xp-slot-test-heading {
|
|
202
|
+
display: grid;
|
|
203
|
+
grid-template-columns: minmax(0, 1fr) auto;
|
|
204
|
+
align-items: start;
|
|
205
|
+
gap: var(--xp-space-2);
|
|
206
|
+
}
|
|
207
|
+
.xp-slot-test-heading > strong { min-width: 0; overflow-wrap: anywhere; }
|
|
208
|
+
.xp-slot-sidebar .xp-ui-banner {
|
|
209
|
+
min-width: 0;
|
|
210
|
+
padding: var(--xp-space-2) var(--xp-space-3);
|
|
211
|
+
gap: var(--xp-space-2);
|
|
212
|
+
font: var(--xp-text-small);
|
|
213
|
+
overflow-wrap: anywhere;
|
|
214
|
+
}
|
|
215
|
+
.xp-slot-sidebar .xp-ui-banner > p { min-width: 0; }
|
|
216
|
+
.xp-slot-version-controls, .xp-slot-weights { display: grid; gap: var(--xp-space-2); min-width: 0; }
|
|
217
|
+
.xp-slot-sidebar .xp-slot-weight-inputs { gap: var(--xp-space-2); }
|
|
218
|
+
.xp-slot-version-item { min-width: 0; }
|
|
219
|
+
.xp-slot-version-group {
|
|
220
|
+
display: grid;
|
|
221
|
+
gap: var(--xp-space-2);
|
|
222
|
+
padding: var(--xp-space-2);
|
|
223
|
+
border: 1px solid var(--xp-border-strong);
|
|
224
|
+
border-radius: var(--xp-radius-control);
|
|
225
|
+
background: var(--xp-surface);
|
|
226
|
+
min-width: 0;
|
|
227
|
+
container-type: inline-size;
|
|
228
|
+
}
|
|
229
|
+
.xp-slot-version-row { display: grid; grid-template-columns: 24px minmax(0, 1fr) 72px; align-items: start; gap: var(--xp-space-half) var(--xp-space-2); min-width: 0; }
|
|
230
|
+
.xp-slot-version-open {
|
|
231
|
+
position: relative;
|
|
232
|
+
grid-area: 1 / 1;
|
|
233
|
+
min-width: 24px;
|
|
234
|
+
min-height: 32px;
|
|
235
|
+
padding: 0;
|
|
236
|
+
border: 0;
|
|
237
|
+
border-radius: var(--xp-radius-control);
|
|
238
|
+
background: transparent;
|
|
239
|
+
cursor: pointer;
|
|
240
|
+
}
|
|
241
|
+
.xp-slot-version-open::before { content: ''; position: absolute; inset-block: 4px; inset-inline-start: 0; width: 3px; border-radius: 2px; background: var(--xp-border-strong); }
|
|
242
|
+
.xp-slot-version-open[aria-pressed='true']::before { background: var(--xp-focus); }
|
|
243
|
+
.xp-slot-version-open:focus-visible { outline: 2px solid var(--xp-focus); outline-offset: 2px; }
|
|
244
|
+
.xp-slot-version-open:disabled { cursor: not-allowed; }
|
|
245
|
+
/* Flatten only field layout boxes so their feedback uses the entire card row. */
|
|
246
|
+
.xp-slot-version-name, .xp-slot-version-traffic, .xp-slot-version-row .xp-ui-field { display: contents; }
|
|
247
|
+
.xp-slot-version-name .xp-ui-input { grid-area: 1 / 2; min-width: 0; font-weight: 600; }
|
|
248
|
+
.xp-slot-version-traffic .xp-ui-input { grid-area: 1 / 3; min-width: 0; }
|
|
249
|
+
.xp-slot-version-label { grid-area: 1 / 2 / auto / -1; align-self: center; min-width: 0; overflow-wrap: anywhere; }
|
|
250
|
+
.xp-slot-version-row .xp-ui-error { grid-column: 1 / -1; margin: 0; }
|
|
251
|
+
/* Reserve one feedback line. Visibility preserves geometry between saves. */
|
|
252
|
+
.xp-slot-version-saved { grid-column: 1 / -1; min-height: 16px; margin: 0; font: var(--xp-text-small); }
|
|
253
|
+
.xp-slot-version-row:has(.xp-ui-error) .xp-slot-version-saved { display: none; }
|
|
254
|
+
.xp-slot-version-row > .xp-slot-version-actions, .xp-slot-version-help { grid-column: 1 / -1; margin: 0; }
|
|
255
|
+
@container (max-width: 220px) {
|
|
256
|
+
.xp-slot-version-group > .xp-slot-version-row { grid-template-columns: 24px minmax(0, 1fr); }
|
|
257
|
+
.xp-slot-version-traffic .xp-ui-input { grid-area: 2 / 2; width: 72px; justify-self: end; }
|
|
258
|
+
.xp-slot-version-traffic .xp-slot-percent { grid-area: 2 / 2; }
|
|
259
|
+
}
|
|
260
|
+
.xp-slot-version-row .xp-ui-field > label {
|
|
261
|
+
position: absolute;
|
|
262
|
+
width: 1px;
|
|
263
|
+
height: 1px;
|
|
264
|
+
padding: 0;
|
|
265
|
+
margin: -1px;
|
|
266
|
+
overflow: hidden;
|
|
267
|
+
clip-path: inset(50%);
|
|
268
|
+
white-space: nowrap;
|
|
269
|
+
}
|
|
270
|
+
.xp-slot-version-row .xp-ui-input { height: 32px; padding-inline: var(--xp-space-2); font-size: 13px; }
|
|
271
|
+
.xp-slot-version-row .xp-ui-input--number { padding-inline-end: 22px; appearance: textfield; }
|
|
272
|
+
.xp-slot-version-row .xp-ui-input--number::-webkit-inner-spin-button,
|
|
273
|
+
.xp-slot-version-row .xp-ui-input--number::-webkit-outer-spin-button { appearance: none; margin: 0; }
|
|
274
|
+
.xp-slot-percent { position: relative; grid-area: 1 / 3; justify-self: end; inset-inline-end: var(--xp-space-2); top: 6px; font: var(--xp-text-small); color: var(--xp-text-2); pointer-events: none; }
|
|
275
|
+
.xp-slot-version-actions { display: flex; align-items: stretch; gap: var(--xp-space-one-half); min-width: 0; }
|
|
276
|
+
.xp-slot-version-actions > * { flex: 1 1 0; min-width: 0; }
|
|
277
|
+
.xp-slot-version-actions > div { display: flex; }
|
|
278
|
+
.xp-slot-version-actions .xp-ui-button { flex: 1; height: auto; min-height: 30px; padding: var(--xp-space-1) var(--xp-space-one-half); font-size: 12px; line-height: 16px; }
|
|
279
|
+
/* Match the solid disabled-button pattern without fading readable field values. */
|
|
280
|
+
.xp-slot-sidebar .xp-ui-input[aria-disabled='true'] {
|
|
281
|
+
opacity: 1;
|
|
282
|
+
background: var(--xp-surface-3);
|
|
283
|
+
border-color: var(--xp-border-strong);
|
|
284
|
+
color: var(--xp-text-2);
|
|
285
|
+
cursor: not-allowed;
|
|
286
|
+
}
|
|
287
|
+
.xp-slot-lock-notice {
|
|
288
|
+
padding: var(--xp-space-2) var(--xp-space-3);
|
|
289
|
+
border: 1px solid var(--xp-warning-border);
|
|
290
|
+
border-radius: var(--xp-radius-control);
|
|
291
|
+
background: var(--xp-warning-bg);
|
|
292
|
+
color: var(--xp-warning);
|
|
293
|
+
font: var(--xp-text-small);
|
|
294
|
+
overflow-wrap: anywhere;
|
|
295
|
+
scroll-margin-block: var(--xp-space-3);
|
|
296
|
+
}
|
|
297
|
+
.xp-slot-lock-notice[data-attention='true'] { border-color: var(--xp-error-border); background: var(--xp-error-bg); color: var(--xp-error); outline: 2px solid var(--xp-error); outline-offset: 2px; }
|
|
298
|
+
@media (prefers-reduced-motion: no-preference) {
|
|
299
|
+
.xp-slot-lock-notice { transition: outline-color 180ms; }
|
|
300
|
+
}
|