@delmaredigital/payload-experiments 0.4.0-rc.9 → 0.4.0
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/README.md +2 -8
- package/dist/admin/MetricSourceSelect.js +10 -3
- package/dist/admin/armSelect/armSelect.model.d.ts +1 -1
- package/dist/admin/blocks/BlockPanel.d.ts +1 -0
- package/dist/admin/blocks/BlockPanel.js +75 -29
- package/dist/admin/blocks/model.js +5 -4
- package/dist/admin/copy/blocks.d.ts +14 -11
- package/dist/admin/copy/blocks.js +33 -22
- package/dist/admin/copy/goals.d.ts +15 -8
- package/dist/admin/copy/goals.js +18 -8
- package/dist/admin/copy/newTest.d.ts +10 -7
- package/dist/admin/copy/newTest.js +14 -7
- package/dist/admin/copy/status.d.ts +1 -1
- package/dist/admin/copy/status.js +2 -1
- package/dist/admin/pageCollections.d.ts +1 -0
- package/dist/admin/pageCollections.js +3 -0
- package/dist/admin/placementStatus.model.js +5 -3
- package/dist/admin/status.model.d.ts +1 -0
- package/dist/admin/status.model.js +2 -1
- package/dist/admin/surface/ResultsRoute.js +4 -8
- package/dist/admin/surface/SurfaceShell.d.ts +4 -2
- package/dist/admin/surface/SurfaceShell.js +28 -3
- package/dist/admin/surface/TestRowMenu.d.ts +13 -0
- package/dist/admin/surface/TestRowMenu.js +163 -0
- package/dist/admin/surface/TestsHome.d.ts +4 -3
- package/dist/admin/surface/TestsHome.js +186 -47
- package/dist/admin/surface/TestsSurface.js +2 -1
- package/dist/admin/surface/goals/DeleteGoalDialog.d.ts +7 -0
- package/dist/admin/surface/goals/DeleteGoalDialog.js +42 -0
- package/dist/admin/surface/goals/GoalForm.d.ts +1 -0
- package/dist/admin/surface/goals/GoalForm.js +280 -198
- package/dist/admin/surface/goals/GoalsList.js +102 -33
- package/dist/admin/surface/goals/data.d.ts +2 -0
- package/dist/admin/surface/goals/data.js +9 -0
- package/dist/admin/surface/goals/goals.css +3 -2
- package/dist/admin/surface/goals/goals.model.d.ts +2 -2
- package/dist/admin/surface/goals/goals.model.js +7 -12
- package/dist/admin/surface/home.model.d.ts +15 -8
- package/dist/admin/surface/home.model.js +22 -18
- package/dist/admin/surface/newTest/NewTest.d.ts +3 -3
- package/dist/admin/surface/newTest/NewTest.js +156 -96
- package/dist/admin/surface/newTest/PageWizard.d.ts +4 -1
- package/dist/admin/surface/newTest/PageWizard.js +93 -68
- package/dist/admin/surface/newTest/newTest.css +28 -11
- package/dist/admin/surface/results/ResultsHeader.d.ts +1 -1
- package/dist/admin/surface/results/ResultsHeader.js +90 -63
- package/dist/admin/surface/surface.css +29 -0
- package/dist/admin/surface/test/TestPage.js +46 -38
- package/dist/admin/surface/useXpStepNav.d.ts +11 -0
- package/dist/admin/surface/useXpStepNav.js +14 -0
- package/dist/admin/views/TestsSurfaceClient.js +27 -3
- package/dist/admin/views/buildSurfaceProps.js +18 -66
- package/dist/arms/copy.d.ts +13 -3
- package/dist/arms/copy.js +5 -4
- package/dist/blocks/createExperimentBlock.js +1 -1
- package/dist/blocks/formState.js +1 -1
- package/dist/collections/experiments/armInvariants.js +8 -5
- package/dist/collections/metrics.js +12 -5
- package/dist/collections/serialize.js +3 -2
- package/dist/db/pageCopies.d.ts +5 -0
- package/dist/db/pageCopies.js +31 -0
- package/dist/db/snapshots.d.ts +1 -0
- package/dist/endpoints/duplicateOriginal.d.ts +38 -0
- package/dist/endpoints/duplicateOriginal.js +414 -0
- package/dist/endpoints/editorSurface.js +1 -1
- package/dist/endpoints/index.js +20 -0
- package/dist/endpoints/pages.js +245 -66
- package/dist/endpoints/placementStatus.js +1 -0
- package/dist/endpoints/results.js +3 -0
- package/dist/endpoints/testVersion.d.ts +2 -0
- package/dist/endpoints/testVersion.js +38 -0
- package/dist/endpoints/transitions.js +4 -5
- package/dist/exports/index.d.ts +1 -1
- package/dist/goals/picker/copy.js +1 -1
- package/dist/goals/sourceLabel.d.ts +2 -0
- package/dist/goals/sourceLabel.js +4 -0
- package/dist/hooks/trackPageCopies.d.ts +11 -0
- package/dist/hooks/trackPageCopies.js +7 -0
- package/dist/labels/arms.d.ts +3 -0
- package/dist/labels/arms.js +8 -0
- package/dist/options.d.ts +2 -0
- package/dist/options.js +18 -2
- package/dist/plugin.js +56 -2
- package/dist/puck/editor/ConfigureTestDrawer.d.ts +7 -7
- package/dist/puck/editor/ConfigureTestDrawer.js +36 -26
- package/dist/puck/editor/ExperimentSlotEditor.d.ts +2 -1
- package/dist/puck/editor/ExperimentSlotEditor.js +219 -106
- package/dist/puck/editor/LeftoverVersions.js +17 -32
- package/dist/puck/editor/QuickTestActions.d.ts +2 -2
- package/dist/puck/editor/QuickTestActions.js +44 -34
- package/dist/puck/editor/ResultsReadout.d.ts +3 -1
- package/dist/puck/editor/ResultsReadout.js +28 -16
- package/dist/puck/editor/VersionBuilder.d.ts +4 -2
- package/dist/puck/editor/VersionBuilder.js +42 -63
- package/dist/puck/editor/armWrites.js +1 -1
- package/dist/puck/editor/copy.d.ts +10 -6
- package/dist/puck/editor/copy.js +22 -12
- package/dist/puck/editor/editor.chrome.css +9 -8
- package/dist/puck/editor/editor.css +14 -9
- package/dist/puck/editor/placementsCache.d.ts +1 -1
- package/dist/puck/editor/placementsCache.js +9 -17
- package/dist/puck/editor/usePageSaveReadiness.d.ts +1 -4
- package/dist/puck/editor/usePageSaveReadiness.js +18 -21
- package/dist/puck/editor/usePlacementNotice.d.ts +2 -2
- package/dist/puck/editor/usePlacementNotice.js +4 -5
- package/dist/puck/nestedTestCopy.js +2 -2
- package/dist/puck/slotConfig.d.ts +1 -1
- package/dist/puck/slotConfig.js +1 -1
- package/dist/results/analyse.d.ts +2 -0
- package/dist/results/analyse.js +2 -2
- package/dist/results/verdict.d.ts +4 -4
- package/dist/results/verdict.js +13 -10
- package/dist/server/runResults.js +2 -1
- package/dist/testSurface/PreviewLinks.d.ts +2 -1
- package/dist/testSurface/PreviewLinks.js +3 -3
- package/dist/testSurface/actions/DecideDialog.d.ts +7 -4
- package/dist/testSurface/actions/DecideDialog.js +71 -59
- package/dist/testSurface/actions/LifecycleAction.d.ts +17 -0
- package/dist/testSurface/actions/LifecycleAction.js +107 -0
- package/dist/testSurface/actions/MakeContentResult.js +1 -1
- package/dist/testSurface/actions/actions.model.d.ts +13 -5
- package/dist/testSurface/actions/actions.model.js +75 -22
- package/dist/testSurface/actions/decide.model.d.ts +1 -0
- package/dist/testSurface/actions/decide.model.js +1 -0
- package/dist/testSurface/allocation.model.js +6 -3
- package/dist/testSurface/api.d.ts +4 -1
- package/dist/testSurface/api.js +22 -14
- package/dist/testSurface/copy/actions.d.ts +36 -14
- package/dist/testSurface/copy/actions.js +39 -17
- package/dist/testSurface/copy/advanced.d.ts +10 -0
- package/dist/testSurface/copy/advanced.js +10 -0
- package/dist/testSurface/copy/arms.d.ts +1 -1
- package/dist/testSurface/copy/arms.js +1 -1
- package/dist/testSurface/copy/audience.d.ts +4 -3
- package/dist/testSurface/copy/audience.js +5 -4
- package/dist/testSurface/copy/common.d.ts +6 -6
- package/dist/testSurface/copy/common.js +6 -6
- package/dist/testSurface/copy/metrics.d.ts +6 -0
- package/dist/testSurface/copy/metrics.js +8 -0
- package/dist/testSurface/copy/pages.d.ts +67 -7
- package/dist/testSurface/copy/pages.js +74 -7
- package/dist/testSurface/copy/readiness.d.ts +8 -6
- package/dist/testSurface/copy/readiness.js +19 -10
- package/dist/testSurface/copy/recommendation.d.ts +1 -22
- package/dist/testSurface/copy/recommendation.js +2 -22
- package/dist/testSurface/copy/results.d.ts +16 -10
- package/dist/testSurface/copy/results.js +19 -11
- package/dist/testSurface/copy/review.d.ts +13 -10
- package/dist/testSurface/copy/review.js +14 -10
- package/dist/testSurface/copy/setting.d.ts +1 -2
- package/dist/testSurface/copy/setting.js +1 -2
- package/dist/testSurface/copy/surface.d.ts +11 -2
- package/dist/testSurface/copy/surface.js +14 -11
- package/dist/testSurface/copy/testPage.d.ts +16 -10
- package/dist/testSurface/copy/testPage.js +24 -18
- package/dist/testSurface/format/date.d.ts +5 -2
- package/dist/testSurface/format/date.js +24 -8
- package/dist/testSurface/format/roundProgress.d.ts +6 -0
- package/dist/testSurface/format/roundProgress.js +15 -0
- package/dist/testSurface/format/useDateFormatter.d.ts +3 -0
- package/dist/testSurface/format/useDateFormatter.js +8 -0
- package/dist/testSurface/labels.d.ts +1 -2
- package/dist/testSurface/labels.js +2 -3
- package/dist/testSurface/lockedNotice.model.d.ts +2 -0
- package/dist/testSurface/lockedNotice.model.js +31 -0
- package/dist/testSurface/readPreflight.d.ts +0 -1
- package/dist/testSurface/readPreflight.js +0 -1
- package/dist/testSurface/results/CiChart.js +2 -1
- package/dist/testSurface/results/DataTable.d.ts +1 -1
- package/dist/testSurface/results/DataTable.js +4 -3
- package/dist/testSurface/results/VerdictHero.d.ts +1 -1
- package/dist/testSurface/results/legacy.d.ts +0 -5
- package/dist/testSurface/results/legacy.js +0 -14
- package/dist/testSurface/results/results.css +2 -2
- package/dist/testSurface/results/results.model.d.ts +8 -3
- package/dist/testSurface/results/results.model.js +25 -21
- package/dist/testSurface/results/snapshot.d.ts +2 -0
- package/dist/testSurface/results/snapshot.js +3 -0
- package/dist/testSurface/surface/contracts.d.ts +6 -1
- package/dist/testSurface/surface/editorPlacement.d.ts +1 -1
- package/dist/testSurface/surface/editorPlacement.js +1 -1
- package/dist/testSurface/surface/pageBlock/pageBlock.model.js +1 -1
- package/dist/testSurface/surface/pageBlock/parts.js +25 -12
- package/dist/testSurface/surface/pagePicker/CopyRoute.d.ts +8 -1
- package/dist/testSurface/surface/pagePicker/CopyRoute.js +243 -22
- package/dist/testSurface/surface/pagePicker/PageCombobox.d.ts +15 -4
- package/dist/testSurface/surface/pagePicker/PageCombobox.js +298 -209
- package/dist/testSurface/surface/pagePicker/pagePicker.css +73 -10
- package/dist/testSurface/surface/pagePicker/pagePicker.model.d.ts +5 -3
- package/dist/testSurface/surface/pagePicker/pagePicker.model.js +17 -2
- package/dist/testSurface/surface/readiness/ActionDialogs.d.ts +5 -3
- package/dist/testSurface/surface/readiness/ActionDialogs.js +213 -207
- package/dist/testSurface/surface/readiness/Banner.d.ts +5 -1
- package/dist/testSurface/surface/readiness/Banner.js +109 -148
- package/dist/testSurface/surface/readiness/SaveStatus.d.ts +5 -2
- package/dist/testSurface/surface/readiness/SaveStatus.js +8 -7
- package/dist/testSurface/surface/readiness/readiness.model.d.ts +14 -5
- package/dist/testSurface/surface/readiness/readiness.model.js +62 -12
- package/dist/testSurface/surface/readiness/useTransition.d.ts +3 -1
- package/dist/testSurface/surface/readiness/useTransition.js +49 -8
- package/dist/testSurface/surface/results/ReleasePages.d.ts +4 -3
- package/dist/testSurface/surface/results/ReleasePages.js +41 -41
- package/dist/testSurface/surface/results/ResultsBody.d.ts +7 -2
- package/dist/testSurface/surface/results/ResultsBody.js +170 -110
- package/dist/testSurface/surface/results/recommendation.model.d.ts +6 -9
- package/dist/testSurface/surface/results/recommendation.model.js +15 -59
- package/dist/testSurface/surface/results/useResults.d.ts +6 -2
- package/dist/testSurface/surface/setting/parts.js +31 -28
- package/dist/testSurface/surface/setting/setting.css +2 -1
- package/dist/testSurface/surface/test/AdvancedSection.js +10 -4
- package/dist/testSurface/surface/test/DeleteTest.d.ts +5 -1
- package/dist/testSurface/surface/test/DeleteTest.js +63 -55
- package/dist/testSurface/surface/test/GoalSection.js +11 -11
- package/dist/testSurface/surface/test/LengthSection.js +21 -13
- package/dist/testSurface/surface/test/PageHoldout.d.ts +1 -1
- package/dist/testSurface/surface/test/PageHoldout.js +7 -7
- package/dist/testSurface/surface/test/ReadinessBar.d.ts +2 -1
- package/dist/testSurface/surface/test/ReadinessBar.js +4 -10
- package/dist/testSurface/surface/test/Section.js +8 -0
- package/dist/testSurface/surface/test/TargetingSection.js +7 -2
- package/dist/testSurface/surface/test/TestSurface.js +17 -43
- package/dist/testSurface/surface/test/VersionsSection.js +93 -70
- package/dist/testSurface/surface/test/fields.d.ts +4 -3
- package/dist/testSurface/surface/test/fields.js +10 -16
- package/dist/testSurface/surface/test/pageParts.js +13 -7
- package/dist/testSurface/surface/test/testPage.css +9 -2
- package/dist/testSurface/surface/useTestDocument.d.ts +1 -3
- package/dist/testSurface/surface/useTestDocument.js +110 -52
- package/dist/testSurface/surface/watchTestDocument.d.ts +15 -0
- package/dist/testSurface/surface/watchTestDocument.js +181 -0
- package/dist/testSurface/surfaceUrls.d.ts +1 -0
- package/dist/testSurface/surfaceUrls.js +4 -0
- package/dist/testSurface/useApi.d.ts +3 -0
- package/dist/transitions/addMetric.d.ts +1 -1
- package/dist/transitions/addMetric.js +5 -1
- package/dist/transitions/kernel.d.ts +2 -0
- package/dist/transitions/kernel.js +1 -1
- package/dist/transitions/pageAddress.d.ts +6 -0
- package/dist/transitions/pageAddress.js +71 -0
- package/dist/transitions/pageVersions.d.ts +1 -1
- package/dist/transitions/preflightData.js +10 -2
- package/dist/transitions/start.d.ts +1 -1
- package/dist/transitions/start.js +8 -5
- package/dist/types/armKey.d.ts +2 -0
- package/dist/types/armKey.js +1 -0
- package/dist/types/contracts.d.ts +11 -1
- package/dist/types/endpoints.d.ts +38 -9
- package/dist/types/endpoints.js +1 -1
- package/dist/types/surface.d.ts +7 -9
- package/dist/ui/Dialog.d.ts +21 -2
- package/dist/ui/Dialog.js +101 -4
- package/dist/ui/Inputs.js +0 -1
- package/dist/ui/ui.css +5 -1
- package/package.json +2 -2
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
import { flattenTopLevelFields } from 'payload/shared';
|
|
2
|
+
import { placementReader } from '../blocks/placementLocale.js';
|
|
3
|
+
import { normalisePath } from '../runtime/normalisePath.js';
|
|
4
|
+
export const PAGE_ADDRESS_FIELDS = [
|
|
5
|
+
'path',
|
|
6
|
+
'slug',
|
|
7
|
+
'pageSegment'
|
|
8
|
+
];
|
|
9
|
+
/** Hosts can resolve drafts in findByPath. For simple addresses, the admin also
|
|
10
|
+
* recognizes never-published drafts when a host lookup only sees live pages. */ export async function findDraftPageByPath(req, entry, path) {
|
|
11
|
+
const config = req.payload.collections?.[entry.slug]?.config ?? req.payload.config.collections?.find((collection)=>collection.slug === entry.slug);
|
|
12
|
+
if (!config?.versions?.drafts) return undefined;
|
|
13
|
+
const key = normalisePath(path);
|
|
14
|
+
const relative = key.replace(/^\/+/, '');
|
|
15
|
+
const segment = relative.split('/').at(-1);
|
|
16
|
+
const unprefixed = relative.slice(relative.indexOf('/') + 1);
|
|
17
|
+
const filters = flattenTopLevelFields(config.fields).flatMap((field)=>{
|
|
18
|
+
if (field.type !== 'text' || field.virtual || !PAGE_ADDRESS_FIELDS.includes(field.name)) return [];
|
|
19
|
+
const values = field.name === 'pageSegment' ? [
|
|
20
|
+
segment
|
|
21
|
+
] : [
|
|
22
|
+
relative,
|
|
23
|
+
unprefixed,
|
|
24
|
+
segment
|
|
25
|
+
];
|
|
26
|
+
const candidates = [
|
|
27
|
+
...new Set(values.flatMap((value)=>value ? [
|
|
28
|
+
value,
|
|
29
|
+
'/' + value,
|
|
30
|
+
value + '/',
|
|
31
|
+
'/' + value + '/'
|
|
32
|
+
] : []))
|
|
33
|
+
];
|
|
34
|
+
return candidates.length ? [
|
|
35
|
+
{
|
|
36
|
+
[field.name]: {
|
|
37
|
+
in: candidates
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
] : [];
|
|
41
|
+
});
|
|
42
|
+
if (!filters.length) return undefined;
|
|
43
|
+
const result = await req.payload.find({
|
|
44
|
+
collection: entry.slug,
|
|
45
|
+
req,
|
|
46
|
+
overrideAccess: false,
|
|
47
|
+
depth: 0,
|
|
48
|
+
draft: false,
|
|
49
|
+
pagination: false,
|
|
50
|
+
limit: 20,
|
|
51
|
+
where: {
|
|
52
|
+
and: [
|
|
53
|
+
{
|
|
54
|
+
_status: {
|
|
55
|
+
equals: 'draft'
|
|
56
|
+
}
|
|
57
|
+
},
|
|
58
|
+
{
|
|
59
|
+
or: filters
|
|
60
|
+
}
|
|
61
|
+
]
|
|
62
|
+
}
|
|
63
|
+
});
|
|
64
|
+
const reader = placementReader(req, entry.slug);
|
|
65
|
+
const input = req.locale === 'all' ? 'all-locales' : 'localized';
|
|
66
|
+
const candidates = result.docs.filter((row)=>{
|
|
67
|
+
const address = entry.pathOf(reader.read(row, input).doc);
|
|
68
|
+
return address !== null && normalisePath(address) === key;
|
|
69
|
+
});
|
|
70
|
+
return candidates.length === 1 ? candidates[0] : undefined;
|
|
71
|
+
}
|
|
@@ -3,7 +3,7 @@ import type { Arm, ExperimentsPageCollection } from '../types/contracts.js';
|
|
|
3
3
|
/** Page copies have fresh nested row ids and editor labels; neither is rendered content. */
|
|
4
4
|
export declare function comparableContent(value: unknown): unknown;
|
|
5
5
|
export declare function identicalPageVersions(req: PayloadRequest, collection: ExperimentsPageCollection | undefined, arms: Arm[]): Promise<{
|
|
6
|
-
arm: import("../types/
|
|
6
|
+
arm: import("../types/armKey.js").ArmKey;
|
|
7
7
|
path: string;
|
|
8
8
|
collection: string;
|
|
9
9
|
id: string | number;
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { findDraftPageByPath } from './pageAddress.js';
|
|
1
2
|
import { nestedPlacementNames, nameNestedPlacements } from './nestedPlacementNames.js';
|
|
2
3
|
import { placementReader } from '../blocks/placementLocale.js';
|
|
3
4
|
import { BLOCK_SLOTS } from '../blocks/model.js';
|
|
@@ -584,8 +585,16 @@ export async function preflightData(req, { experimentId, options, placementLocal
|
|
|
584
585
|
for (const arm of e.arms.filter((arm)=>arm.kind !== 'holdout')){
|
|
585
586
|
const path = arm.pageTarget ?? '';
|
|
586
587
|
let page = null;
|
|
588
|
+
let doc;
|
|
587
589
|
try {
|
|
588
590
|
page = path && collection ? await collection.findByPath(path, req) : null;
|
|
591
|
+
if (path && collection && !page) {
|
|
592
|
+
doc = await findDraftPageByPath(req, collection, path);
|
|
593
|
+
if (doc) page = {
|
|
594
|
+
id: doc.id,
|
|
595
|
+
published: false
|
|
596
|
+
};
|
|
597
|
+
}
|
|
589
598
|
} catch (cause) {
|
|
590
599
|
onPreviewFailure(cause, {
|
|
591
600
|
collection: collection.slug,
|
|
@@ -612,9 +621,8 @@ export async function preflightData(req, { experimentId, options, placementLocal
|
|
|
612
621
|
});
|
|
613
622
|
continue;
|
|
614
623
|
}
|
|
615
|
-
let doc;
|
|
616
624
|
try {
|
|
617
|
-
doc
|
|
625
|
+
doc ??= await req.payload.findByID({
|
|
618
626
|
collection: collection.slug,
|
|
619
627
|
id: page.id,
|
|
620
628
|
req,
|
|
@@ -7,7 +7,7 @@ export type TransitionExperiment = StartExperiment & Record<string, unknown> & {
|
|
|
7
7
|
layerSlices?: number[] | null;
|
|
8
8
|
};
|
|
9
9
|
export declare function readExperiment(req: PayloadRequest, id: DocId): Promise<TransitionExperiment>;
|
|
10
|
-
export declare function refuse(code: RefusalCode, detail?: unknown): never;
|
|
10
|
+
export declare function refuse(code: RefusalCode, detail?: unknown, controlLabel?: string): never;
|
|
11
11
|
export declare function updateExperiment(req: PayloadRequest, id: DocId, data: Record<string, unknown>, system?: boolean): Promise<import("payload").JsonObject & import("payload").TypeWithID>;
|
|
12
12
|
export declare function start<TUser extends {
|
|
13
13
|
id: DocId;
|
|
@@ -11,6 +11,7 @@ import { DEFAULT_SEQUENTIAL_TUNING_PARAMETER } from '../constants.js';
|
|
|
11
11
|
import { claimSlices } from '../db/slices.js';
|
|
12
12
|
import { READINESS_COPY, asymmetricGoalsCopy, firstStartOnlyCopy, sameAddressCopy, interactingTestsCopy, pageInUseCopy, unpublishedPageCopy } from '../testSurface/copy/readiness.js';
|
|
13
13
|
import { GROUP_LABELS } from '../testSurface/copy/arms.js';
|
|
14
|
+
import { controlVersionLabel } from '../labels/arms.js';
|
|
14
15
|
import { XpRefusal } from '../errors.js';
|
|
15
16
|
import { isOpValid } from '../targeting/ops.js';
|
|
16
17
|
import { newSeed } from '../runtime/seed.js';
|
|
@@ -38,7 +39,8 @@ export async function readExperiment(req, id) {
|
|
|
38
39
|
if (!docs[0]) throw new XpRefusal('not-found', 'Experiment not found', undefined, 404);
|
|
39
40
|
return docs[0];
|
|
40
41
|
}
|
|
41
|
-
export function refuse(code, detail) {
|
|
42
|
+
export function refuse(code, detail, controlLabel) {
|
|
43
|
+
const groupLabel = (key)=>key === 'control' ? controlVersionLabel(controlLabel) : GROUP_LABELS[key];
|
|
42
44
|
const messages = {
|
|
43
45
|
'nested-tests': nestedTestCopy.readiness(detail),
|
|
44
46
|
'goal-in-some-versions': asymmetricGoalsCopy(detail),
|
|
@@ -53,7 +55,7 @@ export function refuse(code, detail) {
|
|
|
53
55
|
'page-in-use': pageInUseCopy(detail?.paths?.[0] ?? 'this page'),
|
|
54
56
|
'version-same-address': (()=>{
|
|
55
57
|
const d = detail;
|
|
56
|
-
return sameAddressCopy(
|
|
58
|
+
return sameAddressCopy(groupLabel(d?.arm ?? 'variantA'), groupLabel(d?.otherArm ?? 'control'), d?.path ?? 'this address');
|
|
57
59
|
})(),
|
|
58
60
|
'page-target-unpublished': unpublishedPageCopy(typeof detail === 'string' ? detail : 'This page'),
|
|
59
61
|
'invalid-status': 'This action is not available in the current status.',
|
|
@@ -126,7 +128,7 @@ async function prepareStart(req, options, before, system) {
|
|
|
126
128
|
// Warning-only codes always have ok: true. These exclusions narrow
|
|
127
129
|
// ReadinessCode to RefusalCode, which intentionally excludes warnings.
|
|
128
130
|
const failed = checkStart(input).find((check)=>!check.ok);
|
|
129
|
-
if (failed && failed.code !== 'page-targets-unchecked' && failed.code !== 'make-content-unsupported') refuse(failed.code, failed.detail);
|
|
131
|
+
if (failed && failed.code !== 'page-targets-unchecked' && failed.code !== 'make-content-unsupported') refuse(failed.code, failed.detail, before.arms.find((arm)=>arm.kind === 'control')?.label);
|
|
130
132
|
const at = new Date();
|
|
131
133
|
const caps = await resolveCaps(input.metrics, options.metricSources ?? [], at);
|
|
132
134
|
return {
|
|
@@ -167,6 +169,7 @@ export async function start(req, { experimentId, options, phase: expectedPhase,
|
|
|
167
169
|
if (current.status !== 'draft' && current.status !== 'stopped') refuse('invalid-status');
|
|
168
170
|
if ('error' in prepared) throw prepared.error;
|
|
169
171
|
const { input, at, caps } = prepared;
|
|
172
|
+
const controlLabel = current.arms.find((arm)=>arm.kind === 'control')?.label;
|
|
170
173
|
let placementDocs;
|
|
171
174
|
if (current.kind === 'block') {
|
|
172
175
|
const rescan = await lockAndRescanPlacements(req, exec, options, current, input.placements ?? [], system);
|
|
@@ -176,7 +179,7 @@ export async function start(req, { experimentId, options, phase: expectedPhase,
|
|
|
176
179
|
experiment: current,
|
|
177
180
|
placements: nameNestedPlacements(rescan.placements, await nestedPlacementNames(req, rescan.placements, system))
|
|
178
181
|
}).find((check)=>!check.ok);
|
|
179
|
-
if (failure && failure.code !== 'page-targets-unchecked' && failure.code !== 'make-content-unsupported') refuse(failure.code, failure.detail);
|
|
182
|
+
if (failure && failure.code !== 'page-targets-unchecked' && failure.code !== 'make-content-unsupported') refuse(failure.code, failure.detail, controlLabel);
|
|
180
183
|
}
|
|
181
184
|
if (current.kind === 'page') {
|
|
182
185
|
// Independent experiment/layer locks do not serialize overlapping pages.
|
|
@@ -242,7 +245,7 @@ export async function start(req, { experimentId, options, phase: expectedPhase,
|
|
|
242
245
|
...input,
|
|
243
246
|
experiment: current
|
|
244
247
|
}).find((check)=>!check.ok);
|
|
245
|
-
if (recheck && recheck.code !== 'page-targets-unchecked' && recheck.code !== 'make-content-unsupported') refuse(recheck.code, recheck.detail);
|
|
248
|
+
if (recheck && recheck.code !== 'page-targets-unchecked' && recheck.code !== 'make-content-unsupported') refuse(recheck.code, recheck.detail, controlLabel);
|
|
246
249
|
}
|
|
247
250
|
if (input.metrics.some((metric)=>metric.source.startsWith('click:'))) {
|
|
248
251
|
const content = await detached(req, ()=>goalContent(req, options, current, placementDocs));
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
/** Leaf module: UI code imports this without pulling server types. */ export { };
|
|
@@ -16,7 +16,8 @@ export type ExposurePolicy = 'render' | 'viewport' | 'pageview' | 'manual';
|
|
|
16
16
|
export type ExperimentKind = 'block' | 'page' | 'flag' | 'code';
|
|
17
17
|
export type Status = 'draft' | 'running' | 'stopped' | 'decided' | 'archived';
|
|
18
18
|
export type UnitType = 'visitor' | 'user';
|
|
19
|
-
|
|
19
|
+
import type { ArmKey } from './armKey.js';
|
|
20
|
+
export type { ArmKey };
|
|
20
21
|
export type ArmKind = 'control' | 'variant' | 'holdout';
|
|
21
22
|
export interface TargetingRule {
|
|
22
23
|
attribute: string;
|
|
@@ -108,6 +109,15 @@ export interface ExperimentsPageCollection {
|
|
|
108
109
|
copyHint?: string;
|
|
109
110
|
copyUrl?: string;
|
|
110
111
|
copyLabel?: string;
|
|
112
|
+
/** Enable draft copying for this collection. Omit or set false to use manual setup. */
|
|
113
|
+
copy?: boolean | {
|
|
114
|
+
/** Override fields for the proposed address, or return null for manual setup. Can run more than once and must not write. */
|
|
115
|
+
overrides: (doc: Record<string, unknown>, context: {
|
|
116
|
+
req: PayloadRequest;
|
|
117
|
+
path: string;
|
|
118
|
+
suffix: string;
|
|
119
|
+
}) => Record<string, unknown> | null | Promise<Record<string, unknown> | null>;
|
|
120
|
+
};
|
|
111
121
|
pathOf: (doc: Record<string, unknown>) => string | null;
|
|
112
122
|
/** Lookup with the supplied req and overrideAccess: false. Under an anonymous req (results checks) only published pages are visible, so a hit is { published: true } or null. Under a req that can read drafts (Start), a draft-only page may be reported as { published: false }. */
|
|
113
123
|
findByPath: (path: string, req: PayloadRequest) => Promise<{
|
|
@@ -7,7 +7,7 @@ import type { Snapshot, VerdictCode } from './snapshot.js';
|
|
|
7
7
|
export type ArmIssueCode = 'weights-total' | 'control-count' | 'control-first' | 'holdout-last' | 'holdout-count' | 'variant-count' | 'duplicate-key' | 'duplicate-slot' | 'slot-required' | 'invalid-key';
|
|
8
8
|
/** Content-report dismiss/restore refusals (CORE-44). */
|
|
9
9
|
export type ContentEntryRefusal = 'not-decided' | 'entry-not-found' | 'entry-ok' | 'entry-dismissed' | 'entry-not-dismissed';
|
|
10
|
-
export type RefusalCode = ArmIssueCode | 'nested-tests' | 'goal-in-some-versions' | 'placement-unchecked' | 'placement-unpublished' | 'duplicate-version-row' | 'interacting-tests' | 'placements-changed' | 'page-busy' | 'wrap-target-missing' | 'version-identical' | 'version-same-address' | 'unknown-collection' | 'not-found' | ContentEntryRefusal | 'no-planned-duration' | 'no-primary-metric' | 'no-placements' | 'placement-removed' | 'empty-slot' | 'page-in-use' | 'page-no-targets' | 'page-target-unpublished' | 'page-user-unit' | 'version-page-unavailable' | 'version-page-unchecked' | 'flag-no-point' | 'flag-params-invalid' | 'flag-point-busy' | 'flag-placement-missing' | 'layer-full' | 'layer-unit-mismatch' | 'unknown-metric-source' | 'unit-source-mismatch' | 'no-reach-per-day' | 'invalid-status' | 'first-start-only' | 'stale-draft' | 'stale-edit' | 'round-changed' | 'commit-unverified' | 'allocation-lower' | 'confirmation-required' | 'invalid-winner' | 'slices-taken' | 'locked-placement' | 'not-implemented' | 'forbidden' | 'unauthenticated' | 'body-too-large' | 'invalid-body' | 'too-many-ids' | 'invalid-phase' | 'invalid-ids' | 'recompute-failed' | 'analysis-failed' | 'undeclared-targeting-key' | 'invalid-targeting-rule' | 'block-path-rule' | 'duplicate-metric';
|
|
10
|
+
export type RefusalCode = ArmIssueCode | 'copy-unavailable' | 'copy-not-enabled' | 'copy-no-access' | 'copy-unique-field' | 'copy-orphaned' | 'transaction-lost' | 'nested-tests' | 'goal-in-some-versions' | 'placement-unchecked' | 'placement-unpublished' | 'duplicate-version-row' | 'interacting-tests' | 'placements-changed' | 'page-busy' | 'wrap-target-missing' | 'version-identical' | 'version-same-address' | 'unknown-collection' | 'not-found' | ContentEntryRefusal | 'no-planned-duration' | 'no-primary-metric' | 'no-placements' | 'placement-removed' | 'empty-slot' | 'page-in-use' | 'page-no-targets' | 'page-target-unpublished' | 'page-user-unit' | 'version-page-unavailable' | 'version-page-unchecked' | 'flag-no-point' | 'flag-params-invalid' | 'flag-point-busy' | 'flag-placement-missing' | 'layer-full' | 'layer-unit-mismatch' | 'unknown-metric-source' | 'unit-source-mismatch' | 'no-reach-per-day' | 'invalid-status' | 'first-start-only' | 'stale-draft' | 'stale-edit' | 'round-changed' | 'commit-unverified' | 'allocation-lower' | 'confirmation-required' | 'invalid-winner' | 'slices-taken' | 'locked-placement' | 'not-implemented' | 'forbidden' | 'unauthenticated' | 'body-too-large' | 'invalid-body' | 'too-many-ids' | 'invalid-phase' | 'invalid-ids' | 'recompute-failed' | 'analysis-failed' | 'undeclared-targeting-key' | 'invalid-targeting-rule' | 'block-path-rule' | 'duplicate-metric';
|
|
11
11
|
export type ErrorEnvelope = {
|
|
12
12
|
errors: Array<{
|
|
13
13
|
code: RefusalCode;
|
|
@@ -52,7 +52,7 @@ export type AddMetricWarning = {
|
|
|
52
52
|
export type AddMetricResult = TransitionSuccess & {
|
|
53
53
|
warnings: AddMetricWarning[];
|
|
54
54
|
};
|
|
55
|
-
export type AddMetricBody = {
|
|
55
|
+
export type AddMetricBody = RoundBody & {
|
|
56
56
|
metric: DocId;
|
|
57
57
|
role: 'secondary' | 'guardrail';
|
|
58
58
|
};
|
|
@@ -164,6 +164,7 @@ export interface PhaseSummary {
|
|
|
164
164
|
phaseKind: 'test' | 'rollout';
|
|
165
165
|
startedAt: string;
|
|
166
166
|
endedAt: string | null;
|
|
167
|
+
plannedDurationDays?: number;
|
|
167
168
|
arms: Array<{
|
|
168
169
|
key: string;
|
|
169
170
|
label: string;
|
|
@@ -247,15 +248,25 @@ export type ClickKeysResult = {
|
|
|
247
248
|
label: string;
|
|
248
249
|
}>;
|
|
249
250
|
};
|
|
251
|
+
export type PageRow = {
|
|
252
|
+
id: DocId;
|
|
253
|
+
title: string;
|
|
254
|
+
path: string | null;
|
|
255
|
+
pathKey: string | null;
|
|
256
|
+
published: boolean;
|
|
257
|
+
address?: string;
|
|
258
|
+
draftAddress?: string;
|
|
259
|
+
status?: 'published' | 'draft' | 'changed';
|
|
260
|
+
updatedAt?: string;
|
|
261
|
+
editor?: 'puck' | 'blocks';
|
|
262
|
+
editorUrl?: string;
|
|
263
|
+
};
|
|
250
264
|
export type PagesResult = {
|
|
251
|
-
docs:
|
|
252
|
-
id: DocId;
|
|
253
|
-
title: string;
|
|
254
|
-
path: string | null;
|
|
255
|
-
pathKey: string | null;
|
|
256
|
-
published: boolean;
|
|
257
|
-
}>;
|
|
265
|
+
docs: PageRow[];
|
|
258
266
|
hasNextPage: boolean;
|
|
267
|
+
pageLimitReached?: boolean;
|
|
268
|
+
totalDocs?: number;
|
|
269
|
+
pagingCounter?: number;
|
|
259
270
|
};
|
|
260
271
|
export type PlacementStatusBody = {
|
|
261
272
|
docs?: Array<{
|
|
@@ -271,6 +282,7 @@ export type PageTestStatus = {
|
|
|
271
282
|
role: 'original' | 'version';
|
|
272
283
|
winner: boolean;
|
|
273
284
|
armLabel: string;
|
|
285
|
+
controlLabel?: string;
|
|
274
286
|
winnerLabel?: string;
|
|
275
287
|
winnerTitle?: string;
|
|
276
288
|
winnerPath?: string;
|
|
@@ -338,3 +350,20 @@ export type DeleteImpactResult = {
|
|
|
338
350
|
addresses: string[];
|
|
339
351
|
afterPaths?: Record<string, string>;
|
|
340
352
|
};
|
|
353
|
+
export type CopyPagePlan = {
|
|
354
|
+
title: string;
|
|
355
|
+
path: string;
|
|
356
|
+
phase: number;
|
|
357
|
+
updatedAt: string;
|
|
358
|
+
originalId: DocId;
|
|
359
|
+
originalUpdatedAt: string;
|
|
360
|
+
};
|
|
361
|
+
export type CopyPageResult = {
|
|
362
|
+
doc: Record<string, unknown>;
|
|
363
|
+
copy: {
|
|
364
|
+
id: DocId;
|
|
365
|
+
title: string;
|
|
366
|
+
path: string;
|
|
367
|
+
editorUrl: string;
|
|
368
|
+
};
|
|
369
|
+
};
|
package/dist/types/endpoints.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
|
|
1
|
+
export { };
|
package/dist/types/surface.d.ts
CHANGED
|
@@ -1,6 +1,10 @@
|
|
|
1
|
-
import type { DocId } from './contracts.js';
|
|
2
1
|
import type { SerializedAttributeKeys, SerializedFlagPoint, SerializedMetricSource } from './admin.js';
|
|
3
2
|
export type TestsRoute = 'home' | 'new' | 'test' | 'results' | 'goals' | 'goalNew' | 'goal';
|
|
3
|
+
export type BlockPageCollection = {
|
|
4
|
+
slug: string;
|
|
5
|
+
label: string;
|
|
6
|
+
editors: Array<'puck' | 'blocks'>;
|
|
7
|
+
};
|
|
4
8
|
export interface TestsSurfaceProps {
|
|
5
9
|
route: TestsRoute;
|
|
6
10
|
id?: string;
|
|
@@ -13,18 +17,12 @@ export interface TestsSurfaceProps {
|
|
|
13
17
|
userId?: string | number;
|
|
14
18
|
userCollection?: string;
|
|
15
19
|
isAdmin: boolean;
|
|
16
|
-
|
|
17
|
-
collection: string;
|
|
18
|
-
collectionLabel: string;
|
|
19
|
-
id: DocId;
|
|
20
|
-
title: string;
|
|
21
|
-
editorUrl: string;
|
|
22
|
-
editor: 'puck' | 'blocks';
|
|
23
|
-
}>;
|
|
20
|
+
blockPageCollections?: BlockPageCollection[];
|
|
24
21
|
pageCollections?: Array<{
|
|
25
22
|
slug: string;
|
|
26
23
|
label: string;
|
|
27
24
|
contentChecks: boolean;
|
|
25
|
+
copyEnabled?: true;
|
|
28
26
|
copyHint?: string;
|
|
29
27
|
copyUrl?: string;
|
|
30
28
|
copyLabel?: string;
|
package/dist/ui/Dialog.d.ts
CHANGED
|
@@ -3,7 +3,7 @@ import './ui.css';
|
|
|
3
3
|
/** Native modal stays in its rendering document, including a Puck canvas iframe.
|
|
4
4
|
* `initialFocus="cancel"` targets the focusable control marked `data-dialog-cancel`.
|
|
5
5
|
*/
|
|
6
|
-
export declare function Dialog({ open, title, onClose, children, dismissible, initialFocus, className, headerActions, closeOnBackdrop }: {
|
|
6
|
+
export declare function Dialog({ open, title, descriptionId, onClose, children, dismissible, initialFocus, className, headerActions, closeOnBackdrop }: {
|
|
7
7
|
open: boolean;
|
|
8
8
|
className?: string;
|
|
9
9
|
headerActions?: ReactNode;
|
|
@@ -11,6 +11,25 @@ export declare function Dialog({ open, title, onClose, children, dismissible, in
|
|
|
11
11
|
dismissible?: boolean;
|
|
12
12
|
initialFocus?: 'cancel';
|
|
13
13
|
title: string;
|
|
14
|
-
|
|
14
|
+
descriptionId?: string;
|
|
15
|
+
onClose: () => void | false;
|
|
15
16
|
children: ReactNode;
|
|
16
17
|
}): import("react").JSX.Element;
|
|
18
|
+
export declare function ConfirmDialog({ open, title, description, children, error, busy, busyLabel, cancelLabel, onClose, confirm, secondaryAction }: {
|
|
19
|
+
open?: boolean;
|
|
20
|
+
title: string;
|
|
21
|
+
description?: ReactNode;
|
|
22
|
+
children?: ReactNode;
|
|
23
|
+
error?: string | null;
|
|
24
|
+
busy?: boolean;
|
|
25
|
+
busyLabel?: string;
|
|
26
|
+
cancelLabel: string;
|
|
27
|
+
onClose: () => void;
|
|
28
|
+
secondaryAction?: ReactNode;
|
|
29
|
+
confirm?: {
|
|
30
|
+
label: string;
|
|
31
|
+
onClick: () => void | Promise<void>;
|
|
32
|
+
disabled?: boolean;
|
|
33
|
+
destructive?: boolean;
|
|
34
|
+
};
|
|
35
|
+
}): import("react").JSX.Element;
|
package/dist/ui/Dialog.js
CHANGED
|
@@ -1,7 +1,31 @@
|
|
|
1
1
|
'use client';
|
|
2
|
-
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
3
3
|
import { useEffect, useId, useRef } from 'react';
|
|
4
|
+
import { Button } from './Button.js';
|
|
4
5
|
import './ui.css';
|
|
6
|
+
const modalBackgrounds = new WeakMap();
|
|
7
|
+
function inertBackground(dialog) {
|
|
8
|
+
const elements = [
|
|
9
|
+
...dialog.ownerDocument.querySelectorAll('[data-dialog-background]')
|
|
10
|
+
].filter((element)=>!element.contains(dialog));
|
|
11
|
+
for (const element of elements){
|
|
12
|
+
const state = modalBackgrounds.get(element) ?? {
|
|
13
|
+
dialogs: 0,
|
|
14
|
+
wasInert: element.hasAttribute('inert')
|
|
15
|
+
};
|
|
16
|
+
state.dialogs++;
|
|
17
|
+
modalBackgrounds.set(element, state);
|
|
18
|
+
element.setAttribute('inert', '');
|
|
19
|
+
}
|
|
20
|
+
return ()=>{
|
|
21
|
+
for (const element of elements){
|
|
22
|
+
const state = modalBackgrounds.get(element);
|
|
23
|
+
if (--state.dialogs > 0) continue;
|
|
24
|
+
if (!state.wasInert) element.removeAttribute('inert');
|
|
25
|
+
modalBackgrounds.delete(element);
|
|
26
|
+
}
|
|
27
|
+
};
|
|
28
|
+
}
|
|
5
29
|
function focusable(node) {
|
|
6
30
|
return [
|
|
7
31
|
...node.querySelectorAll('button, a[href], input, select, textarea, [tabindex]')
|
|
@@ -16,7 +40,7 @@ function focusable(node) {
|
|
|
16
40
|
}
|
|
17
41
|
/** Native modal stays in its rendering document, including a Puck canvas iframe.
|
|
18
42
|
* `initialFocus="cancel"` targets the focusable control marked `data-dialog-cancel`.
|
|
19
|
-
*/ export function Dialog({ open, title, onClose, children, dismissible = true, initialFocus, className = '', headerActions, closeOnBackdrop = false }) {
|
|
43
|
+
*/ export function Dialog({ open, title, descriptionId, onClose, children, dismissible = true, initialFocus, className = '', headerActions, closeOnBackdrop = false }) {
|
|
20
44
|
const ref = useRef(null);
|
|
21
45
|
const heading = useId();
|
|
22
46
|
const backdropPress = useRef(false);
|
|
@@ -29,14 +53,14 @@ function focusable(node) {
|
|
|
29
53
|
const closeRequested = useRef(false);
|
|
30
54
|
const requestClose = ()=>{
|
|
31
55
|
if (!open || !dismissible || closeRequested.current) return;
|
|
32
|
-
closeRequested.current = true;
|
|
33
|
-
onClose();
|
|
56
|
+
if (onClose() !== false) closeRequested.current = true;
|
|
34
57
|
};
|
|
35
58
|
useEffect(()=>{
|
|
36
59
|
const node = ref.current;
|
|
37
60
|
if (!node || !open) return;
|
|
38
61
|
const doc = node.ownerDocument;
|
|
39
62
|
const previous = doc.activeElement;
|
|
63
|
+
const scope = previous?.closest('[data-dialog-focus-scope]');
|
|
40
64
|
closeRequested.current = false;
|
|
41
65
|
// Observe before overlay portals stop pointerdown during ancestor capture.
|
|
42
66
|
const down = (event)=>{
|
|
@@ -52,6 +76,7 @@ function focusable(node) {
|
|
|
52
76
|
doc.addEventListener('pointerup', up, true);
|
|
53
77
|
doc.addEventListener('pointercancel', cancel, true);
|
|
54
78
|
node.showModal();
|
|
79
|
+
const restoreBackground = inertBackground(node);
|
|
55
80
|
const elements = focusable(node);
|
|
56
81
|
const preferred = initialFocus === 'cancel' ? elements.find((element)=>element.hasAttribute('data-dialog-cancel')) : undefined;
|
|
57
82
|
(preferred ?? elements[0] ?? node).focus();
|
|
@@ -59,8 +84,13 @@ function focusable(node) {
|
|
|
59
84
|
doc.removeEventListener('pointerdown', down, true);
|
|
60
85
|
doc.removeEventListener('pointerup', up, true);
|
|
61
86
|
doc.removeEventListener('pointercancel', cancel, true);
|
|
87
|
+
restoreBackground();
|
|
62
88
|
node.close();
|
|
63
89
|
if (previous?.isConnected) previous.focus();
|
|
90
|
+
if (doc.activeElement === doc.body && scope?.isConnected) {
|
|
91
|
+
const fallback = scope.querySelector('[data-dialog-focus-fallback]') ?? scope;
|
|
92
|
+
fallback.focus();
|
|
93
|
+
}
|
|
64
94
|
};
|
|
65
95
|
}, [
|
|
66
96
|
open,
|
|
@@ -69,6 +99,7 @@ function focusable(node) {
|
|
|
69
99
|
return /*#__PURE__*/ _jsxs("dialog", {
|
|
70
100
|
ref: ref,
|
|
71
101
|
"aria-labelledby": heading,
|
|
102
|
+
"aria-describedby": descriptionId,
|
|
72
103
|
className: `xp-ui-dialog ${className}`,
|
|
73
104
|
tabIndex: -1,
|
|
74
105
|
onCancel: (event)=>{
|
|
@@ -121,3 +152,69 @@ function focusable(node) {
|
|
|
121
152
|
]
|
|
122
153
|
});
|
|
123
154
|
}
|
|
155
|
+
export function ConfirmDialog({ open = true, title, description, children, error, busy = false, busyLabel, cancelLabel, onClose, confirm, secondaryAction }) {
|
|
156
|
+
const pending = useRef(false);
|
|
157
|
+
const descriptionId = useId();
|
|
158
|
+
function close() {
|
|
159
|
+
if (busy) return false;
|
|
160
|
+
onClose();
|
|
161
|
+
}
|
|
162
|
+
async function submit() {
|
|
163
|
+
if (!confirm || confirm.disabled || busy || pending.current) return;
|
|
164
|
+
pending.current = true;
|
|
165
|
+
try {
|
|
166
|
+
await confirm.onClick();
|
|
167
|
+
} finally{
|
|
168
|
+
pending.current = false;
|
|
169
|
+
}
|
|
170
|
+
}
|
|
171
|
+
return /*#__PURE__*/ _jsx(Dialog, {
|
|
172
|
+
open: open,
|
|
173
|
+
title: title,
|
|
174
|
+
descriptionId: open && description ? descriptionId : undefined,
|
|
175
|
+
initialFocus: "cancel",
|
|
176
|
+
dismissible: !busy,
|
|
177
|
+
onClose: close,
|
|
178
|
+
children: open ? /*#__PURE__*/ _jsxs(_Fragment, {
|
|
179
|
+
children: [
|
|
180
|
+
description ? typeof description === 'string' ? /*#__PURE__*/ _jsx("p", {
|
|
181
|
+
id: descriptionId,
|
|
182
|
+
children: description
|
|
183
|
+
}) : /*#__PURE__*/ _jsx("div", {
|
|
184
|
+
id: descriptionId,
|
|
185
|
+
children: description
|
|
186
|
+
}) : null,
|
|
187
|
+
children,
|
|
188
|
+
busy && busyLabel ? /*#__PURE__*/ _jsx("p", {
|
|
189
|
+
role: "status",
|
|
190
|
+
children: busyLabel
|
|
191
|
+
}) : null,
|
|
192
|
+
error ? /*#__PURE__*/ _jsx("p", {
|
|
193
|
+
role: "alert",
|
|
194
|
+
className: "xp-ui-error",
|
|
195
|
+
children: error
|
|
196
|
+
}) : null,
|
|
197
|
+
/*#__PURE__*/ _jsxs("div", {
|
|
198
|
+
className: "xp-ui-button-group xp-ui-confirm-actions",
|
|
199
|
+
children: [
|
|
200
|
+
/*#__PURE__*/ _jsx(Button, {
|
|
201
|
+
"data-dialog-cancel": true,
|
|
202
|
+
"aria-disabled": busy || undefined,
|
|
203
|
+
onClick: close,
|
|
204
|
+
children: cancelLabel
|
|
205
|
+
}),
|
|
206
|
+
secondaryAction,
|
|
207
|
+
confirm ? /*#__PURE__*/ _jsx(Button, {
|
|
208
|
+
variant: confirm.destructive ? 'danger' : 'primary',
|
|
209
|
+
disabled: confirm.disabled && !busy,
|
|
210
|
+
"aria-busy": busy || undefined,
|
|
211
|
+
"aria-disabled": busy || confirm.disabled || undefined,
|
|
212
|
+
onClick: ()=>void submit(),
|
|
213
|
+
children: confirm.label
|
|
214
|
+
}) : null
|
|
215
|
+
]
|
|
216
|
+
})
|
|
217
|
+
]
|
|
218
|
+
}) : null
|
|
219
|
+
});
|
|
220
|
+
}
|
package/dist/ui/Inputs.js
CHANGED
|
@@ -85,7 +85,6 @@ export function Select({ label, labelAction, help, error, ...props }) {
|
|
|
85
85
|
labelAction: labelAction,
|
|
86
86
|
children: /*#__PURE__*/ _jsx(SelectControl, {
|
|
87
87
|
...props,
|
|
88
|
-
"aria-labelledby": props['aria-labelledby'] ?? (props['aria-label'] ? undefined : `${props.id}-label`),
|
|
89
88
|
"aria-invalid": Boolean(error) || props['aria-invalid'] || undefined,
|
|
90
89
|
"aria-describedby": described(field, props['aria-describedby'])
|
|
91
90
|
})
|
package/dist/ui/ui.css
CHANGED
|
@@ -69,7 +69,8 @@
|
|
|
69
69
|
.xp-ui-breadcrumb a:hover { color: var(--xp-text); }
|
|
70
70
|
.xp-ui-breadcrumb [aria-current] { color: var(--xp-text); }
|
|
71
71
|
.xp-ui-dialog { width: min(480px, calc(100% - 32px)); max-height: calc(100% - 32px); overflow: auto; padding: 24px; border: 1px solid var(--xp-border); border-radius: var(--xp-radius-card); background: var(--xp-surface); color: var(--xp-text); font: var(--xp-text-body); box-shadow: 0 16px 48px var(--xp-overlay); }
|
|
72
|
-
.xp-ui-dialog h2 { margin: 0 0 16px; font: var(--xp-text-title); }
|
|
72
|
+
.xp-ui-dialog h2 { margin: 0 0 16px; font: var(--xp-text-title); overflow-wrap: anywhere; }
|
|
73
|
+
.xp-ui-dialog > [id]:has(+ :is(.xp-ui-field, .xp-ui-banner)), .xp-ui-dialog > .xp-ui-banner:has(+ .xp-ui-field) { margin-block-end: var(--xp-space-4); }
|
|
73
74
|
.xp-ui-dialog::backdrop { background: var(--xp-overlay); }
|
|
74
75
|
.xp-ui-chips { width: 100%; max-width: 100%; min-width: 0; display: grid; gap: var(--xp-space-2); margin-block: var(--xp-space-4); color: var(--xp-text); font-family: var(--xp-font-body); }
|
|
75
76
|
.xp-ui-chips-control { width: 100%; max-width: 100%; min-width: 0; display: flex; align-items: center; flex-wrap: wrap; gap: var(--xp-space-1); padding: var(--xp-space-2); border: 1px solid var(--xp-border-control); border-radius: var(--xp-radius); background: var(--xp-input-bg); }
|
|
@@ -85,6 +86,9 @@
|
|
|
85
86
|
.xp-ui-chips p:not(.xp-ui-error) { margin: 0; color: var(--xp-text-muted); font-size: var(--xp-font-size-small); }
|
|
86
87
|
/* Quiet actions and breadcrumb links stay neutral; only the selected tab takes the text accent. */
|
|
87
88
|
.xp-ui-button-group { display: flex; flex-wrap: wrap; gap: 8px; min-width: 0; max-width: 100%; }
|
|
89
|
+
.xp-ui-confirm-actions { justify-content: flex-end; gap: var(--xp-space-2); margin-block-start: var(--xp-space-4); }
|
|
90
|
+
.xp-lifecycle-action { display: inline-flex; flex-direction: column; align-items: flex-start; gap: var(--xp-space-1); min-width: 0; }
|
|
91
|
+
.xp-lifecycle-action > .xp-ui-help { margin: 0; max-width: 24ch; }
|
|
88
92
|
.xp-ui-inline-row { display: flex; flex-wrap: wrap; align-items: end; gap: var(--xp-space-3); min-width: 0; }
|
|
89
93
|
.xp-ui-inline-row > .xp-ui-field { flex: 1 1 auto; min-width: 0; }
|
|
90
94
|
.xp-ui-inline-row > .xp-ui-button { flex: 0 0 auto; }
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@delmaredigital/payload-experiments",
|
|
3
|
-
"version": "0.4.0
|
|
3
|
+
"version": "0.4.0",
|
|
4
4
|
"description": "No-code A/B testing for Payload CMS and Next.js: block, page and flag experiments with holdouts, layers, exposure logging and honest statistics inside the admin — no vendor",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"license": "MIT",
|
|
@@ -127,7 +127,7 @@
|
|
|
127
127
|
},
|
|
128
128
|
"homepage": "https://delmaredigital.com/developers",
|
|
129
129
|
"devDependencies": {
|
|
130
|
-
"@delmaredigital/payload-puck": "0.12.
|
|
130
|
+
"@delmaredigital/payload-puck": "0.12.5",
|
|
131
131
|
"payload": "^3.90.2",
|
|
132
132
|
"@payloadcms/db-postgres": "^3.90.2",
|
|
133
133
|
"@payloadcms/ui": "^3.90.2",
|