@delmaredigital/payload-experiments 0.4.0-rc.7 → 0.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +9 -15
- package/dist/admin/MetricSourceSelect.js +10 -3
- package/dist/admin/armSelect/armSelect.model.d.ts +1 -1
- package/dist/admin/blocks/BlockPanel.d.ts +1 -0
- package/dist/admin/blocks/BlockPanel.js +75 -29
- package/dist/admin/blocks/model.js +7 -6
- package/dist/admin/copy/blocks.d.ts +14 -11
- package/dist/admin/copy/blocks.js +33 -22
- package/dist/admin/copy/goals.d.ts +15 -8
- package/dist/admin/copy/goals.js +18 -8
- package/dist/admin/copy/newTest.d.ts +10 -7
- package/dist/admin/copy/newTest.js +14 -7
- package/dist/admin/copy/status.d.ts +1 -1
- package/dist/admin/copy/status.js +2 -1
- package/dist/admin/pageCollections.d.ts +1 -0
- package/dist/admin/pageCollections.js +3 -0
- package/dist/admin/placementStatus.model.js +5 -3
- package/dist/admin/status.model.d.ts +1 -0
- package/dist/admin/status.model.js +2 -1
- package/dist/admin/surface/ResultsRoute.js +12 -10
- package/dist/admin/surface/SurfaceShell.d.ts +4 -2
- package/dist/admin/surface/SurfaceShell.js +28 -3
- package/dist/admin/surface/TestRowMenu.d.ts +13 -0
- package/dist/admin/surface/TestRowMenu.js +163 -0
- package/dist/admin/surface/TestsHome.d.ts +4 -3
- package/dist/admin/surface/TestsHome.js +224 -52
- package/dist/admin/surface/TestsSurface.js +2 -1
- package/dist/admin/surface/goals/DeleteGoalDialog.d.ts +7 -0
- package/dist/admin/surface/goals/DeleteGoalDialog.js +42 -0
- package/dist/admin/surface/goals/GoalForm.d.ts +1 -0
- package/dist/admin/surface/goals/GoalForm.js +280 -198
- package/dist/admin/surface/goals/GoalsList.js +102 -33
- package/dist/admin/surface/goals/data.d.ts +2 -0
- package/dist/admin/surface/goals/data.js +9 -0
- package/dist/admin/surface/goals/goals.css +3 -2
- package/dist/admin/surface/goals/goals.model.d.ts +2 -2
- package/dist/admin/surface/goals/goals.model.js +7 -12
- package/dist/admin/surface/home.model.d.ts +15 -8
- package/dist/admin/surface/home.model.js +22 -18
- package/dist/admin/surface/newTest/NewTest.d.ts +3 -3
- package/dist/admin/surface/newTest/NewTest.js +156 -96
- package/dist/admin/surface/newTest/PageWizard.d.ts +4 -1
- package/dist/admin/surface/newTest/PageWizard.js +99 -68
- package/dist/admin/surface/newTest/newTest.css +28 -11
- package/dist/admin/surface/results/ResultsHeader.d.ts +1 -1
- package/dist/admin/surface/results/ResultsHeader.js +98 -66
- package/dist/admin/surface/surface.css +29 -0
- package/dist/admin/surface/test/TestPage.js +46 -38
- package/dist/admin/surface/useXpStepNav.d.ts +11 -0
- package/dist/admin/surface/useXpStepNav.js +14 -0
- package/dist/admin/views/TestsSurfaceClient.js +27 -3
- package/dist/admin/views/buildSurfaceProps.js +18 -66
- package/dist/arms/copy.d.ts +13 -3
- package/dist/arms/copy.js +5 -4
- package/dist/blocks/createExperimentBlock.js +1 -1
- package/dist/blocks/formState.js +2 -2
- package/dist/collections/experiments/armInvariants.js +8 -5
- package/dist/collections/experiments/config.js +8 -3
- 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 +12 -5
- package/dist/collections/metricsGuards.js +2 -0
- package/dist/collections/serialize.js +8 -6
- 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/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/results.d.ts +5 -1
- package/dist/db/results.js +21 -5
- package/dist/db/snapshots.d.ts +2 -0
- package/dist/endpoints/deleteImpact.js +2 -1
- package/dist/endpoints/duplicateOriginal.d.ts +38 -0
- package/dist/endpoints/duplicateOriginal.js +414 -0
- package/dist/endpoints/editorSurface.js +1 -1
- package/dist/endpoints/events.js +103 -39
- package/dist/endpoints/index.js +22 -8
- package/dist/endpoints/pages.js +245 -66
- package/dist/endpoints/placementStatus.js +8 -4
- package/dist/endpoints/results.d.ts +1 -1
- package/dist/endpoints/results.js +9 -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 +4 -0
- package/dist/errors.js +6 -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/index.d.ts +1 -1
- package/dist/exports/rsc.d.ts +1 -0
- package/dist/exports/rsc.js +1 -0
- package/dist/goals/fairness.js +2 -2
- package/dist/goals/picker/copy.js +1 -1
- package/dist/goals/sourceLabel.d.ts +2 -0
- package/dist/goals/sourceLabel.js +4 -0
- package/dist/hooks/hostHook.js +6 -2
- package/dist/hooks/pageGuard.js +4 -0
- package/dist/hooks/trackPageCopies.d.ts +11 -0
- package/dist/hooks/trackPageCopies.js +7 -0
- package/dist/labels/arms.d.ts +3 -0
- package/dist/labels/arms.js +8 -0
- package/dist/lib/fetchAllDocs.d.ts +1 -1
- package/dist/manifest/compile.js +8 -5
- package/dist/onInit.js +14 -0
- package/dist/options.d.ts +2 -0
- package/dist/options.js +23 -2
- package/dist/plugin.js +56 -2
- 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/editor/ConfigureTestDrawer.d.ts +7 -7
- package/dist/puck/editor/ConfigureTestDrawer.js +40 -29
- package/dist/puck/editor/ExperimentSlotEditor.d.ts +2 -1
- package/dist/puck/editor/ExperimentSlotEditor.js +376 -139
- package/dist/puck/editor/LeftoverVersions.js +17 -32
- package/dist/puck/editor/QuickTestActions.d.ts +6 -3
- package/dist/puck/editor/QuickTestActions.js +55 -33
- package/dist/puck/editor/ResultsReadout.d.ts +4 -1
- package/dist/puck/editor/ResultsReadout.js +28 -15
- package/dist/puck/editor/VersionBuilder.d.ts +17 -4
- package/dist/puck/editor/VersionBuilder.js +175 -112
- package/dist/puck/editor/armWrites.js +2 -2
- package/dist/puck/editor/armsCache.js +1 -3
- package/dist/puck/editor/copy.d.ts +14 -7
- package/dist/puck/editor/copy.js +26 -13
- package/dist/puck/editor/editor.chrome.css +10 -8
- package/dist/puck/editor/editor.css +15 -9
- package/dist/puck/editor/editor.model.d.ts +1 -0
- package/dist/puck/editor/placementsCache.d.ts +4 -0
- package/dist/puck/editor/usePageSaveReadiness.d.ts +6 -0
- package/dist/puck/editor/usePageSaveReadiness.js +31 -0
- package/dist/puck/nestedTestCopy.js +2 -2
- package/dist/puck/slotConfig.d.ts +1 -1
- package/dist/puck/slotConfig.js +1 -1
- package/dist/results/aggregate.d.ts +6 -3
- package/dist/results/aggregate.js +9 -9
- package/dist/results/analyse.d.ts +2 -0
- package/dist/results/analyse.js +2 -2
- 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.d.ts +4 -4
- package/dist/results/verdict.js +15 -11
- 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 +20 -2
- package/dist/server/getAssignments.js +11 -10
- package/dist/server/recordContentChange.d.ts +1 -1
- package/dist/server/recordContentChange.js +11 -2
- package/dist/server/resolveExperimentBlocks.js +2 -4
- package/dist/server/resolveExperimentData.js +2 -5
- package/dist/server/runResults.js +54 -15
- package/dist/server/startExperiment.d.ts +20 -0
- package/dist/server/startExperiment.js +70 -0
- package/dist/server/trackConversion.js +10 -13
- package/dist/testSurface/PreviewLinks.d.ts +2 -1
- package/dist/testSurface/PreviewLinks.js +3 -3
- package/dist/testSurface/actions/DecideDialog.d.ts +10 -4
- package/dist/testSurface/actions/DecideDialog.js +93 -63
- package/dist/testSurface/actions/LifecycleAction.d.ts +17 -0
- package/dist/testSurface/actions/LifecycleAction.js +107 -0
- package/dist/testSurface/actions/MakeContentResult.d.ts +4 -3
- package/dist/testSurface/actions/MakeContentResult.js +10 -2
- package/dist/testSurface/actions/actions.model.d.ts +13 -5
- package/dist/testSurface/actions/actions.model.js +75 -22
- package/dist/testSurface/actions/decide.model.d.ts +1 -0
- package/dist/testSurface/actions/decide.model.js +1 -0
- package/dist/testSurface/allocation.model.js +6 -3
- package/dist/testSurface/api.d.ts +9 -6
- package/dist/testSurface/api.js +43 -23
- package/dist/testSurface/copy/actions.d.ts +37 -14
- package/dist/testSurface/copy/actions.js +40 -17
- package/dist/testSurface/copy/advanced.d.ts +10 -0
- package/dist/testSurface/copy/advanced.js +10 -0
- package/dist/testSurface/copy/arms.d.ts +1 -1
- package/dist/testSurface/copy/arms.js +1 -1
- package/dist/testSurface/copy/audience.d.ts +4 -3
- package/dist/testSurface/copy/audience.js +5 -4
- package/dist/testSurface/copy/common.d.ts +8 -6
- package/dist/testSurface/copy/common.js +8 -6
- package/dist/testSurface/copy/languages.d.ts +1 -0
- package/dist/testSurface/copy/languages.js +1 -0
- package/dist/testSurface/copy/metrics.d.ts +7 -0
- package/dist/testSurface/copy/metrics.js +9 -0
- package/dist/testSurface/copy/pages.d.ts +67 -7
- package/dist/testSurface/copy/pages.js +74 -7
- package/dist/testSurface/copy/readiness.d.ts +20 -7
- package/dist/testSurface/copy/readiness.js +36 -10
- package/dist/testSurface/copy/recommendation.d.ts +1 -22
- package/dist/testSurface/copy/recommendation.js +2 -22
- package/dist/testSurface/copy/results.d.ts +21 -12
- package/dist/testSurface/copy/results.js +24 -13
- package/dist/testSurface/copy/review.d.ts +13 -10
- package/dist/testSurface/copy/review.js +14 -10
- package/dist/testSurface/copy/setting.d.ts +1 -2
- package/dist/testSurface/copy/setting.js +1 -2
- package/dist/testSurface/copy/surface.d.ts +11 -2
- package/dist/testSurface/copy/surface.js +14 -11
- package/dist/testSurface/copy/testPage.d.ts +36 -12
- package/dist/testSurface/copy/testPage.js +53 -16
- package/dist/testSurface/format/date.d.ts +5 -2
- package/dist/testSurface/format/date.js +24 -8
- package/dist/testSurface/format/roundProgress.d.ts +6 -0
- package/dist/testSurface/format/roundProgress.js +15 -0
- package/dist/testSurface/format/useDateFormatter.d.ts +3 -0
- package/dist/testSurface/format/useDateFormatter.js +8 -0
- package/dist/testSurface/labels.d.ts +1 -2
- package/dist/testSurface/labels.js +2 -3
- package/dist/testSurface/lockedNotice.model.d.ts +2 -0
- package/dist/testSurface/lockedNotice.model.js +31 -0
- package/dist/testSurface/readPreflight.d.ts +4 -0
- package/dist/testSurface/readPreflight.js +6 -0
- package/dist/testSurface/readinessRead.d.ts +3 -0
- package/dist/testSurface/readinessRead.js +4 -0
- package/dist/testSurface/results/CiChart.js +2 -1
- package/dist/testSurface/results/DataTable.d.ts +1 -1
- package/dist/testSurface/results/DataTable.js +4 -3
- package/dist/testSurface/results/VerdictHero.d.ts +3 -2
- package/dist/testSurface/results/VerdictHero.js +5 -1
- package/dist/testSurface/results/legacy.d.ts +0 -5
- package/dist/testSurface/results/legacy.js +0 -14
- package/dist/testSurface/results/results.css +2 -2
- package/dist/testSurface/results/results.model.d.ts +9 -4
- package/dist/testSurface/results/results.model.js +31 -23
- package/dist/testSurface/results/snapshot.d.ts +2 -0
- package/dist/testSurface/results/snapshot.js +3 -0
- package/dist/testSurface/surface/contracts.d.ts +13 -1
- package/dist/testSurface/surface/editorPlacement.d.ts +3 -3
- package/dist/testSurface/surface/editorPlacement.js +2 -2
- package/dist/testSurface/surface/pageBlock/pageBlock.model.js +3 -3
- package/dist/testSurface/surface/pageBlock/parts.js +25 -12
- package/dist/testSurface/surface/pagePicker/CopyRoute.d.ts +8 -1
- package/dist/testSurface/surface/pagePicker/CopyRoute.js +243 -22
- package/dist/testSurface/surface/pagePicker/PageCombobox.d.ts +15 -4
- package/dist/testSurface/surface/pagePicker/PageCombobox.js +300 -197
- package/dist/testSurface/surface/pagePicker/pagePicker.css +73 -10
- package/dist/testSurface/surface/pagePicker/pagePicker.model.d.ts +5 -3
- package/dist/testSurface/surface/pagePicker/pagePicker.model.js +17 -2
- package/dist/testSurface/surface/readiness/ActionDialogs.d.ts +9 -5
- package/dist/testSurface/surface/readiness/ActionDialogs.js +241 -230
- package/dist/testSurface/surface/readiness/Banner.d.ts +5 -1
- package/dist/testSurface/surface/readiness/Banner.js +113 -141
- package/dist/testSurface/surface/readiness/SaveStatus.d.ts +8 -4
- package/dist/testSurface/surface/readiness/SaveStatus.js +23 -22
- package/dist/testSurface/surface/readiness/readiness.model.d.ts +20 -6
- package/dist/testSurface/surface/readiness/readiness.model.js +168 -21
- package/dist/testSurface/surface/readiness/useTransition.d.ts +6 -4
- package/dist/testSurface/surface/readiness/useTransition.js +57 -14
- package/dist/testSurface/surface/results/ReleasePages.d.ts +6 -3
- package/dist/testSurface/surface/results/ReleasePages.js +42 -41
- package/dist/testSurface/surface/results/ResultsBody.d.ts +11 -4
- package/dist/testSurface/surface/results/ResultsBody.js +221 -118
- package/dist/testSurface/surface/results/recommendation.model.d.ts +6 -9
- package/dist/testSurface/surface/results/recommendation.model.js +15 -59
- package/dist/testSurface/surface/results/useResults.d.ts +13 -8
- package/dist/testSurface/surface/results/useResults.js +3 -2
- package/dist/testSurface/surface/setting/parts.js +89 -46
- package/dist/testSurface/surface/setting/setting.css +2 -1
- package/dist/testSurface/surface/test/AdvancedSection.js +11 -4
- package/dist/testSurface/surface/test/DeleteTest.d.ts +10 -2
- package/dist/testSurface/surface/test/DeleteTest.js +173 -74
- package/dist/testSurface/surface/test/GoalSection.js +18 -14
- package/dist/testSurface/surface/test/LengthSection.js +24 -13
- package/dist/testSurface/surface/test/PageHoldout.d.ts +1 -1
- package/dist/testSurface/surface/test/PageHoldout.js +11 -8
- package/dist/testSurface/surface/test/ReadinessBar.d.ts +2 -1
- package/dist/testSurface/surface/test/ReadinessBar.js +4 -10
- package/dist/testSurface/surface/test/Section.js +8 -0
- package/dist/testSurface/surface/test/TargetingSection.js +82 -12
- package/dist/testSurface/surface/test/TestSurface.js +73 -37
- package/dist/testSurface/surface/test/VersionsSection.js +141 -91
- package/dist/testSurface/surface/test/fields.d.ts +32 -6
- package/dist/testSurface/surface/test/fields.js +166 -52
- package/dist/testSurface/surface/test/pageParts.js +27 -12
- package/dist/testSurface/surface/test/testPage.css +9 -2
- package/dist/testSurface/surface/test/testPage.model.d.ts +1 -0
- package/dist/testSurface/surface/test/testPage.model.js +6 -0
- package/dist/testSurface/surface/testDocument.model.d.ts +3 -0
- package/dist/testSurface/surface/testDocument.model.js +4 -1
- package/dist/testSurface/surface/useTestDocument.d.ts +21 -5
- package/dist/testSurface/surface/useTestDocument.js +472 -167
- package/dist/testSurface/surface/watchTestDocument.d.ts +15 -0
- package/dist/testSurface/surface/watchTestDocument.js +181 -0
- package/dist/testSurface/surfaceUrls.d.ts +1 -0
- package/dist/testSurface/surfaceUrls.js +4 -0
- package/dist/testSurface/useApi.d.ts +8 -5
- package/dist/testSurface/useOnTestReturn.d.ts +2 -0
- package/dist/testSurface/useOnTestReturn.js +27 -0
- package/dist/testSurface/useReadinessPolling.js +3 -1
- 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 +1 -0
- package/dist/transitions/checkStart.js +17 -6
- package/dist/transitions/decide.d.ts +1 -1
- package/dist/transitions/decide.js +5 -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 +12 -8
- package/dist/transitions/nestedPlacementNames.d.ts +2 -2
- package/dist/transitions/nestedPlacementNames.js +4 -5
- package/dist/transitions/pageAddress.d.ts +6 -0
- package/dist/transitions/pageAddress.js +71 -0
- package/dist/transitions/pageVersions.d.ts +1 -1
- package/dist/transitions/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 +8 -7
- package/dist/transitions/placements.d.ts +2 -0
- package/dist/transitions/placements.js +5 -5
- package/dist/transitions/preflightData.d.ts +3 -2
- package/dist/transitions/preflightData.js +77 -43
- 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 +7 -9
- package/dist/transitions/start.js +75 -39
- 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/armKey.d.ts +2 -0
- package/dist/types/armKey.js +1 -0
- package/dist/types/contracts.d.ts +17 -4
- package/dist/types/endpoints.d.ts +89 -17
- package/dist/types/endpoints.js +1 -1
- package/dist/types/runtime.d.ts +15 -9
- package/dist/types/snapshot.d.ts +2 -0
- package/dist/types/surface.d.ts +7 -9
- package/dist/ui/ChipsInput.d.ts +8 -1
- package/dist/ui/ChipsInput.js +17 -4
- package/dist/ui/Dialog.d.ts +21 -2
- package/dist/ui/Dialog.js +101 -4
- package/dist/ui/Inputs.js +0 -1
- package/dist/ui/ui.css +5 -1
- package/package.json +2 -2
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
'use client';
|
|
2
2
|
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
3
|
-
import {
|
|
3
|
+
import { useId, useLayoutEffect, useState } from 'react';
|
|
4
4
|
import { TextInput, NumberInput, Textarea, Select, CheckboxList as UICheckboxList } from '../../../ui/Inputs.js';
|
|
5
|
+
import { Button } from '../../../ui/Button.js';
|
|
6
|
+
import { Banner } from '../../../ui/Feedback.js';
|
|
5
7
|
import { TEST_PAGE as C } from '../../copy/testPage.js';
|
|
6
8
|
import { EDITABLE_BY_STATUS } from '../../../collections/experiments/editability.js';
|
|
7
9
|
import { lockedReason } from '../../lockedNotice.model.js';
|
|
@@ -9,9 +11,9 @@ export function reasonFor(test, field) {
|
|
|
9
11
|
return test.doc ? lockedReason(test.doc.status, field, EDITABLE_BY_STATUS) : null;
|
|
10
12
|
}
|
|
11
13
|
export function save(test, field, patch) {
|
|
12
|
-
if (!test.doc || reasonFor(test, field)) return;
|
|
13
|
-
test.stage(patch());
|
|
14
|
+
if (!test.doc || reasonFor(test, field) || !test.stage(patch())) return false;
|
|
14
15
|
void test.commit();
|
|
16
|
+
return true;
|
|
15
17
|
}
|
|
16
18
|
export function FieldErrors({ test, path }) {
|
|
17
19
|
return /*#__PURE__*/ _jsx(_Fragment, {
|
|
@@ -22,12 +24,11 @@ export function FieldErrors({ test, path }) {
|
|
|
22
24
|
}, key))
|
|
23
25
|
});
|
|
24
26
|
}
|
|
25
|
-
export function ReadOnly({ label, value,
|
|
27
|
+
export function ReadOnly({ label, value, labelAction, hideLabel }) {
|
|
26
28
|
return /*#__PURE__*/ _jsxs("div", {
|
|
27
29
|
className: "xp-read-only",
|
|
28
|
-
title: reason ?? undefined,
|
|
29
30
|
children: [
|
|
30
|
-
/*#__PURE__*/ _jsxs("div", {
|
|
31
|
+
!hideLabel ? /*#__PURE__*/ _jsxs("div", {
|
|
31
32
|
className: "xp-ui-field-label",
|
|
32
33
|
children: [
|
|
33
34
|
/*#__PURE__*/ _jsx("strong", {
|
|
@@ -35,65 +36,178 @@ export function ReadOnly({ label, value, reason, labelAction }) {
|
|
|
35
36
|
}),
|
|
36
37
|
labelAction
|
|
37
38
|
]
|
|
38
|
-
}),
|
|
39
|
+
}) : null,
|
|
39
40
|
/*#__PURE__*/ _jsx("p", {
|
|
40
41
|
children: value
|
|
41
|
-
})
|
|
42
|
-
reason ? /*#__PURE__*/ _jsx("small", {
|
|
43
|
-
children: reason
|
|
44
|
-
}) : null
|
|
42
|
+
})
|
|
45
43
|
]
|
|
46
44
|
});
|
|
47
45
|
}
|
|
48
|
-
|
|
46
|
+
export function useFieldDraft(test, key, label, saved, scope) {
|
|
47
|
+
const { mountDraft, submitDraft, trackDraft } = test;
|
|
48
|
+
const [localEdit, setLocalEdit] = useState(null);
|
|
49
|
+
const edit = mountDraft ? test.fieldDrafts?.[key] : localEdit;
|
|
50
|
+
const conflict = Boolean(edit && !edit.saving && (edit.scope !== scope || edit.base !== saved && edit.value !== saved));
|
|
51
|
+
useLayoutEffect(()=>mountDraft?.(key), [
|
|
52
|
+
key,
|
|
53
|
+
mountDraft
|
|
54
|
+
]);
|
|
55
|
+
const update = (draft)=>mountDraft ? trackDraft(key, draft) : setLocalEdit(draft);
|
|
56
|
+
return {
|
|
57
|
+
value: edit?.value ?? saved,
|
|
58
|
+
dirty: Boolean(edit),
|
|
59
|
+
saving: Boolean(edit?.saving),
|
|
60
|
+
retry: Boolean(edit?.retry),
|
|
61
|
+
conflict,
|
|
62
|
+
change (value) {
|
|
63
|
+
update(value === saved && !conflict ? null : {
|
|
64
|
+
label,
|
|
65
|
+
base: edit?.base ?? saved,
|
|
66
|
+
scope: edit ? edit.scope : scope,
|
|
67
|
+
value
|
|
68
|
+
});
|
|
69
|
+
},
|
|
70
|
+
submit (save) {
|
|
71
|
+
if (submitDraft) submitDraft(key, save);
|
|
72
|
+
else if (save() !== false) update(null);
|
|
73
|
+
},
|
|
74
|
+
discard () {
|
|
75
|
+
update(null);
|
|
76
|
+
}
|
|
77
|
+
};
|
|
78
|
+
}
|
|
79
|
+
export function SavedValueChanged({ id, value, reason, showReason = true, conflict, announce, onKeep, onDiscard }) {
|
|
80
|
+
return /*#__PURE__*/ _jsx("div", {
|
|
81
|
+
id: id,
|
|
82
|
+
className: "xp-field-draft-notice",
|
|
83
|
+
children: /*#__PURE__*/ _jsx(Banner, {
|
|
84
|
+
tone: "error",
|
|
85
|
+
action: /*#__PURE__*/ _jsxs("div", {
|
|
86
|
+
className: "xp-ui-button-group",
|
|
87
|
+
children: [
|
|
88
|
+
onKeep ? /*#__PURE__*/ _jsx(Button, {
|
|
89
|
+
size: "sm",
|
|
90
|
+
onClick: onKeep,
|
|
91
|
+
children: conflict ? C.keepEdit : C.retryEdit
|
|
92
|
+
}) : null,
|
|
93
|
+
/*#__PURE__*/ _jsx(Button, {
|
|
94
|
+
size: "sm",
|
|
95
|
+
variant: "quiet",
|
|
96
|
+
onClick: onDiscard,
|
|
97
|
+
children: C.useSavedValue
|
|
98
|
+
})
|
|
99
|
+
]
|
|
100
|
+
}),
|
|
101
|
+
children: /*#__PURE__*/ _jsxs("span", {
|
|
102
|
+
children: [
|
|
103
|
+
reason ? showReason ? reason : null : conflict ? C.savedValueChanged : null,
|
|
104
|
+
' ',
|
|
105
|
+
onKeep && conflict ? C.conflictChoice : C.draftNotSaved,
|
|
106
|
+
' ',
|
|
107
|
+
C.savedValue,
|
|
108
|
+
" ",
|
|
109
|
+
/*#__PURE__*/ _jsx("strong", {
|
|
110
|
+
children: value || C.emptyValue
|
|
111
|
+
})
|
|
112
|
+
]
|
|
113
|
+
}, announce)
|
|
114
|
+
})
|
|
115
|
+
});
|
|
116
|
+
}
|
|
117
|
+
/** Announce the existing choices again when blur or Enter cannot commit. */ export function useDraftAnnouncement() {
|
|
118
|
+
const [announcement, setAnnouncement] = useState(0);
|
|
119
|
+
return [
|
|
120
|
+
announcement,
|
|
121
|
+
()=>setAnnouncement((count)=>count + 1)
|
|
122
|
+
];
|
|
123
|
+
}
|
|
124
|
+
/** Local typing is intentionally separate from staging: build the current group on commit. */ export function TextEdit({ test, label, draftKey = label, value, preview, onCommit, reason, multiline, placeholder, type = 'text', min, max, required, onDraft, scope, isValid, invalidMessage, hideLabel = false, disabled = false, help }) {
|
|
49
125
|
const id = useId();
|
|
50
|
-
const
|
|
126
|
+
const edit = useFieldDraft(test, draftKey, label, String(value), scope);
|
|
127
|
+
const [announcement, announce] = useDraftAnnouncement();
|
|
51
128
|
const [error, setError] = useState(null);
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
129
|
+
if (error && !edit.dirty) setError(null);
|
|
130
|
+
const discard = ()=>{
|
|
131
|
+
edit.discard();
|
|
132
|
+
onDraft?.(null);
|
|
133
|
+
setError(null);
|
|
134
|
+
};
|
|
135
|
+
const locked = Boolean(reason || disabled);
|
|
136
|
+
const choice = edit.dirty && !edit.saving && (edit.conflict || edit.retry || locked || Boolean(error));
|
|
137
|
+
const choiceId = choice ? `${id}-new-value` : undefined;
|
|
138
|
+
const commit = (confirmed = false)=>{
|
|
139
|
+
if (!edit.dirty || edit.saving) return;
|
|
140
|
+
if (locked || test.stale || choice && !confirmed) {
|
|
141
|
+
announce();
|
|
142
|
+
return;
|
|
143
|
+
}
|
|
144
|
+
const draft = edit.value;
|
|
145
|
+
if (draft === String(value)) {
|
|
146
|
+
discard();
|
|
147
|
+
return;
|
|
148
|
+
}
|
|
58
149
|
if (isValid && !isValid(draft)) {
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
onDraft?.(String(value));
|
|
150
|
+
onDraft?.(null);
|
|
151
|
+
setError(invalidMessage ?? C.editInvalid);
|
|
62
152
|
return;
|
|
63
153
|
}
|
|
64
|
-
onCommit(draft);
|
|
154
|
+
edit.submit(()=>onCommit(draft));
|
|
155
|
+
onDraft?.(null);
|
|
65
156
|
};
|
|
66
|
-
if (reason && !
|
|
157
|
+
if (reason && !edit.dirty) return /*#__PURE__*/ _jsx(ReadOnly, {
|
|
67
158
|
label: label,
|
|
68
|
-
|
|
69
|
-
|
|
159
|
+
hideLabel: hideLabel,
|
|
160
|
+
value: value === '' && placeholder ? placeholder : value
|
|
70
161
|
});
|
|
71
162
|
const Input = multiline ? Textarea : type === 'number' ? NumberInput : TextInput;
|
|
72
|
-
return /*#__PURE__*/
|
|
163
|
+
return /*#__PURE__*/ _jsxs("div", {
|
|
73
164
|
className: hideLabel ? 'xp-grid-field' : undefined,
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
165
|
+
children: [
|
|
166
|
+
/*#__PURE__*/ _jsx(Input, {
|
|
167
|
+
id: id,
|
|
168
|
+
label: label,
|
|
169
|
+
"aria-label": label,
|
|
170
|
+
value: edit.dirty ? edit.value : preview ?? edit.value,
|
|
171
|
+
disabled: disabled && !edit.dirty,
|
|
172
|
+
readOnly: locked || test.stale || edit.saving,
|
|
173
|
+
"aria-describedby": choiceId,
|
|
174
|
+
placeholder: placeholder,
|
|
175
|
+
min: min,
|
|
176
|
+
max: max,
|
|
177
|
+
required: required,
|
|
178
|
+
help: help,
|
|
179
|
+
error: error ?? undefined,
|
|
180
|
+
onChange: (e)=>{
|
|
181
|
+
if (locked || test.stale || edit.saving) return;
|
|
182
|
+
const draft = e.target.value;
|
|
183
|
+
setError(null);
|
|
184
|
+
edit.change(draft);
|
|
185
|
+
onDraft?.(draft === String(value) || edit.conflict ? null : draft);
|
|
186
|
+
},
|
|
187
|
+
onBlur: ()=>commit(),
|
|
188
|
+
onKeyDown: (e)=>{
|
|
189
|
+
if (e.key === 'Escape' && edit.dirty && !edit.saving) {
|
|
190
|
+
e.preventDefault();
|
|
191
|
+
e.stopPropagation();
|
|
192
|
+
discard();
|
|
193
|
+
}
|
|
194
|
+
if (e.key === 'Enter' && !e.nativeEvent.isComposing && (choice || !multiline)) {
|
|
195
|
+
e.preventDefault();
|
|
196
|
+
commit();
|
|
197
|
+
}
|
|
198
|
+
}
|
|
199
|
+
}),
|
|
200
|
+
choiceId ? /*#__PURE__*/ _jsx(SavedValueChanged, {
|
|
201
|
+
id: choiceId,
|
|
202
|
+
value: String(value),
|
|
203
|
+
reason: reason,
|
|
204
|
+
showReason: false,
|
|
205
|
+
conflict: edit.conflict,
|
|
206
|
+
announce: announcement,
|
|
207
|
+
onKeep: !locked && !test.stale && !error ? ()=>commit(true) : undefined,
|
|
208
|
+
onDiscard: discard
|
|
209
|
+
}) : null
|
|
210
|
+
]
|
|
97
211
|
});
|
|
98
212
|
}
|
|
99
213
|
export const positiveInteger = (raw)=>raw.trim() !== '' && Number.isInteger(Number(raw)) && Number(raw) > 0;
|
|
@@ -102,7 +216,6 @@ export function SelectEdit({ label, value, options, groups, reason, onCommit, re
|
|
|
102
216
|
if (reason) {
|
|
103
217
|
return /*#__PURE__*/ _jsx(ReadOnly, {
|
|
104
218
|
label: label,
|
|
105
|
-
reason: reason,
|
|
106
219
|
labelAction: labelAction,
|
|
107
220
|
value: readOnlyValue ?? options.find((o)=>o.value === value)?.label ?? value
|
|
108
221
|
});
|
|
@@ -132,7 +245,6 @@ export function CheckboxList({ label, value, options, reason, onToggle, readOnly
|
|
|
132
245
|
const id = useId();
|
|
133
246
|
if (reason) return /*#__PURE__*/ _jsx(ReadOnly, {
|
|
134
247
|
label: label,
|
|
135
|
-
reason: reason,
|
|
136
248
|
value: readOnlyValue ?? value.map((v)=>options.find((o)=>o.value === v)?.label ?? v).join(', ')
|
|
137
249
|
});
|
|
138
250
|
return /*#__PURE__*/ _jsx(UICheckboxList, {
|
|
@@ -150,6 +262,7 @@ export function TestName({ test }) {
|
|
|
150
262
|
return /*#__PURE__*/ _jsxs(_Fragment, {
|
|
151
263
|
children: [
|
|
152
264
|
/*#__PURE__*/ _jsx(TextEdit, {
|
|
265
|
+
test: test,
|
|
153
266
|
label: C.name,
|
|
154
267
|
value: test.doc?.name ?? '',
|
|
155
268
|
reason: reasonFor(test, 'name'),
|
|
@@ -168,6 +281,7 @@ export function Hypothesis({ test }) {
|
|
|
168
281
|
return /*#__PURE__*/ _jsxs(_Fragment, {
|
|
169
282
|
children: [
|
|
170
283
|
/*#__PURE__*/ _jsx(TextEdit, {
|
|
284
|
+
test: test,
|
|
171
285
|
label: C.hypothesis,
|
|
172
286
|
value: test.doc?.hypothesis ?? '',
|
|
173
287
|
multiline: true,
|
|
@@ -1,5 +1,8 @@
|
|
|
1
1
|
'use client';
|
|
2
2
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
3
|
+
import { useState } from 'react';
|
|
4
|
+
import { holdoutContent } from '../../copy/audience.js';
|
|
5
|
+
import { actionGroupLabel } from '../../actions/actions.model.js';
|
|
3
6
|
import { TEST_PAGE as C } from '../../copy/testPage.js';
|
|
4
7
|
import { pageTargetIssue, setPageTarget, showsPageTarget } from '../../arms/pageTarget.model.js';
|
|
5
8
|
import { normalisePath } from '../../../runtime/normalisePath.js';
|
|
@@ -9,28 +12,35 @@ import { testPageCollection } from '../pagePicker/pagePicker.model.js';
|
|
|
9
12
|
import { PAGE_COPY as P } from '../../copy/pages.js';
|
|
10
13
|
import { FieldErrors, reasonFor, save, TextEdit } from './fields.js';
|
|
11
14
|
export function VersionContent({ test, surface, armIndex }) {
|
|
12
|
-
const
|
|
13
|
-
|
|
14
|
-
|
|
15
|
+
const doc = test.doc;
|
|
16
|
+
const arm = doc?.arms[armIndex];
|
|
17
|
+
const collection = doc && testPageCollection(surface.pageCollections, doc, test.preflight?.pagePlacements);
|
|
18
|
+
const usesAddress = !collection;
|
|
19
|
+
const [wasUsingAddress, setWasUsingAddress] = useState(usesAddress);
|
|
20
|
+
// Readiness can discover a page collection while someone is typing an address.
|
|
21
|
+
const addressKey = `page-address:${arm?.key}`;
|
|
22
|
+
if (!test.fieldDrafts?.[addressKey] && wasUsingAddress !== usesAddress) setWasUsingAddress(usesAddress);
|
|
23
|
+
if (!arm || !doc) return null;
|
|
24
|
+
if (!showsPageTarget(doc.kind, arm.kind)) return /*#__PURE__*/ _jsx("span", {
|
|
15
25
|
className: "xp-content-chip",
|
|
16
|
-
children:
|
|
26
|
+
children: holdoutContent(actionGroupLabel('control', test.doc?.arms.find((arm)=>arm.key === 'control')?.label))
|
|
17
27
|
});
|
|
18
|
-
const collection = testPageCollection(surface.pageCollections, test.doc, test.preflight?.pagePlacements);
|
|
19
28
|
const placement = test.preflight?.pagePlacements?.find((entry)=>entry.arm === arm.key && entry.collection === collection?.slug && entry.id != null && arm.pageTarget && normalisePath(entry.path) === normalisePath(arm.pageTarget));
|
|
20
|
-
if (collection) {
|
|
29
|
+
if (collection && !wasUsingAddress) {
|
|
21
30
|
const picker = /*#__PURE__*/ _jsx(PageCombobox, {
|
|
22
31
|
collection: collection,
|
|
23
32
|
test: test,
|
|
24
33
|
armKey: arm.key,
|
|
25
|
-
apiRoute: surface.apiRoute
|
|
26
|
-
|
|
34
|
+
apiRoute: surface.apiRoute,
|
|
35
|
+
contentLocale: surface.contentLocale
|
|
36
|
+
}, `${collection.slug}-${arm.key}`);
|
|
27
37
|
return /*#__PURE__*/ _jsxs("div", {
|
|
28
38
|
className: "xp-version-content xp-version-content--page",
|
|
29
39
|
children: [
|
|
30
40
|
/*#__PURE__*/ _jsx("strong", {
|
|
31
41
|
children: P.where
|
|
32
42
|
}),
|
|
33
|
-
placement?.id != null ? /*#__PURE__*/ _jsxs("div", {
|
|
43
|
+
placement?.id != null && (arm.kind !== 'variant' || placement.published || doc.status !== 'draft' && doc.status !== 'stopped') ? /*#__PURE__*/ _jsxs("div", {
|
|
34
44
|
children: [
|
|
35
45
|
placement.editorUrl ? /*#__PURE__*/ _jsx("a", {
|
|
36
46
|
href: placement.editorUrl,
|
|
@@ -48,9 +58,12 @@ export function VersionContent({ test, surface, armIndex }) {
|
|
|
48
58
|
]
|
|
49
59
|
}) : null,
|
|
50
60
|
arm.kind === 'variant' ? /*#__PURE__*/ _jsx(CopyRoute, {
|
|
51
|
-
collection: collection
|
|
52
|
-
|
|
53
|
-
|
|
61
|
+
collection: collection,
|
|
62
|
+
arm: arm,
|
|
63
|
+
test: test,
|
|
64
|
+
surface: surface,
|
|
65
|
+
children: picker
|
|
66
|
+
}, `${collection.slug}/${arm.key}`) : picker,
|
|
54
67
|
/*#__PURE__*/ _jsx(FieldErrors, {
|
|
55
68
|
test: test,
|
|
56
69
|
path: `arms.${armIndex}.pageTarget`
|
|
@@ -67,6 +80,8 @@ export function VersionContent({ test, surface, armIndex }) {
|
|
|
67
80
|
children: issue ? C.addPageAddress : C.pageReady
|
|
68
81
|
}),
|
|
69
82
|
/*#__PURE__*/ _jsx(TextEdit, {
|
|
83
|
+
test: test,
|
|
84
|
+
draftKey: addressKey,
|
|
70
85
|
label: `${arm.label}: ${C.pageAddress}`,
|
|
71
86
|
value: arm.pageTarget ?? '',
|
|
72
87
|
reason: reasonFor(test, 'arms'),
|
|
@@ -32,7 +32,11 @@
|
|
|
32
32
|
:where(.xp-test-surface) .xp-ui-checkbox-list { display: flex; flex-wrap: wrap; gap: var(--xp-space-2) var(--xp-space-4); }
|
|
33
33
|
:where(.xp-test-surface) .xp-duration-suggestion { align-items: center; margin-top: var(--xp-space-4); }
|
|
34
34
|
:where(.xp-test-surface) .xp-read-only { padding-block: .5rem; }
|
|
35
|
-
:where(.xp-test-surface) .xp-read-only p { margin-block: .5rem; }
|
|
35
|
+
:where(.xp-test-surface) .xp-read-only p { margin-block: .5rem; color: var(--xp-text); font: var(--xp-text-body); }
|
|
36
|
+
:where(.xp-test-surface) .xp-section-lock { margin-block: 0; }
|
|
37
|
+
:where(.xp-test-surface) .xp-page-binding-row { align-items: center; }
|
|
38
|
+
:where(.xp-test-surface) .xp-page-binding { margin-block-end: var(--xp-space-4); }
|
|
39
|
+
:where(.xp-test-surface) .xp-page-binding > .xp-ui-help { margin-block: var(--xp-space-2) 0; }
|
|
36
40
|
:where(.xp-test-surface) .xp-field-error { color: var(--xp-error-text); }
|
|
37
41
|
|
|
38
42
|
:where(.xp-test-surface) .xp-targeting-row { display: grid; grid-template-columns: var(--xp-targeting-attribute-width) var(--xp-targeting-comparison-width) minmax(0, 1fr); align-items: start; gap: var(--xp-space-3); border: 1px solid var(--xp-border); border-radius: var(--xp-radius-control); padding: var(--xp-space-4); margin-bottom: var(--xp-space-4); }
|
|
@@ -46,6 +50,10 @@
|
|
|
46
50
|
:where(.xp-test-surface) .xp-targeting-row, :where(.xp-test-surface) .xp-field-grid { grid-template-columns: 1fr; }
|
|
47
51
|
}
|
|
48
52
|
|
|
53
|
+
:where(.xp-test-surface) .xp-version-rows.xp-version-rows--setting { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); align-items: start; }
|
|
54
|
+
:where(.xp-test-surface) .xp-version-rows--setting .xp-version-row { align-items: start; }
|
|
55
|
+
:where(.xp-test-surface) .xp-version-rows--setting .xp-setting-values { grid-column: 2; min-width: 0; }
|
|
56
|
+
|
|
49
57
|
:where(.xp-test-surface) .xp-test-layout { display: grid; grid-template-columns: 220px minmax(0, 1fr); align-items: start; gap: var(--xp-space-8); }
|
|
50
58
|
:where(.xp-test-surface) .xp-test-content { display: grid; gap: var(--xp-space-8); min-width: 0; max-width: 760px; }
|
|
51
59
|
:where(.xp-test-surface) .xp-test-rail { position: sticky; top: var(--xp-space-6); min-width: 0; }
|
|
@@ -98,7 +106,6 @@
|
|
|
98
106
|
|
|
99
107
|
:where(.xp-test-surface) .xp-readiness--bar { grid-template-columns: minmax(0, 1fr); }
|
|
100
108
|
:where(.xp-test-surface) .xp-readiness--bar > .xp-readiness__actions { grid-column: 1; grid-row: auto; justify-content: flex-start; }
|
|
101
|
-
:where(.xp-test-surface) .xp-readiness-action-reason { display: block; }
|
|
102
109
|
|
|
103
110
|
:where(.xp-test-surface) .xp-test-advanced.xp-ui-section--blocked { border-color: var(--xp-error-border); }
|
|
104
111
|
:where(.xp-test-surface) .xp-test-rail-mark--blocked { display: grid; place-items: center; width: 20px; height: 20px; border: 1px solid var(--xp-error-border); border-radius: 50%; }
|
|
@@ -4,6 +4,7 @@ export declare function orderedVersions(arms: readonly Arm[]): Array<{
|
|
|
4
4
|
arm: Arm;
|
|
5
5
|
index: number;
|
|
6
6
|
}>;
|
|
7
|
+
export declare function trafficSplit(arms: readonly Arm[]): string;
|
|
7
8
|
/** Normalised visual shares only; invalid saved weights still surface as validation issues. */
|
|
8
9
|
export declare function trafficShares(arms: readonly Arm[]): number[];
|
|
9
10
|
export declare function durationSuggestion(preflight: PreflightResult | null, savedDays?: number | null): {
|
|
@@ -11,6 +11,12 @@ export function orderedVersions(arms) {
|
|
|
11
11
|
index
|
|
12
12
|
})).sort((a, b)=>ORDER.indexOf(a.arm.key) - ORDER.indexOf(b.arm.key));
|
|
13
13
|
}
|
|
14
|
+
export function trafficSplit(arms) {
|
|
15
|
+
return JSON.stringify(arms.map((arm)=>[
|
|
16
|
+
arm.key,
|
|
17
|
+
arm.weight
|
|
18
|
+
]));
|
|
19
|
+
}
|
|
14
20
|
/** Normalised visual shares only; invalid saved weights still surface as validation issues. */ export function trafficShares(arms) {
|
|
15
21
|
const weights = arms.map((arm)=>Number.isFinite(arm.weight) ? Math.max(0, arm.weight) : 0);
|
|
16
22
|
const sum = weights.reduce((a, b)=>a + b, 0);
|
|
@@ -8,6 +8,8 @@ export interface TestDocument {
|
|
|
8
8
|
status: Status;
|
|
9
9
|
kind: ExperimentKind;
|
|
10
10
|
unitType: UnitType;
|
|
11
|
+
phase?: number;
|
|
12
|
+
updatedAt?: string;
|
|
11
13
|
hypothesis?: string | null;
|
|
12
14
|
arms: Arm[];
|
|
13
15
|
targeting?: TargetingRule[] | null;
|
|
@@ -34,6 +36,7 @@ export interface TestDocument {
|
|
|
34
36
|
export type TestDocumentPatch = Partial<Pick<TestDocument, EditableField>>;
|
|
35
37
|
/** Drop unknown and locked keys even when the caller is untyped. Groups replace whole groups. */
|
|
36
38
|
export declare function editablePatch(status: Status, partial: TestDocumentPatch): TestDocumentPatch;
|
|
39
|
+
export declare function sameTestValue(left: unknown, right: unknown): boolean;
|
|
37
40
|
/** Only changed top-level keys go on the wire; arrays and groups remain intact. */
|
|
38
41
|
export declare function changedPatch(saved: TestDocument, staged: TestDocumentPatch): TestDocumentPatch;
|
|
39
42
|
/** Payload validation details may be nested under errors[0].data or top-level data. */
|
|
@@ -28,8 +28,11 @@ function canonical(value) {
|
|
|
28
28
|
]));
|
|
29
29
|
return value;
|
|
30
30
|
}
|
|
31
|
+
export function sameTestValue(left, right) {
|
|
32
|
+
return left === right || JSON.stringify(canonical(left)) === JSON.stringify(canonical(right));
|
|
33
|
+
}
|
|
31
34
|
/** Only changed top-level keys go on the wire; arrays and groups remain intact. */ export function changedPatch(saved, staged) {
|
|
32
|
-
return Object.fromEntries(Object.entries(editablePatch(saved.status, staged)).filter(([key, value])
|
|
35
|
+
return Object.fromEntries(Object.entries(editablePatch(saved.status, staged)).filter(([key, value])=>!sameTestValue(saved[key], value)));
|
|
33
36
|
}
|
|
34
37
|
const object = (value)=>value !== null && typeof value === 'object' && !Array.isArray(value) ? value : undefined;
|
|
35
38
|
/** Payload validation details may be nested under errors[0].data or top-level data. */ export function payloadFieldErrors(envelope, section = '_section', fallback = "Couldn't save these changes. Try again.") {
|
|
@@ -2,19 +2,29 @@ import type { Arm, DocId } from '../../types/contracts.js';
|
|
|
2
2
|
import type { PreflightResult } from '../../types/endpoints.js';
|
|
3
3
|
import { type ReadinessRead } from '../readinessRead.js';
|
|
4
4
|
import type { TestDocument, TestDocumentPatch } from './testDocument.model.js';
|
|
5
|
+
export type FieldDraft = {
|
|
6
|
+
label: string;
|
|
7
|
+
base: string;
|
|
8
|
+
scope?: string;
|
|
9
|
+
value: string;
|
|
10
|
+
saving?: boolean;
|
|
11
|
+
retry?: boolean;
|
|
12
|
+
};
|
|
5
13
|
/** Section data only: staging never saves. Call commit on blur or a section action. */
|
|
6
|
-
export declare function useTestDocument(id: DocId, { apiRoute, contentLocale,
|
|
14
|
+
export declare function useTestDocument(id: DocId, { apiRoute, contentLocale, enabled, onDocument, onPreflight, requestPreflight }: {
|
|
7
15
|
apiRoute: string;
|
|
8
16
|
contentLocale?: string;
|
|
9
|
-
refetchPreflightOnFocus?: boolean;
|
|
10
17
|
enabled?: boolean;
|
|
11
18
|
onDocument?: (doc: TestDocument) => void;
|
|
12
19
|
onPreflight?: (preflight: PreflightResult) => void;
|
|
13
20
|
requestPreflight?: (signal: AbortSignal, supersede?: boolean) => Promise<Response>;
|
|
14
21
|
}): {
|
|
15
|
-
|
|
22
|
+
syncDocument: (read: ReadinessRead | undefined) => void;
|
|
23
|
+
stage: (partial: TestDocumentPatch) => boolean;
|
|
16
24
|
commit: () => Promise<void>;
|
|
17
|
-
reload: (
|
|
25
|
+
reload: ({ discardDrafts }?: {
|
|
26
|
+
discardDrafts?: boolean | undefined;
|
|
27
|
+
}) => Promise<void>;
|
|
18
28
|
refreshPreflight: (supersede?: boolean) => Promise<void>;
|
|
19
29
|
choosePage: (arm: Arm["key"], page: {
|
|
20
30
|
id: DocId;
|
|
@@ -22,6 +32,9 @@ export declare function useTestDocument(id: DocId, { apiRoute, contentLocale, re
|
|
|
22
32
|
title?: string;
|
|
23
33
|
published?: boolean;
|
|
24
34
|
}) => Promise<void>;
|
|
35
|
+
trackDraft: (id: string, draft: FieldDraft | null) => void;
|
|
36
|
+
mountDraft: (id: string) => (() => void) | undefined;
|
|
37
|
+
submitDraft: (id: string, submit: () => void) => void;
|
|
25
38
|
chosenPages: Partial<Record<Arm["key"], {
|
|
26
39
|
id: DocId;
|
|
27
40
|
path: string;
|
|
@@ -33,8 +46,11 @@ export declare function useTestDocument(id: DocId, { apiRoute, contentLocale, re
|
|
|
33
46
|
preflightRead?: ReadinessRead;
|
|
34
47
|
preflightError: string | null;
|
|
35
48
|
preflightPending: boolean;
|
|
36
|
-
/** Includes staged edits and all queued or in-flight PATCHes. */
|
|
49
|
+
/** Includes field drafts, staged edits and all queued or in-flight PATCHes. */
|
|
37
50
|
hasUnsaved: boolean;
|
|
51
|
+
fieldDrafts?: Readonly<Record<string, FieldDraft>>;
|
|
52
|
+
detachedDrafts?: string[];
|
|
53
|
+
statusReadPending?: boolean;
|
|
38
54
|
loadState: "loading" | "ready" | "forbidden" | "missing" | "error";
|
|
39
55
|
saving: "idle" | "saving" | "saved" | "error";
|
|
40
56
|
stale: boolean;
|