@delmaredigital/payload-experiments 0.4.0-rc.3 → 0.4.0-rc.5
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 +6 -13
- 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 +23 -25
- package/dist/admin/surface/results/ResultsHeader.d.ts +2 -2
- package/dist/admin/surface/results/ResultsHeader.js +22 -15
- 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/fairness.d.ts +1 -1
- package/dist/goals/fairness.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 +73 -9
- package/dist/puck/editor/EditorControls.d.ts +14 -0
- package/dist/puck/editor/EditorControls.js +99 -0
- package/dist/puck/editor/ExperimentSlotEditor.js +690 -79
- package/dist/puck/editor/LeftoverVersions.d.ts +13 -0
- package/dist/puck/editor/LeftoverVersions.js +115 -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 +3 -0
- package/dist/puck/editor/QuickTestActions.js +50 -0
- package/dist/puck/editor/ResultsReadout.js +8 -5
- package/dist/puck/editor/VersionBuilder.d.ts +20 -6
- package/dist/puck/editor/VersionBuilder.js +80 -50
- package/dist/puck/editor/armWrites.d.ts +3 -1
- package/dist/puck/editor/armWrites.js +2 -1
- package/dist/puck/editor/armsCache.d.ts +3 -1
- package/dist/puck/editor/armsCache.js +20 -3
- package/dist/puck/editor/cloneSlot.d.ts +2 -0
- package/dist/puck/editor/cloneSlot.js +7 -0
- package/dist/puck/editor/copy.d.ts +42 -5
- package/dist/puck/editor/copy.js +43 -6
- package/dist/puck/editor/editor.chrome.css +44 -0
- package/dist/puck/editor/editor.css +68 -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/experimentOutlinePlugin.js +96 -28
- package/dist/puck/editor/localPlacements.d.ts +2 -0
- package/dist/puck/editor/localPlacements.js +29 -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 +50 -0
- package/dist/puck/editor/placementsCache.js +258 -0
- package/dist/puck/editor/sidebar.d.ts +12 -0
- package/dist/puck/editor/sidebar.js +77 -0
- package/dist/puck/editor/usePlacementNotice.d.ts +3 -0
- package/dist/puck/editor/usePlacementNotice.js +14 -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 +5 -6
- package/dist/{admin → testSurface}/copy/common.d.ts +3 -1
- package/dist/{admin → testSurface}/copy/common.js +5 -1
- package/dist/{admin → testSurface}/copy/readiness.d.ts +20 -1
- package/dist/{admin → testSurface}/copy/readiness.js +25 -1
- package/dist/{admin → testSurface}/copy/testPage.d.ts +4 -0
- package/dist/{admin → testSurface}/copy/testPage.js +8 -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/readPreflight.d.ts +9 -0
- package/dist/testSurface/readPreflight.js +38 -0
- package/dist/testSurface/readinessRead.d.ts +50 -0
- package/dist/testSurface/readinessRead.js +46 -0
- package/dist/testSurface/results/results.css +64 -0
- package/dist/{admin → testSurface}/surface/contracts.d.ts +7 -2
- package/dist/testSurface/surface/editorPlacement.d.ts +21 -0
- package/dist/testSurface/surface/editorPlacement.js +60 -0
- package/dist/{admin → testSurface}/surface/pageBlock/parts.js +19 -9
- package/dist/testSurface/surface/pagePicker/pagePicker.css +10 -0
- package/dist/{admin → testSurface}/surface/readiness/ActionDialogs.js +37 -7
- package/dist/testSurface/surface/readiness/Banner.d.ts +2 -0
- package/dist/{admin → testSurface}/surface/readiness/Banner.js +106 -68
- 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 +9 -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 +13 -0
- package/dist/{admin → testSurface}/surface/readiness/readiness.model.js +51 -36
- package/dist/{admin → testSurface}/surface/readiness/useTransition.d.ts +5 -2
- package/dist/testSurface/surface/readiness/useTransition.js +98 -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/{admin → testSurface}/surface/test/AdvancedSection.js +1 -0
- package/dist/testSurface/surface/test/GoalSection.d.ts +4 -0
- package/dist/{admin → testSurface}/surface/test/GoalSection.js +4 -2
- package/dist/testSurface/surface/test/LengthSection.d.ts +2 -0
- package/dist/{admin → testSurface}/surface/test/LengthSection.js +2 -1
- package/dist/{admin → testSurface}/surface/test/Rail.js +7 -4
- package/dist/{admin → testSurface}/surface/test/ReadinessBar.js +1 -2
- 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 +5 -0
- package/dist/testSurface/surface/test/TestSurface.d.ts +19 -0
- package/dist/testSurface/surface/test/TestSurface.js +213 -0
- package/dist/testSurface/surface/test/VersionsSection.d.ts +5 -0
- package/dist/{admin → testSurface}/surface/test/VersionsSection.js +13 -6
- package/dist/testSurface/surface/test/testPage.css +104 -0
- package/dist/{admin → testSurface}/surface/useTestDocument.d.ts +9 -2
- package/dist/{admin → testSurface}/surface/useTestDocument.js +92 -46
- package/dist/{admin → testSurface}/surfaceUrls.js +1 -1
- package/dist/testSurface/useReadinessPolling.d.ts +3 -0
- package/dist/testSurface/useReadinessPolling.js +24 -0
- 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/preflightData.js +1 -1
- package/dist/transitions/start.js +2 -2
- package/dist/types/endpoints.d.ts +1 -1
- package/dist/ui/Card.d.ts +2 -1
- package/dist/ui/Card.js +4 -4
- 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 +4 -3
- package/dist/ui/Tabs.js +47 -32
- package/dist/ui/ui.css +24 -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/readiness/Banner.d.ts +0 -5
- package/dist/admin/surface/readiness/SaveStatus.d.ts +0 -5
- package/dist/admin/surface/readiness/SaveStatus.js +0 -53
- 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 -48
- 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/parts.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/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/ReadinessBar.d.ts +0 -0
- /package/dist/{admin → testSurface}/surface/test/TargetingSection.d.ts +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,13 @@
|
|
|
1
|
+
import type { ArmSlot } from '../../types/puck.js';
|
|
2
|
+
import type { EditorExperiment } from './editor.model.js';
|
|
3
|
+
import type { ArmWrites } from './VersionBuilder.js';
|
|
4
|
+
/** Page content stays editable even when it does not belong to the selected test. */
|
|
5
|
+
export declare function LeftoverVersions({ slots, experiment, writes, canManage, countBlocks, onDelete, onSelect }: {
|
|
6
|
+
slots: ArmSlot[];
|
|
7
|
+
experiment: EditorExperiment;
|
|
8
|
+
writes: ArmWrites;
|
|
9
|
+
canManage: boolean;
|
|
10
|
+
countBlocks: (slot: ArmSlot) => number;
|
|
11
|
+
onDelete: (slot: ArmSlot) => void;
|
|
12
|
+
onSelect: (slot: ArmSlot) => void;
|
|
13
|
+
}): import("react").JSX.Element;
|
|
@@ -0,0 +1,115 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
3
|
+
import { useState } from 'react';
|
|
4
|
+
import { Button } from '../../ui/Button.js';
|
|
5
|
+
import { Dialog } from '../../ui/Dialog.js';
|
|
6
|
+
import { slotLabels } from '../copy.js';
|
|
7
|
+
import { editorCopy as C } from './copy.js';
|
|
8
|
+
import { tabsFor } from './editor.model.js';
|
|
9
|
+
/** Page content stays editable even when it does not belong to the selected test. */ export function LeftoverVersions({ slots, experiment, writes, canManage, countBlocks, onDelete, onSelect }) {
|
|
10
|
+
const [deleting, setDeleting] = useState(null);
|
|
11
|
+
const versions = new Intl.ListFormat('en', {
|
|
12
|
+
style: 'long',
|
|
13
|
+
type: 'conjunction'
|
|
14
|
+
}).format(tabsFor(experiment).map((tab)=>tab.label));
|
|
15
|
+
const notice = (slot)=>/*#__PURE__*/ _jsxs("div", {
|
|
16
|
+
children: [
|
|
17
|
+
/*#__PURE__*/ _jsx("p", {
|
|
18
|
+
children: C.orphan(slotLabels[slot], versions)
|
|
19
|
+
}),
|
|
20
|
+
/*#__PURE__*/ _jsxs("div", {
|
|
21
|
+
className: "xp-ui-button-group",
|
|
22
|
+
children: [
|
|
23
|
+
canManage && experiment.status === 'draft' ? /*#__PURE__*/ _jsx(Button, {
|
|
24
|
+
disabled: writes.busy,
|
|
25
|
+
onClick: async ()=>{
|
|
26
|
+
const saved = await writes.write((arms)=>{
|
|
27
|
+
if (arms.some((arm)=>arm.key === slot)) return arms;
|
|
28
|
+
const next = [
|
|
29
|
+
...arms
|
|
30
|
+
];
|
|
31
|
+
const holdout = next.findIndex((arm)=>arm.kind === 'holdout');
|
|
32
|
+
next.splice(holdout < 0 ? next.length : holdout, 0, {
|
|
33
|
+
key: slot,
|
|
34
|
+
slot,
|
|
35
|
+
kind: 'variant',
|
|
36
|
+
label: slotLabels[slot],
|
|
37
|
+
weight: 0
|
|
38
|
+
});
|
|
39
|
+
return next;
|
|
40
|
+
}, {
|
|
41
|
+
draftOnly: true
|
|
42
|
+
});
|
|
43
|
+
if (saved) onSelect(slot);
|
|
44
|
+
},
|
|
45
|
+
children: C.addLeftover
|
|
46
|
+
}) : null,
|
|
47
|
+
/*#__PURE__*/ _jsx(Button, {
|
|
48
|
+
onClick: ()=>setDeleting(slot),
|
|
49
|
+
children: C.deleteContent
|
|
50
|
+
})
|
|
51
|
+
]
|
|
52
|
+
})
|
|
53
|
+
]
|
|
54
|
+
}, slot);
|
|
55
|
+
return /*#__PURE__*/ _jsxs(_Fragment, {
|
|
56
|
+
children: [
|
|
57
|
+
slots.length > 2 ? /*#__PURE__*/ _jsxs("details", {
|
|
58
|
+
className: "xp-ui-banner xp-ui-banner--warning xp-slot-leftovers",
|
|
59
|
+
children: [
|
|
60
|
+
/*#__PURE__*/ _jsxs("summary", {
|
|
61
|
+
children: [
|
|
62
|
+
/*#__PURE__*/ _jsx("span", {
|
|
63
|
+
"aria-hidden": "true",
|
|
64
|
+
children: "⚠ "
|
|
65
|
+
}),
|
|
66
|
+
C.leftovers(slots.map((slot)=>slotLabels[slot]).join(', '))
|
|
67
|
+
]
|
|
68
|
+
}),
|
|
69
|
+
slots.map(notice)
|
|
70
|
+
]
|
|
71
|
+
}) : slots.map((slot)=>/*#__PURE__*/ _jsxs("div", {
|
|
72
|
+
className: "xp-ui-banner xp-ui-banner--warning xp-slot-leftovers",
|
|
73
|
+
children: [
|
|
74
|
+
/*#__PURE__*/ _jsx("span", {
|
|
75
|
+
"aria-hidden": "true",
|
|
76
|
+
children: "⚠"
|
|
77
|
+
}),
|
|
78
|
+
notice(slot)
|
|
79
|
+
]
|
|
80
|
+
}, slot)),
|
|
81
|
+
deleting ? /*#__PURE__*/ _jsx(Dialog, {
|
|
82
|
+
open: true,
|
|
83
|
+
title: C.deleteContentTitle(slotLabels[deleting]),
|
|
84
|
+
initialFocus: "cancel",
|
|
85
|
+
onClose: ()=>setDeleting(null),
|
|
86
|
+
children: /*#__PURE__*/ _jsxs("div", {
|
|
87
|
+
className: "xp-slot-drawer",
|
|
88
|
+
children: [
|
|
89
|
+
/*#__PURE__*/ _jsx("p", {
|
|
90
|
+
children: C.deleteContentHelp(slotLabels[deleting], countBlocks(deleting))
|
|
91
|
+
}),
|
|
92
|
+
/*#__PURE__*/ _jsxs("div", {
|
|
93
|
+
className: "xp-ui-button-group",
|
|
94
|
+
children: [
|
|
95
|
+
/*#__PURE__*/ _jsx(Button, {
|
|
96
|
+
"data-dialog-cancel": true,
|
|
97
|
+
onClick: ()=>setDeleting(null),
|
|
98
|
+
children: C.cancel
|
|
99
|
+
}),
|
|
100
|
+
/*#__PURE__*/ _jsx(Button, {
|
|
101
|
+
variant: "danger",
|
|
102
|
+
onClick: ()=>{
|
|
103
|
+
onDelete(deleting);
|
|
104
|
+
setDeleting(null);
|
|
105
|
+
},
|
|
106
|
+
children: C.deleteContent
|
|
107
|
+
})
|
|
108
|
+
]
|
|
109
|
+
})
|
|
110
|
+
]
|
|
111
|
+
})
|
|
112
|
+
}) : null
|
|
113
|
+
]
|
|
114
|
+
});
|
|
115
|
+
}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { ReadinessRead } from '../../testSurface/readinessRead.js';
|
|
2
|
+
/** Chrome and sidebar consume the settled read's sentence and recovery policy. */
|
|
3
|
+
export declare function PlacementNotice({ read, message, running, onRetry }: {
|
|
4
|
+
read?: ReadinessRead;
|
|
5
|
+
message?: string;
|
|
6
|
+
running: boolean;
|
|
7
|
+
onRetry(): void;
|
|
8
|
+
}): import("react").JSX.Element | null;
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
3
|
+
import { Banner } from '../../ui/Banner.js';
|
|
4
|
+
import { Button } from '../../ui/Button.js';
|
|
5
|
+
import { editorCopy } from './copy.js';
|
|
6
|
+
/** Chrome and sidebar consume the settled read's sentence and recovery policy. */ export function PlacementNotice({ read, message, running, onRetry }) {
|
|
7
|
+
const sentence = read?.message ?? message;
|
|
8
|
+
return sentence ? /*#__PURE__*/ _jsxs(Banner, {
|
|
9
|
+
tone: running && !read?.message ? 'warning' : 'error',
|
|
10
|
+
action: read?.retry ? /*#__PURE__*/ _jsx(Button, {
|
|
11
|
+
onClick: onRetry,
|
|
12
|
+
children: editorCopy.retrySetup
|
|
13
|
+
}) : undefined,
|
|
14
|
+
children: [
|
|
15
|
+
running && !read?.message ? /*#__PURE__*/ _jsx("span", {
|
|
16
|
+
"aria-hidden": "true",
|
|
17
|
+
children: "⚠ "
|
|
18
|
+
}) : null,
|
|
19
|
+
sentence
|
|
20
|
+
]
|
|
21
|
+
}) : null;
|
|
22
|
+
}
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
3
|
+
import { READINESS_COPY } from '../../testSurface/copy/readiness.js';
|
|
4
|
+
import { canStartTest, readyToStart } from '../../testSurface/readinessRead.js';
|
|
5
|
+
import { useState } from 'react';
|
|
6
|
+
import { Button } from '../../ui/Button.js';
|
|
7
|
+
import { availableActions } from '../../testSurface/actions/actions.model.js';
|
|
8
|
+
import { ConfirmAction } from '../../testSurface/surface/readiness/ActionDialogs.js';
|
|
9
|
+
import { useTransition } from '../../testSurface/surface/readiness/useTransition.js';
|
|
10
|
+
import { createApi } from '../../testSurface/api.js';
|
|
11
|
+
/** Same transition runner and confirmation as the drawer; Decide stays there. */ export function QuickTestActions({ test, surface }) {
|
|
12
|
+
const [confirm, setConfirm] = useState(false);
|
|
13
|
+
const transition = useTransition(test, undefined, surface);
|
|
14
|
+
const doc = test.doc;
|
|
15
|
+
const action = availableActions({
|
|
16
|
+
...doc,
|
|
17
|
+
canManage: surface.canManage
|
|
18
|
+
}).find((item)=>doc.status === 'draft' ? item.id === 'start' : doc.status === 'running' && item.id === 'stop');
|
|
19
|
+
if (!action) return null;
|
|
20
|
+
const ready = !transition.checking && canStartTest(test, surface.editorPlacementMessage);
|
|
21
|
+
const showAction = action.id !== 'start' || readyToStart(test, surface.editorPlacementMessage) && !test.hasUnsaved;
|
|
22
|
+
return /*#__PURE__*/ _jsxs(_Fragment, {
|
|
23
|
+
children: [
|
|
24
|
+
showAction && action.id === 'start' ? /*#__PURE__*/ _jsx("p", {
|
|
25
|
+
role: "status",
|
|
26
|
+
children: READINESS_COPY.ready
|
|
27
|
+
}) : null,
|
|
28
|
+
showAction ? /*#__PURE__*/ _jsx(Button, {
|
|
29
|
+
disabled: transition.busy || confirm || test.hasUnsaved || action.id === 'start' && !ready,
|
|
30
|
+
busy: transition.busy,
|
|
31
|
+
onClick: ()=>{
|
|
32
|
+
if (action.id === 'start') void transition.run('start', ()=>createApi(surface.apiRoute).start(doc.id));
|
|
33
|
+
else setConfirm(true);
|
|
34
|
+
},
|
|
35
|
+
children: action.label
|
|
36
|
+
}) : null,
|
|
37
|
+
transition.error ? /*#__PURE__*/ _jsx("p", {
|
|
38
|
+
role: "alert",
|
|
39
|
+
children: transition.error
|
|
40
|
+
}) : null,
|
|
41
|
+
confirm ? /*#__PURE__*/ _jsx(ConfirmAction, {
|
|
42
|
+
test: test,
|
|
43
|
+
surface: surface,
|
|
44
|
+
action: action,
|
|
45
|
+
winnerLabel: "",
|
|
46
|
+
onClose: ()=>setConfirm(false)
|
|
47
|
+
}) : null
|
|
48
|
+
]
|
|
49
|
+
});
|
|
50
|
+
}
|
|
@@ -2,11 +2,8 @@
|
|
|
2
2
|
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
3
3
|
import { useEffect, useRef, useState } from 'react';
|
|
4
4
|
import { Button } from '../../ui/Button.js';
|
|
5
|
+
import { formatCount } from '../../testSurface/results/format.js';
|
|
5
6
|
import { editorCopy as C } from './copy.js';
|
|
6
|
-
// Matches admin/results/format.ts formatCount; importing it would pull admin copy into this bundle.
|
|
7
|
-
const formatCount = (value)=>typeof value === 'number' && Number.isFinite(value) ? new Intl.NumberFormat('en-US', {
|
|
8
|
-
maximumFractionDigits: 0
|
|
9
|
-
}).format(value) : '—';
|
|
10
7
|
export function ResultsReadout({ id, api, experiment }) {
|
|
11
8
|
const [data, setData] = useState(null);
|
|
12
9
|
const [refresh, setRefresh] = useState(0);
|
|
@@ -56,7 +53,8 @@ export function ResultsReadout({ id, api, experiment }) {
|
|
|
56
53
|
}, [
|
|
57
54
|
id,
|
|
58
55
|
api,
|
|
59
|
-
refresh
|
|
56
|
+
refresh,
|
|
57
|
+
experiment.status
|
|
60
58
|
]);
|
|
61
59
|
return /*#__PURE__*/ _jsxs("div", {
|
|
62
60
|
className: "xp-slot-readout",
|
|
@@ -83,6 +81,11 @@ export function ResultsReadout({ id, api, experiment }) {
|
|
|
83
81
|
className: "xp-ui-help",
|
|
84
82
|
children: C.loading
|
|
85
83
|
}),
|
|
84
|
+
busy && data ? /*#__PURE__*/ _jsx("p", {
|
|
85
|
+
role: "status",
|
|
86
|
+
className: "xp-ui-help",
|
|
87
|
+
children: C.refreshing
|
|
88
|
+
}) : null,
|
|
86
89
|
/*#__PURE__*/ _jsx(Button, {
|
|
87
90
|
variant: "quiet",
|
|
88
91
|
size: "sm",
|
|
@@ -1,8 +1,11 @@
|
|
|
1
|
-
import type
|
|
1
|
+
import { type ReactNode, type RefObject } from 'react';
|
|
2
|
+
import type { Arm, ArmKey } from '../../types/contracts.js';
|
|
2
3
|
import type { ArmSlot } from '../../types/puck.js';
|
|
3
4
|
import type { EditorExperiment } from './editor.model.js';
|
|
4
|
-
export declare function useArmWrites(url: string, publish: (doc: EditorExperiment) => void, isCurrent: () => boolean, onWrite: () => void): {
|
|
5
|
-
write: (transform: (arms: Arm[]) => Arm[]
|
|
5
|
+
export declare function useArmWrites(url: string, publish: (doc: EditorExperiment) => void, isCurrent: () => boolean, onWrite: () => void, onSaved?: () => void): {
|
|
6
|
+
write: (transform: (arms: Arm[]) => Arm[], options?: {
|
|
7
|
+
draftOnly?: boolean;
|
|
8
|
+
}) => Promise<Arm[] | undefined>;
|
|
6
9
|
busy: boolean;
|
|
7
10
|
error: string | null;
|
|
8
11
|
};
|
|
@@ -12,23 +15,34 @@ export declare function AddVariant({ experiment, writes, onSelect }: {
|
|
|
12
15
|
writes: ArmWrites;
|
|
13
16
|
onSelect: (slot: ArmSlot) => void;
|
|
14
17
|
}): import("react").JSX.Element | null;
|
|
15
|
-
export declare function VersionActions({ arm, writes, editable, open, onOpenChange, canCopy, onCopy, onRequestRemove }: {
|
|
18
|
+
export declare function VersionActions({ arm, writes, editable, running, open, onOpenChange, canCopy, onCopy, onRequestRemove }: {
|
|
16
19
|
arm: EditorExperiment['arms'][number];
|
|
17
20
|
writes: ArmWrites;
|
|
18
21
|
editable: boolean;
|
|
22
|
+
running?: boolean;
|
|
19
23
|
open: boolean;
|
|
20
24
|
onOpenChange: (open: boolean) => void;
|
|
21
25
|
canCopy: boolean;
|
|
22
26
|
onCopy: (slot: ArmSlot) => void;
|
|
23
27
|
onRequestRemove: () => void;
|
|
24
28
|
}): import("react").JSX.Element;
|
|
25
|
-
export declare function RemoveVersion({ arm, writes, onRemove, onClose }: {
|
|
29
|
+
export declare function RemoveVersion({ arm, writes, count, shared, onRemove, onClose }: {
|
|
26
30
|
arm: EditorExperiment['arms'][number];
|
|
27
31
|
writes: ArmWrites;
|
|
32
|
+
count: number;
|
|
33
|
+
shared: boolean | undefined;
|
|
28
34
|
onRemove: (slot: ArmSlot) => void;
|
|
29
35
|
onClose: () => void;
|
|
30
36
|
}): import("react").JSX.Element;
|
|
31
|
-
export
|
|
37
|
+
export type WeightEdits = Partial<Record<ArmKey, string>>;
|
|
38
|
+
export declare function VersionWeights({ experiment, writes, edits, setEdits, groupId, splitIntent, editable, beforeSplit, actions }: {
|
|
32
39
|
experiment: EditorExperiment;
|
|
33
40
|
writes: ArmWrites;
|
|
41
|
+
edits: WeightEdits;
|
|
42
|
+
setEdits: (edits: WeightEdits) => void;
|
|
43
|
+
groupId: string;
|
|
44
|
+
splitIntent: RefObject<boolean>;
|
|
45
|
+
editable?: boolean;
|
|
46
|
+
beforeSplit?: ReactNode;
|
|
47
|
+
actions?: (arm: EditorExperiment['arms'][number]) => ReactNode;
|
|
34
48
|
}): import("react").JSX.Element;
|
|
@@ -9,18 +9,20 @@ import { Dialog } from '../../ui/Dialog.js';
|
|
|
9
9
|
import { NumberInput, TextInput } from '../../ui/Inputs.js';
|
|
10
10
|
import { ArmWriteError, writeArms } from './armWrites.js';
|
|
11
11
|
import { editorCopy as C } from './copy.js';
|
|
12
|
-
export function useArmWrites(url, publish, isCurrent, onWrite) {
|
|
12
|
+
export function useArmWrites(url, publish, isCurrent, onWrite, onSaved) {
|
|
13
13
|
const guard = useRef(false);
|
|
14
14
|
const [busy, setBusy] = useState(false);
|
|
15
15
|
const [error, setError] = useState(null);
|
|
16
|
-
async function write(transform) {
|
|
16
|
+
async function write(transform, options) {
|
|
17
17
|
if (guard.current) return;
|
|
18
18
|
guard.current = true;
|
|
19
19
|
onWrite();
|
|
20
20
|
setBusy(true);
|
|
21
21
|
setError(null);
|
|
22
22
|
try {
|
|
23
|
-
|
|
23
|
+
const saved = await writeArms(url, transform, publish, options);
|
|
24
|
+
onSaved?.();
|
|
25
|
+
return saved;
|
|
24
26
|
} catch (error) {
|
|
25
27
|
if (isCurrent()) setError(error instanceof ArmWriteError ? error.message : C.writeNetwork);
|
|
26
28
|
} finally{
|
|
@@ -50,7 +52,7 @@ export function AddVariant({ experiment, writes, onSelect }) {
|
|
|
50
52
|
children: C.add
|
|
51
53
|
});
|
|
52
54
|
}
|
|
53
|
-
export function VersionActions({ arm, writes, editable, open, onOpenChange, canCopy, onCopy, onRequestRemove }) {
|
|
55
|
+
export function VersionActions({ arm, writes, editable, running = false, open, onOpenChange, canCopy, onCopy, onRequestRemove }) {
|
|
54
56
|
const id = useId();
|
|
55
57
|
const [name, setName] = useState(null);
|
|
56
58
|
const [invalid, setInvalid] = useState(false);
|
|
@@ -76,10 +78,10 @@ export function VersionActions({ arm, writes, editable, open, onOpenChange, canC
|
|
|
76
78
|
// Focus leaving the canvas iframe (Puck's own panels) or the window fires window blur, not a document pointerdown.
|
|
77
79
|
const leave = ()=>onOpenChange(false);
|
|
78
80
|
const view = doc?.defaultView;
|
|
79
|
-
doc?.addEventListener('pointerdown', outside);
|
|
81
|
+
doc?.addEventListener('pointerdown', outside, true);
|
|
80
82
|
view?.addEventListener('blur', leave);
|
|
81
83
|
return ()=>{
|
|
82
|
-
doc?.removeEventListener('pointerdown', outside);
|
|
84
|
+
doc?.removeEventListener('pointerdown', outside, true);
|
|
83
85
|
view?.removeEventListener('blur', leave);
|
|
84
86
|
};
|
|
85
87
|
}, [
|
|
@@ -125,7 +127,7 @@ export function VersionActions({ arm, writes, editable, open, onOpenChange, canC
|
|
|
125
127
|
/*#__PURE__*/ _jsxs("div", {
|
|
126
128
|
className: "xp-slot-version-anchor",
|
|
127
129
|
children: [
|
|
128
|
-
editable || arm.kind !== 'control' ? /*#__PURE__*/
|
|
130
|
+
editable || arm.kind !== 'control' ? /*#__PURE__*/ _jsxs(Button, {
|
|
129
131
|
size: "sm",
|
|
130
132
|
variant: "quiet",
|
|
131
133
|
"aria-label": C.menu(arm.label),
|
|
@@ -133,7 +135,10 @@ export function VersionActions({ arm, writes, editable, open, onOpenChange, canC
|
|
|
133
135
|
"aria-controls": `${id}-menu`,
|
|
134
136
|
disabled: writes.busy,
|
|
135
137
|
onClick: ()=>onOpenChange(!open),
|
|
136
|
-
children:
|
|
138
|
+
children: [
|
|
139
|
+
C.options,
|
|
140
|
+
" ▾"
|
|
141
|
+
]
|
|
137
142
|
}) : null,
|
|
138
143
|
open ? /*#__PURE__*/ _jsxs("div", {
|
|
139
144
|
id: `${id}-menu`,
|
|
@@ -152,7 +157,7 @@ export function VersionActions({ arm, writes, editable, open, onOpenChange, canC
|
|
|
152
157
|
},
|
|
153
158
|
children: C.rename
|
|
154
159
|
}) : null,
|
|
155
|
-
arm.kind
|
|
160
|
+
arm.kind === 'variant' ? /*#__PURE__*/ _jsxs(_Fragment, {
|
|
156
161
|
children: [
|
|
157
162
|
/*#__PURE__*/ _jsx(Button, {
|
|
158
163
|
variant: "quiet",
|
|
@@ -164,16 +169,24 @@ export function VersionActions({ arm, writes, editable, open, onOpenChange, canC
|
|
|
164
169
|
},
|
|
165
170
|
children: C.copy
|
|
166
171
|
}),
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
onClick: ()=>{
|
|
171
|
-
closeMenu();
|
|
172
|
-
onRequestRemove();
|
|
173
|
-
},
|
|
174
|
-
children: C.remove
|
|
172
|
+
!canCopy ? /*#__PURE__*/ _jsx("p", {
|
|
173
|
+
className: "xp-ui-help",
|
|
174
|
+
children: C.copyEmpty
|
|
175
175
|
}) : null
|
|
176
176
|
]
|
|
177
|
+
}) : null,
|
|
178
|
+
arm.kind !== 'control' && editable ? /*#__PURE__*/ _jsx(Button, {
|
|
179
|
+
variant: "quiet",
|
|
180
|
+
size: "sm",
|
|
181
|
+
onClick: ()=>{
|
|
182
|
+
closeMenu();
|
|
183
|
+
onRequestRemove();
|
|
184
|
+
},
|
|
185
|
+
children: C.removeVersion
|
|
186
|
+
}) : null,
|
|
187
|
+
running ? /*#__PURE__*/ _jsx("p", {
|
|
188
|
+
className: "xp-ui-help",
|
|
189
|
+
children: C.runningVersions
|
|
177
190
|
}) : null
|
|
178
191
|
]
|
|
179
192
|
}) : null
|
|
@@ -203,8 +216,8 @@ export function VersionActions({ arm, writes, editable, open, onOpenChange, canC
|
|
|
203
216
|
]
|
|
204
217
|
});
|
|
205
218
|
}
|
|
206
|
-
export function RemoveVersion({ arm, writes, onRemove, onClose }) {
|
|
207
|
-
const slot = arm.key;
|
|
219
|
+
export function RemoveVersion({ arm, writes, count, shared, onRemove, onClose }) {
|
|
220
|
+
const slot = arm.key === 'holdout' ? undefined : arm.key;
|
|
208
221
|
const [tried, setTried] = useState(false);
|
|
209
222
|
return /*#__PURE__*/ _jsx(Dialog, {
|
|
210
223
|
open: true,
|
|
@@ -216,8 +229,13 @@ export function RemoveVersion({ arm, writes, onRemove, onClose }) {
|
|
|
216
229
|
className: "xp-slot-drawer",
|
|
217
230
|
children: [
|
|
218
231
|
/*#__PURE__*/ _jsx("p", {
|
|
219
|
-
children: C.removeHelp
|
|
232
|
+
children: C.removeHelp(count)
|
|
220
233
|
}),
|
|
234
|
+
shared === undefined ? /*#__PURE__*/ _jsx("p", {
|
|
235
|
+
children: C.removeScopeUnknown
|
|
236
|
+
}) : shared ? /*#__PURE__*/ _jsx("p", {
|
|
237
|
+
children: C.removeShared
|
|
238
|
+
}) : null,
|
|
221
239
|
tried && writes.error ? /*#__PURE__*/ _jsx("p", {
|
|
222
240
|
role: "alert",
|
|
223
241
|
className: "xp-ui-error",
|
|
@@ -239,7 +257,7 @@ export function RemoveVersion({ arm, writes, onRemove, onClose }) {
|
|
|
239
257
|
setTried(true);
|
|
240
258
|
const saved = await writes.write((arms)=>splitEvenly(removeArm(arms, arm.key)));
|
|
241
259
|
if (saved) {
|
|
242
|
-
onRemove(slot);
|
|
260
|
+
if (slot) onRemove(slot);
|
|
243
261
|
onClose();
|
|
244
262
|
}
|
|
245
263
|
},
|
|
@@ -251,10 +269,9 @@ export function RemoveVersion({ arm, writes, onRemove, onClose }) {
|
|
|
251
269
|
})
|
|
252
270
|
});
|
|
253
271
|
}
|
|
254
|
-
export function VersionWeights({ experiment, writes }) {
|
|
272
|
+
export function VersionWeights({ experiment, writes, edits, setEdits, groupId, splitIntent, editable = true, beforeSplit, actions }) {
|
|
255
273
|
const id = useId();
|
|
256
274
|
const split = useRef(null);
|
|
257
|
-
const [edits, setEdits] = useState({});
|
|
258
275
|
const invalidKeys = new Set(Object.entries(edits).filter(([, raw])=>raw.trim() === '' || !Number.isInteger(Number(raw)) || Number(raw) < 0 || Number(raw) > 100).map(([key])=>key));
|
|
259
276
|
const apply = (arms)=>arms.reduce((next, arm)=>edits[arm.key] === undefined ? next : (()=>{
|
|
260
277
|
const value = edits[arm.key].trim() === '' ? NaN : Number(edits[arm.key]);
|
|
@@ -264,35 +281,41 @@ export function VersionWeights({ experiment, writes }) {
|
|
|
264
281
|
const issues = checkArms(live, 'block');
|
|
265
282
|
async function commit() {
|
|
266
283
|
if (!Object.keys(edits).length || invalidKeys.size || issues.length) return;
|
|
267
|
-
|
|
268
|
-
if (saved) setEdits({});
|
|
284
|
+
await writes.write(apply);
|
|
269
285
|
}
|
|
270
286
|
return /*#__PURE__*/ _jsxs("div", {
|
|
271
287
|
className: "xp-slot-weights",
|
|
272
288
|
children: [
|
|
273
289
|
/*#__PURE__*/ _jsx("div", {
|
|
274
290
|
className: "xp-slot-weight-inputs",
|
|
275
|
-
children: experiment.arms.map((arm)=>/*#__PURE__*/
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
291
|
+
children: experiment.arms.map((arm)=>/*#__PURE__*/ _jsxs("div", {
|
|
292
|
+
className: "xp-slot-weight-row",
|
|
293
|
+
children: [
|
|
294
|
+
/*#__PURE__*/ _jsx(NumberInput, {
|
|
295
|
+
id: `${id}-${arm.key}`,
|
|
296
|
+
label: C.weight(arm.label),
|
|
297
|
+
min: 0,
|
|
298
|
+
max: 100,
|
|
299
|
+
step: 1,
|
|
300
|
+
value: edits[arm.key] ?? live.find((current)=>current.key === arm.key)?.weight ?? '',
|
|
301
|
+
disabled: writes.busy || !editable,
|
|
302
|
+
error: invalidKeys.has(arm.key) ? C.invalidShare : undefined,
|
|
303
|
+
onChange: (event)=>setEdits({
|
|
304
|
+
[arm.key]: event.target.value
|
|
305
|
+
}),
|
|
306
|
+
onBlur: (event)=>{
|
|
307
|
+
const target = event.relatedTarget;
|
|
308
|
+
if (!splitIntent.current && !(typeof target?.closest === 'function' && target.closest('[data-xp-split]')?.getAttribute('data-xp-split') === groupId)) void commit();
|
|
309
|
+
},
|
|
310
|
+
onKeyDown: (event)=>{
|
|
311
|
+
if (event.key === 'Enter') {
|
|
312
|
+
event.preventDefault();
|
|
313
|
+
void commit();
|
|
314
|
+
}
|
|
315
|
+
}
|
|
286
316
|
}),
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
},
|
|
290
|
-
onKeyDown: (event)=>{
|
|
291
|
-
if (event.key === 'Enter') {
|
|
292
|
-
event.preventDefault();
|
|
293
|
-
void commit();
|
|
294
|
-
}
|
|
295
|
-
}
|
|
317
|
+
actions?.(arm)
|
|
318
|
+
]
|
|
296
319
|
}, arm.key))
|
|
297
320
|
}),
|
|
298
321
|
Object.keys(edits).length && !invalidKeys.size ? issues.map((issue, i)=>/*#__PURE__*/ _jsx("p", {
|
|
@@ -300,18 +323,25 @@ export function VersionWeights({ experiment, writes }) {
|
|
|
300
323
|
className: "xp-ui-error",
|
|
301
324
|
children: issueMessage(issue, totalWeight(live))
|
|
302
325
|
}, i)) : null,
|
|
303
|
-
|
|
326
|
+
beforeSplit,
|
|
327
|
+
editable ? /*#__PURE__*/ _jsx("div", {
|
|
304
328
|
ref: split,
|
|
329
|
+
"data-xp-split": groupId,
|
|
330
|
+
onPointerDownCapture: ()=>{
|
|
331
|
+
// Pointer intent reaches the destination before the source iframe loses focus.
|
|
332
|
+
splitIntent.current = true;
|
|
333
|
+
setTimeout(()=>{
|
|
334
|
+
splitIntent.current = false;
|
|
335
|
+
}, 0);
|
|
336
|
+
},
|
|
305
337
|
children: /*#__PURE__*/ _jsx(Button, {
|
|
306
338
|
variant: "quiet",
|
|
307
339
|
size: "sm",
|
|
308
340
|
disabled: writes.busy,
|
|
309
|
-
onClick:
|
|
310
|
-
if (await writes.write(splitEvenly)) setEdits({});
|
|
311
|
-
},
|
|
341
|
+
onClick: ()=>void writes.write(splitEvenly),
|
|
312
342
|
children: C.split
|
|
313
343
|
})
|
|
314
|
-
})
|
|
344
|
+
}) : null
|
|
315
345
|
]
|
|
316
346
|
});
|
|
317
347
|
}
|
|
@@ -4,4 +4,6 @@ export declare class ArmWriteError extends Error {
|
|
|
4
4
|
}
|
|
5
5
|
export declare function readExperiment(url: string, signal?: AbortSignal): Promise<EditorExperiment>;
|
|
6
6
|
/** Each intent is applied to a fresh document, guarded by the collection's compare-and-set header. */
|
|
7
|
-
export declare function writeArms(url: string, transform: (arms: Arm[]) => Arm[], publish: (doc: EditorExperiment) => void
|
|
7
|
+
export declare function writeArms(url: string, transform: (arms: Arm[]) => Arm[], publish: (doc: EditorExperiment) => void, { draftOnly }?: {
|
|
8
|
+
draftOnly?: boolean;
|
|
9
|
+
}): Promise<Arm[]>;
|
|
@@ -31,9 +31,10 @@ export async function readExperiment(url, signal) {
|
|
|
31
31
|
].includes(value.status)) throw new ArmWriteError(editorCopy.lockedGeneric);
|
|
32
32
|
return value;
|
|
33
33
|
}
|
|
34
|
-
/** Each intent is applied to a fresh document, guarded by the collection's compare-and-set header. */ export async function writeArms(url, transform, publish) {
|
|
34
|
+
/** Each intent is applied to a fresh document, guarded by the collection's compare-and-set header. */ export async function writeArms(url, transform, publish, { draftOnly = false } = {}) {
|
|
35
35
|
const fresh = await readExperiment(`${url}?depth=0`);
|
|
36
36
|
publish(fresh);
|
|
37
|
+
if (draftOnly && fresh.status !== 'draft') throw new ArmWriteError(editorCopy.draftOnly);
|
|
37
38
|
if (fresh.status !== 'draft' && fresh.status !== 'stopped') throw new ArmWriteError(editorCopy.locked[fresh.status]);
|
|
38
39
|
if (!fresh.updatedAt || !Array.isArray(fresh.arms)) throw new ArmWriteError(editorCopy.writeUnreadable);
|
|
39
40
|
const arms = withSlotsFor(transform(fresh.arms), 'block');
|
|
@@ -2,13 +2,15 @@ import type { DocId } from '../../types/contracts.js';
|
|
|
2
2
|
import type { EditorExperiment } from './editor.model.js';
|
|
3
3
|
type Arms = {
|
|
4
4
|
arms: string[];
|
|
5
|
+
doc?: EditorExperiment;
|
|
5
6
|
};
|
|
6
7
|
/** Only the first mounted block discards a document left by an earlier editor. */
|
|
7
8
|
export declare function acquireArms(testId: DocId): () => void;
|
|
8
9
|
/** Share the request, but abort it only after its last mounted consumer leaves. */
|
|
9
10
|
export declare function loadArms(testId: DocId, load: (signal: AbortSignal) => Promise<EditorExperiment>, signal: AbortSignal): Promise<EditorExperiment>;
|
|
10
11
|
export declare function subscribe(listener: () => void): () => void;
|
|
11
|
-
|
|
12
|
+
export declare function publishExperiment(testId: DocId, doc: EditorExperiment): void;
|
|
13
|
+
/** undefined means unknown. */
|
|
12
14
|
export declare function setArms(testId: DocId, arms: string[] | undefined): void;
|
|
13
15
|
export declare function useArms(testId: DocId | undefined): Arms | undefined;
|
|
14
16
|
export {};
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
'use client';
|
|
2
2
|
import { useSyncExternalStore } from 'react';
|
|
3
3
|
const cache = new Map();
|
|
4
|
+
const revisions = new Map();
|
|
4
5
|
const listeners = new Set();
|
|
5
6
|
const pending = new Map();
|
|
6
7
|
const mounted = new Map();
|
|
@@ -29,11 +30,14 @@ const mounted = new Map();
|
|
|
29
30
|
promise: undefined
|
|
30
31
|
};
|
|
31
32
|
const entry = request;
|
|
33
|
+
const revision = revisions.get(key) ?? 0;
|
|
32
34
|
entry.promise = load(controller.signal).then((doc)=>{
|
|
33
|
-
if (
|
|
35
|
+
if ((revisions.get(key) ?? 0) !== revision) return cache.get(key)?.doc ?? doc;
|
|
36
|
+
if (!controller.signal.aborted) publishExperiment(testId, doc);
|
|
34
37
|
return doc;
|
|
35
38
|
}, (error)=>{
|
|
36
|
-
if (
|
|
39
|
+
if ((revisions.get(key) ?? 0) !== revision && cache.get(key)?.doc) return cache.get(key).doc;
|
|
40
|
+
if (!controller.signal.aborted && (revisions.get(key) ?? 0) === revision) setArms(testId, undefined);
|
|
37
41
|
throw error;
|
|
38
42
|
}).finally(()=>{
|
|
39
43
|
if (pending.get(key) === entry) pending.delete(key);
|
|
@@ -63,7 +67,20 @@ export function subscribe(listener) {
|
|
|
63
67
|
listeners.delete(listener);
|
|
64
68
|
};
|
|
65
69
|
}
|
|
66
|
-
|
|
70
|
+
export function publishExperiment(testId, doc) {
|
|
71
|
+
const previous = cache.get(String(testId))?.doc;
|
|
72
|
+
// Surface reads and chrome writes share this producer too. A GET that began
|
|
73
|
+
// before a save cannot overwrite its newer server timestamp when it finishes.
|
|
74
|
+
if (previous?.updatedAt && doc.updatedAt && Date.parse(previous.updatedAt) > Date.parse(doc.updatedAt)) return;
|
|
75
|
+
revisions.set(String(testId), (revisions.get(String(testId)) ?? 0) + 1);
|
|
76
|
+
cache.set(String(testId), {
|
|
77
|
+
arms: doc.arms.map((arm)=>arm.key),
|
|
78
|
+
doc
|
|
79
|
+
});
|
|
80
|
+
for (const listener of listeners)listener();
|
|
81
|
+
}
|
|
82
|
+
/** undefined means unknown. */ export function setArms(testId, arms) {
|
|
83
|
+
revisions.set(String(testId), (revisions.get(String(testId)) ?? 0) + 1);
|
|
67
84
|
if (arms) cache.set(String(testId), {
|
|
68
85
|
arms: [
|
|
69
86
|
...arms
|
|
@@ -1,3 +1,5 @@
|
|
|
1
1
|
import type { Slot } from '../../types/puck.js';
|
|
2
2
|
/** Clone JSON Puck slot data, refreshing component ids even inside nested slots. */
|
|
3
3
|
export declare function cloneSlot(slot: Slot): Slot;
|
|
4
|
+
/** Count the Puck blocks that will be removed, including nested version content. */
|
|
5
|
+
export declare function countSlotBlocks(value: unknown): number;
|