@delmaredigital/payload-experiments 0.4.0-rc.3 → 0.4.0-rc.4
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/LayerUsage.js +1 -1
- package/dist/admin/MetricSourceSelect.js +2 -2
- package/dist/admin/PlacementStatus.js +1 -1
- package/dist/admin/TestsDashboardCards.js +2 -2
- package/dist/admin/TestsNavLink.js +2 -2
- package/dist/admin/blocks/BlockPanel.js +3 -3
- package/dist/admin/blocks/TestBlockField.js +3 -3
- package/dist/admin/blocks/formApi.js +1 -1
- package/dist/admin/blocks/model.js +1 -1
- package/dist/admin/blocks/statusCache.js +1 -1
- package/dist/admin/components/RootViewMessage.js +1 -1
- package/dist/admin/copy/blocks.d.ts +2 -2
- package/dist/admin/copy/blocks.js +3 -2
- package/dist/admin/copy/goals.d.ts +5 -1
- package/dist/admin/copy/goals.js +9 -3
- package/dist/admin/goals/XpGoalField.js +155 -129
- package/dist/admin/goals/xpGoalField.css +2 -3
- package/dist/admin/status.model.js +1 -1
- package/dist/admin/surface/ResultsRoute.d.ts +2 -1
- package/dist/admin/surface/ResultsRoute.js +4 -3
- package/dist/admin/surface/SurfaceShell.js +2 -2
- package/dist/admin/surface/TestsHome.d.ts +1 -1
- package/dist/admin/surface/TestsHome.js +3 -3
- package/dist/admin/surface/TestsSurface.js +2 -2
- package/dist/admin/surface/goals/GoalForm.d.ts +1 -1
- package/dist/admin/surface/goals/GoalForm.js +55 -7
- package/dist/admin/surface/goals/GoalsList.d.ts +1 -1
- package/dist/admin/surface/goals/GoalsList.js +4 -4
- package/dist/admin/surface/goals/data.js +2 -2
- package/dist/admin/surface/goals/goals.css +7 -0
- package/dist/admin/surface/goals/goals.model.d.ts +11 -1
- package/dist/admin/surface/goals/goals.model.js +43 -0
- package/dist/admin/surface/home.model.d.ts +1 -1
- package/dist/admin/surface/home.model.js +5 -5
- package/dist/admin/surface/newTest/NewTest.d.ts +1 -1
- package/dist/admin/surface/newTest/NewTest.js +1 -1
- package/dist/admin/surface/newTest/PageWizard.d.ts +1 -1
- package/dist/admin/surface/newTest/PageWizard.js +13 -13
- package/dist/admin/surface/results/ResultsHeader.d.ts +2 -2
- package/dist/admin/surface/results/ResultsHeader.js +8 -8
- package/dist/admin/surface/test/TestPage.d.ts +1 -2
- package/dist/admin/surface/test/TestPage.js +45 -156
- package/dist/admin/views/ExperimentsRootView.js +1 -1
- package/dist/admin/views/TestsNavLinkServer.js +1 -1
- package/dist/admin/views/renderCollectionList.js +1 -1
- package/dist/admin/views/renderTestsSurface.js +1 -1
- package/dist/blocks/placementLocale.d.ts +21 -0
- package/dist/blocks/placementLocale.js +115 -0
- package/dist/collections/experiments/config.js +1 -1
- package/dist/collections/metrics.js +1 -1
- package/dist/db/bulkPlacementRemoval.d.ts +30 -0
- package/dist/db/bulkPlacementRemoval.js +107 -0
- package/dist/db/placements.d.ts +2 -0
- package/dist/db/placements.js +8 -0
- package/dist/endpoints/editorSurface.d.ts +3 -0
- package/dist/endpoints/editorSurface.js +31 -0
- package/dist/endpoints/index.js +28 -1
- package/dist/errors.d.ts +1 -0
- package/dist/errors.js +2 -0
- package/dist/fields/xpGoal.js +1 -1
- package/dist/goals/picker/clickGoalPicker.model.d.ts +8 -1
- package/dist/goals/picker/clickGoalPicker.model.js +20 -2
- package/dist/goals/picker/copy.d.ts +4 -2
- package/dist/goals/picker/copy.js +4 -2
- package/dist/goals/picker/useClickGoalPicker.d.ts +1 -1
- package/dist/goals/picker/useClickGoalPicker.js +4 -2
- package/dist/hooks/blockRemovalRule.d.ts +29 -0
- package/dist/hooks/blockRemovalRule.js +141 -0
- package/dist/hooks/pageGuard.d.ts +24 -2
- package/dist/hooks/pageGuard.js +178 -24
- package/dist/lib/placementPages.d.ts +9 -0
- package/dist/{admin/previewLinks.model.js → lib/placementPages.js} +1 -4
- package/dist/onInit.js +22 -0
- package/dist/plugin.js +2 -1
- package/dist/puck/ExperimentPicker.js +25 -10
- package/dist/puck/copy.d.ts +4 -1
- package/dist/puck/copy.js +4 -1
- package/dist/puck/editor/ConfigureTestDrawer.d.ts +21 -0
- package/dist/puck/editor/ConfigureTestDrawer.js +147 -0
- package/dist/puck/editor/CreateExperimentDrawer.d.ts +11 -2
- package/dist/puck/editor/CreateExperimentDrawer.js +69 -9
- package/dist/puck/editor/EditorControls.d.ts +14 -0
- package/dist/puck/editor/EditorControls.js +99 -0
- package/dist/puck/editor/ExperimentSlotEditor.js +317 -51
- package/dist/puck/editor/ResultsReadout.js +3 -5
- package/dist/puck/editor/VersionBuilder.js +2 -2
- package/dist/puck/editor/armsCache.d.ts +3 -1
- package/dist/puck/editor/armsCache.js +20 -3
- package/dist/puck/editor/copy.d.ts +18 -2
- package/dist/puck/editor/copy.js +19 -3
- package/dist/puck/editor/editor.chrome.css +33 -0
- package/dist/puck/editor/editor.css +39 -0
- package/dist/puck/editor/editor.model.d.ts +14 -0
- package/dist/puck/editor/editor.model.js +58 -1
- package/dist/puck/editor/editorSurface.d.ts +10 -0
- package/dist/puck/editor/editorSurface.js +65 -0
- package/dist/puck/editor/localPlacements.d.ts +2 -0
- package/dist/puck/editor/localPlacements.js +29 -0
- package/dist/puck/editor/placementsCache.d.ts +19 -0
- package/dist/puck/editor/placementsCache.js +83 -0
- package/dist/puck/editor/xpGoalPuckEditorField.js +109 -98
- package/dist/puck/experimentSlotField.d.ts +3 -0
- package/dist/puck/experimentSlotField.js +15 -4
- package/dist/{admin → testSurface}/actions/DecideDialog.d.ts +2 -1
- package/dist/{admin → testSurface}/actions/DecideDialog.js +6 -4
- package/dist/{admin → testSurface}/api.js +4 -5
- package/dist/{admin → testSurface}/copy/common.d.ts +2 -0
- package/dist/{admin → testSurface}/copy/common.js +2 -0
- package/dist/{admin → testSurface}/copy/readiness.d.ts +3 -0
- package/dist/{admin → testSurface}/copy/readiness.js +3 -0
- package/dist/{admin → testSurface}/copy/testPage.d.ts +3 -0
- package/dist/{admin → testSurface}/copy/testPage.js +7 -2
- package/dist/testSurface/format/adminURL.d.ts +7 -0
- package/dist/testSurface/format/adminURL.js +9 -0
- package/dist/{admin → testSurface}/placements/placementLabels.js +1 -1
- package/dist/{admin → testSurface}/previewLinks.model.d.ts +1 -6
- package/dist/testSurface/previewLinks.model.js +4 -0
- package/dist/testSurface/results/results.css +64 -0
- package/dist/{admin → testSurface}/surface/contracts.d.ts +1 -0
- package/dist/{admin → testSurface}/surface/pageBlock/parts.js +6 -6
- package/dist/testSurface/surface/pagePicker/pagePicker.css +10 -0
- package/dist/{admin → testSurface}/surface/readiness/useTransition.js +1 -0
- package/dist/{admin → testSurface}/surface/results/ResultsBody.d.ts +2 -2
- package/dist/{admin → testSurface}/surface/results/ResultsBody.js +18 -11
- package/dist/testSurface/surface/setting/setting.css +17 -0
- package/dist/testSurface/surface/test/GoalSection.d.ts +4 -0
- package/dist/{admin → testSurface}/surface/test/GoalSection.js +3 -2
- package/dist/testSurface/surface/test/TestSurface.d.ts +18 -0
- package/dist/testSurface/surface/test/TestSurface.js +152 -0
- package/dist/testSurface/surface/test/VersionsSection.d.ts +5 -0
- package/dist/{admin → testSurface}/surface/test/VersionsSection.js +12 -6
- package/dist/testSurface/surface/test/testPage.css +92 -0
- package/dist/{admin → testSurface}/surface/useTestDocument.d.ts +5 -1
- package/dist/{admin → testSurface}/surface/useTestDocument.js +34 -3
- package/dist/{admin → testSurface}/surfaceUrls.js +1 -1
- package/dist/transitions/placementInteractions.js +1 -1
- package/dist/transitions/placements.d.ts +27 -8
- package/dist/transitions/placements.js +77 -6
- package/dist/transitions/start.js +2 -2
- package/dist/types/endpoints.d.ts +1 -1
- package/dist/ui/Dialog.d.ts +4 -1
- package/dist/ui/Dialog.js +41 -3
- package/dist/ui/Drawer.d.ts +10 -0
- package/dist/ui/Drawer.js +29 -0
- package/dist/ui/Tabs.d.ts +3 -3
- package/dist/ui/Tabs.js +35 -33
- package/dist/ui/ui.css +6 -0
- package/package.json +1 -1
- package/dist/admin/actions/ConfirmDialog.d.ts +0 -19
- package/dist/admin/actions/ConfirmDialog.js +0 -149
- package/dist/admin/results/results.css +0 -64
- package/dist/admin/styles.css +0 -10
- package/dist/admin/styles.d.ts +0 -2
- package/dist/admin/styles.js +0 -3
- package/dist/admin/surface/pagePicker/pagePicker.css +0 -10
- package/dist/admin/surface/setting/setting.css +0 -17
- package/dist/admin/surface/test/GoalSection.d.ts +0 -2
- package/dist/admin/surface/test/VersionsSection.d.ts +0 -4
- package/dist/admin/surface/test/testPage.css +0 -92
- /package/dist/{admin → testSurface}/PreviewLinks.d.ts +0 -0
- /package/dist/{admin → testSurface}/PreviewLinks.js +0 -0
- /package/dist/{admin → testSurface}/actions/MakeContentResult.d.ts +0 -0
- /package/dist/{admin → testSurface}/actions/MakeContentResult.js +0 -0
- /package/dist/{admin → testSurface}/actions/actions.model.d.ts +0 -0
- /package/dist/{admin → testSurface}/actions/actions.model.js +0 -0
- /package/dist/{admin → testSurface}/actions/decide.model.d.ts +0 -0
- /package/dist/{admin → testSurface}/actions/decide.model.js +0 -0
- /package/dist/{admin → testSurface}/allocation.model.d.ts +0 -0
- /package/dist/{admin → testSurface}/allocation.model.js +0 -0
- /package/dist/{admin → testSurface}/api.d.ts +0 -0
- /package/dist/{admin → testSurface}/arms/arms.model.d.ts +0 -0
- /package/dist/{admin → testSurface}/arms/arms.model.js +0 -0
- /package/dist/{admin → testSurface}/arms/pageTarget.model.d.ts +0 -0
- /package/dist/{admin → testSurface}/arms/pageTarget.model.js +0 -0
- /package/dist/{admin → testSurface}/arms/params.model.d.ts +0 -0
- /package/dist/{admin → testSurface}/arms/params.model.js +0 -0
- /package/dist/{admin → testSurface}/copy/actions.d.ts +0 -0
- /package/dist/{admin → testSurface}/copy/actions.js +0 -0
- /package/dist/{admin → testSurface}/copy/advanced.d.ts +0 -0
- /package/dist/{admin → testSurface}/copy/advanced.js +0 -0
- /package/dist/{admin → testSurface}/copy/arms.d.ts +0 -0
- /package/dist/{admin → testSurface}/copy/arms.js +0 -0
- /package/dist/{admin → testSurface}/copy/audience.d.ts +0 -0
- /package/dist/{admin → testSurface}/copy/audience.js +0 -0
- /package/dist/{admin → testSurface}/copy/metrics.d.ts +0 -0
- /package/dist/{admin → testSurface}/copy/metrics.js +0 -0
- /package/dist/{admin → testSurface}/copy/pages.d.ts +0 -0
- /package/dist/{admin → testSurface}/copy/pages.js +0 -0
- /package/dist/{admin → testSurface}/copy/recommendation.d.ts +0 -0
- /package/dist/{admin → testSurface}/copy/recommendation.js +0 -0
- /package/dist/{admin → testSurface}/copy/results.d.ts +0 -0
- /package/dist/{admin → testSurface}/copy/results.js +0 -0
- /package/dist/{admin → testSurface}/copy/review.d.ts +0 -0
- /package/dist/{admin → testSurface}/copy/review.js +0 -0
- /package/dist/{admin → testSurface}/copy/setting.d.ts +0 -0
- /package/dist/{admin → testSurface}/copy/setting.js +0 -0
- /package/dist/{admin → testSurface}/copy/surface.d.ts +0 -0
- /package/dist/{admin → testSurface}/copy/surface.js +0 -0
- /package/dist/{admin → testSurface}/format/date.d.ts +0 -0
- /package/dist/{admin → testSurface}/format/date.js +0 -0
- /package/dist/{admin → testSurface}/labels.d.ts +0 -0
- /package/dist/{admin → testSurface}/labels.js +0 -0
- /package/dist/{admin → testSurface}/lockedNotice.model.d.ts +0 -0
- /package/dist/{admin → testSurface}/lockedNotice.model.js +0 -0
- /package/dist/{admin → testSurface}/metricSource.model.d.ts +0 -0
- /package/dist/{admin → testSurface}/metricSource.model.js +0 -0
- /package/dist/{admin → testSurface}/placements/placementLabels.d.ts +0 -0
- /package/dist/{admin → testSurface}/placements/placementLabels.model.d.ts +0 -0
- /package/dist/{admin → testSurface}/placements/placementLabels.model.js +0 -0
- /package/dist/{admin → testSurface}/placements/usePlacementLabels.d.ts +0 -0
- /package/dist/{admin → testSurface}/placements/usePlacementLabels.js +0 -0
- /package/dist/{admin → testSurface}/reload.d.ts +0 -0
- /package/dist/{admin → testSurface}/reload.js +0 -0
- /package/dist/{admin → testSurface}/results/CappedCell.d.ts +0 -0
- /package/dist/{admin → testSurface}/results/CappedCell.js +0 -0
- /package/dist/{admin → testSurface}/results/CiChart.d.ts +0 -0
- /package/dist/{admin → testSurface}/results/CiChart.js +0 -0
- /package/dist/{admin → testSurface}/results/DataQualityPanel.d.ts +0 -0
- /package/dist/{admin → testSurface}/results/DataQualityPanel.js +0 -0
- /package/dist/{admin → testSurface}/results/DataTable.d.ts +0 -0
- /package/dist/{admin → testSurface}/results/DataTable.js +0 -0
- /package/dist/{admin → testSurface}/results/StatTile.d.ts +0 -0
- /package/dist/{admin → testSurface}/results/StatTile.js +0 -0
- /package/dist/{admin → testSurface}/results/VerdictHero.d.ts +0 -0
- /package/dist/{admin → testSurface}/results/VerdictHero.js +0 -0
- /package/dist/{admin → testSurface}/results/chart.model.d.ts +0 -0
- /package/dist/{admin → testSurface}/results/chart.model.js +0 -0
- /package/dist/{admin → testSurface}/results/format.d.ts +0 -0
- /package/dist/{admin → testSurface}/results/format.js +0 -0
- /package/dist/{admin → testSurface}/results/legacy.d.ts +0 -0
- /package/dist/{admin → testSurface}/results/legacy.js +0 -0
- /package/dist/{admin → testSurface}/results/releasePages.model.d.ts +0 -0
- /package/dist/{admin → testSurface}/results/releasePages.model.js +0 -0
- /package/dist/{admin → testSurface}/results/results.model.d.ts +0 -0
- /package/dist/{admin → testSurface}/results/results.model.js +0 -0
- /package/dist/{admin → testSurface}/results/snapshot.d.ts +0 -0
- /package/dist/{admin → testSurface}/results/snapshot.js +0 -0
- /package/dist/{admin → testSurface}/review/review.model.d.ts +0 -0
- /package/dist/{admin → testSurface}/review/review.model.js +0 -0
- /package/dist/{admin → testSurface}/surface/contracts.js +0 -0
- /package/dist/{admin → testSurface}/surface/pageBlock/pageBlock.model.d.ts +0 -0
- /package/dist/{admin → testSurface}/surface/pageBlock/pageBlock.model.js +0 -0
- /package/dist/{admin → testSurface}/surface/pageBlock/parts.d.ts +0 -0
- /package/dist/{admin → testSurface}/surface/pagePicker/CopyRoute.d.ts +0 -0
- /package/dist/{admin → testSurface}/surface/pagePicker/CopyRoute.js +0 -0
- /package/dist/{admin → testSurface}/surface/pagePicker/PageCombobox.d.ts +0 -0
- /package/dist/{admin → testSurface}/surface/pagePicker/PageCombobox.js +0 -0
- /package/dist/{admin → testSurface}/surface/pagePicker/pagePicker.model.d.ts +0 -0
- /package/dist/{admin → testSurface}/surface/pagePicker/pagePicker.model.js +0 -0
- /package/dist/{admin → testSurface}/surface/readiness/ActionDialogs.d.ts +0 -0
- /package/dist/{admin → testSurface}/surface/readiness/ActionDialogs.js +0 -0
- /package/dist/{admin → testSurface}/surface/readiness/Banner.d.ts +0 -0
- /package/dist/{admin → testSurface}/surface/readiness/Banner.js +0 -0
- /package/dist/{admin → testSurface}/surface/readiness/SaveStatus.d.ts +0 -0
- /package/dist/{admin → testSurface}/surface/readiness/SaveStatus.js +0 -0
- /package/dist/{admin → testSurface}/surface/readiness/parts.d.ts +0 -0
- /package/dist/{admin → testSurface}/surface/readiness/parts.js +0 -0
- /package/dist/{admin → testSurface}/surface/readiness/readiness.model.d.ts +0 -0
- /package/dist/{admin → testSurface}/surface/readiness/readiness.model.js +0 -0
- /package/dist/{admin → testSurface}/surface/readiness/useTransition.d.ts +0 -0
- /package/dist/{admin → testSurface}/surface/results/ReleasePages.d.ts +0 -0
- /package/dist/{admin → testSurface}/surface/results/ReleasePages.js +0 -0
- /package/dist/{admin → testSurface}/surface/results/recommendation.model.d.ts +0 -0
- /package/dist/{admin → testSurface}/surface/results/recommendation.model.js +0 -0
- /package/dist/{admin → testSurface}/surface/results/useResults.d.ts +0 -0
- /package/dist/{admin → testSurface}/surface/results/useResults.js +0 -0
- /package/dist/{admin → testSurface}/surface/setting/parts.d.ts +0 -0
- /package/dist/{admin → testSurface}/surface/setting/parts.js +0 -0
- /package/dist/{admin → testSurface}/surface/setting/setting.model.d.ts +0 -0
- /package/dist/{admin → testSurface}/surface/setting/setting.model.js +0 -0
- /package/dist/{admin → testSurface}/surface/test/AdvancedSection.d.ts +0 -0
- /package/dist/{admin → testSurface}/surface/test/AdvancedSection.js +0 -0
- /package/dist/{admin → testSurface}/surface/test/LengthSection.d.ts +0 -0
- /package/dist/{admin → testSurface}/surface/test/LengthSection.js +0 -0
- /package/dist/{admin → testSurface}/surface/test/PageHoldout.d.ts +0 -0
- /package/dist/{admin → testSurface}/surface/test/PageHoldout.js +0 -0
- /package/dist/{admin → testSurface}/surface/test/Rail.d.ts +0 -0
- /package/dist/{admin → testSurface}/surface/test/Rail.js +0 -0
- /package/dist/{admin → testSurface}/surface/test/ReadinessBar.d.ts +0 -0
- /package/dist/{admin → testSurface}/surface/test/ReadinessBar.js +0 -0
- /package/dist/{admin → testSurface}/surface/test/Section.d.ts +0 -0
- /package/dist/{admin → testSurface}/surface/test/Section.js +0 -0
- /package/dist/{admin → testSurface}/surface/test/TargetingSection.d.ts +0 -0
- /package/dist/{admin → testSurface}/surface/test/TargetingSection.js +0 -0
- /package/dist/{admin → testSurface}/surface/test/fields.d.ts +0 -0
- /package/dist/{admin → testSurface}/surface/test/fields.js +0 -0
- /package/dist/{admin → testSurface}/surface/test/jumpToSection.d.ts +0 -0
- /package/dist/{admin → testSurface}/surface/test/jumpToSection.js +0 -0
- /package/dist/{admin → testSurface}/surface/test/pageParts.d.ts +0 -0
- /package/dist/{admin → testSurface}/surface/test/pageParts.js +0 -0
- /package/dist/{admin → testSurface}/surface/test/testPage.model.d.ts +0 -0
- /package/dist/{admin → testSurface}/surface/test/testPage.model.js +0 -0
- /package/dist/{admin → testSurface}/surface/testDocument.model.d.ts +0 -0
- /package/dist/{admin → testSurface}/surface/testDocument.model.js +0 -0
- /package/dist/{admin → testSurface}/surfaceUrls.d.ts +0 -0
- /package/dist/{admin → testSurface}/targeting/targeting.model.d.ts +0 -0
- /package/dist/{admin → testSurface}/targeting/targeting.model.js +0 -0
- /package/dist/{admin → testSurface}/theme.d.ts +0 -0
- /package/dist/{admin → testSurface}/theme.js +0 -0
- /package/dist/{admin → testSurface}/useApi.d.ts +0 -0
- /package/dist/{admin → testSurface}/useApi.js +0 -0
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import type { DocId } from '../../types/contracts.js';
|
|
2
|
+
import type { resolvePuckRoutes } from '../routes.js';
|
|
3
|
+
import './editor.css';
|
|
4
|
+
export declare function ConfigureTestDrawer({ id, routes, onClose }: {
|
|
5
|
+
id: DocId;
|
|
6
|
+
routes: ReturnType<typeof resolvePuckRoutes>;
|
|
7
|
+
onClose: () => void;
|
|
8
|
+
}): import("react").JSX.Element;
|
|
9
|
+
/** Separate document root, like the creation dialog: Puck has no ancestor handlers here. */
|
|
10
|
+
export declare function openConfigureTestDrawer(source: HTMLElement, routes: ReturnType<typeof resolvePuckRoutes>, id: DocId): {
|
|
11
|
+
close: () => void;
|
|
12
|
+
};
|
|
13
|
+
/** The canvas already has current permissions; use them without a second read. */
|
|
14
|
+
export declare function ConfigureTestControl({ id, routes }: {
|
|
15
|
+
id: DocId;
|
|
16
|
+
routes: ReturnType<typeof resolvePuckRoutes>;
|
|
17
|
+
}): import("react").JSX.Element;
|
|
18
|
+
export declare function ConfigureTestButton({ id, routes }: {
|
|
19
|
+
id: DocId;
|
|
20
|
+
routes: ReturnType<typeof resolvePuckRoutes>;
|
|
21
|
+
}): import("react").JSX.Element | null;
|
|
@@ -0,0 +1,147 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
3
|
+
import { useEffect, useRef, useState } from 'react';
|
|
4
|
+
import { createRoot } from 'react-dom/client';
|
|
5
|
+
import { registerOverlayPortal } from '@puckeditor/core';
|
|
6
|
+
import { TestSurface } from '../../testSurface/surface/test/TestSurface.js';
|
|
7
|
+
import { Drawer } from '../../ui/Drawer.js';
|
|
8
|
+
import { Button } from '../../ui/Button.js';
|
|
9
|
+
import { TEST_PAGE } from '../../testSurface/copy/testPage.js';
|
|
10
|
+
import { readSurface, useEditorSurface } from './editorSurface.js';
|
|
11
|
+
import { editorCopy as C } from './copy.js';
|
|
12
|
+
import { publishExperiment } from './armsCache.js';
|
|
13
|
+
import { publishPlacements } from './placementsCache.js';
|
|
14
|
+
import './editor.css';
|
|
15
|
+
export function ConfigureTestDrawer({ id, routes, onClose }) {
|
|
16
|
+
const [title, setTitle] = useState(C.configure);
|
|
17
|
+
const [state, setState] = useState({});
|
|
18
|
+
const [attempt, setAttempt] = useState(0);
|
|
19
|
+
useEffect(()=>{
|
|
20
|
+
let active = true;
|
|
21
|
+
setState({});
|
|
22
|
+
void readSurface(routes.api).then((result)=>{
|
|
23
|
+
if (active) setState(result.surface ? {
|
|
24
|
+
surface: {
|
|
25
|
+
...result.surface,
|
|
26
|
+
adminRoute: routes.admin,
|
|
27
|
+
apiRoute: routes.api
|
|
28
|
+
}
|
|
29
|
+
} : result);
|
|
30
|
+
});
|
|
31
|
+
return ()=>{
|
|
32
|
+
active = false;
|
|
33
|
+
};
|
|
34
|
+
}, [
|
|
35
|
+
routes.api,
|
|
36
|
+
routes.admin,
|
|
37
|
+
attempt
|
|
38
|
+
]);
|
|
39
|
+
// Unknown permissions use the test page's authoritative admin access check.
|
|
40
|
+
const testUrl = `${routes.admin}/experiments/${encodeURIComponent(id)}`;
|
|
41
|
+
const openUrl = state.surface && !state.surface.canManage && state.surface.canReadResults ? `${testUrl}/results` : testUrl;
|
|
42
|
+
return /*#__PURE__*/ _jsx(Drawer, {
|
|
43
|
+
title: title,
|
|
44
|
+
closeLabel: C.closeConfigure,
|
|
45
|
+
onClose: onClose,
|
|
46
|
+
actions: /*#__PURE__*/ _jsx(Button, {
|
|
47
|
+
variant: state.error === 'unavailable' ? 'primary' : 'link',
|
|
48
|
+
size: "sm",
|
|
49
|
+
href: openUrl,
|
|
50
|
+
target: "_blank",
|
|
51
|
+
rel: "noopener noreferrer",
|
|
52
|
+
children: C.openInTab
|
|
53
|
+
}),
|
|
54
|
+
children: /*#__PURE__*/ _jsx("div", {
|
|
55
|
+
className: "xp-configure-panel xp-test-surface",
|
|
56
|
+
onClickCapture: (event)=>{
|
|
57
|
+
// Internal section jumps stay in the drawer; navigation never replaces the editor.
|
|
58
|
+
const link = event.target.closest('a[href]');
|
|
59
|
+
if (link && !link.getAttribute('href')?.startsWith('#')) {
|
|
60
|
+
link.target = '_blank';
|
|
61
|
+
link.rel = 'noopener noreferrer';
|
|
62
|
+
}
|
|
63
|
+
},
|
|
64
|
+
children: state.surface ? /*#__PURE__*/ _jsx(TestSurface, {
|
|
65
|
+
id: id,
|
|
66
|
+
surface: state.surface,
|
|
67
|
+
embedded: true,
|
|
68
|
+
onTitleChange: setTitle,
|
|
69
|
+
onDocument: (doc)=>publishExperiment(id, doc),
|
|
70
|
+
onPreflight: (preflight)=>publishPlacements(routes.api, id, preflight.placements)
|
|
71
|
+
}) : /*#__PURE__*/ _jsxs("div", {
|
|
72
|
+
role: state.error ? 'alert' : 'status',
|
|
73
|
+
children: [
|
|
74
|
+
/*#__PURE__*/ _jsx("p", {
|
|
75
|
+
children: state.error === 'forbidden' ? TEST_PAGE.forbidden : state.error ? C.setupUnavailable : TEST_PAGE.loading
|
|
76
|
+
}),
|
|
77
|
+
state.error === 'unavailable' ? /*#__PURE__*/ _jsx(Button, {
|
|
78
|
+
onClick: ()=>setAttempt((value)=>value + 1),
|
|
79
|
+
children: C.retrySetup
|
|
80
|
+
}) : null
|
|
81
|
+
]
|
|
82
|
+
})
|
|
83
|
+
})
|
|
84
|
+
});
|
|
85
|
+
}
|
|
86
|
+
/** Separate document root, like the creation dialog: Puck has no ancestor handlers here. */ export function openConfigureTestDrawer(source, routes, id) {
|
|
87
|
+
// A canvas iframe's modal would cover only the canvas. Mount over the whole editor.
|
|
88
|
+
const doc = source.ownerDocument.defaultView?.frameElement?.ownerDocument ?? source.ownerDocument;
|
|
89
|
+
const container = doc.createElement('div');
|
|
90
|
+
container.className = 'xp-slot-root xp-slot-editor xp-configure-host';
|
|
91
|
+
const themeSource = source.closest('.xp-slot-root') ?? source;
|
|
92
|
+
container.style.cssText = themeSource.style.cssText;
|
|
93
|
+
if (source.closest('[data-theme="dark"], .dark')) container.dataset.theme = 'dark';
|
|
94
|
+
doc.body.append(container);
|
|
95
|
+
const release = registerOverlayPortal(container, {
|
|
96
|
+
disableDrag: true
|
|
97
|
+
});
|
|
98
|
+
const root = createRoot(container);
|
|
99
|
+
let closed = false;
|
|
100
|
+
const close = ()=>{
|
|
101
|
+
if (closed) return;
|
|
102
|
+
closed = true;
|
|
103
|
+
queueMicrotask(()=>{
|
|
104
|
+
root.unmount();
|
|
105
|
+
release?.();
|
|
106
|
+
container.remove();
|
|
107
|
+
if (source.isConnected) source.focus();
|
|
108
|
+
});
|
|
109
|
+
};
|
|
110
|
+
root.render(/*#__PURE__*/ _jsx("div", {
|
|
111
|
+
onClick: (event)=>event.stopPropagation(),
|
|
112
|
+
onKeyDown: (event)=>event.stopPropagation(),
|
|
113
|
+
onPointerMove: (event)=>event.stopPropagation(),
|
|
114
|
+
onPointerUp: (event)=>event.stopPropagation(),
|
|
115
|
+
children: /*#__PURE__*/ _jsx(ConfigureTestDrawer, {
|
|
116
|
+
id: id,
|
|
117
|
+
routes: routes,
|
|
118
|
+
onClose: close
|
|
119
|
+
})
|
|
120
|
+
}));
|
|
121
|
+
return {
|
|
122
|
+
close
|
|
123
|
+
};
|
|
124
|
+
}
|
|
125
|
+
/** The canvas already has current permissions; use them without a second read. */ export function ConfigureTestControl({ id, routes }) {
|
|
126
|
+
const drawer = useRef(undefined);
|
|
127
|
+
useEffect(()=>()=>drawer.current?.close(), [
|
|
128
|
+
id,
|
|
129
|
+
routes.api
|
|
130
|
+
]);
|
|
131
|
+
return /*#__PURE__*/ _jsx(Button, {
|
|
132
|
+
variant: "primary",
|
|
133
|
+
onClick: (event)=>{
|
|
134
|
+
drawer.current?.close();
|
|
135
|
+
drawer.current = openConfigureTestDrawer(event.currentTarget, routes, id);
|
|
136
|
+
},
|
|
137
|
+
children: C.configure
|
|
138
|
+
});
|
|
139
|
+
}
|
|
140
|
+
export function ConfigureTestButton({ id, routes }) {
|
|
141
|
+
const access = useEditorSurface(routes.api);
|
|
142
|
+
if (!access.surface || !access.surface.canManage && !access.surface.canReadResults) return null;
|
|
143
|
+
return /*#__PURE__*/ _jsx(ConfigureTestControl, {
|
|
144
|
+
id: id,
|
|
145
|
+
routes: routes
|
|
146
|
+
});
|
|
147
|
+
}
|
|
@@ -1,7 +1,16 @@
|
|
|
1
|
+
import type { resolvePuckRoutes } from '../routes.js';
|
|
1
2
|
import type { ExperimentRef } from '../../types/puck.js';
|
|
3
|
+
import type { Arm } from '../../types/contracts.js';
|
|
2
4
|
import './editor.css';
|
|
3
|
-
export declare function CreateExperimentDrawer({ onCreate, onClose, initialName }: {
|
|
5
|
+
export declare function CreateExperimentDrawer({ onCreate, onClose, initialName, arms, label, onPendingChange }: {
|
|
4
6
|
initialName?: string;
|
|
5
|
-
|
|
7
|
+
arms?: Arm[] | (() => Promise<Arm[]>);
|
|
8
|
+
label?: string;
|
|
9
|
+
onPendingChange?: (pending: boolean) => void;
|
|
10
|
+
onCreate: (experiment: ExperimentRef) => boolean;
|
|
6
11
|
onClose: () => void;
|
|
7
12
|
}): import("react").JSX.Element;
|
|
13
|
+
/** The dialog belongs to the document so deleting its block during POST cannot hide the created test. */
|
|
14
|
+
export declare function openCreateExperimentDrawer(source: HTMLElement, routes: ReturnType<typeof resolvePuckRoutes>, props: Omit<Parameters<typeof CreateExperimentDrawer>[0], 'onClose' | 'onPendingChange'>): {
|
|
15
|
+
closeIfIdle: () => void;
|
|
16
|
+
};
|
|
@@ -5,45 +5,65 @@ import { Dialog } from '../../ui/Dialog.js';
|
|
|
5
5
|
import { TextInput } from '../../ui/TextInput.js';
|
|
6
6
|
import { Button } from '../../ui/Button.js';
|
|
7
7
|
import { Banner } from '../../ui/Banner.js';
|
|
8
|
-
import { usePuckRoutes } from '../hostContext.js';
|
|
8
|
+
import { PuckHostProvider, usePuckRoutes } from '../hostContext.js';
|
|
9
|
+
import { createRoot } from 'react-dom/client';
|
|
9
10
|
import { CreateRefused, createTest } from './createTest.js';
|
|
10
11
|
import { editorCopy } from './copy.js';
|
|
12
|
+
import { invalidatePlacements } from './placementsCache.js';
|
|
11
13
|
import './editor.css';
|
|
12
|
-
export function CreateExperimentDrawer({ onCreate, onClose, initialName = '' }) {
|
|
13
|
-
const { api } = usePuckRoutes();
|
|
14
|
+
export function CreateExperimentDrawer({ onCreate, onClose, initialName = '', arms, label = editorCopy.createLabel, onPendingChange }) {
|
|
15
|
+
const { api, admin } = usePuckRoutes();
|
|
14
16
|
const nameId = useId();
|
|
15
17
|
const [name, setName] = useState(initialName);
|
|
16
18
|
const inFlight = useRef(false);
|
|
17
19
|
const [pending, setPending] = useState(false);
|
|
18
20
|
const [error, setError] = useState('');
|
|
21
|
+
const [unbound, setUnbound] = useState();
|
|
19
22
|
async function submitNew() {
|
|
20
23
|
if (inFlight.current || !name.trim()) return;
|
|
21
24
|
inFlight.current = true;
|
|
22
25
|
setPending(true);
|
|
26
|
+
onPendingChange?.(true);
|
|
23
27
|
setError('');
|
|
24
28
|
try {
|
|
29
|
+
const versions = typeof arms === 'function' ? await arms() : arms;
|
|
25
30
|
const experiment = await createTest(api, {
|
|
26
31
|
name,
|
|
27
32
|
kind: 'block',
|
|
28
|
-
unitType: 'visitor'
|
|
33
|
+
unitType: 'visitor',
|
|
34
|
+
arms: versions
|
|
29
35
|
});
|
|
30
|
-
|
|
31
|
-
onClose();
|
|
36
|
+
invalidatePlacements(api, experiment.id);
|
|
37
|
+
if (onCreate(experiment)) onClose();
|
|
38
|
+
else setUnbound(experiment);
|
|
32
39
|
} catch (cause) {
|
|
33
40
|
setError(cause instanceof CreateRefused ? cause.message : editorCopy.createError);
|
|
34
41
|
} finally{
|
|
35
42
|
inFlight.current = false;
|
|
36
43
|
setPending(false);
|
|
44
|
+
onPendingChange?.(false);
|
|
37
45
|
}
|
|
38
46
|
}
|
|
39
47
|
return /*#__PURE__*/ _jsx(Dialog, {
|
|
40
48
|
open: true,
|
|
41
|
-
title:
|
|
49
|
+
title: label,
|
|
42
50
|
onClose: onClose,
|
|
43
51
|
dismissible: !pending,
|
|
44
52
|
children: /*#__PURE__*/ _jsxs("div", {
|
|
45
53
|
className: "xp-slot-drawer",
|
|
46
54
|
children: [
|
|
55
|
+
unbound ? /*#__PURE__*/ _jsxs("p", {
|
|
56
|
+
children: [
|
|
57
|
+
editorCopy.createdUnbound,
|
|
58
|
+
' ',
|
|
59
|
+
/*#__PURE__*/ _jsx("a", {
|
|
60
|
+
href: `${admin}/experiments/${encodeURIComponent(unbound.id)}`,
|
|
61
|
+
target: "_blank",
|
|
62
|
+
rel: "noopener noreferrer",
|
|
63
|
+
children: editorCopy.openTest
|
|
64
|
+
})
|
|
65
|
+
]
|
|
66
|
+
}) : null,
|
|
47
67
|
/*#__PURE__*/ _jsx(TextInput, {
|
|
48
68
|
id: nameId,
|
|
49
69
|
label: editorCopy.name,
|
|
@@ -60,11 +80,11 @@ export function CreateExperimentDrawer({ onCreate, onClose, initialName = '' })
|
|
|
60
80
|
children: [
|
|
61
81
|
/*#__PURE__*/ _jsx(Button, {
|
|
62
82
|
variant: "primary",
|
|
63
|
-
disabled: pending || !name.trim(),
|
|
83
|
+
disabled: pending || !!unbound || !name.trim(),
|
|
64
84
|
onClick: ()=>{
|
|
65
85
|
void submitNew();
|
|
66
86
|
},
|
|
67
|
-
children: pending ? editorCopy.creating :
|
|
87
|
+
children: pending ? editorCopy.creating : label
|
|
68
88
|
}),
|
|
69
89
|
/*#__PURE__*/ _jsx(Button, {
|
|
70
90
|
disabled: pending,
|
|
@@ -77,3 +97,43 @@ export function CreateExperimentDrawer({ onCreate, onClose, initialName = '' })
|
|
|
77
97
|
})
|
|
78
98
|
});
|
|
79
99
|
}
|
|
100
|
+
/** The dialog belongs to the document so deleting its block during POST cannot hide the created test. */ export function openCreateExperimentDrawer(source, routes, props) {
|
|
101
|
+
const container = source.ownerDocument.createElement('div');
|
|
102
|
+
container.className = 'xp-slot-dialog-host';
|
|
103
|
+
const tokenRoot = source.ownerDocument.createElement('div');
|
|
104
|
+
tokenRoot.className = 'xp-slot-root xp-slot-editor';
|
|
105
|
+
tokenRoot.style.cssText = source.style.cssText;
|
|
106
|
+
container.append(tokenRoot);
|
|
107
|
+
if (source.closest('[data-theme="dark"], .dark')) container.dataset.theme = 'dark';
|
|
108
|
+
source.ownerDocument.body.append(container);
|
|
109
|
+
const root = createRoot(tokenRoot);
|
|
110
|
+
let pending = false, closed = false;
|
|
111
|
+
const close = ()=>{
|
|
112
|
+
if (closed) return;
|
|
113
|
+
closed = true;
|
|
114
|
+
// Cleanup can originate from the creator's unmount commit.
|
|
115
|
+
queueMicrotask(()=>{
|
|
116
|
+
root.unmount();
|
|
117
|
+
container.remove();
|
|
118
|
+
});
|
|
119
|
+
};
|
|
120
|
+
root.render(/*#__PURE__*/ _jsx(PuckHostProvider, {
|
|
121
|
+
routes: routes,
|
|
122
|
+
children: /*#__PURE__*/ _jsx("div", {
|
|
123
|
+
onClick: (event)=>event.stopPropagation(),
|
|
124
|
+
onKeyDown: (event)=>event.stopPropagation(),
|
|
125
|
+
children: /*#__PURE__*/ _jsx(CreateExperimentDrawer, {
|
|
126
|
+
...props,
|
|
127
|
+
onPendingChange: (value)=>{
|
|
128
|
+
pending = value;
|
|
129
|
+
},
|
|
130
|
+
onClose: close
|
|
131
|
+
})
|
|
132
|
+
})
|
|
133
|
+
}));
|
|
134
|
+
return {
|
|
135
|
+
closeIfIdle: ()=>{
|
|
136
|
+
if (!pending) close();
|
|
137
|
+
}
|
|
138
|
+
};
|
|
139
|
+
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { type ReactNode } from 'react';
|
|
2
|
+
export declare const CONTROL_SELECTOR = "button, a, label, input, select, textarea, [role=\"tab\"], [role=\"menu\"], [role=\"listbox\"], dialog, [role=\"dialog\"], [contenteditable=\"true\"]";
|
|
3
|
+
/** Give React a delegation boundary before Puck's native component click listeners.
|
|
4
|
+
* A normal React onClick runs too late: native child/parent selection already ran.
|
|
5
|
+
* The portal target is this chrome element in the canvas's ownerDocument, so
|
|
6
|
+
* React delegates here inside Puck's iframe too, before its component listener.
|
|
7
|
+
* Puck 0.24 chunk-DQXMVPVM.mjs:3754–3778, 3847, 12996–12999.
|
|
8
|
+
*/
|
|
9
|
+
export declare function EditorControls({ children, className, selected, onSelect }: {
|
|
10
|
+
children: ReactNode;
|
|
11
|
+
className: string;
|
|
12
|
+
selected?: boolean;
|
|
13
|
+
onSelect?: () => void;
|
|
14
|
+
}): import("react").JSX.Element;
|
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
3
|
+
import { registerOverlayPortal, useGetPuck } from '@puckeditor/core';
|
|
4
|
+
import { useEffect, useRef, useState } from 'react';
|
|
5
|
+
import { createPortal } from 'react-dom';
|
|
6
|
+
export const CONTROL_SELECTOR = 'button, a, label, input, select, textarea, [role="tab"], [role="menu"], [role="listbox"], dialog, [role="dialog"], [contenteditable="true"]';
|
|
7
|
+
/** Give React a delegation boundary before Puck's native component click listeners.
|
|
8
|
+
* A normal React onClick runs too late: native child/parent selection already ran.
|
|
9
|
+
* The portal target is this chrome element in the canvas's ownerDocument, so
|
|
10
|
+
* React delegates here inside Puck's iframe too, before its component listener.
|
|
11
|
+
* Puck 0.24 chunk-DQXMVPVM.mjs:3754–3778, 3847, 12996–12999.
|
|
12
|
+
*/ export function EditorControls({ children, className, selected, onSelect }) {
|
|
13
|
+
const getPuck = useGetPuck();
|
|
14
|
+
const endedDrag = useRef(false);
|
|
15
|
+
const select = ()=>{
|
|
16
|
+
// Puck keeps isDragging true through drop processing. Capture pointerup too,
|
|
17
|
+
// since drop completion may clear it before the browser dispatches click.
|
|
18
|
+
const suppress = endedDrag.current || getPuck().appState.ui.isDragging;
|
|
19
|
+
endedDrag.current = false;
|
|
20
|
+
if (!suppress) onSelect?.();
|
|
21
|
+
};
|
|
22
|
+
const [element, setElement] = useState(null);
|
|
23
|
+
useEffect(()=>{
|
|
24
|
+
if (!element) return;
|
|
25
|
+
// Puck 0.24's supported per-element portals. The header must still reach
|
|
26
|
+
// Puck's pointer sensor, even after keyboard focus; only controls disable drag.
|
|
27
|
+
const cleanup = registerOverlayPortal(element, {
|
|
28
|
+
disableDragOnFocus: false
|
|
29
|
+
});
|
|
30
|
+
const controls = new Map();
|
|
31
|
+
const update = ()=>{
|
|
32
|
+
for (const [node, release] of controls)if (!element.contains(node)) {
|
|
33
|
+
release?.();
|
|
34
|
+
controls.delete(node);
|
|
35
|
+
}
|
|
36
|
+
for (const node of element.querySelectorAll(CONTROL_SELECTOR)){
|
|
37
|
+
if (!controls.has(node)) controls.set(node, registerOverlayPortal(node, {
|
|
38
|
+
disableDrag: true
|
|
39
|
+
}));
|
|
40
|
+
}
|
|
41
|
+
};
|
|
42
|
+
update();
|
|
43
|
+
const observer = new MutationObserver(update);
|
|
44
|
+
observer.observe(element, {
|
|
45
|
+
childList: true,
|
|
46
|
+
subtree: true
|
|
47
|
+
});
|
|
48
|
+
return ()=>{
|
|
49
|
+
observer.disconnect();
|
|
50
|
+
cleanup?.();
|
|
51
|
+
for (const release of controls.values())release?.();
|
|
52
|
+
};
|
|
53
|
+
}, [
|
|
54
|
+
element
|
|
55
|
+
]);
|
|
56
|
+
useEffect(()=>{
|
|
57
|
+
if (!element) return;
|
|
58
|
+
// Padding belongs to the portal target itself, outside React's portal tree.
|
|
59
|
+
const paddingClick = (event)=>{
|
|
60
|
+
if (event.target !== element) return;
|
|
61
|
+
event.stopPropagation();
|
|
62
|
+
select();
|
|
63
|
+
};
|
|
64
|
+
element.addEventListener('click', paddingClick);
|
|
65
|
+
return ()=>element.removeEventListener('click', paddingClick);
|
|
66
|
+
});
|
|
67
|
+
useEffect(()=>{
|
|
68
|
+
if (!element) return;
|
|
69
|
+
const down = ()=>{
|
|
70
|
+
endedDrag.current = false;
|
|
71
|
+
};
|
|
72
|
+
const up = ()=>{
|
|
73
|
+
endedDrag.current = getPuck().appState.ui.isDragging;
|
|
74
|
+
};
|
|
75
|
+
element.addEventListener('pointerdown', down, true);
|
|
76
|
+
element.addEventListener('pointerup', up, true);
|
|
77
|
+
return ()=>{
|
|
78
|
+
element.removeEventListener('pointerdown', down, true);
|
|
79
|
+
element.removeEventListener('pointerup', up, true);
|
|
80
|
+
};
|
|
81
|
+
}, [
|
|
82
|
+
element,
|
|
83
|
+
getPuck
|
|
84
|
+
]);
|
|
85
|
+
return /*#__PURE__*/ _jsx("div", {
|
|
86
|
+
ref: setElement,
|
|
87
|
+
className: className,
|
|
88
|
+
"data-selected": selected,
|
|
89
|
+
children: element ? /*#__PURE__*/ createPortal(/*#__PURE__*/ _jsx("div", {
|
|
90
|
+
className: "xp-slot-control-events",
|
|
91
|
+
onClick: (event)=>{
|
|
92
|
+
event.stopPropagation();
|
|
93
|
+
if (!event.target.closest(CONTROL_SELECTOR)) select();
|
|
94
|
+
},
|
|
95
|
+
onKeyDown: (event)=>event.stopPropagation(),
|
|
96
|
+
children: children
|
|
97
|
+
}), element) : null
|
|
98
|
+
});
|
|
99
|
+
}
|