@delmaredigital/payload-experiments 0.4.1 → 0.5.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 -5
- package/dist/admin/blocks/model.js +2 -0
- package/dist/admin/copy/blocks.d.ts +1 -0
- package/dist/admin/copy/blocks.js +1 -0
- package/dist/admin/copy/status.d.ts +3 -0
- package/dist/admin/copy/status.js +3 -0
- package/dist/admin/placementStatus.model.js +3 -0
- package/dist/admin/status.model.d.ts +3 -2
- package/dist/admin/status.model.js +9 -3
- package/dist/admin/surface/ResultsRoute.js +2 -1
- package/dist/admin/surface/TestsHome.d.ts +2 -1
- package/dist/admin/surface/TestsHome.js +31 -11
- package/dist/admin/surface/TestsSurface.js +4 -0
- package/dist/admin/surface/home.model.d.ts +11 -6
- package/dist/admin/surface/home.model.js +19 -8
- package/dist/admin/surface/newTest/PageWizard.js +13 -3
- package/dist/admin/surface/results/ResultsHeader.js +43 -9
- package/dist/admin/surface/test/TestPage.js +11 -1
- package/dist/admin/useLayerUsage.d.ts +1 -1
- package/dist/admin/views/buildSurfaceProps.js +3 -0
- package/dist/cohorts/build.d.ts +35 -0
- package/dist/cohorts/build.js +134 -0
- package/dist/cohorts/key.d.ts +12 -0
- package/dist/cohorts/key.js +15 -0
- package/dist/cohorts/maintenance.d.ts +10 -0
- package/dist/cohorts/maintenance.js +70 -0
- package/dist/cohorts/readiness.d.ts +30 -0
- package/dist/cohorts/readiness.js +54 -0
- package/dist/cohorts/readinessData.d.ts +29 -0
- package/dist/cohorts/readinessData.js +123 -0
- package/dist/cohorts/rule.d.ts +33 -0
- package/dist/cohorts/rule.js +50 -0
- package/dist/collections/cohortMembers.d.ts +4 -0
- package/dist/collections/cohortMembers.js +95 -0
- package/dist/collections/experiments/config.js +157 -7
- package/dist/collections/experiments/editability.js +10 -6
- package/dist/collections/experiments/lockHook.js +39 -20
- package/dist/collections/index.js +4 -1
- package/dist/collections/phases.js +4 -1
- package/dist/constants.d.ts +2 -0
- package/dist/constants.js +2 -0
- package/dist/db/adapter.d.ts +1 -1
- package/dist/db/adapter.js +14 -4
- package/dist/db/appends.js +1 -1
- package/dist/db/cohortMembership.d.ts +11 -0
- package/dist/db/cohortMembership.js +31 -0
- package/dist/db/cohortPool.d.ts +9 -0
- package/dist/db/cohortPool.js +53 -0
- package/dist/db/cohortTransactions.d.ts +3 -0
- package/dist/db/cohortTransactions.js +52 -0
- package/dist/db/cohorts.d.ts +72 -0
- package/dist/db/cohorts.js +280 -0
- package/dist/db/erase.d.ts +2 -0
- package/dist/db/erase.js +21 -2
- package/dist/db/events.d.ts +2 -0
- package/dist/db/events.js +8 -0
- package/dist/db/executor.d.ts +2 -0
- package/dist/db/executor.js +8 -0
- package/dist/db/locks.d.ts +7 -0
- package/dist/db/locks.js +13 -1
- package/dist/db/names.d.ts +95 -1
- package/dist/db/names.js +95 -1
- package/dist/db/occupancy.d.ts +21 -0
- package/dist/db/occupancy.js +46 -0
- package/dist/db/pageOccupancy.d.ts +4 -4
- package/dist/db/pageOccupancy.js +13 -10
- package/dist/db/pgExecutor.d.ts +4 -0
- package/dist/db/pgExecutor.js +1 -1
- package/dist/db/placements.js +1 -1
- package/dist/db/results.d.ts +5 -2
- package/dist/db/results.js +32 -5
- package/dist/db/slices.d.ts +9 -2
- package/dist/db/slices.js +15 -8
- package/dist/db/snapshots.d.ts +16 -1
- package/dist/db/snapshots.js +27 -2
- package/dist/db/sql.d.ts +2 -2
- package/dist/db/sql.js +1 -2
- package/dist/endpoints/cohortSources.d.ts +16 -0
- package/dist/endpoints/cohortSources.js +335 -0
- package/dist/endpoints/contentLocale.d.ts +1 -1
- package/dist/endpoints/events.js +82 -18
- package/dist/endpoints/index.js +45 -1
- package/dist/endpoints/pausedBy.d.ts +14 -0
- package/dist/endpoints/pausedBy.js +94 -0
- package/dist/endpoints/preflight.js +4 -1
- package/dist/endpoints/previewToken.js +2 -0
- package/dist/endpoints/results.d.ts +2 -2
- package/dist/endpoints/results.js +111 -3
- package/dist/endpoints/routeId.d.ts +2 -1
- package/dist/endpoints/routeId.js +6 -2
- package/dist/endpoints/summary.js +24 -1
- package/dist/endpoints/transitions.d.ts +7 -0
- package/dist/endpoints/transitions.js +50 -1
- package/dist/events/rows.d.ts +1 -1
- package/dist/events/rows.js +5 -3
- package/dist/exports/index.d.ts +2 -0
- package/dist/exports/index.js +1 -0
- package/dist/exports/runtimeProxy.d.ts +1 -0
- package/dist/exports/runtimeProxy.js +1 -0
- package/dist/hooks/blockRemovalRule.js +7 -4
- package/dist/hooks/pageGuard.js +1 -1
- package/dist/labels/status.d.ts +15 -0
- package/dist/labels/status.js +12 -0
- package/dist/manifest/compile.d.ts +15 -4
- package/dist/manifest/compile.js +91 -3
- package/dist/onInit.js +4 -1
- package/dist/options.d.ts +1 -0
- package/dist/options.js +10 -0
- package/dist/proxy/consentFallback.d.ts +1 -1
- package/dist/proxy/consentFallback.js +4 -4
- package/dist/proxy/control.d.ts +1 -1
- package/dist/proxy/control.js +2 -2
- package/dist/proxy/pageRewrite.d.ts +1 -1
- package/dist/proxy/pageRewrite.js +3 -2
- package/dist/proxy/resolve.js +76 -17
- package/dist/puck/ExperimentPicker.js +2 -1
- package/dist/puck/copy.d.ts +6 -5
- package/dist/puck/copy.js +3 -7
- package/dist/puck/editor/ExperimentSlotEditor.js +16 -5
- package/dist/puck/editor/QuickTestActions.js +7 -1
- package/dist/puck/editor/armWrites.js +6 -1
- package/dist/puck/editor/copy.d.ts +3 -0
- package/dist/puck/editor/copy.js +3 -0
- package/dist/puck/editor/editor.css +2 -1
- package/dist/puck/editor/editor.model.d.ts +2 -1
- package/dist/puck/editor/editor.model.js +2 -0
- package/dist/puck/editor/placementsCache.d.ts +1 -1
- package/dist/puck/editor/placementsCache.js +6 -3
- package/dist/results/analyse.d.ts +3 -1
- package/dist/results/analyse.js +20 -3
- package/dist/results/health.d.ts +11 -0
- package/dist/results/health.js +38 -0
- package/dist/results/power.d.ts +1 -1
- package/dist/results/power.js +1 -1
- package/dist/results/snapshot.d.ts +8 -2
- package/dist/results/snapshot.js +23 -1
- package/dist/results/unitValues.d.ts +48 -0
- package/dist/results/unitValues.js +166 -0
- package/dist/runtime/assign.d.ts +7 -3
- package/dist/runtime/assign.js +12 -4
- package/dist/runtime/cohortCookie.d.ts +15 -0
- package/dist/runtime/cohortCookie.js +72 -0
- package/dist/runtime/cohortLookup.d.ts +9 -0
- package/dist/runtime/cohortLookup.js +25 -0
- package/dist/runtime/eligibility.d.ts +11 -5
- package/dist/runtime/eligibility.js +33 -7
- package/dist/runtime/header.d.ts +1 -0
- package/dist/runtime/header.js +1 -1
- package/dist/runtime/proxyRuntime.js +5 -1
- package/dist/runtime/targeting.d.ts +3 -2
- package/dist/runtime/targeting.js +2 -1
- package/dist/sanitizeReadinessDetail.d.ts +2 -2
- package/dist/sanitizeReadinessDetail.js +41 -4
- package/dist/schedule/activeTime.d.ts +28 -0
- package/dist/schedule/activeTime.js +322 -0
- package/dist/schedule/ranges.d.ts +13 -0
- package/dist/schedule/ranges.js +11 -0
- package/dist/schedule/roundTime.d.ts +10 -0
- package/dist/schedule/roundTime.js +45 -0
- package/dist/schedule/types.d.ts +29 -0
- package/dist/schedule/types.js +1 -0
- package/dist/server/cohortLookup.d.ts +3 -0
- package/dist/server/cohortLookup.js +7 -0
- package/dist/server/eraseUser.d.ts +1 -0
- package/dist/server/getAssignments.js +63 -40
- package/dist/server/previewDraft.d.ts +1 -1
- package/dist/server/previewDraft.js +3 -2
- package/dist/server/recordExposures.js +4 -2
- package/dist/server/runResults.js +97 -150
- package/dist/testSurface/actions/LifecycleAction.d.ts +2 -1
- package/dist/testSurface/actions/LifecycleAction.js +15 -5
- package/dist/testSurface/actions/actions.model.d.ts +13 -2
- package/dist/testSurface/actions/actions.model.js +38 -5
- package/dist/testSurface/api.d.ts +13 -1
- package/dist/testSurface/api.js +19 -0
- package/dist/testSurface/copy/actions.d.ts +13 -0
- package/dist/testSurface/copy/actions.js +13 -0
- package/dist/testSurface/copy/cohorts.d.ts +68 -0
- package/dist/testSurface/copy/cohorts.js +81 -0
- package/dist/testSurface/copy/common.d.ts +2 -3
- package/dist/testSurface/copy/common.js +4 -4
- package/dist/testSurface/copy/inputs.d.ts +3 -0
- package/dist/testSurface/copy/inputs.js +3 -0
- package/dist/testSurface/copy/readiness.d.ts +20 -6
- package/dist/testSurface/copy/readiness.js +42 -9
- package/dist/testSurface/copy/results.d.ts +1 -0
- package/dist/testSurface/copy/results.js +1 -0
- package/dist/testSurface/copy/schedule.d.ts +58 -0
- package/dist/testSurface/copy/schedule.js +150 -0
- package/dist/testSurface/copy/surface.d.ts +2 -0
- package/dist/testSurface/copy/surface.js +2 -0
- package/dist/testSurface/copy/testPage.d.ts +12 -2
- package/dist/testSurface/copy/testPage.js +17 -2
- package/dist/testSurface/format/roundProgress.d.ts +13 -1
- package/dist/testSurface/format/roundProgress.js +34 -5
- package/dist/testSurface/format/scheduleStatus.d.ts +34 -0
- package/dist/testSurface/format/scheduleStatus.js +93 -0
- package/dist/testSurface/format/useScheduleClock.d.ts +3 -0
- package/dist/testSurface/format/useScheduleClock.js +20 -0
- package/dist/testSurface/labels.d.ts +4 -9
- package/dist/testSurface/labels.js +2 -7
- package/dist/testSurface/lockedNotice.model.d.ts +2 -2
- package/dist/testSurface/lockedNotice.model.js +16 -3
- package/dist/testSurface/readPreflight.d.ts +3 -0
- package/dist/testSurface/readPreflight.js +14 -0
- package/dist/testSurface/readinessRead.d.ts +2 -2
- package/dist/testSurface/results/DataQualityPanel.js +7 -7
- package/dist/testSurface/results/results.model.d.ts +1 -1
- package/dist/testSurface/results/results.model.js +34 -6
- package/dist/testSurface/review/cohortEstimate.d.ts +11 -0
- package/dist/testSurface/review/cohortEstimate.js +32 -0
- package/dist/testSurface/surface/contracts.d.ts +2 -1
- package/dist/testSurface/surface/contracts.js +1 -0
- package/dist/testSurface/surface/editorPlacement.d.ts +1 -0
- package/dist/testSurface/surface/readiness/ActionDialogs.d.ts +3 -2
- package/dist/testSurface/surface/readiness/ActionDialogs.js +121 -32
- package/dist/testSurface/surface/readiness/Banner.js +29 -11
- package/dist/testSurface/surface/readiness/readiness.model.d.ts +20 -2
- package/dist/testSurface/surface/readiness/readiness.model.js +35 -5
- package/dist/testSurface/surface/readiness/useTransition.js +17 -5
- package/dist/testSurface/surface/results/ResultsBody.js +44 -8
- package/dist/testSurface/surface/results/useResults.d.ts +16 -1
- package/dist/testSurface/surface/results/useResults.js +17 -6
- package/dist/testSurface/surface/test/CohortRuleEditor.d.ts +16 -0
- package/dist/testSurface/surface/test/CohortRuleEditor.js +492 -0
- package/dist/testSurface/surface/test/LengthSection.js +26 -6
- package/dist/testSurface/surface/test/ScheduleDateInput.d.ts +4 -0
- package/dist/testSurface/surface/test/ScheduleDateInput.js +15 -0
- package/dist/testSurface/surface/test/ScheduleSection.d.ts +2 -0
- package/dist/testSurface/surface/test/ScheduleSection.js +322 -0
- package/dist/testSurface/surface/test/Section.js +1 -1
- package/dist/testSurface/surface/test/TargetingSection.js +306 -182
- package/dist/testSurface/surface/test/TestSurface.js +9 -0
- package/dist/testSurface/surface/test/fields.d.ts +2 -1
- package/dist/testSurface/surface/test/fields.js +3 -3
- package/dist/testSurface/surface/test/jumpToSection.d.ts +1 -1
- package/dist/testSurface/surface/test/jumpToSection.js +4 -4
- package/dist/testSurface/surface/test/testPage.css +26 -0
- package/dist/testSurface/surface/testDocument.model.d.ts +12 -1
- package/dist/testSurface/surface/testDocument.model.js +2 -1
- package/dist/testSurface/surface/useTestDocument.js +11 -4
- package/dist/testSurface/targeting/targeting.model.d.ts +2 -1
- package/dist/testSurface/targeting/targeting.model.js +1 -1
- package/dist/testSurface/useApi.d.ts +12 -0
- package/dist/transitions/addMetric.js +5 -2
- package/dist/transitions/allocate.js +6 -1
- package/dist/transitions/assertNoOverlap.d.ts +9 -0
- package/dist/transitions/assertNoOverlap.js +24 -0
- package/dist/transitions/buildCohorts.d.ts +10 -0
- package/dist/transitions/buildCohorts.js +68 -0
- package/dist/transitions/cancelSchedule.d.ts +4 -0
- package/dist/transitions/cancelSchedule.js +42 -0
- package/dist/transitions/checkStart.d.ts +17 -3
- package/dist/transitions/checkStart.js +20 -7
- package/dist/transitions/decide.js +35 -11
- package/dist/transitions/kernel.d.ts +3 -1
- package/dist/transitions/kernel.js +5 -2
- package/dist/transitions/pause.d.ts +4 -0
- package/dist/transitions/pause.js +35 -0
- package/dist/transitions/phaseRecord.d.ts +19 -2
- package/dist/transitions/phaseRecord.js +50 -11
- package/dist/transitions/placementInteractions.js +1 -1
- package/dist/transitions/preflightData.d.ts +11 -3
- package/dist/transitions/preflightData.js +134 -81
- package/dist/transitions/reschedule.d.ts +4 -0
- package/dist/transitions/reschedule.js +58 -0
- package/dist/transitions/resume.d.ts +4 -0
- package/dist/transitions/resume.js +32 -0
- package/dist/transitions/scheduledRound.d.ts +18 -0
- package/dist/transitions/scheduledRound.js +42 -0
- package/dist/transitions/start.d.ts +4 -0
- package/dist/transitions/start.js +136 -55
- package/dist/transitions/startReads.d.ts +14 -0
- package/dist/transitions/startReads.js +27 -0
- package/dist/transitions/stop.d.ts +10 -0
- package/dist/transitions/stop.js +35 -22
- package/dist/types/admin.d.ts +1 -1
- package/dist/types/contracts.d.ts +7 -1
- package/dist/types/endpoints.d.ts +72 -3
- package/dist/types/manifest.d.ts +9 -0
- package/dist/types/runtime.d.ts +5 -0
- package/dist/types/snapshot.d.ts +10 -0
- package/dist/types/status.d.ts +1 -0
- package/dist/types/status.js +1 -0
- package/dist/types/surface.d.ts +1 -0
- package/dist/ui/Feedback.d.ts +9 -6
- package/dist/ui/Feedback.js +10 -9
- package/dist/ui/SelectControl.js +1 -1
- package/dist/ui/ui.css +2 -1
- package/package.json +2 -2
|
@@ -1,221 +1,345 @@
|
|
|
1
1
|
'use client';
|
|
2
2
|
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
3
3
|
import { Button } from '../../../ui/Button.js';
|
|
4
|
-
import { useId, useState } from 'react';
|
|
4
|
+
import { Fragment, useEffect, useId, useRef, useState } from 'react';
|
|
5
5
|
import { ChipsInput } from '../../../ui/ChipsInput.js';
|
|
6
6
|
import { AUDIENCE_COPY } from '../../copy/audience.js';
|
|
7
|
+
import { readCohortRule, writeCohortRule } from '../../../cohorts/rule.js';
|
|
8
|
+
import { COHORT_COPY, COHORT_EDITOR, cohortRuleSummary } from '../../copy/cohorts.js';
|
|
9
|
+
import { sameTestValue } from '../testDocument.model.js';
|
|
7
10
|
import { coerceValue, emptyListHint, humaniseAttribute, opLabel, opsFor, readListValue, readTargetingRules, valueInput } from '../../targeting/targeting.model.js';
|
|
8
11
|
import { TEST_PAGE as C, NUMBER_COMPARISONS } from '../../copy/testPage.js';
|
|
9
12
|
import { CheckboxList, FieldErrors, ReadOnly, reasonFor, save, SavedValueChanged, SelectEdit, TextEdit, useDraftAnnouncement, useFieldDraft } from './fields.js';
|
|
10
13
|
import { Section } from './Section.js';
|
|
14
|
+
import { CohortRuleEditor, EMPTY_COHORT_RULE } from './CohortRuleEditor.js';
|
|
11
15
|
export function TargetingSection({ test, surface }) {
|
|
12
16
|
const id = useId();
|
|
13
17
|
const doc = test.doc;
|
|
14
18
|
const rules = readTargetingRules(doc.targeting ?? []);
|
|
15
19
|
// Removing a row invalidates index-based drafts, including unfinished chip text.
|
|
16
20
|
const [rowsRevision, setRowsRevision] = useState(0);
|
|
21
|
+
const [pending, setPending] = useState([]);
|
|
22
|
+
const nextDraft = useRef(0);
|
|
23
|
+
const [remembered, setRemembered] = useState({});
|
|
24
|
+
const sourceFor = (id)=>{
|
|
25
|
+
const picked = remembered[id];
|
|
26
|
+
const saved = test.preflight?.cohortSources?.find((source)=>String(source.id) === id);
|
|
27
|
+
return picked?.preflight === test.preflight ? picked?.source ?? saved : saved ?? picked?.source;
|
|
28
|
+
};
|
|
29
|
+
const onSource = (source)=>setRemembered((current)=>({
|
|
30
|
+
...current,
|
|
31
|
+
[String(source.id)]: {
|
|
32
|
+
source,
|
|
33
|
+
preflight: test.preflight
|
|
34
|
+
}
|
|
35
|
+
}));
|
|
17
36
|
const reason = reasonFor(test, 'targeting');
|
|
18
37
|
const update = (transform)=>save(test, 'targeting', ()=>({
|
|
19
38
|
targeting: transform(readTargetingRules(test.doc.targeting ?? []))
|
|
20
39
|
}));
|
|
40
|
+
const remove = (index, cohort)=>{
|
|
41
|
+
if (!update((current)=>current.filter((row, i)=>i !== index || row.kind === 'cohort' !== cohort))) return;
|
|
42
|
+
setRowsRevision((revision)=>revision + 1);
|
|
43
|
+
setPending((rows)=>rows.map((row)=>row.before > index ? {
|
|
44
|
+
...row,
|
|
45
|
+
before: row.before - 1
|
|
46
|
+
} : row));
|
|
47
|
+
};
|
|
48
|
+
const storedRowKey = (row, index)=>row.kind === 'cohort' ? 'id' in row && row.id != null ? `cohort:${row.id}` : `cohort:${rowsRevision}:${index}:${JSON.stringify(row)}` : `row:${rowsRevision}:${index}`;
|
|
49
|
+
const newDraftKey = (id)=>`cohort-new:${id}`;
|
|
50
|
+
const inserted = pending.find((row)=>row.submitted && !test.fieldDrafts?.[newDraftKey(row.id)]?.retry && sameTestValue(readCohortRule(rules[row.before]), row.submitted));
|
|
51
|
+
const savedInsert = inserted && !test.fieldDrafts?.[newDraftKey(inserted.id)] ? inserted : undefined;
|
|
52
|
+
// Until PATCH settles, keep the same mounted editor and hide its optimistic copy.
|
|
53
|
+
useEffect(()=>{
|
|
54
|
+
if (!savedInsert) return;
|
|
55
|
+
setPending((rows)=>rows.filter((row)=>row.id !== savedInsert.id).map((row)=>row.before > savedInsert.before || row.before === savedInsert.before && row.id > savedInsert.id ? {
|
|
56
|
+
...row,
|
|
57
|
+
before: row.before + 1
|
|
58
|
+
} : row));
|
|
59
|
+
}, [
|
|
60
|
+
savedInsert
|
|
61
|
+
]);
|
|
62
|
+
const pendingAt = (before)=>reason ? [] : pending.filter((row)=>Math.min(row.before, rules.length) === before).map((row)=>/*#__PURE__*/ _jsx(CohortRuleEditor, {
|
|
63
|
+
draftId: newDraftKey(row.id),
|
|
64
|
+
index: before,
|
|
65
|
+
pending: true,
|
|
66
|
+
saved: EMPTY_COHORT_RULE,
|
|
67
|
+
test: test,
|
|
68
|
+
surface: surface,
|
|
69
|
+
sourceFor: sourceFor,
|
|
70
|
+
onSource: onSource,
|
|
71
|
+
onRemove: ()=>setPending((rows)=>rows.filter((item)=>item.id !== row.id)),
|
|
72
|
+
onDiscard: ()=>setPending((rows)=>rows.map((item)=>item.id === row.id ? {
|
|
73
|
+
...item,
|
|
74
|
+
submitted: undefined
|
|
75
|
+
} : item)),
|
|
76
|
+
onSave: (rule)=>{
|
|
77
|
+
if (!update((current)=>[
|
|
78
|
+
...current.slice(0, before),
|
|
79
|
+
writeCohortRule(rule),
|
|
80
|
+
...current.slice(before)
|
|
81
|
+
])) return false;
|
|
82
|
+
setPending((rows)=>rows.map((item)=>item.id === row.id ? {
|
|
83
|
+
...item,
|
|
84
|
+
before,
|
|
85
|
+
submitted: rule
|
|
86
|
+
} : item));
|
|
87
|
+
return true;
|
|
88
|
+
}
|
|
89
|
+
}, newDraftKey(row.id)));
|
|
21
90
|
// Page block tests are scoped by their page; path rules belong to setting and flag tests (ruling Nov 3).
|
|
22
91
|
const blockPath = (key)=>test.doc.kind === 'block' && key === 'path';
|
|
23
92
|
const keys = Object.keys(surface.attributeKeys).filter((key)=>!blockPath(key));
|
|
93
|
+
const renderRow = (rule, index)=>{
|
|
94
|
+
if (rule.kind === 'cohort') {
|
|
95
|
+
const cohort = readCohortRule(rule);
|
|
96
|
+
const summary = test.preflight?.cohortSummaries?.find((item)=>sameTestValue(item.rule, cohort))?.summary;
|
|
97
|
+
if (reason) return /*#__PURE__*/ _jsx("p", {
|
|
98
|
+
id: `xp-targeting-${index}`,
|
|
99
|
+
tabIndex: -1,
|
|
100
|
+
children: summary ?? (cohort ? cohortRuleSummary(cohort) : COHORT_COPY.unavailable)
|
|
101
|
+
});
|
|
102
|
+
return /*#__PURE__*/ _jsx(CohortRuleEditor, {
|
|
103
|
+
test: test,
|
|
104
|
+
surface: surface,
|
|
105
|
+
index: index,
|
|
106
|
+
draftId: storedRowKey(rule, index),
|
|
107
|
+
saved: cohort ?? EMPTY_COHORT_RULE,
|
|
108
|
+
sourceFor: sourceFor,
|
|
109
|
+
onSource: onSource,
|
|
110
|
+
onRemove: ()=>remove(index, true),
|
|
111
|
+
onSave: (next)=>update((current)=>current.map((row, i)=>i === index && row.kind === 'cohort' ? {
|
|
112
|
+
...writeCohortRule(next),
|
|
113
|
+
...'id' in row ? {
|
|
114
|
+
id: row.id
|
|
115
|
+
} : {}
|
|
116
|
+
} : row))
|
|
117
|
+
});
|
|
118
|
+
}
|
|
119
|
+
const removeRule = ()=>remove(index, false);
|
|
120
|
+
if (blockPath(rule.attribute)) return /*#__PURE__*/ _jsxs("div", {
|
|
121
|
+
className: "xp-targeting-row",
|
|
122
|
+
children: [
|
|
123
|
+
/*#__PURE__*/ _jsx("p", {
|
|
124
|
+
className: "xp-ui-help",
|
|
125
|
+
children: C.blockPathRule
|
|
126
|
+
}),
|
|
127
|
+
/*#__PURE__*/ _jsx(FieldErrors, {
|
|
128
|
+
test: test,
|
|
129
|
+
path: `targeting.${index}`
|
|
130
|
+
}),
|
|
131
|
+
!reason ? /*#__PURE__*/ _jsx("div", {
|
|
132
|
+
className: "xp-ui-button-group",
|
|
133
|
+
children: /*#__PURE__*/ _jsx(Button, {
|
|
134
|
+
variant: "link",
|
|
135
|
+
size: "sm",
|
|
136
|
+
onClick: removeRule,
|
|
137
|
+
children: C.removeRule
|
|
138
|
+
})
|
|
139
|
+
}) : null
|
|
140
|
+
]
|
|
141
|
+
});
|
|
142
|
+
const attribute = surface.attributeKeys[rule.attribute];
|
|
143
|
+
const input = valueInput(attribute, rule.op);
|
|
144
|
+
const setRule = (partial)=>update((current)=>current.map((row, i)=>i === index && row.kind !== 'cohort' ? {
|
|
145
|
+
...row,
|
|
146
|
+
...partial
|
|
147
|
+
} : row));
|
|
148
|
+
const hint = emptyListHint(rule.op, rule.value);
|
|
149
|
+
const draftKey = JSON.stringify([
|
|
150
|
+
'targeting',
|
|
151
|
+
rowsRevision,
|
|
152
|
+
index,
|
|
153
|
+
rule.attribute,
|
|
154
|
+
rule.op,
|
|
155
|
+
rules.length
|
|
156
|
+
]);
|
|
157
|
+
const changeValue = (raw)=>{
|
|
158
|
+
const current = test.doc.targeting?.[index];
|
|
159
|
+
const schema = current && current.kind !== 'cohort' && surface.attributeKeys[current.attribute];
|
|
160
|
+
if (!current || current.kind === 'cohort' || !schema) return false;
|
|
161
|
+
const value = coerceValue(schema.type, current.op, raw);
|
|
162
|
+
return value !== null && setRule({
|
|
163
|
+
value
|
|
164
|
+
});
|
|
165
|
+
};
|
|
166
|
+
return /*#__PURE__*/ _jsxs("div", {
|
|
167
|
+
className: "xp-targeting-row",
|
|
168
|
+
children: [
|
|
169
|
+
/*#__PURE__*/ _jsx(SelectEdit, {
|
|
170
|
+
label: C.attribute,
|
|
171
|
+
reason: reason,
|
|
172
|
+
value: rule.attribute,
|
|
173
|
+
options: [
|
|
174
|
+
...keys,
|
|
175
|
+
...!attribute ? [
|
|
176
|
+
rule.attribute
|
|
177
|
+
] : []
|
|
178
|
+
].map((key)=>({
|
|
179
|
+
value: key,
|
|
180
|
+
label: humaniseAttribute(key)
|
|
181
|
+
})),
|
|
182
|
+
onCommit: (value)=>{
|
|
183
|
+
const key = String(value);
|
|
184
|
+
const type = surface.attributeKeys[key].type;
|
|
185
|
+
setRule({
|
|
186
|
+
attribute: key,
|
|
187
|
+
op: 'eq',
|
|
188
|
+
value: type === 'boolean' ? false : type === 'number' ? 0 : ''
|
|
189
|
+
});
|
|
190
|
+
}
|
|
191
|
+
}),
|
|
192
|
+
/*#__PURE__*/ _jsx(SelectEdit, {
|
|
193
|
+
label: C.comparison,
|
|
194
|
+
reason: reason,
|
|
195
|
+
value: rule.op,
|
|
196
|
+
options: opsFor(attribute?.type).map((op)=>({
|
|
197
|
+
value: op,
|
|
198
|
+
label: attribute?.type === 'number' ? NUMBER_COMPARISONS[op] : opLabel(attribute.type, op)
|
|
199
|
+
})),
|
|
200
|
+
onCommit: (value)=>{
|
|
201
|
+
const op = value;
|
|
202
|
+
const current = readTargetingRules(test.doc.targeting ?? [])[index];
|
|
203
|
+
setRule({
|
|
204
|
+
op,
|
|
205
|
+
value: coerceValue(attribute.type, op, current?.kind === 'cohort' ? undefined : current?.value) ?? ''
|
|
206
|
+
});
|
|
207
|
+
}
|
|
208
|
+
}),
|
|
209
|
+
input.kind === 'multiselect' ? /*#__PURE__*/ _jsx(CheckboxList, {
|
|
210
|
+
label: C.value,
|
|
211
|
+
reason: reason,
|
|
212
|
+
value: readListValue(rule.value),
|
|
213
|
+
options: input.options ?? [],
|
|
214
|
+
onToggle: (value, checked)=>{
|
|
215
|
+
const latest = test.doc.targeting?.[index];
|
|
216
|
+
const values = readListValue(latest?.kind === 'cohort' ? undefined : latest?.value);
|
|
217
|
+
changeValue(checked ? [
|
|
218
|
+
...new Set([
|
|
219
|
+
...values,
|
|
220
|
+
value
|
|
221
|
+
])
|
|
222
|
+
] : values.filter((saved)=>saved !== value));
|
|
223
|
+
}
|
|
224
|
+
}) : input.kind === 'chips' ? /*#__PURE__*/ _jsx(TargetingChips, {
|
|
225
|
+
draftKey: draftKey,
|
|
226
|
+
test: test,
|
|
227
|
+
id: `${id}-${index}-value`,
|
|
228
|
+
label: C.targetingValue(humaniseAttribute(rule.attribute)),
|
|
229
|
+
values: readListValue(rule.value),
|
|
230
|
+
reason: reason,
|
|
231
|
+
onCommit: changeValue
|
|
232
|
+
}, draftKey) : input.kind === 'select' ? /*#__PURE__*/ _jsx(SelectEdit, {
|
|
233
|
+
label: C.value,
|
|
234
|
+
reason: reason,
|
|
235
|
+
value: String(rule.value),
|
|
236
|
+
options: input.options ?? [],
|
|
237
|
+
onCommit: changeValue
|
|
238
|
+
}) : input.kind === 'boolean' ? /*#__PURE__*/ _jsx(SelectEdit, {
|
|
239
|
+
label: C.value,
|
|
240
|
+
reason: reason,
|
|
241
|
+
value: String(rule.value),
|
|
242
|
+
options: [
|
|
243
|
+
{
|
|
244
|
+
value: 'true',
|
|
245
|
+
label: C.yes
|
|
246
|
+
},
|
|
247
|
+
{
|
|
248
|
+
value: 'false',
|
|
249
|
+
label: C.no
|
|
250
|
+
}
|
|
251
|
+
],
|
|
252
|
+
onCommit: changeValue
|
|
253
|
+
}) : /*#__PURE__*/ _jsx(TextEdit, {
|
|
254
|
+
test: test,
|
|
255
|
+
draftKey: draftKey,
|
|
256
|
+
label: C.value,
|
|
257
|
+
reason: reason,
|
|
258
|
+
value: Array.isArray(rule.value) ? rule.value.join(', ') : String(rule.value),
|
|
259
|
+
type: input.kind === 'number' ? 'number' : 'text',
|
|
260
|
+
onCommit: changeValue
|
|
261
|
+
}),
|
|
262
|
+
hint ? /*#__PURE__*/ _jsx("p", {
|
|
263
|
+
children: hint
|
|
264
|
+
}) : null,
|
|
265
|
+
/*#__PURE__*/ _jsx(FieldErrors, {
|
|
266
|
+
test: test,
|
|
267
|
+
path: `targeting.${index}`
|
|
268
|
+
}),
|
|
269
|
+
!reason ? /*#__PURE__*/ _jsx("div", {
|
|
270
|
+
className: "xp-ui-button-group",
|
|
271
|
+
children: /*#__PURE__*/ _jsx(Button, {
|
|
272
|
+
variant: "link",
|
|
273
|
+
size: "sm",
|
|
274
|
+
onClick: removeRule,
|
|
275
|
+
children: C.removeRule
|
|
276
|
+
})
|
|
277
|
+
}) : null
|
|
278
|
+
]
|
|
279
|
+
});
|
|
280
|
+
};
|
|
24
281
|
return /*#__PURE__*/ _jsxs(Section, {
|
|
25
282
|
surface: surface,
|
|
26
283
|
test: test,
|
|
27
284
|
sectionId: "who",
|
|
28
285
|
children: [
|
|
29
286
|
/*#__PURE__*/ _jsx("p", {
|
|
30
|
-
children: rules.length ? C.rulesSummary : C.everyone
|
|
31
|
-
}),
|
|
32
|
-
rules.map((rule, index)=>{
|
|
33
|
-
const remove = ()=>{
|
|
34
|
-
setRowsRevision((revision)=>revision + 1);
|
|
35
|
-
update((current)=>current.filter((_, i)=>i !== index));
|
|
36
|
-
};
|
|
37
|
-
if (blockPath(rule.attribute)) return /*#__PURE__*/ _jsxs("div", {
|
|
38
|
-
className: "xp-targeting-row",
|
|
39
|
-
children: [
|
|
40
|
-
/*#__PURE__*/ _jsx("p", {
|
|
41
|
-
className: "xp-ui-help",
|
|
42
|
-
children: C.blockPathRule
|
|
43
|
-
}),
|
|
44
|
-
!reason ? /*#__PURE__*/ _jsx("div", {
|
|
45
|
-
className: "xp-ui-button-group",
|
|
46
|
-
children: /*#__PURE__*/ _jsx(Button, {
|
|
47
|
-
variant: "link",
|
|
48
|
-
size: "sm",
|
|
49
|
-
onClick: remove,
|
|
50
|
-
children: C.removeRule
|
|
51
|
-
})
|
|
52
|
-
}) : null
|
|
53
|
-
]
|
|
54
|
-
}, `${rowsRevision}-${index}`);
|
|
55
|
-
const attribute = surface.attributeKeys[rule.attribute];
|
|
56
|
-
const input = valueInput(attribute, rule.op);
|
|
57
|
-
const setRule = (partial)=>update((current)=>current.map((row, i)=>i === index ? {
|
|
58
|
-
...row,
|
|
59
|
-
...partial
|
|
60
|
-
} : row));
|
|
61
|
-
const hint = emptyListHint(rule.op, rule.value);
|
|
62
|
-
const draftKey = JSON.stringify([
|
|
63
|
-
'targeting',
|
|
64
|
-
rowsRevision,
|
|
65
|
-
index,
|
|
66
|
-
rule.attribute,
|
|
67
|
-
rule.op,
|
|
68
|
-
rules.length
|
|
69
|
-
]);
|
|
70
|
-
const changeValue = (raw)=>{
|
|
71
|
-
const current = test.doc.targeting?.[index];
|
|
72
|
-
const schema = current && surface.attributeKeys[current.attribute];
|
|
73
|
-
if (!current || !schema) return false;
|
|
74
|
-
const value = coerceValue(schema.type, current.op, raw);
|
|
75
|
-
return value !== null && setRule({
|
|
76
|
-
value
|
|
77
|
-
});
|
|
78
|
-
};
|
|
79
|
-
return /*#__PURE__*/ _jsxs("div", {
|
|
80
|
-
className: "xp-targeting-row",
|
|
81
|
-
children: [
|
|
82
|
-
/*#__PURE__*/ _jsx(SelectEdit, {
|
|
83
|
-
label: C.attribute,
|
|
84
|
-
reason: reason,
|
|
85
|
-
value: rule.attribute,
|
|
86
|
-
options: [
|
|
87
|
-
...keys,
|
|
88
|
-
...!attribute ? [
|
|
89
|
-
rule.attribute
|
|
90
|
-
] : []
|
|
91
|
-
].map((key)=>({
|
|
92
|
-
value: key,
|
|
93
|
-
label: humaniseAttribute(key)
|
|
94
|
-
})),
|
|
95
|
-
onCommit: (value)=>{
|
|
96
|
-
const key = String(value);
|
|
97
|
-
const type = surface.attributeKeys[key].type;
|
|
98
|
-
setRule({
|
|
99
|
-
attribute: key,
|
|
100
|
-
op: 'eq',
|
|
101
|
-
value: type === 'boolean' ? false : type === 'number' ? 0 : ''
|
|
102
|
-
});
|
|
103
|
-
}
|
|
104
|
-
}),
|
|
105
|
-
/*#__PURE__*/ _jsx(SelectEdit, {
|
|
106
|
-
label: C.comparison,
|
|
107
|
-
reason: reason,
|
|
108
|
-
value: rule.op,
|
|
109
|
-
options: opsFor(attribute?.type).map((op)=>({
|
|
110
|
-
value: op,
|
|
111
|
-
label: attribute?.type === 'number' ? NUMBER_COMPARISONS[op] : opLabel(attribute.type, op)
|
|
112
|
-
})),
|
|
113
|
-
onCommit: (value)=>{
|
|
114
|
-
const op = value;
|
|
115
|
-
const current = readTargetingRules(test.doc.targeting ?? [])[index];
|
|
116
|
-
setRule({
|
|
117
|
-
op,
|
|
118
|
-
value: coerceValue(attribute.type, op, current?.value) ?? ''
|
|
119
|
-
});
|
|
120
|
-
}
|
|
121
|
-
}),
|
|
122
|
-
input.kind === 'multiselect' ? /*#__PURE__*/ _jsx(CheckboxList, {
|
|
123
|
-
label: C.value,
|
|
124
|
-
reason: reason,
|
|
125
|
-
value: readListValue(rule.value),
|
|
126
|
-
options: input.options ?? [],
|
|
127
|
-
onToggle: (value, checked)=>{
|
|
128
|
-
const values = readListValue(test.doc.targeting?.[index]?.value);
|
|
129
|
-
changeValue(checked ? [
|
|
130
|
-
...new Set([
|
|
131
|
-
...values,
|
|
132
|
-
value
|
|
133
|
-
])
|
|
134
|
-
] : values.filter((saved)=>saved !== value));
|
|
135
|
-
}
|
|
136
|
-
}) : input.kind === 'chips' ? /*#__PURE__*/ _jsx(TargetingChips, {
|
|
137
|
-
draftKey: draftKey,
|
|
138
|
-
test: test,
|
|
139
|
-
id: `${id}-${index}-value`,
|
|
140
|
-
label: C.targetingValue(humaniseAttribute(rule.attribute)),
|
|
141
|
-
values: readListValue(rule.value),
|
|
142
|
-
reason: reason,
|
|
143
|
-
onCommit: changeValue
|
|
144
|
-
}, draftKey) : input.kind === 'select' ? /*#__PURE__*/ _jsx(SelectEdit, {
|
|
145
|
-
label: C.value,
|
|
146
|
-
reason: reason,
|
|
147
|
-
value: String(rule.value),
|
|
148
|
-
options: input.options ?? [],
|
|
149
|
-
onCommit: changeValue
|
|
150
|
-
}) : input.kind === 'boolean' ? /*#__PURE__*/ _jsx(SelectEdit, {
|
|
151
|
-
label: C.value,
|
|
152
|
-
reason: reason,
|
|
153
|
-
value: String(rule.value),
|
|
154
|
-
options: [
|
|
155
|
-
{
|
|
156
|
-
value: 'true',
|
|
157
|
-
label: C.yes
|
|
158
|
-
},
|
|
159
|
-
{
|
|
160
|
-
value: 'false',
|
|
161
|
-
label: C.no
|
|
162
|
-
}
|
|
163
|
-
],
|
|
164
|
-
onCommit: changeValue
|
|
165
|
-
}) : /*#__PURE__*/ _jsx(TextEdit, {
|
|
166
|
-
test: test,
|
|
167
|
-
draftKey: draftKey,
|
|
168
|
-
label: C.value,
|
|
169
|
-
reason: reason,
|
|
170
|
-
value: Array.isArray(rule.value) ? rule.value.join(', ') : String(rule.value),
|
|
171
|
-
type: input.kind === 'number' ? 'number' : 'text',
|
|
172
|
-
onCommit: changeValue
|
|
173
|
-
}),
|
|
174
|
-
hint ? /*#__PURE__*/ _jsx("p", {
|
|
175
|
-
children: hint
|
|
176
|
-
}) : null,
|
|
177
|
-
/*#__PURE__*/ _jsx(FieldErrors, {
|
|
178
|
-
test: test,
|
|
179
|
-
path: `targeting.${index}`
|
|
180
|
-
}),
|
|
181
|
-
!reason ? /*#__PURE__*/ _jsx("div", {
|
|
182
|
-
className: "xp-ui-button-group",
|
|
183
|
-
children: /*#__PURE__*/ _jsx(Button, {
|
|
184
|
-
variant: "link",
|
|
185
|
-
size: "sm",
|
|
186
|
-
onClick: remove,
|
|
187
|
-
children: C.removeRule
|
|
188
|
-
})
|
|
189
|
-
}) : null
|
|
190
|
-
]
|
|
191
|
-
}, `${rowsRevision}-${index}`);
|
|
287
|
+
children: rules.length || !reason && pending.length ? C.rulesSummary : C.everyone
|
|
192
288
|
}),
|
|
289
|
+
[
|
|
290
|
+
...rules.flatMap((rule, index)=>[
|
|
291
|
+
...pendingAt(index),
|
|
292
|
+
...inserted?.before === index ? [] : [
|
|
293
|
+
/*#__PURE__*/ _jsx(Fragment, {
|
|
294
|
+
children: renderRow(rule, index)
|
|
295
|
+
}, storedRowKey(rule, index))
|
|
296
|
+
]
|
|
297
|
+
]),
|
|
298
|
+
...pendingAt(rules.length)
|
|
299
|
+
],
|
|
193
300
|
!reason && !keys.length ? /*#__PURE__*/ _jsx("p", {
|
|
194
301
|
className: "xp-ui-help",
|
|
195
|
-
children:
|
|
302
|
+
children: COHORT_EDITOR.noAttributes
|
|
196
303
|
}) : null,
|
|
197
|
-
!reason ? /*#__PURE__*/
|
|
304
|
+
!reason ? /*#__PURE__*/ _jsxs("div", {
|
|
198
305
|
className: "xp-ui-button-group",
|
|
199
|
-
children:
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
306
|
+
children: [
|
|
307
|
+
/*#__PURE__*/ _jsx(Button, {
|
|
308
|
+
disabled: !keys.length,
|
|
309
|
+
onClick: ()=>{
|
|
310
|
+
const attribute = keys[0];
|
|
311
|
+
const type = surface.attributeKeys[attribute].type;
|
|
312
|
+
update((current)=>[
|
|
313
|
+
...current,
|
|
314
|
+
{
|
|
315
|
+
attribute,
|
|
316
|
+
op: 'eq',
|
|
317
|
+
value: type === 'boolean' ? false : type === 'number' ? 0 : ''
|
|
318
|
+
}
|
|
319
|
+
]);
|
|
320
|
+
},
|
|
321
|
+
children: C.addRule
|
|
322
|
+
}),
|
|
323
|
+
/*#__PURE__*/ _jsx(Button, {
|
|
324
|
+
disabled: test.stale || test.statusReadPending,
|
|
325
|
+
onClick: ()=>{
|
|
326
|
+
const draft = {
|
|
327
|
+
id: ++nextDraft.current,
|
|
328
|
+
before: rules.length
|
|
329
|
+
};
|
|
330
|
+
setPending((rows)=>[
|
|
331
|
+
...rows,
|
|
332
|
+
draft
|
|
333
|
+
]);
|
|
334
|
+
},
|
|
335
|
+
children: COHORT_EDITOR.add
|
|
336
|
+
})
|
|
337
|
+
]
|
|
215
338
|
}) : null,
|
|
216
339
|
/*#__PURE__*/ _jsx(FieldErrors, {
|
|
217
340
|
test: test,
|
|
218
|
-
path: "targeting"
|
|
341
|
+
path: "targeting",
|
|
342
|
+
exact: true
|
|
219
343
|
})
|
|
220
344
|
]
|
|
221
345
|
});
|
|
@@ -14,6 +14,7 @@ import { VersionsSection } from './VersionsSection.js';
|
|
|
14
14
|
import { GoalSection } from './GoalSection.js';
|
|
15
15
|
import { TargetingSection } from './TargetingSection.js';
|
|
16
16
|
import { LengthSection } from './LengthSection.js';
|
|
17
|
+
import { ScheduleSection } from './ScheduleSection.js';
|
|
17
18
|
import { AdvancedSection } from './AdvancedSection.js';
|
|
18
19
|
import { Button } from '../../../ui/Button.js';
|
|
19
20
|
import { Banner } from '../../../ui/Feedback.js';
|
|
@@ -24,6 +25,7 @@ import { usePlacementNotice } from '../../../puck/editor/usePlacementNotice.js';
|
|
|
24
25
|
import { subscribePlacements, cachedPreflight, cachedReadinessRead, placementsPending, placementsBlocking, placementReadError } from '../../../puck/editor/placementsCache.js';
|
|
25
26
|
import { currentPuckDocument } from '../../../puck/editor/editor.model.js';
|
|
26
27
|
import { editorPlacementMessage, editorPreflight } from '../editorPlacement.js';
|
|
28
|
+
import { useScheduleClock } from '../../format/useScheduleClock.js';
|
|
27
29
|
import './testPage.css';
|
|
28
30
|
export function TestSurface({ id, surface, onTitleChange, renderFrame, embedded = false, onDocument, onPreflight, requestPreflight }) {
|
|
29
31
|
const [barHeight, setBarHeight] = useState();
|
|
@@ -35,6 +37,10 @@ export function TestSurface({ id, surface, onTitleChange, renderFrame, embedded
|
|
|
35
37
|
onPreflight,
|
|
36
38
|
requestPreflight
|
|
37
39
|
});
|
|
40
|
+
// The setup fields unlock their running-round edits at the scheduled start.
|
|
41
|
+
useScheduleClock(documentState.doc ? [
|
|
42
|
+
documentState.doc
|
|
43
|
+
] : [], surface.timeZone);
|
|
38
44
|
const [placementRead, setPlacementRead] = useState();
|
|
39
45
|
const placementKey = JSON.stringify([
|
|
40
46
|
surface.apiRoute,
|
|
@@ -238,6 +244,9 @@ export function TestSurface({ id, surface, onTitleChange, renderFrame, embedded
|
|
|
238
244
|
/*#__PURE__*/ _jsx(LengthSection, {
|
|
239
245
|
...props
|
|
240
246
|
}),
|
|
247
|
+
/*#__PURE__*/ _jsx(ScheduleSection, {
|
|
248
|
+
...props
|
|
249
|
+
}),
|
|
241
250
|
/*#__PURE__*/ _jsx(AdvancedSection, {
|
|
242
251
|
...props
|
|
243
252
|
}),
|
|
@@ -4,9 +4,10 @@ import type { EditableField } from '../../../types/admin.js';
|
|
|
4
4
|
import type { TestDocumentPatch } from '../testDocument.model.js';
|
|
5
5
|
export declare function reasonFor(test: TestDocApi, field: string): string | null;
|
|
6
6
|
export declare function save(test: TestDocApi, field: EditableField, patch: () => TestDocumentPatch): boolean;
|
|
7
|
-
export declare function FieldErrors({ test, path }: {
|
|
7
|
+
export declare function FieldErrors({ test, path, exact }: {
|
|
8
8
|
test: TestDocApi;
|
|
9
9
|
path: string;
|
|
10
|
+
exact?: boolean;
|
|
10
11
|
}): import("react").JSX.Element;
|
|
11
12
|
export declare function ReadOnly({ label, value, labelAction, hideLabel }: {
|
|
12
13
|
label: string;
|
|
@@ -8,16 +8,16 @@ import { TEST_PAGE as C } from '../../copy/testPage.js';
|
|
|
8
8
|
import { EDITABLE_BY_STATUS } from '../../../collections/experiments/editability.js';
|
|
9
9
|
import { lockedReason } from '../../lockedNotice.model.js';
|
|
10
10
|
export function reasonFor(test, field) {
|
|
11
|
-
return test.doc ? lockedReason(test.doc.status, field, EDITABLE_BY_STATUS) : null;
|
|
11
|
+
return test.doc ? lockedReason(test.doc.status, field, EDITABLE_BY_STATUS, test.doc.startedAt) : null;
|
|
12
12
|
}
|
|
13
13
|
export function save(test, field, patch) {
|
|
14
14
|
if (!test.doc || reasonFor(test, field) || !test.stage(patch())) return false;
|
|
15
15
|
void test.commit();
|
|
16
16
|
return true;
|
|
17
17
|
}
|
|
18
|
-
export function FieldErrors({ test, path }) {
|
|
18
|
+
export function FieldErrors({ test, path, exact = false }) {
|
|
19
19
|
return /*#__PURE__*/ _jsx(_Fragment, {
|
|
20
|
-
children: Object.entries(test.errors).filter(([key])=>key === path || key.startsWith(`${path}.`)).map(([key, message])=>/*#__PURE__*/ _jsx("p", {
|
|
20
|
+
children: Object.entries(test.errors).filter(([key])=>key === path || !exact && key.startsWith(`${path}.`)).map(([key, message])=>/*#__PURE__*/ _jsx("p", {
|
|
21
21
|
className: "xp-field-error",
|
|
22
22
|
role: "alert",
|
|
23
23
|
children: message
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import type { SectionId } from '../contracts.js';
|
|
2
2
|
/** Open disclosures before scrolling, then give keyboard users a meaningful landing. */
|
|
3
|
-
export declare function jumpToSection(section: SectionId, arm?: string): void;
|
|
3
|
+
export declare function jumpToSection(section: SectionId, arm?: string, rule?: number, owner?: Document): void;
|
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
/** Open disclosures before scrolling, then give keyboard users a meaningful landing. */ export function jumpToSection(section, arm) {
|
|
2
|
-
const target =
|
|
1
|
+
/** Open disclosures before scrolling, then give keyboard users a meaningful landing. */ export function jumpToSection(section, arm, rule, owner = document) {
|
|
2
|
+
const target = owner.getElementById(`section-${section}`);
|
|
3
3
|
if (target instanceof HTMLDetailsElement) target.open = true;
|
|
4
|
-
const row = arm ?
|
|
4
|
+
const row = rule !== undefined ? owner.getElementById(`xp-targeting-${rule}`) : arm ? owner.getElementById(`xp-version-${arm}`) : null;
|
|
5
5
|
(row ?? target)?.scrollIntoView?.({
|
|
6
6
|
block: 'start'
|
|
7
7
|
});
|
|
8
|
-
(row ??
|
|
8
|
+
(row ?? owner.getElementById(`title-${section}`))?.focus({
|
|
9
9
|
preventScroll: true
|
|
10
10
|
});
|
|
11
11
|
}
|
|
@@ -109,3 +109,29 @@
|
|
|
109
109
|
|
|
110
110
|
:where(.xp-test-surface) .xp-test-advanced.xp-ui-section--blocked { border-color: var(--xp-error-border); }
|
|
111
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%; }
|
|
112
|
+
.xp-schedule-windows, .xp-schedule-window {
|
|
113
|
+
display: grid;
|
|
114
|
+
gap: .75rem;
|
|
115
|
+
justify-items: start;
|
|
116
|
+
min-inline-size: 0;
|
|
117
|
+
}
|
|
118
|
+
.xp-schedule-window {
|
|
119
|
+
width: 100%;
|
|
120
|
+
padding: .875rem;
|
|
121
|
+
border: 1px solid var(--xp-border);
|
|
122
|
+
border-radius: .5rem;
|
|
123
|
+
}
|
|
124
|
+
.xp-schedule-window .xp-field-grid { width: 100%; }
|
|
125
|
+
.xp-schedule-window .xp-ui-button.xp-schedule-day[aria-pressed='true'] {
|
|
126
|
+
background: var(--xp-text);
|
|
127
|
+
color: var(--xp-surface);
|
|
128
|
+
border-color: var(--xp-text);
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
:where(.xp-test-surface) .xp-targeting-row.xp-cohort-row { grid-template-columns: minmax(0, 1fr); }
|
|
132
|
+
.xp-cohort-row p { margin-block: 0; }
|
|
133
|
+
.xp-cohort-row .xp-cohort-options { border: 0; padding: 0; margin: 0; min-inline-size: 0; }
|
|
134
|
+
.xp-cohort-options legend { padding: 0; margin-block-end: var(--xp-space-2); }
|
|
135
|
+
.xp-cohort-row .xp-ui-button[aria-pressed] { border-radius: 999px; }
|
|
136
|
+
.xp-cohort-row .xp-ui-button[aria-pressed='true'] { background: var(--xp-text); border-color: var(--xp-text); color: var(--xp-surface); }
|
|
137
|
+
.xp-cohort-row .xp-page-option { flex-wrap: wrap; }
|