@delmaredigital/payload-experiments 0.4.0-rc.1 → 0.4.0-rc.10
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 +284 -772
- 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.d.ts +1 -0
- package/dist/admin/TestsDashboardCards.js +5 -9
- package/dist/admin/TestsNavLink.d.ts +1 -0
- package/dist/admin/TestsNavLink.js +5 -11
- package/dist/admin/blocks/BlockPanel.d.ts +1 -0
- package/dist/admin/blocks/BlockPanel.js +129 -37
- package/dist/admin/blocks/TestBlockField.js +3 -3
- package/dist/admin/blocks/formApi.d.ts +3 -0
- package/dist/admin/blocks/formApi.js +10 -4
- package/dist/admin/blocks/inject.js +1 -0
- package/dist/admin/blocks/model.d.ts +3 -2
- package/dist/admin/blocks/model.js +10 -6
- package/dist/admin/blocks/statusCache.d.ts +2 -0
- package/dist/admin/blocks/statusCache.js +12 -3
- package/dist/admin/components/RootViewMessage.js +1 -1
- package/dist/admin/copy/blocks.d.ts +21 -1
- package/dist/admin/copy/blocks.js +40 -6
- package/dist/admin/copy/goals.d.ts +6 -1
- package/dist/admin/copy/goals.js +10 -3
- package/dist/admin/copy/newTest.d.ts +6 -7
- package/dist/admin/copy/newTest.js +9 -7
- package/dist/admin/goals/XpGoalField.d.ts +2 -0
- package/dist/admin/goals/XpGoalField.js +156 -114
- package/dist/admin/goals/xpGoalField.css +47 -0
- package/dist/admin/pageCollections.d.ts +1 -0
- package/dist/admin/pageCollections.js +3 -0
- package/dist/admin/paths.d.ts +3 -0
- package/dist/admin/paths.js +3 -0
- package/dist/admin/placementStatus.model.js +1 -1
- package/dist/admin/status.model.js +1 -1
- package/dist/admin/surface/ResultsRoute.d.ts +2 -1
- package/dist/admin/surface/ResultsRoute.js +20 -24
- package/dist/admin/surface/SurfaceShell.js +5 -2
- package/dist/admin/surface/TestRowMenu.d.ts +6 -0
- package/dist/admin/surface/TestRowMenu.js +156 -0
- package/dist/admin/surface/TestsHome.d.ts +5 -3
- package/dist/admin/surface/TestsHome.js +266 -58
- package/dist/admin/surface/TestsSurface.js +8 -7
- package/dist/admin/surface/goals/GoalForm.d.ts +1 -1
- package/dist/admin/surface/goals/GoalForm.js +95 -54
- package/dist/admin/surface/goals/GoalsList.d.ts +1 -1
- package/dist/admin/surface/goals/GoalsList.js +5 -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 +9 -8
- package/dist/admin/surface/home.model.js +22 -21
- package/dist/admin/surface/newTest/NewTest.d.ts +4 -4
- package/dist/admin/surface/newTest/NewTest.js +98 -94
- package/dist/admin/surface/newTest/PageWizard.d.ts +2 -1
- package/dist/admin/surface/newTest/PageWizard.js +111 -76
- package/dist/admin/surface/newTest/newTest.css +28 -9
- package/dist/admin/surface/results/ResultsHeader.d.ts +2 -2
- package/dist/admin/surface/results/ResultsHeader.js +58 -54
- package/dist/admin/surface/surface.css +10 -0
- package/dist/admin/surface/test/TestPage.d.ts +1 -2
- package/dist/admin/surface/test/TestPage.js +42 -162
- package/dist/admin/theme.css +2 -0
- package/dist/admin/views/CollectionListRedirect.d.ts +1 -0
- package/dist/admin/views/CollectionListRedirect.js +1 -1
- package/dist/admin/views/ExperimentsRootView.js +18 -165
- package/dist/admin/views/GoalEditRedirect.d.ts +4 -0
- package/dist/admin/views/GoalEditRedirect.js +14 -0
- package/dist/admin/views/GoalsCollectionListView.d.ts +2 -0
- package/dist/admin/views/GoalsCollectionListView.js +4 -0
- package/dist/admin/views/TestsCollectionListView.d.ts +2 -0
- package/dist/admin/views/TestsCollectionListView.js +4 -0
- package/dist/admin/views/TestsNavLinkServer.d.ts +1 -0
- package/dist/admin/views/TestsNavLinkServer.js +2 -2
- package/dist/admin/views/TestsSurfaceClient.d.ts +3 -0
- package/dist/admin/views/TestsSurfaceClient.js +11 -0
- package/dist/admin/views/buildSurfaceProps.d.ts +8 -0
- package/dist/admin/views/buildSurfaceProps.js +102 -0
- package/dist/admin/views/renderCollectionList.d.ts +2 -0
- package/dist/admin/views/renderCollectionList.js +34 -0
- package/dist/admin/views/renderTestsSurface.d.ts +3 -0
- package/dist/admin/views/renderTestsSurface.js +34 -0
- package/dist/blocks/bindings.js +8 -14
- package/dist/blocks/formState.js +1 -1
- package/dist/blocks/placementLanguages.d.ts +7 -0
- package/dist/blocks/placementLanguages.js +27 -0
- package/dist/blocks/placementLocale.d.ts +37 -0
- package/dist/blocks/placementLocale.js +270 -0
- package/dist/collections/experiments/config.js +17 -8
- package/dist/collections/experiments/deleteGuard.js +2 -2
- package/dist/collections/experiments/lockHook.js +21 -2
- package/dist/collections/experiments/pickSlug.js +2 -0
- package/dist/collections/metrics.js +16 -4
- package/dist/collections/metricsGuards.js +2 -0
- package/dist/collections/serialize.js +5 -4
- package/dist/constants.d.ts +1 -0
- package/dist/constants.js +1 -0
- package/dist/db/adapter.d.ts +9 -1
- package/dist/db/adapter.js +77 -1
- package/dist/db/appends.d.ts +13 -0
- package/dist/db/appends.js +49 -0
- package/dist/db/bulkPlacementRemoval.d.ts +30 -0
- package/dist/db/bulkPlacementRemoval.js +111 -0
- package/dist/db/delete.d.ts +1 -1
- package/dist/db/delete.js +2 -4
- package/dist/db/events.d.ts +9 -0
- package/dist/db/events.js +42 -8
- package/dist/db/executor.d.ts +7 -1
- package/dist/db/executor.js +7 -3
- package/dist/db/pageCopies.d.ts +5 -0
- package/dist/db/pageCopies.js +31 -0
- package/dist/db/placements.d.ts +2 -0
- package/dist/db/placements.js +8 -0
- package/dist/db/results.d.ts +5 -1
- package/dist/db/results.js +21 -5
- package/dist/db/snapshots.d.ts +1 -0
- 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 +207 -0
- package/dist/endpoints/duplicateOriginal.d.ts +38 -0
- package/dist/endpoints/duplicateOriginal.js +407 -0
- package/dist/endpoints/editorSurface.d.ts +3 -0
- package/dist/endpoints/editorSurface.js +31 -0
- package/dist/endpoints/events.js +103 -39
- package/dist/endpoints/index.js +57 -9
- package/dist/endpoints/pages.js +247 -64
- package/dist/endpoints/placementStatus.js +13 -5
- package/dist/endpoints/preflight.d.ts +1 -1
- package/dist/endpoints/preflight.js +17 -2
- package/dist/endpoints/results.d.ts +1 -1
- package/dist/endpoints/results.js +6 -2
- package/dist/endpoints/routeId.d.ts +2 -2
- package/dist/endpoints/routeId.js +11 -5
- package/dist/endpoints/summary.js +46 -12
- package/dist/endpoints/testVersion.d.ts +2 -0
- package/dist/endpoints/testVersion.js +38 -0
- package/dist/endpoints/transitions.js +41 -29
- package/dist/errors.d.ts +5 -0
- package/dist/errors.js +8 -0
- package/dist/events/request.d.ts +6 -2
- package/dist/events/request.js +35 -8
- package/dist/events/rows.d.ts +1 -1
- package/dist/events/rows.js +24 -8
- package/dist/events/writable.d.ts +9 -0
- package/dist/events/writable.js +13 -0
- package/dist/exports/adminClient.d.ts +1 -1
- package/dist/exports/adminClient.js +1 -1
- package/dist/exports/adminRsc.d.ts +3 -0
- package/dist/exports/adminRsc.js +3 -0
- package/dist/exports/index.d.ts +1 -1
- package/dist/exports/rsc.d.ts +1 -0
- package/dist/exports/rsc.js +1 -0
- package/dist/fields/xpGoal.js +3 -15
- package/dist/goals/fairness.d.ts +1 -1
- package/dist/goals/fairness.js +44 -35
- 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 +6 -2
- package/dist/goals/picker/copy.js +11 -2
- package/dist/goals/picker/useClickGoalPicker.d.ts +1 -1
- package/dist/goals/picker/useClickGoalPicker.js +4 -2
- package/dist/goals/validate.d.ts +3 -0
- package/dist/goals/validate.js +15 -0
- package/dist/hooks/blockRemovalRule.d.ts +30 -0
- package/dist/hooks/blockRemovalRule.js +165 -0
- package/dist/hooks/hostHook.js +6 -2
- package/dist/hooks/pageGuard.d.ts +27 -2
- package/dist/hooks/pageGuard.js +213 -45
- package/dist/hooks/puckGoals.d.ts +5 -0
- package/dist/hooks/puckGoals.js +62 -0
- package/dist/hooks/puckNestedTests.d.ts +8 -0
- package/dist/hooks/puckNestedTests.js +36 -0
- package/dist/hooks/trackPageCopies.d.ts +11 -0
- package/dist/hooks/trackPageCopies.js +7 -0
- package/dist/lib/fetchAllDocs.d.ts +1 -1
- package/dist/lib/placementPages.d.ts +10 -0
- package/dist/{admin/previewLinks.model.js → lib/placementPages.js} +10 -5
- package/dist/manifest/compile.d.ts +2 -1
- package/dist/manifest/compile.js +13 -6
- package/dist/onInit.js +36 -0
- package/dist/options.d.ts +2 -0
- package/dist/options.js +23 -2
- package/dist/plugin.js +19 -20
- package/dist/proxy/pageNavigation.d.ts +4 -0
- package/dist/proxy/pageNavigation.js +28 -0
- package/dist/proxy/resolve.js +52 -25
- package/dist/puck/ExperimentPicker.d.ts +2 -1
- package/dist/puck/ExperimentPicker.js +62 -40
- package/dist/puck/ExperimentSlot.js +3 -1
- package/dist/puck/copy.d.ts +5 -1
- package/dist/puck/copy.js +5 -1
- package/dist/puck/editor/ConfigureTestDrawer.d.ts +25 -0
- package/dist/puck/editor/ConfigureTestDrawer.js +150 -0
- package/dist/puck/editor/CreateExperimentDrawer.d.ts +12 -2
- package/dist/puck/editor/CreateExperimentDrawer.js +89 -21
- package/dist/puck/editor/EditorControls.d.ts +14 -0
- package/dist/puck/editor/EditorControls.js +99 -0
- package/dist/puck/editor/ExperimentSlotEditor.js +951 -179
- package/dist/puck/editor/LeftoverVersions.d.ts +15 -0
- package/dist/puck/editor/LeftoverVersions.js +79 -0
- package/dist/puck/editor/PlacementNotice.d.ts +8 -0
- package/dist/puck/editor/PlacementNotice.js +22 -0
- package/dist/puck/editor/QuickTestActions.d.ts +6 -0
- package/dist/puck/editor/QuickTestActions.js +57 -0
- package/dist/puck/editor/ResultsReadout.d.ts +2 -1
- package/dist/puck/editor/ResultsReadout.js +10 -6
- package/dist/puck/editor/VersionBuilder.d.ts +66 -12
- package/dist/puck/editor/VersionBuilder.js +554 -231
- package/dist/puck/editor/armWrites.d.ts +11 -2
- package/dist/puck/editor/armWrites.js +43 -4
- package/dist/puck/editor/armsCache.d.ts +3 -1
- package/dist/puck/editor/armsCache.js +20 -4
- package/dist/puck/editor/blockClipboard.d.ts +16 -0
- package/dist/puck/editor/blockClipboard.js +20 -0
- package/dist/puck/editor/cloneSlot.d.ts +2 -0
- package/dist/puck/editor/cloneSlot.js +7 -0
- package/dist/puck/editor/copy.d.ts +64 -19
- package/dist/puck/editor/copy.js +72 -20
- package/dist/puck/editor/createTest.d.ts +3 -0
- package/dist/puck/editor/createTest.js +33 -0
- package/dist/puck/editor/editor.chrome.css +191 -19
- package/dist/puck/editor/editor.css +328 -24
- package/dist/puck/editor/editor.model.d.ts +17 -1
- package/dist/puck/editor/editor.model.js +61 -4
- package/dist/puck/editor/editorSurface.d.ts +10 -0
- package/dist/puck/editor/editorSurface.js +65 -0
- package/dist/puck/editor/experimentOutlinePlugin.js +96 -28
- package/dist/puck/editor/localPlacements.d.ts +5 -0
- package/dist/puck/editor/localPlacements.js +43 -0
- package/dist/puck/editor/outlineVersion.d.ts +5 -0
- package/dist/puck/editor/outlineVersion.js +36 -0
- package/dist/puck/editor/placementsCache.d.ts +60 -0
- package/dist/puck/editor/placementsCache.js +263 -0
- package/dist/puck/editor/sidebar.d.ts +8 -0
- package/dist/puck/editor/sidebar.js +74 -0
- package/dist/puck/editor/usePageSaveReadiness.d.ts +6 -0
- package/dist/puck/editor/usePageSaveReadiness.js +31 -0
- package/dist/puck/editor/usePlacementNotice.d.ts +3 -0
- package/dist/puck/editor/usePlacementNotice.js +15 -0
- package/dist/puck/editor/xpGoalPuckEditorField.js +105 -86
- package/dist/puck/experimentSlotField.d.ts +3 -0
- package/dist/puck/experimentSlotField.js +15 -4
- 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 +20 -0
- package/dist/puck/visibility.js +81 -0
- package/dist/results/aggregate.d.ts +6 -3
- package/dist/results/aggregate.js +9 -9
- package/dist/results/health.d.ts +8 -0
- package/dist/results/health.js +28 -0
- package/dist/results/identityCredit.d.ts +1 -0
- package/dist/results/identityCredit.js +4 -1
- package/dist/results/verdict.js +2 -1
- package/dist/runtime/cookie.d.ts +10 -2
- package/dist/runtime/cookie.js +38 -6
- package/dist/runtime/cookieOptions.d.ts +6 -0
- package/dist/runtime/cookieOptions.js +14 -0
- package/dist/runtime/proxyRuntime.d.ts +1 -0
- package/dist/runtime/proxyRuntime.js +18 -8
- package/dist/runtime/signing.d.ts +1 -0
- package/dist/runtime/signing.js +5 -0
- package/dist/sanitizeReadinessDetail.d.ts +2 -2
- package/dist/sanitizeReadinessDetail.js +22 -2
- package/dist/server/getAssignments.js +11 -10
- package/dist/server/recordContentChange.d.ts +1 -1
- package/dist/server/recordContentChange.js +48 -22
- package/dist/server/resolveExperimentBlocks.js +2 -4
- package/dist/server/resolveExperimentData.js +8 -8
- package/dist/server/runResults.js +52 -14
- package/dist/server/startExperiment.d.ts +20 -0
- package/dist/server/startExperiment.js +70 -0
- package/dist/server/trackConversion.js +10 -13
- package/dist/{admin → testSurface}/PreviewLinks.js +6 -2
- package/dist/testSurface/actions/DecideDialog.d.ts +16 -0
- package/dist/{admin → testSurface}/actions/DecideDialog.js +78 -55
- package/dist/testSurface/actions/LifecycleAction.d.ts +16 -0
- package/dist/testSurface/actions/LifecycleAction.js +105 -0
- package/dist/{admin → testSurface}/actions/MakeContentResult.d.ts +4 -3
- package/dist/{admin → testSurface}/actions/MakeContentResult.js +10 -2
- package/dist/{admin → testSurface}/actions/actions.model.d.ts +13 -5
- package/dist/testSurface/actions/actions.model.js +122 -0
- package/dist/{admin → testSurface}/api.d.ts +20 -7
- package/dist/{admin → testSurface}/api.js +72 -22
- package/dist/testSurface/contentLocaleURL.d.ts +2 -0
- package/dist/testSurface/contentLocaleURL.js +3 -0
- package/dist/{admin → testSurface}/copy/actions.d.ts +28 -8
- package/dist/{admin → testSurface}/copy/actions.js +31 -11
- package/dist/{admin → testSurface}/copy/common.d.ts +13 -4
- package/dist/{admin → testSurface}/copy/common.js +18 -8
- package/dist/testSurface/copy/languages.d.ts +12 -0
- package/dist/testSurface/copy/languages.js +8 -0
- package/dist/{admin → testSurface}/copy/metrics.d.ts +1 -0
- package/dist/{admin → testSurface}/copy/metrics.js +1 -0
- package/dist/testSurface/copy/pages.d.ts +84 -0
- package/dist/testSurface/copy/pages.js +90 -0
- package/dist/{admin → testSurface}/copy/readiness.d.ts +38 -4
- package/dist/{admin → testSurface}/copy/readiness.js +52 -7
- package/dist/{admin → testSurface}/copy/results.d.ts +6 -3
- package/dist/{admin → testSurface}/copy/results.js +6 -3
- package/dist/{admin → testSurface}/copy/review.d.ts +1 -1
- package/dist/{admin → testSurface}/copy/review.js +1 -1
- package/dist/{admin → testSurface}/copy/surface.d.ts +11 -2
- package/dist/{admin → testSurface}/copy/surface.js +13 -10
- package/dist/{admin → testSurface}/copy/testPage.d.ts +53 -8
- package/dist/testSurface/copy/testPage.js +165 -0
- package/dist/testSurface/format/adminURL.d.ts +7 -0
- package/dist/testSurface/format/adminURL.js +9 -0
- package/dist/testSurface/placementLabel.d.ts +8 -0
- package/dist/testSurface/placementLabel.js +24 -0
- package/dist/{admin → testSurface}/placements/placementLabels.d.ts +2 -0
- package/dist/{admin → testSurface}/placements/placementLabels.js +3 -2
- package/dist/{admin → testSurface}/previewLinks.model.d.ts +1 -6
- package/dist/testSurface/previewLinks.model.js +4 -0
- package/dist/testSurface/readPreflight.d.ts +13 -0
- package/dist/testSurface/readPreflight.js +44 -0
- package/dist/testSurface/readinessRead.d.ts +53 -0
- package/dist/testSurface/readinessRead.js +50 -0
- package/dist/{admin → testSurface}/results/VerdictHero.d.ts +2 -1
- package/dist/{admin → testSurface}/results/VerdictHero.js +5 -1
- package/dist/testSurface/results/results.css +64 -0
- package/dist/{admin → testSurface}/results/results.model.js +6 -2
- package/dist/{admin → testSurface}/surface/contracts.d.ts +17 -3
- package/dist/testSurface/surface/editorPlacement.d.ts +26 -0
- package/dist/testSurface/surface/editorPlacement.js +78 -0
- package/dist/testSurface/surface/pageBlock/pageBlock.model.js +9 -0
- package/dist/{admin → testSurface}/surface/pageBlock/parts.js +39 -11
- package/dist/testSurface/surface/pagePicker/CopyRoute.d.ts +13 -0
- package/dist/testSurface/surface/pagePicker/CopyRoute.js +273 -0
- package/dist/testSurface/surface/pagePicker/PageCombobox.d.ts +21 -0
- package/dist/testSurface/surface/pagePicker/PageCombobox.js +503 -0
- package/dist/testSurface/surface/pagePicker/pagePicker.css +73 -0
- package/dist/{admin → testSurface}/surface/pagePicker/pagePicker.model.d.ts +7 -3
- package/dist/{admin → testSurface}/surface/pagePicker/pagePicker.model.js +17 -2
- package/dist/{admin → testSurface}/surface/readiness/ActionDialogs.d.ts +8 -4
- package/dist/testSurface/surface/readiness/ActionDialogs.js +351 -0
- package/dist/{admin → testSurface}/surface/readiness/Banner.d.ts +2 -3
- package/dist/testSurface/surface/readiness/Banner.js +187 -0
- package/dist/testSurface/surface/readiness/BlockerList.d.ts +11 -0
- package/dist/testSurface/surface/readiness/BlockerList.js +31 -0
- package/dist/testSurface/surface/readiness/SaveStatus.d.ts +10 -0
- package/dist/testSurface/surface/readiness/SaveStatus.js +66 -0
- package/dist/{admin → testSurface}/surface/readiness/parts.js +0 -2
- package/dist/{admin → testSurface}/surface/readiness/readiness.model.d.ts +28 -2
- package/dist/testSurface/surface/readiness/readiness.model.js +377 -0
- package/dist/testSurface/surface/readiness/useTransition.d.ts +16 -0
- package/dist/testSurface/surface/readiness/useTransition.js +141 -0
- package/dist/{admin → testSurface}/surface/results/ReleasePages.d.ts +6 -3
- package/dist/{admin → testSurface}/surface/results/ReleasePages.js +40 -40
- package/dist/{admin → testSurface}/surface/results/ResultsBody.d.ts +7 -3
- package/dist/{admin → testSurface}/surface/results/ResultsBody.js +108 -44
- package/dist/{admin → testSurface}/surface/results/useResults.d.ts +26 -8
- package/dist/{admin → testSurface}/surface/results/useResults.js +3 -2
- package/dist/{admin → testSurface}/surface/setting/parts.js +58 -18
- package/dist/testSurface/surface/setting/setting.css +17 -0
- package/dist/{admin → testSurface}/surface/test/AdvancedSection.js +2 -0
- package/dist/testSurface/surface/test/DeleteTest.d.ts +23 -0
- package/dist/testSurface/surface/test/DeleteTest.js +270 -0
- package/dist/testSurface/surface/test/GoalSection.d.ts +4 -0
- package/dist/{admin → testSurface}/surface/test/GoalSection.js +116 -86
- package/dist/testSurface/surface/test/LengthSection.d.ts +2 -0
- package/dist/{admin → testSurface}/surface/test/LengthSection.js +5 -1
- package/dist/{admin → testSurface}/surface/test/PageHoldout.js +4 -1
- package/dist/{admin → testSurface}/surface/test/Rail.js +7 -4
- package/dist/{admin → testSurface}/surface/test/ReadinessBar.d.ts +1 -0
- package/dist/{admin → testSurface}/surface/test/ReadinessBar.js +2 -3
- package/dist/{admin → testSurface}/surface/test/Section.d.ts +3 -1
- package/dist/testSurface/surface/test/Section.js +80 -0
- package/dist/{admin → testSurface}/surface/test/TargetingSection.js +82 -12
- package/dist/testSurface/surface/test/TestSurface.d.ts +19 -0
- package/dist/testSurface/surface/test/TestSurface.js +265 -0
- package/dist/testSurface/surface/test/VersionsSection.d.ts +5 -0
- package/dist/{admin → testSurface}/surface/test/VersionsSection.js +69 -35
- package/dist/{admin → testSurface}/surface/test/fields.d.ts +30 -7
- package/dist/testSurface/surface/test/fields.js +306 -0
- package/dist/{admin → testSurface}/surface/test/pageParts.js +27 -43
- package/dist/testSurface/surface/test/testPage.css +103 -0
- package/dist/{admin → testSurface}/surface/test/testPage.model.d.ts +1 -0
- package/dist/{admin → testSurface}/surface/test/testPage.model.js +6 -0
- package/dist/{admin → testSurface}/surface/testDocument.model.d.ts +3 -0
- package/dist/{admin → testSurface}/surface/testDocument.model.js +4 -1
- package/dist/testSurface/surface/useTestDocument.d.ts +60 -0
- package/dist/testSurface/surface/useTestDocument.js +782 -0
- package/dist/testSurface/surface/watchTestDocument.d.ts +15 -0
- package/dist/testSurface/surface/watchTestDocument.js +181 -0
- package/dist/testSurface/surfaceUrls.d.ts +7 -0
- package/dist/testSurface/surfaceUrls.js +19 -0
- package/dist/{admin → testSurface}/useApi.d.ts +21 -5
- package/dist/testSurface/useOnTestReturn.d.ts +2 -0
- package/dist/testSurface/useOnTestReturn.js +27 -0
- package/dist/testSurface/useReadinessPolling.d.ts +3 -0
- package/dist/testSurface/useReadinessPolling.js +26 -0
- package/dist/transitions/addMetric.d.ts +2 -5
- package/dist/transitions/addMetric.js +5 -1
- package/dist/transitions/allocate.d.ts +2 -2
- package/dist/transitions/allocate.js +3 -1
- package/dist/transitions/archive.d.ts +1 -1
- package/dist/transitions/archive.js +3 -2
- package/dist/transitions/checkStart.d.ts +6 -1
- package/dist/transitions/checkStart.js +133 -17
- package/dist/transitions/contentFields.js +9 -5
- package/dist/transitions/decide.d.ts +1 -1
- package/dist/transitions/decide.js +6 -3
- package/dist/transitions/deleteExperiment.d.ts +2 -2
- package/dist/transitions/deleteExperiment.js +17 -7
- package/dist/transitions/kernel.d.ts +4 -0
- package/dist/transitions/kernel.js +9 -4
- package/dist/transitions/makeContent.d.ts +2 -1
- package/dist/transitions/makeContent.js +41 -17
- package/dist/transitions/nestedPlacementNames.d.ts +5 -0
- package/dist/transitions/nestedPlacementNames.js +32 -0
- package/dist/transitions/pageAddress.d.ts +6 -0
- package/dist/transitions/pageAddress.js +71 -0
- package/dist/transitions/pageVersions.js +3 -1
- package/dist/transitions/phaseRecord.d.ts +2 -0
- package/dist/transitions/phaseRecord.js +5 -0
- package/dist/transitions/placementInteractions.d.ts +3 -3
- package/dist/transitions/placementInteractions.js +16 -12
- package/dist/transitions/placements.d.ts +54 -8
- package/dist/transitions/placements.js +304 -81
- package/dist/transitions/preflightData.d.ts +5 -3
- package/dist/transitions/preflightData.js +137 -40
- package/dist/transitions/releaseHoldout.d.ts +2 -1
- package/dist/transitions/releaseHoldout.js +3 -1
- package/dist/transitions/releasePages.d.ts +2 -1
- package/dist/transitions/releasePages.js +3 -1
- package/dist/transitions/resolveCaps.d.ts +2 -4
- package/dist/transitions/start.d.ts +6 -8
- package/dist/transitions/start.js +72 -35
- package/dist/transitions/startReads.d.ts +7 -0
- package/dist/transitions/startReads.js +28 -0
- package/dist/transitions/stop.d.ts +2 -1
- package/dist/transitions/stop.js +3 -2
- package/dist/types/contracts.d.ts +15 -3
- package/dist/types/endpoints.d.ts +121 -17
- package/dist/types/puck.d.ts +1 -0
- package/dist/types/runtime.d.ts +15 -9
- package/dist/types/snapshot.d.ts +2 -0
- package/dist/types/surface.d.ts +9 -9
- package/dist/ui/Button.js +2 -2
- package/dist/ui/Card.d.ts +2 -1
- package/dist/ui/Card.js +4 -4
- package/dist/ui/ChipsInput.d.ts +8 -1
- package/dist/ui/ChipsInput.js +17 -4
- package/dist/ui/Dialog.d.ts +24 -2
- package/dist/ui/Dialog.js +116 -6
- package/dist/ui/Drawer.d.ts +10 -0
- package/dist/ui/Drawer.js +29 -0
- package/dist/ui/Inputs.d.ts +4 -3
- package/dist/ui/Inputs.js +7 -4
- package/dist/ui/SelectControl.d.ts +33 -0
- package/dist/ui/SelectControl.js +504 -0
- package/dist/ui/Tabs.d.ts +4 -4
- package/dist/ui/Tabs.js +35 -32
- package/dist/ui/ui.css +49 -5
- package/package.json +3 -2
- package/dist/admin/actions/ConfirmDialog.d.ts +0 -19
- package/dist/admin/actions/ConfirmDialog.js +0 -149
- package/dist/admin/actions/DecideDialog.d.ts +0 -10
- package/dist/admin/actions/actions.model.js +0 -70
- package/dist/admin/copy/pages.d.ts +0 -26
- package/dist/admin/copy/pages.js +0 -26
- package/dist/admin/copy/testPage.js +0 -104
- 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/pageBlock/pageBlock.model.js +0 -8
- package/dist/admin/surface/pagePicker/CopyRoute.d.ts +0 -6
- package/dist/admin/surface/pagePicker/CopyRoute.js +0 -53
- package/dist/admin/surface/pagePicker/PagePicker.d.ts +0 -10
- package/dist/admin/surface/pagePicker/PagePicker.js +0 -172
- package/dist/admin/surface/readiness/ActionDialogs.js +0 -337
- package/dist/admin/surface/readiness/Banner.js +0 -190
- package/dist/admin/surface/readiness/SaveStatus.d.ts +0 -5
- package/dist/admin/surface/readiness/SaveStatus.js +0 -53
- package/dist/admin/surface/readiness/readiness.model.js +0 -205
- package/dist/admin/surface/readiness/useTransition.d.ts +0 -11
- package/dist/admin/surface/readiness/useTransition.js +0 -35
- package/dist/admin/surface/setting/setting.css +0 -17
- package/dist/admin/surface/test/GoalSection.d.ts +0 -2
- package/dist/admin/surface/test/LengthSection.d.ts +0 -2
- package/dist/admin/surface/test/Section.js +0 -47
- package/dist/admin/surface/test/VersionsSection.d.ts +0 -4
- package/dist/admin/surface/test/fields.js +0 -216
- package/dist/admin/surface/test/testPage.css +0 -97
- package/dist/admin/surface/useTestDocument.d.ts +0 -32
- package/dist/admin/surface/useTestDocument.js +0 -415
- /package/dist/{admin → testSurface}/PreviewLinks.d.ts +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}/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/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/recommendation.d.ts +0 -0
- /package/dist/{admin → testSurface}/copy/recommendation.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}/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.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/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/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/parts.d.ts +0 -0
- /package/dist/{admin → testSurface}/surface/readiness/parts.d.ts +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/setting/parts.d.ts +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/PageHoldout.d.ts +0 -0
- /package/dist/{admin → testSurface}/surface/test/Rail.d.ts +0 -0
- /package/dist/{admin → testSurface}/surface/test/TargetingSection.d.ts +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}/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.js +0 -0
package/dist/puck/copy.js
CHANGED
|
@@ -9,10 +9,14 @@ export const slotLabels = {
|
|
|
9
9
|
export const pickerCopy = {
|
|
10
10
|
label: 'Test',
|
|
11
11
|
none: 'No test',
|
|
12
|
+
choose: 'Choose a test',
|
|
12
13
|
search: 'Search tests',
|
|
13
14
|
loading: 'Loading tests…',
|
|
14
15
|
error: "Couldn't load tests.",
|
|
15
|
-
forbidden: "You
|
|
16
|
+
forbidden: "You don't have access to this test. You can still edit its content.",
|
|
17
|
+
forbiddenUnbound: "You don't have access to tests.",
|
|
18
|
+
unavailable: "This test isn't available to you. You can still edit its content.",
|
|
19
|
+
resultsOnly: "You can view this test's results.",
|
|
16
20
|
statuses: {
|
|
17
21
|
draft: 'Draft',
|
|
18
22
|
running: 'Running',
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import type { DocId } from '../../types/contracts.js';
|
|
2
|
+
import type { resolvePuckRoutes } from '../routes.js';
|
|
3
|
+
import './editor.css';
|
|
4
|
+
type ConfigureRoutes = ReturnType<typeof resolvePuckRoutes> & {
|
|
5
|
+
contentLocale?: string;
|
|
6
|
+
};
|
|
7
|
+
export declare function ConfigureTestDrawer({ id, routes, onClose }: {
|
|
8
|
+
id: DocId;
|
|
9
|
+
routes: ConfigureRoutes;
|
|
10
|
+
onClose: () => void;
|
|
11
|
+
}): import("react").JSX.Element;
|
|
12
|
+
/** Separate document root, like the creation dialog: Puck has no ancestor handlers here. */
|
|
13
|
+
export declare function openConfigureTestDrawer(source: HTMLElement, routes: ConfigureRoutes, id: DocId): {
|
|
14
|
+
close: () => void;
|
|
15
|
+
};
|
|
16
|
+
/** The canvas already has current permissions; use them without a second read. */
|
|
17
|
+
export declare function ConfigureTestControl({ id, routes }: {
|
|
18
|
+
id: DocId;
|
|
19
|
+
routes: ConfigureRoutes;
|
|
20
|
+
}): import("react").JSX.Element;
|
|
21
|
+
export declare function ConfigureTestButton({ id, routes }: {
|
|
22
|
+
id: DocId;
|
|
23
|
+
routes: ConfigureRoutes;
|
|
24
|
+
}): import("react").JSX.Element | null;
|
|
25
|
+
export {};
|
|
@@ -0,0 +1,150 @@
|
|
|
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 { readEditorPreflight } 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: {
|
|
67
|
+
...state.surface,
|
|
68
|
+
contentLocale: routes.contentLocale
|
|
69
|
+
},
|
|
70
|
+
embedded: true,
|
|
71
|
+
onTitleChange: setTitle,
|
|
72
|
+
onDocument: (doc)=>publishExperiment(id, doc),
|
|
73
|
+
requestPreflight: (signal, supersede)=>readEditorPreflight(routes.api, id, signal, supersede, routes.contentLocale)
|
|
74
|
+
}) : /*#__PURE__*/ _jsxs("div", {
|
|
75
|
+
role: state.error ? 'alert' : 'status',
|
|
76
|
+
children: [
|
|
77
|
+
/*#__PURE__*/ _jsx("p", {
|
|
78
|
+
children: state.error === 'forbidden' ? TEST_PAGE.forbidden : state.error ? C.setupUnavailable : TEST_PAGE.loading
|
|
79
|
+
}),
|
|
80
|
+
state.error === 'unavailable' ? /*#__PURE__*/ _jsx(Button, {
|
|
81
|
+
onClick: ()=>setAttempt((value)=>value + 1),
|
|
82
|
+
children: C.retrySetup
|
|
83
|
+
}) : null
|
|
84
|
+
]
|
|
85
|
+
})
|
|
86
|
+
})
|
|
87
|
+
});
|
|
88
|
+
}
|
|
89
|
+
/** Separate document root, like the creation dialog: Puck has no ancestor handlers here. */ export function openConfigureTestDrawer(source, routes, id) {
|
|
90
|
+
// A canvas iframe's modal would cover only the canvas. Mount over the whole editor.
|
|
91
|
+
const doc = source.ownerDocument.defaultView?.frameElement?.ownerDocument ?? source.ownerDocument;
|
|
92
|
+
const container = doc.createElement('div');
|
|
93
|
+
container.className = 'xp-slot-root xp-slot-editor xp-configure-host';
|
|
94
|
+
const themeSource = source.closest('.xp-slot-root') ?? source;
|
|
95
|
+
container.style.cssText = themeSource.style.cssText;
|
|
96
|
+
if (source.closest('[data-theme="dark"], .dark')) container.dataset.theme = 'dark';
|
|
97
|
+
doc.body.append(container);
|
|
98
|
+
const release = registerOverlayPortal(container, {
|
|
99
|
+
disableDrag: true
|
|
100
|
+
});
|
|
101
|
+
const root = createRoot(container);
|
|
102
|
+
let closed = false;
|
|
103
|
+
const close = ()=>{
|
|
104
|
+
if (closed) return;
|
|
105
|
+
closed = true;
|
|
106
|
+
queueMicrotask(()=>{
|
|
107
|
+
root.unmount();
|
|
108
|
+
release?.();
|
|
109
|
+
container.remove();
|
|
110
|
+
if (source.isConnected) source.focus();
|
|
111
|
+
});
|
|
112
|
+
};
|
|
113
|
+
root.render(/*#__PURE__*/ _jsx("div", {
|
|
114
|
+
onClick: (event)=>event.stopPropagation(),
|
|
115
|
+
onKeyDown: (event)=>event.stopPropagation(),
|
|
116
|
+
onPointerMove: (event)=>event.stopPropagation(),
|
|
117
|
+
onPointerUp: (event)=>event.stopPropagation(),
|
|
118
|
+
children: /*#__PURE__*/ _jsx(ConfigureTestDrawer, {
|
|
119
|
+
id: id,
|
|
120
|
+
routes: routes,
|
|
121
|
+
onClose: close
|
|
122
|
+
})
|
|
123
|
+
}));
|
|
124
|
+
return {
|
|
125
|
+
close
|
|
126
|
+
};
|
|
127
|
+
}
|
|
128
|
+
/** The canvas already has current permissions; use them without a second read. */ export function ConfigureTestControl({ id, routes }) {
|
|
129
|
+
const drawer = useRef(undefined);
|
|
130
|
+
useEffect(()=>()=>drawer.current?.close(), [
|
|
131
|
+
id,
|
|
132
|
+
routes.api
|
|
133
|
+
]);
|
|
134
|
+
return /*#__PURE__*/ _jsx(Button, {
|
|
135
|
+
variant: "primary",
|
|
136
|
+
onClick: (event)=>{
|
|
137
|
+
drawer.current?.close();
|
|
138
|
+
drawer.current = openConfigureTestDrawer(event.currentTarget, routes, id);
|
|
139
|
+
},
|
|
140
|
+
children: C.configure
|
|
141
|
+
});
|
|
142
|
+
}
|
|
143
|
+
export function ConfigureTestButton({ id, routes }) {
|
|
144
|
+
const access = useEditorSurface(routes.api);
|
|
145
|
+
if (!access.surface || !access.surface.canManage && !access.surface.canReadResults) return null;
|
|
146
|
+
return /*#__PURE__*/ _jsx(ConfigureTestControl, {
|
|
147
|
+
id: id,
|
|
148
|
+
routes: routes
|
|
149
|
+
});
|
|
150
|
+
}
|
|
@@ -1,7 +1,17 @@
|
|
|
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, created }: {
|
|
6
|
+
created?: ExperimentRef;
|
|
4
7
|
initialName?: string;
|
|
5
|
-
|
|
8
|
+
arms?: Arm[] | (() => Promise<Arm[]>);
|
|
9
|
+
label?: string;
|
|
10
|
+
onPendingChange?: (pending: boolean) => void;
|
|
11
|
+
onCreate: (experiment: ExperimentRef) => boolean;
|
|
6
12
|
onClose: () => void;
|
|
7
13
|
}): import("react").JSX.Element;
|
|
14
|
+
/** The dialog belongs to the document so deleting its block during POST cannot hide the created test. */
|
|
15
|
+
export declare function openCreateExperimentDrawer(source: HTMLElement, routes: ReturnType<typeof resolvePuckRoutes>, props: Omit<Parameters<typeof CreateExperimentDrawer>[0], 'onClose' | 'onPendingChange'>): {
|
|
16
|
+
closeIfIdle: () => void;
|
|
17
|
+
};
|
|
@@ -1,71 +1,99 @@
|
|
|
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 { useId, useRef, useState } from 'react';
|
|
4
4
|
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.createAnother, onPendingChange, created }) {
|
|
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(created);
|
|
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: [
|
|
47
|
-
/*#__PURE__*/
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
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,
|
|
67
|
+
!unbound ? /*#__PURE__*/ _jsxs(_Fragment, {
|
|
68
|
+
children: [
|
|
69
|
+
/*#__PURE__*/ _jsx(TextInput, {
|
|
70
|
+
id: nameId,
|
|
71
|
+
label: editorCopy.name,
|
|
72
|
+
value: name,
|
|
73
|
+
disabled: pending,
|
|
74
|
+
onChange: (event)=>setName(event.currentTarget.value)
|
|
75
|
+
}),
|
|
76
|
+
error ? /*#__PURE__*/ _jsx(Banner, {
|
|
77
|
+
tone: "error",
|
|
78
|
+
children: error
|
|
79
|
+
}) : null,
|
|
80
|
+
!name.trim() ? /*#__PURE__*/ _jsx("p", {
|
|
81
|
+
className: "xp-ui-help",
|
|
82
|
+
children: editorCopy.enterName
|
|
83
|
+
}) : null
|
|
84
|
+
]
|
|
57
85
|
}) : null,
|
|
58
86
|
/*#__PURE__*/ _jsxs("div", {
|
|
59
87
|
className: "xp-ui-button-group",
|
|
60
88
|
children: [
|
|
61
|
-
/*#__PURE__*/ _jsx(Button, {
|
|
89
|
+
!unbound ? /*#__PURE__*/ _jsx(Button, {
|
|
62
90
|
variant: "primary",
|
|
63
91
|
disabled: pending || !name.trim(),
|
|
64
92
|
onClick: ()=>{
|
|
65
93
|
void submitNew();
|
|
66
94
|
},
|
|
67
|
-
children: pending ? editorCopy.creating :
|
|
68
|
-
}),
|
|
95
|
+
children: pending ? editorCopy.creating : label
|
|
96
|
+
}) : null,
|
|
69
97
|
/*#__PURE__*/ _jsx(Button, {
|
|
70
98
|
disabled: pending,
|
|
71
99
|
onClick: onClose,
|
|
@@ -77,3 +105,43 @@ export function CreateExperimentDrawer({ onCreate, onClose, initialName = '' })
|
|
|
77
105
|
})
|
|
78
106
|
});
|
|
79
107
|
}
|
|
108
|
+
/** The dialog belongs to the document so deleting its block during POST cannot hide the created test. */ export function openCreateExperimentDrawer(source, routes, props) {
|
|
109
|
+
const container = source.ownerDocument.createElement('div');
|
|
110
|
+
container.className = 'xp-slot-dialog-host';
|
|
111
|
+
const tokenRoot = source.ownerDocument.createElement('div');
|
|
112
|
+
tokenRoot.className = 'xp-slot-root xp-slot-editor';
|
|
113
|
+
tokenRoot.style.cssText = source.style.cssText;
|
|
114
|
+
container.append(tokenRoot);
|
|
115
|
+
if (source.closest('[data-theme="dark"], .dark')) container.dataset.theme = 'dark';
|
|
116
|
+
source.ownerDocument.body.append(container);
|
|
117
|
+
const root = createRoot(tokenRoot);
|
|
118
|
+
let pending = false, closed = false;
|
|
119
|
+
const close = ()=>{
|
|
120
|
+
if (closed) return;
|
|
121
|
+
closed = true;
|
|
122
|
+
// Cleanup can originate from the creator's unmount commit.
|
|
123
|
+
queueMicrotask(()=>{
|
|
124
|
+
root.unmount();
|
|
125
|
+
container.remove();
|
|
126
|
+
});
|
|
127
|
+
};
|
|
128
|
+
root.render(/*#__PURE__*/ _jsx(PuckHostProvider, {
|
|
129
|
+
routes: routes,
|
|
130
|
+
children: /*#__PURE__*/ _jsx("div", {
|
|
131
|
+
onClick: (event)=>event.stopPropagation(),
|
|
132
|
+
onKeyDown: (event)=>event.stopPropagation(),
|
|
133
|
+
children: /*#__PURE__*/ _jsx(CreateExperimentDrawer, {
|
|
134
|
+
...props,
|
|
135
|
+
onPendingChange: (value)=>{
|
|
136
|
+
pending = value;
|
|
137
|
+
},
|
|
138
|
+
onClose: close
|
|
139
|
+
})
|
|
140
|
+
})
|
|
141
|
+
}));
|
|
142
|
+
return {
|
|
143
|
+
closeIfIdle: ()=>{
|
|
144
|
+
if (!pending) close();
|
|
145
|
+
}
|
|
146
|
+
};
|
|
147
|
+
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { type ReactNode } from 'react';
|
|
2
|
+
export declare const CONTROL_SELECTOR = "button, a, summary, 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, summary, 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
|
+
}
|