@delmaredigital/payload-experiments 0.4.0-rc.6 → 0.4.0-rc.7
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/blocks/BlockPanel.js +6 -4
- package/dist/admin/blocks/inject.js +1 -0
- package/dist/admin/blocks/model.d.ts +3 -2
- package/dist/admin/blocks/model.js +8 -4
- package/dist/admin/copy/blocks.d.ts +3 -2
- package/dist/admin/copy/blocks.js +7 -6
- package/dist/admin/surface/ResultsRoute.js +2 -1
- package/dist/admin/surface/TestsHome.d.ts +2 -1
- package/dist/admin/surface/TestsHome.js +91 -37
- package/dist/admin/surface/TestsSurface.js +3 -0
- package/dist/admin/surface/home.model.d.ts +2 -0
- package/dist/admin/surface/newTest/PageWizard.js +1 -0
- package/dist/admin/surface/newTest/newTest.css +1 -1
- package/dist/admin/views/TestsSurfaceClient.d.ts +3 -0
- package/dist/admin/views/TestsSurfaceClient.js +11 -0
- package/dist/admin/views/buildSurfaceProps.js +10 -3
- package/dist/blocks/bindings.js +3 -2
- package/dist/blocks/placementLanguages.d.ts +7 -0
- package/dist/blocks/placementLanguages.js +27 -0
- package/dist/blocks/placementLocale.d.ts +21 -7
- package/dist/blocks/placementLocale.js +218 -67
- package/dist/db/appends.d.ts +13 -0
- package/dist/db/appends.js +49 -0
- package/dist/db/bulkPlacementRemoval.js +8 -4
- package/dist/endpoints/contentLocale.d.ts +6 -0
- package/dist/endpoints/contentLocale.js +15 -0
- package/dist/endpoints/deleteImpact.d.ts +6 -0
- package/dist/endpoints/deleteImpact.js +206 -0
- package/dist/endpoints/index.js +7 -0
- package/dist/endpoints/pages.js +7 -3
- package/dist/endpoints/placementStatus.js +6 -1
- package/dist/endpoints/preflight.d.ts +1 -1
- package/dist/endpoints/preflight.js +17 -2
- package/dist/exports/adminClient.d.ts +1 -1
- package/dist/exports/adminClient.js +1 -1
- package/dist/exports/index.d.ts +1 -1
- package/dist/goals/fairness.js +38 -31
- package/dist/hooks/blockRemovalRule.d.ts +2 -2
- package/dist/hooks/blockRemovalRule.js +16 -14
- package/dist/hooks/pageGuard.d.ts +3 -0
- package/dist/hooks/pageGuard.js +33 -23
- package/dist/hooks/puckNestedTests.d.ts +8 -0
- package/dist/hooks/puckNestedTests.js +36 -0
- package/dist/lib/placementPages.d.ts +2 -1
- package/dist/lib/placementPages.js +10 -2
- package/dist/manifest/compile.d.ts +2 -1
- package/dist/manifest/compile.js +5 -1
- package/dist/puck/ExperimentPicker.js +40 -37
- package/dist/puck/editor/ConfigureTestDrawer.d.ts +8 -4
- package/dist/puck/editor/ConfigureTestDrawer.js +4 -2
- package/dist/puck/editor/ExperimentSlotEditor.js +135 -104
- package/dist/puck/editor/LeftoverVersions.d.ts +1 -1
- package/dist/puck/editor/LeftoverVersions.js +40 -43
- package/dist/puck/editor/VersionBuilder.d.ts +18 -1
- package/dist/puck/editor/VersionBuilder.js +217 -39
- package/dist/puck/editor/blockClipboard.d.ts +16 -0
- package/dist/puck/editor/blockClipboard.js +20 -0
- package/dist/puck/editor/copy.d.ts +8 -1
- package/dist/puck/editor/copy.js +9 -1
- package/dist/puck/editor/editor.chrome.css +117 -3
- package/dist/puck/editor/editor.css +130 -8
- package/dist/puck/editor/editor.model.d.ts +2 -1
- package/dist/puck/editor/editor.model.js +2 -2
- package/dist/puck/editor/localPlacements.d.ts +1 -0
- package/dist/puck/editor/localPlacements.js +12 -0
- package/dist/puck/editor/placementsCache.d.ts +18 -12
- package/dist/puck/editor/placementsCache.js +52 -47
- package/dist/puck/editor/usePlacementNotice.d.ts +1 -1
- package/dist/puck/editor/usePlacementNotice.js +4 -3
- package/dist/puck/experimentSlug.d.ts +2 -0
- package/dist/puck/experimentSlug.js +3 -0
- package/dist/puck/nestedTestCopy.d.ts +8 -0
- package/dist/puck/nestedTestCopy.js +22 -0
- package/dist/puck/nestedTests.d.ts +17 -0
- package/dist/puck/nestedTests.js +30 -0
- package/dist/puck/slotConfig.d.ts +1 -1
- package/dist/puck/slotConfig.js +17 -4
- package/dist/puck/visibility.d.ts +2 -3
- package/dist/puck/visibility.js +11 -7
- package/dist/server/recordContentChange.js +34 -19
- package/dist/server/resolveExperimentData.js +2 -2
- package/dist/testSurface/PreviewLinks.js +6 -2
- package/dist/testSurface/api.d.ts +6 -3
- package/dist/testSurface/api.js +10 -6
- package/dist/testSurface/contentLocaleURL.d.ts +2 -0
- package/dist/testSurface/contentLocaleURL.js +3 -0
- package/dist/testSurface/copy/common.d.ts +4 -0
- package/dist/testSurface/copy/common.js +8 -4
- package/dist/testSurface/copy/languages.d.ts +11 -0
- package/dist/testSurface/copy/languages.js +7 -0
- package/dist/testSurface/copy/readiness.d.ts +1 -1
- package/dist/testSurface/copy/readiness.js +1 -1
- package/dist/testSurface/copy/testPage.d.ts +21 -0
- package/dist/testSurface/copy/testPage.js +21 -0
- package/dist/testSurface/placementLabel.d.ts +8 -0
- package/dist/testSurface/placementLabel.js +24 -0
- package/dist/testSurface/placements/placementLabels.d.ts +2 -0
- package/dist/testSurface/placements/placementLabels.js +2 -1
- package/dist/testSurface/results/results.css +1 -1
- package/dist/testSurface/surface/contracts.d.ts +2 -0
- package/dist/testSurface/surface/editorPlacement.d.ts +5 -0
- package/dist/testSurface/surface/editorPlacement.js +18 -0
- package/dist/testSurface/surface/pageBlock/pageBlock.model.js +2 -1
- package/dist/testSurface/surface/pageBlock/parts.js +24 -6
- package/dist/testSurface/surface/readiness/readiness.model.js +9 -2
- package/dist/testSurface/surface/results/useResults.d.ts +4 -1
- package/dist/testSurface/surface/test/DeleteTest.d.ts +15 -0
- package/dist/testSurface/surface/test/DeleteTest.js +171 -0
- package/dist/testSurface/surface/test/TestSurface.js +29 -9
- package/dist/testSurface/surface/useTestDocument.d.ts +2 -1
- package/dist/testSurface/surface/useTestDocument.js +20 -4
- package/dist/testSurface/useApi.d.ts +4 -1
- package/dist/transitions/checkStart.d.ts +4 -1
- package/dist/transitions/checkStart.js +117 -14
- package/dist/transitions/contentFields.js +9 -5
- package/dist/transitions/makeContent.js +5 -4
- package/dist/transitions/nestedPlacementNames.d.ts +5 -0
- package/dist/transitions/nestedPlacementNames.js +33 -0
- package/dist/transitions/pageVersions.js +3 -1
- package/dist/transitions/placementInteractions.js +7 -4
- package/dist/transitions/placements.d.ts +26 -1
- package/dist/transitions/placements.js +219 -56
- package/dist/transitions/preflightData.d.ts +2 -1
- package/dist/transitions/preflightData.js +66 -3
- package/dist/transitions/start.js +4 -1
- package/dist/types/endpoints.d.ts +35 -1
- package/dist/types/endpoints.js +1 -1
- package/dist/types/surface.d.ts +2 -0
- package/dist/ui/Button.js +2 -2
- package/dist/ui/Inputs.d.ts +4 -3
- package/dist/ui/Inputs.js +9 -9
- package/dist/ui/SelectControl.d.ts +33 -0
- package/dist/ui/SelectControl.js +504 -0
- package/dist/ui/ui.css +13 -5
- package/package.json +3 -2
|
@@ -281,11 +281,19 @@
|
|
|
281
281
|
.xp-ui-input::placeholder { color: var(--xp-text-3); }
|
|
282
282
|
.xp-ui-input:hover { border-color: var(--xp-text-3); }
|
|
283
283
|
.xp-ui-input[aria-invalid='true'] { border-color: var(--xp-error); }
|
|
284
|
-
.xp-ui-input--number { text-align:
|
|
285
|
-
/* The
|
|
286
|
-
.xp-ui-
|
|
287
|
-
.xp-ui-
|
|
288
|
-
.xp-ui-
|
|
284
|
+
.xp-ui-input--number { text-align: end; font-variant-numeric: tabular-nums; }
|
|
285
|
+
/* The open menu inherits the control's tokens, even in a dialog or canvas iframe. */
|
|
286
|
+
.xp-ui-combobox-wrap { display: block; position: relative; min-width: 0; max-width: 100%; }
|
|
287
|
+
.xp-ui-combobox { display: flex; align-items: center; justify-content: space-between; gap: var(--xp-space-2); cursor: pointer; text-align: start; }
|
|
288
|
+
.xp-ui-combobox > span:first-child { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
|
|
289
|
+
.xp-ui-combobox-chevron { flex: 0 0 auto; width: 7px; height: 7px; margin-inline-end: 4px; border-right: 2px solid var(--xp-text-2); border-bottom: 2px solid var(--xp-text-2); transform: translateY(-2px) rotate(45deg); }
|
|
290
|
+
.xp-ui-combobox-popup { box-sizing: border-box; position: fixed; inset: auto; margin: 0; padding: var(--xp-space-1); overflow: auto; overscroll-behavior: contain; border: 1px solid var(--xp-border-strong); border-radius: var(--xp-radius-control); background: var(--xp-surface); color: var(--xp-text); font: var(--xp-text-body); z-index: 2147483647; }
|
|
291
|
+
.xp-ui-combobox-popup:popover-open { display: block; }
|
|
292
|
+
.xp-ui-combobox-option { padding: var(--xp-space-2); border-radius: var(--xp-space-1); cursor: pointer; overflow-wrap: anywhere; }
|
|
293
|
+
.xp-ui-combobox-option[data-active='true'] { background: var(--xp-surface-3); outline: 1px solid var(--xp-border-strong); outline-offset: -1px; }
|
|
294
|
+
.xp-ui-combobox-option[aria-disabled='true'] { color: var(--xp-text-3); cursor: not-allowed; }
|
|
295
|
+
.xp-ui-combobox-group { padding: var(--xp-space-2); color: var(--xp-text-2); font: var(--xp-text-small); }
|
|
296
|
+
.xp-ui-combobox-validation { position: absolute; width: 1px; height: 1px; opacity: 0; pointer-events: none; }
|
|
289
297
|
.xp-ui-help { margin: 0; color: var(--xp-text-2); font: var(--xp-text-small); }
|
|
290
298
|
.xp-ui-error { margin: 0; color: var(--xp-error); font: var(--xp-text-small); }
|
|
291
299
|
.xp-ui-toggle { appearance: none; display: inline-block; width: 32px; height: 20px; margin: 0; padding: 2px; border-radius: 20px; border: 1px solid var(--xp-border-strong); background: var(--xp-surface-3); cursor: pointer; transition: background-color var(--xp-motion); }
|
|
@@ -518,6 +526,21 @@
|
|
|
518
526
|
[class*="_PuckFields"] .xp-slot-root .xp-ui-error { color: var(--xp-error); }
|
|
519
527
|
[class*="_PuckFields"] .xp-slot-root .xp-ui-help { color: var(--xp-text-2); }
|
|
520
528
|
[class*="_PuckFields"] .xp-slot-root .xp-ui-field label { color: var(--xp-text); }
|
|
529
|
+
/* Native popovers keep this ancestry in the top layer. The fallback portals to
|
|
530
|
+
the nearest open dialog or owner-document body, copying the trigger's --xp-*
|
|
531
|
+
tokens; outside the field subtree, shared ui.css supplies the menu colors. */
|
|
532
|
+
[class*="_PuckFields"] .xp-slot-root .xp-ui-combobox { color: var(--xp-text); background: var(--xp-surface); border-color: var(--xp-border-strong); }
|
|
533
|
+
[class*="_PuckFields"] .xp-slot-root .xp-ui-combobox:hover { border-color: var(--xp-text-3); }
|
|
534
|
+
[class*="_PuckFields"] .xp-slot-root .xp-ui-combobox:focus-visible { outline: 2px solid var(--xp-focus); }
|
|
535
|
+
[class*="_PuckFields"] .xp-slot-root .xp-ui-combobox[aria-invalid='true'] { border-color: var(--xp-error); }
|
|
536
|
+
[class*="_PuckFields"] .xp-slot-root .xp-ui-combobox:disabled { opacity: 1; color: var(--xp-text-2); background: var(--xp-surface-3); border-color: var(--xp-border-strong); }
|
|
537
|
+
[class*="_PuckFields"] .xp-slot-root .xp-ui-combobox > span:first-child { color: inherit; }
|
|
538
|
+
[class*="_PuckFields"] .xp-slot-root .xp-ui-combobox-chevron { border-right-color: var(--xp-text-2); border-bottom-color: var(--xp-text-2); }
|
|
539
|
+
[class*="_PuckFields"] .xp-slot-root .xp-ui-combobox-popup { color: var(--xp-text); background: var(--xp-surface); border-color: var(--xp-border-strong); }
|
|
540
|
+
[class*="_PuckFields"] .xp-slot-root .xp-ui-combobox-option { color: var(--xp-text); }
|
|
541
|
+
[class*="_PuckFields"] .xp-slot-root .xp-ui-combobox-option[data-active='true'] { color: var(--xp-text); background: var(--xp-surface-3); outline: 1px solid var(--xp-border-strong); }
|
|
542
|
+
[class*="_PuckFields"] .xp-slot-root .xp-ui-combobox-option[aria-disabled='true'] { color: var(--xp-text-3); }
|
|
543
|
+
[class*="_PuckFields"] .xp-slot-root .xp-ui-combobox-group { color: var(--xp-text-2); }
|
|
521
544
|
[class*="_PuckFields"] .xp-puck-field .xp-ui-button:disabled,
|
|
522
545
|
[class*="_PuckFields"] .xp-puck-field .xp-ui-button[aria-disabled='true'] {
|
|
523
546
|
opacity: 1;
|
|
@@ -558,9 +581,6 @@
|
|
|
558
581
|
/* Grid stretching must not turn a status chip into a full-width bar. */
|
|
559
582
|
.xp-slot-sidebar .xp-ui-status { justify-self: start; width: max-content; }
|
|
560
583
|
.xp-slot-sidebar fieldset { min-width: 0; }
|
|
561
|
-
.xp-slot-sidebar .xp-slot-version-group[data-active='true'] { border-inline-start: 3px solid var(--xp-focus); }
|
|
562
|
-
.xp-slot-sidebar .xp-slot-version-name { display: flex; align-items: end; gap: var(--xp-space-2); }
|
|
563
|
-
.xp-slot-sidebar .xp-slot-version-name > .xp-ui-field { flex: 1; min-width: 0; }
|
|
564
584
|
|
|
565
585
|
.xp-slot-header .xp-ui-status { flex: none; }
|
|
566
586
|
|
|
@@ -570,3 +590,105 @@
|
|
|
570
590
|
overflow-wrap: anywhere;
|
|
571
591
|
text-overflow: clip;
|
|
572
592
|
}
|
|
593
|
+
|
|
594
|
+
/* Compact field cards fit the Puck sidebar and wrap by their own available width. */
|
|
595
|
+
.xp-slot-sidebar .xp-slot-test-heading {
|
|
596
|
+
display: grid;
|
|
597
|
+
grid-template-columns: minmax(0, 1fr) auto;
|
|
598
|
+
align-items: start;
|
|
599
|
+
gap: var(--xp-space-2);
|
|
600
|
+
}
|
|
601
|
+
.xp-slot-test-heading > strong { min-width: 0; overflow-wrap: anywhere; }
|
|
602
|
+
.xp-slot-sidebar .xp-ui-banner {
|
|
603
|
+
min-width: 0;
|
|
604
|
+
padding: var(--xp-space-2) var(--xp-space-3);
|
|
605
|
+
gap: var(--xp-space-2);
|
|
606
|
+
font: var(--xp-text-small);
|
|
607
|
+
overflow-wrap: anywhere;
|
|
608
|
+
}
|
|
609
|
+
.xp-slot-sidebar .xp-ui-banner > p { min-width: 0; }
|
|
610
|
+
.xp-slot-version-controls, .xp-slot-weights { display: grid; gap: var(--xp-space-2); min-width: 0; }
|
|
611
|
+
.xp-slot-sidebar .xp-slot-weight-inputs { gap: var(--xp-space-2); }
|
|
612
|
+
.xp-slot-version-item { min-width: 0; }
|
|
613
|
+
.xp-slot-version-group {
|
|
614
|
+
display: grid;
|
|
615
|
+
gap: var(--xp-space-2);
|
|
616
|
+
padding: var(--xp-space-2);
|
|
617
|
+
border: 1px solid var(--xp-border-strong);
|
|
618
|
+
border-radius: var(--xp-radius-control);
|
|
619
|
+
background: var(--xp-surface);
|
|
620
|
+
min-width: 0;
|
|
621
|
+
container-type: inline-size;
|
|
622
|
+
}
|
|
623
|
+
.xp-slot-version-row { display: grid; grid-template-columns: 24px minmax(0, 1fr) 72px; align-items: start; gap: var(--xp-space-half) var(--xp-space-2); min-width: 0; }
|
|
624
|
+
.xp-slot-version-open {
|
|
625
|
+
position: relative;
|
|
626
|
+
grid-area: 1 / 1;
|
|
627
|
+
min-width: 24px;
|
|
628
|
+
min-height: 32px;
|
|
629
|
+
padding: 0;
|
|
630
|
+
border: 0;
|
|
631
|
+
border-radius: var(--xp-radius-control);
|
|
632
|
+
background: transparent;
|
|
633
|
+
cursor: pointer;
|
|
634
|
+
}
|
|
635
|
+
.xp-slot-version-open::before { content: ''; position: absolute; inset-block: 4px; inset-inline-start: 0; width: 3px; border-radius: 2px; background: var(--xp-border-strong); }
|
|
636
|
+
.xp-slot-version-open[aria-pressed='true']::before { background: var(--xp-focus); }
|
|
637
|
+
.xp-slot-version-open:focus-visible { outline: 2px solid var(--xp-focus); outline-offset: 2px; }
|
|
638
|
+
.xp-slot-version-open:disabled { cursor: not-allowed; }
|
|
639
|
+
/* Flatten only field layout boxes so their feedback uses the entire card row. */
|
|
640
|
+
.xp-slot-version-name, .xp-slot-version-traffic, .xp-slot-version-row .xp-ui-field { display: contents; }
|
|
641
|
+
.xp-slot-version-name .xp-ui-input { grid-area: 1 / 2; min-width: 0; font-weight: 600; }
|
|
642
|
+
.xp-slot-version-traffic .xp-ui-input { grid-area: 1 / 3; min-width: 0; }
|
|
643
|
+
.xp-slot-version-label { grid-area: 1 / 2 / auto / -1; align-self: center; min-width: 0; overflow-wrap: anywhere; }
|
|
644
|
+
.xp-slot-version-row .xp-ui-error { grid-column: 1 / -1; margin: 0; }
|
|
645
|
+
/* Reserve one feedback line. Visibility preserves geometry between saves. */
|
|
646
|
+
.xp-slot-version-saved { grid-column: 1 / -1; min-height: 16px; margin: 0; font: var(--xp-text-small); }
|
|
647
|
+
.xp-slot-version-row:has(.xp-ui-error) .xp-slot-version-saved { display: none; }
|
|
648
|
+
.xp-slot-version-row > .xp-slot-version-actions, .xp-slot-version-help { grid-column: 1 / -1; margin: 0; }
|
|
649
|
+
@container (max-width: 220px) {
|
|
650
|
+
.xp-slot-version-group > .xp-slot-version-row { grid-template-columns: 24px minmax(0, 1fr); }
|
|
651
|
+
.xp-slot-version-traffic .xp-ui-input { grid-area: 2 / 2; width: 72px; justify-self: end; }
|
|
652
|
+
.xp-slot-version-traffic .xp-slot-percent { grid-area: 2 / 2; }
|
|
653
|
+
}
|
|
654
|
+
.xp-slot-version-row .xp-ui-field > label {
|
|
655
|
+
position: absolute;
|
|
656
|
+
width: 1px;
|
|
657
|
+
height: 1px;
|
|
658
|
+
padding: 0;
|
|
659
|
+
margin: -1px;
|
|
660
|
+
overflow: hidden;
|
|
661
|
+
clip-path: inset(50%);
|
|
662
|
+
white-space: nowrap;
|
|
663
|
+
}
|
|
664
|
+
.xp-slot-version-row .xp-ui-input { height: 32px; padding-inline: var(--xp-space-2); font-size: 13px; }
|
|
665
|
+
.xp-slot-version-row .xp-ui-input--number { padding-inline-end: 22px; appearance: textfield; }
|
|
666
|
+
.xp-slot-version-row .xp-ui-input--number::-webkit-inner-spin-button,
|
|
667
|
+
.xp-slot-version-row .xp-ui-input--number::-webkit-outer-spin-button { appearance: none; margin: 0; }
|
|
668
|
+
.xp-slot-percent { position: relative; grid-area: 1 / 3; justify-self: end; inset-inline-end: var(--xp-space-2); top: 6px; font: var(--xp-text-small); color: var(--xp-text-2); pointer-events: none; }
|
|
669
|
+
.xp-slot-version-actions { display: flex; align-items: stretch; gap: var(--xp-space-one-half); min-width: 0; }
|
|
670
|
+
.xp-slot-version-actions > * { flex: 1 1 0; min-width: 0; }
|
|
671
|
+
.xp-slot-version-actions > div { display: flex; }
|
|
672
|
+
.xp-slot-version-actions .xp-ui-button { flex: 1; height: auto; min-height: 30px; padding: var(--xp-space-1) var(--xp-space-one-half); font-size: 12px; line-height: 16px; }
|
|
673
|
+
/* Match the solid disabled-button pattern without fading readable field values. */
|
|
674
|
+
.xp-slot-sidebar .xp-ui-input[aria-disabled='true'] {
|
|
675
|
+
opacity: 1;
|
|
676
|
+
background: var(--xp-surface-3);
|
|
677
|
+
border-color: var(--xp-border-strong);
|
|
678
|
+
color: var(--xp-text-2);
|
|
679
|
+
cursor: not-allowed;
|
|
680
|
+
}
|
|
681
|
+
.xp-slot-lock-notice {
|
|
682
|
+
padding: var(--xp-space-2) var(--xp-space-3);
|
|
683
|
+
border: 1px solid var(--xp-warning-border);
|
|
684
|
+
border-radius: var(--xp-radius-control);
|
|
685
|
+
background: var(--xp-warning-bg);
|
|
686
|
+
color: var(--xp-warning);
|
|
687
|
+
font: var(--xp-text-small);
|
|
688
|
+
overflow-wrap: anywhere;
|
|
689
|
+
scroll-margin-block: var(--xp-space-3);
|
|
690
|
+
}
|
|
691
|
+
.xp-slot-lock-notice[data-attention='true'] { border-color: var(--xp-error-border); background: var(--xp-error-bg); color: var(--xp-error); outline: 2px solid var(--xp-error); outline-offset: 2px; }
|
|
692
|
+
@media (prefers-reduced-motion: no-preference) {
|
|
693
|
+
.xp-slot-lock-notice { transition: outline-color 180ms; }
|
|
694
|
+
}
|
|
@@ -8,13 +8,14 @@ export type EditorExperiment = {
|
|
|
8
8
|
arms: Array<Pick<Arm, 'key' | 'kind' | 'label'> & Partial<Arm>>;
|
|
9
9
|
decision?: {
|
|
10
10
|
winnerArm?: string;
|
|
11
|
+
discardedAt?: string;
|
|
11
12
|
} | null;
|
|
12
13
|
};
|
|
13
14
|
export declare function tabsFor(experiment?: Pick<EditorExperiment, 'arms'> | null): Array<{
|
|
14
15
|
slot: ArmSlot;
|
|
15
16
|
label: string;
|
|
16
17
|
}>;
|
|
17
|
-
export declare function bannerFor(status?: Status | null, winner?: string, original?: string): string;
|
|
18
|
+
export declare function bannerFor(status?: Status | null, winner?: string, original?: string, decision?: EditorExperiment['decision']): string;
|
|
18
19
|
/** Preserve the block's populated slots and the current test's versions, without carrying test settings. */
|
|
19
20
|
export declare function armsFromBlock(experiment: Pick<EditorExperiment, 'arms'>, content: Partial<Record<ArmSlot, unknown>>): Arm[];
|
|
20
21
|
/** The host's Payload Puck editor route identifies the saved document, including in an iframe. */
|
|
@@ -15,7 +15,7 @@ export function tabsFor(experiment) {
|
|
|
15
15
|
}
|
|
16
16
|
]).sort((a, b)=>Number(b.slot === 'control') - Number(a.slot === 'control'));
|
|
17
17
|
}
|
|
18
|
-
export function bannerFor(status, winner = editorCopy.labels.control, original = editorCopy.labels.control) {
|
|
18
|
+
export function bannerFor(status, winner = editorCopy.labels.control, original = editorCopy.labels.control, decision) {
|
|
19
19
|
switch(status){
|
|
20
20
|
case 'draft':
|
|
21
21
|
case 'stopped':
|
|
@@ -25,7 +25,7 @@ export function bannerFor(status, winner = editorCopy.labels.control, original =
|
|
|
25
25
|
case 'decided':
|
|
26
26
|
return editorCopy.decided(winner);
|
|
27
27
|
case 'archived':
|
|
28
|
-
return editorCopy.archived;
|
|
28
|
+
return decision?.winnerArm && !decision.discardedAt ? editorCopy.archived(winner) : editorCopy.archivedOriginal(original, Boolean(decision?.discardedAt));
|
|
29
29
|
default:
|
|
30
30
|
return editorCopy.unbound;
|
|
31
31
|
}
|
|
@@ -2,3 +2,4 @@ import { type BlockVisibility } from '../visibility.js';
|
|
|
2
2
|
import type { Data } from '@puckeditor/core';
|
|
3
3
|
export declare function localPlacements(data: Data): Map<string, Set<string>>;
|
|
4
4
|
export declare function localBlockVisibility(data: Data, id: string): BlockVisibility | undefined;
|
|
5
|
+
export declare function localNestedTests(data: Data): import("../nestedTests.js").NestedTest[];
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { nestedTests } from '../nestedTests.js';
|
|
1
2
|
import { walkVisiblePuck } from '../visibility.js';
|
|
2
3
|
// Puck data is immutable. Selection, hover and drag state reuse this
|
|
3
4
|
// result, and every block on the page shares a single traversal per data change.
|
|
@@ -29,3 +30,14 @@ export function localBlockVisibility(data, id) {
|
|
|
29
30
|
}
|
|
30
31
|
return blocks.get(id);
|
|
31
32
|
}
|
|
33
|
+
const nestedPages = new WeakMap();
|
|
34
|
+
export function localNestedTests(data) {
|
|
35
|
+
let nested = nestedPages.get(data);
|
|
36
|
+
if (!nested) {
|
|
37
|
+
nested = nestedTests(data, {
|
|
38
|
+
includeHidden: true
|
|
39
|
+
});
|
|
40
|
+
nestedPages.set(data, nested);
|
|
41
|
+
}
|
|
42
|
+
return nested;
|
|
43
|
+
}
|
|
@@ -2,10 +2,13 @@ import type { DocId } from '../../types/contracts.js';
|
|
|
2
2
|
import type { PreflightResult } from '../../types/endpoints.js';
|
|
3
3
|
type Placements = PreflightResult['placements'];
|
|
4
4
|
/** Share mounted reads, but destructive actions always bypass settled cached knowledge. */
|
|
5
|
-
export declare function refreshPlacements(api: string, id: DocId): Promise<{
|
|
5
|
+
export declare function refreshPlacements(api: string, id: DocId, contentLocale?: string): Promise<{
|
|
6
6
|
collection: string;
|
|
7
7
|
id: DocId;
|
|
8
8
|
title: string;
|
|
9
|
+
locales?: string[];
|
|
10
|
+
allLocales?: true;
|
|
11
|
+
slotCount?: number;
|
|
9
12
|
url?: string;
|
|
10
13
|
editorUrl?: string;
|
|
11
14
|
slots?: Record<import("../../types/puck.js").ArmSlot, number>;
|
|
@@ -13,29 +16,32 @@ export declare function refreshPlacements(api: string, id: DocId): Promise<{
|
|
|
13
16
|
detail?: string;
|
|
14
17
|
}[] | undefined>;
|
|
15
18
|
/** Focus storms share the last attempt (including polling), at most once per ten seconds. */
|
|
16
|
-
export declare function focusPlacements(api: string, id: DocId): Promise<{
|
|
19
|
+
export declare function focusPlacements(api: string, id: DocId, contentLocale?: string): Promise<{
|
|
17
20
|
collection: string;
|
|
18
21
|
id: DocId;
|
|
19
22
|
title: string;
|
|
23
|
+
locales?: string[];
|
|
24
|
+
allLocales?: true;
|
|
25
|
+
slotCount?: number;
|
|
20
26
|
url?: string;
|
|
21
27
|
editorUrl?: string;
|
|
22
28
|
slots?: Record<import("../../types/puck.js").ArmSlot, number>;
|
|
23
29
|
ok: boolean;
|
|
24
30
|
detail?: string;
|
|
25
31
|
}[] | undefined>;
|
|
26
|
-
export declare function invalidatePlacements(api: string, id: DocId): void;
|
|
32
|
+
export declare function invalidatePlacements(api: string, id: DocId, contentLocale?: string): void;
|
|
27
33
|
/** Listen without starting a request; the drawer already owns its initial preflight. */
|
|
28
|
-
export declare function subscribePlacements(api: string, id: DocId, notify: (placements: Placements | undefined) => void): () => void;
|
|
29
|
-
export declare function acquirePlacements(api: string, id: DocId, notify: (placements: Placements | undefined) => void, fresh?: boolean): () => void;
|
|
34
|
+
export declare function subscribePlacements(api: string, id: DocId, notify: (placements: Placements | undefined) => void, contentLocale?: string): () => void;
|
|
35
|
+
export declare function acquirePlacements(api: string, id: DocId, notify: (placements: Placements | undefined) => void, fresh?: boolean, contentLocale?: string): () => void;
|
|
30
36
|
/** Drawer preflight uses this same producer and follows a superseding post-write read. */
|
|
31
|
-
export declare function readEditorPreflight(api: string, id: DocId, signal: AbortSignal, supersede?: boolean): Promise<Response>;
|
|
37
|
+
export declare function readEditorPreflight(api: string, id: DocId, signal: AbortSignal, supersede?: boolean, contentLocale?: string): Promise<Response>;
|
|
32
38
|
/** Current readiness shares the same request and lifetime as placements. */
|
|
33
|
-
export declare function cachedPreflight(api: string, id: DocId): PreflightResult | undefined;
|
|
39
|
+
export declare function cachedPreflight(api: string, id: DocId, contentLocale?: string): PreflightResult | undefined;
|
|
34
40
|
/** Mandatory post-write/refusal reads guard Start in every shared consumer. */
|
|
35
|
-
export declare function placementsBlocking(api: string, id: DocId): boolean;
|
|
36
|
-
export declare function placementsPending(api: string, id: DocId): boolean;
|
|
41
|
+
export declare function placementsBlocking(api: string, id: DocId, contentLocale?: string): boolean;
|
|
42
|
+
export declare function placementsPending(api: string, id: DocId, contentLocale?: string): boolean;
|
|
37
43
|
/** Pending reads retain the complete settled classification, including terminal outcomes. */
|
|
38
|
-
export declare function cachedReadinessRead(api: string, id: DocId): {
|
|
44
|
+
export declare function cachedReadinessRead(api: string, id: DocId, contentLocale?: string): {
|
|
39
45
|
status: number;
|
|
40
46
|
loadState: "forbidden" | "error" | "missing" | "ready";
|
|
41
47
|
kind: string;
|
|
@@ -45,6 +51,6 @@ export declare function cachedReadinessRead(api: string, id: DocId): {
|
|
|
45
51
|
retry: boolean;
|
|
46
52
|
pollDelay: number | null;
|
|
47
53
|
} | undefined;
|
|
48
|
-
export declare function placementReadError(api: string, id: DocId): string | undefined;
|
|
49
|
-
export declare function watchPlacementNotice(api: string, id: DocId, doc: Document): () => void;
|
|
54
|
+
export declare function placementReadError(api: string, id: DocId, contentLocale?: string): string | undefined;
|
|
55
|
+
export declare function watchPlacementNotice(api: string, id: DocId, doc: Document, contentLocale?: string): () => void;
|
|
50
56
|
export {};
|
|
@@ -1,14 +1,18 @@
|
|
|
1
|
+
import { contentLocaleURL } from '../../testSurface/contentLocaleURL.js';
|
|
1
2
|
import { isPreflightResult, readPreflight } from '../../testSurface/readPreflight.js';
|
|
2
3
|
import { classifyReadinessRead } from '../../testSurface/readinessRead.js';
|
|
3
4
|
const cache = new Map();
|
|
4
5
|
const latest = new Map();
|
|
5
6
|
const consumers = new Map();
|
|
6
|
-
const keyFor = (api, id)=>JSON.stringify([
|
|
7
|
+
const keyFor = (api, id, contentLocale)=>JSON.stringify([
|
|
7
8
|
api,
|
|
8
|
-
String(id)
|
|
9
|
+
String(id),
|
|
10
|
+
...contentLocale ? [
|
|
11
|
+
contentLocale
|
|
12
|
+
] : []
|
|
9
13
|
]);
|
|
10
|
-
function read(api, id, fresh, blocking = false) {
|
|
11
|
-
const key = keyFor(api, id);
|
|
14
|
+
function read(api, id, fresh, blocking = false, contentLocale) {
|
|
15
|
+
const key = keyFor(api, id, contentLocale);
|
|
12
16
|
const cached = cache.get(key);
|
|
13
17
|
if (cached && (!fresh || cached.pending)) return cached;
|
|
14
18
|
const controller = new AbortController();
|
|
@@ -29,7 +33,7 @@ function read(api, id, fresh, blocking = false) {
|
|
|
29
33
|
for (const notify of consumers.get(key)?.listeners ?? [])notify(entry.value);
|
|
30
34
|
entry.promise = (async ()=>{
|
|
31
35
|
try {
|
|
32
|
-
const { response, body: data } = await readPreflight((signal)=>fetch(`${api}/xp/experiments/${encodeURIComponent(id)}/preflight`, {
|
|
36
|
+
const { response, body: data } = await readPreflight((signal)=>fetch(contentLocaleURL(`${api}/xp/experiments/${encodeURIComponent(id)}/preflight`, contentLocale), {
|
|
33
37
|
credentials: 'include',
|
|
34
38
|
cache: 'no-store',
|
|
35
39
|
signal
|
|
@@ -66,23 +70,23 @@ function read(api, id, fresh, blocking = false) {
|
|
|
66
70
|
});
|
|
67
71
|
return entry;
|
|
68
72
|
}
|
|
69
|
-
/** Share mounted reads, but destructive actions always bypass settled cached knowledge. */ export function refreshPlacements(api, id) {
|
|
70
|
-
return read(api, id, true).promise;
|
|
73
|
+
/** Share mounted reads, but destructive actions always bypass settled cached knowledge. */ export function refreshPlacements(api, id, contentLocale) {
|
|
74
|
+
return read(api, id, true, false, contentLocale).promise;
|
|
71
75
|
}
|
|
72
|
-
/** Focus storms share the last attempt (including polling), at most once per ten seconds. */ export function focusPlacements(api, id) {
|
|
73
|
-
const previous = latest.get(keyFor(api, id));
|
|
76
|
+
/** Focus storms share the last attempt (including polling), at most once per ten seconds. */ export function focusPlacements(api, id, contentLocale) {
|
|
77
|
+
const previous = latest.get(keyFor(api, id, contentLocale));
|
|
74
78
|
if (previous && Date.now() - previous.startedAt < 10_000) return previous.promise;
|
|
75
|
-
return read(api, id, true).promise;
|
|
79
|
+
return read(api, id, true, false, contentLocale).promise;
|
|
76
80
|
}
|
|
77
|
-
export function invalidatePlacements(api, id) {
|
|
78
|
-
const key = keyFor(api, id);
|
|
81
|
+
export function invalidatePlacements(api, id, contentLocale) {
|
|
82
|
+
const key = keyFor(api, id, contentLocale);
|
|
79
83
|
cache.get(key)?.controller.abort();
|
|
80
84
|
cache.delete(key);
|
|
81
|
-
if (consumers.get(key)?.listeners.size) void read(api, id, true, true).promise;
|
|
85
|
+
if (consumers.get(key)?.listeners.size) void read(api, id, true, true, contentLocale).promise;
|
|
82
86
|
else latest.delete(key);
|
|
83
87
|
}
|
|
84
|
-
/** Listen without starting a request; the drawer already owns its initial preflight. */ export function subscribePlacements(api, id, notify) {
|
|
85
|
-
const key = keyFor(api, id);
|
|
88
|
+
/** Listen without starting a request; the drawer already owns its initial preflight. */ export function subscribePlacements(api, id, notify, contentLocale) {
|
|
89
|
+
const key = keyFor(api, id, contentLocale);
|
|
86
90
|
let group = consumers.get(key);
|
|
87
91
|
if (!group) {
|
|
88
92
|
const listeners = new Set();
|
|
@@ -109,10 +113,10 @@ export function invalidatePlacements(api, id) {
|
|
|
109
113
|
}
|
|
110
114
|
};
|
|
111
115
|
}
|
|
112
|
-
export function acquirePlacements(api, id, notify, fresh = false) {
|
|
113
|
-
const release = subscribePlacements(api, id, notify);
|
|
114
|
-
const key = keyFor(api, id);
|
|
115
|
-
const entry = read(api, id, fresh);
|
|
116
|
+
export function acquirePlacements(api, id, notify, fresh = false, contentLocale) {
|
|
117
|
+
const release = subscribePlacements(api, id, notify, contentLocale);
|
|
118
|
+
const key = keyFor(api, id, contentLocale);
|
|
119
|
+
const entry = read(api, id, fresh, false, contentLocale);
|
|
116
120
|
if (entry.value !== undefined) notify(entry.value);
|
|
117
121
|
let active = true;
|
|
118
122
|
void entry.promise.then(()=>{
|
|
@@ -123,24 +127,24 @@ export function acquirePlacements(api, id, notify, fresh = false) {
|
|
|
123
127
|
release();
|
|
124
128
|
};
|
|
125
129
|
}
|
|
126
|
-
/** Drawer preflight uses this same producer and follows a superseding post-write read. */ export async function readEditorPreflight(api, id, signal, supersede = false) {
|
|
130
|
+
/** Drawer preflight uses this same producer and follows a superseding post-write read. */ export async function readEditorPreflight(api, id, signal, supersede = false, contentLocale) {
|
|
127
131
|
if (signal.aborted) return new Response(null, {
|
|
128
132
|
status: 503
|
|
129
133
|
});
|
|
130
|
-
const release = subscribePlacements(api, id, ()=>{});
|
|
134
|
+
const release = subscribePlacements(api, id, ()=>{}, contentLocale);
|
|
131
135
|
signal.addEventListener('abort', release, {
|
|
132
136
|
once: true
|
|
133
137
|
});
|
|
134
138
|
try {
|
|
135
|
-
if (supersede) invalidatePlacements(api, id);
|
|
136
|
-
const previous = latest.get(keyFor(api, id));
|
|
137
|
-
let entry = previous && Date.now() - previous.startedAt < 10_000 ? previous : read(api, id, true);
|
|
139
|
+
if (supersede) invalidatePlacements(api, id, contentLocale);
|
|
140
|
+
const previous = latest.get(keyFor(api, id, contentLocale));
|
|
141
|
+
let entry = previous && Date.now() - previous.startedAt < 10_000 ? previous : read(api, id, true, false, contentLocale);
|
|
138
142
|
while(!signal.aborted){
|
|
139
143
|
await entry.promise;
|
|
140
144
|
if (signal.aborted) return new Response(null, {
|
|
141
145
|
status: 503
|
|
142
146
|
});
|
|
143
|
-
const current = latest.get(keyFor(api, id));
|
|
147
|
+
const current = latest.get(keyFor(api, id, contentLocale));
|
|
144
148
|
if (current && current !== entry) {
|
|
145
149
|
entry = current;
|
|
146
150
|
continue;
|
|
@@ -157,27 +161,27 @@ export function acquirePlacements(api, id, notify, fresh = false) {
|
|
|
157
161
|
release();
|
|
158
162
|
}
|
|
159
163
|
}
|
|
160
|
-
/** Current readiness shares the same request and lifetime as placements. */ export function cachedPreflight(api, id) {
|
|
161
|
-
const entry = latest.get(keyFor(api, id));
|
|
164
|
+
/** Current readiness shares the same request and lifetime as placements. */ export function cachedPreflight(api, id, contentLocale) {
|
|
165
|
+
const entry = latest.get(keyFor(api, id, contentLocale));
|
|
162
166
|
return entry?.preflight ?? (entry?.pending ? entry.previousPreflight : undefined);
|
|
163
167
|
}
|
|
164
|
-
/** Mandatory post-write/refusal reads guard Start in every shared consumer. */ export function placementsBlocking(api, id) {
|
|
165
|
-
const entry = cache.get(keyFor(api, id));
|
|
168
|
+
/** Mandatory post-write/refusal reads guard Start in every shared consumer. */ export function placementsBlocking(api, id, contentLocale) {
|
|
169
|
+
const entry = cache.get(keyFor(api, id, contentLocale));
|
|
166
170
|
return entry?.pending === true && entry.blocking;
|
|
167
171
|
}
|
|
168
|
-
export function placementsPending(api, id) {
|
|
169
|
-
return cache.get(keyFor(api, id))?.pending === true;
|
|
172
|
+
export function placementsPending(api, id, contentLocale) {
|
|
173
|
+
return cache.get(keyFor(api, id, contentLocale))?.pending === true;
|
|
170
174
|
}
|
|
171
|
-
/** Pending reads retain the complete settled classification, including terminal outcomes. */ export function cachedReadinessRead(api, id) {
|
|
172
|
-
const entry = latest.get(keyFor(api, id));
|
|
175
|
+
/** Pending reads retain the complete settled classification, including terminal outcomes. */ export function cachedReadinessRead(api, id, contentLocale) {
|
|
176
|
+
const entry = latest.get(keyFor(api, id, contentLocale));
|
|
173
177
|
return entry?.pending ? entry.previousRead : entry?.read;
|
|
174
178
|
}
|
|
175
|
-
export function placementReadError(api, id) {
|
|
176
|
-
return cachedReadinessRead(api, id)?.message;
|
|
179
|
+
export function placementReadError(api, id, contentLocale) {
|
|
180
|
+
return cachedReadinessRead(api, id, contentLocale)?.message;
|
|
177
181
|
}
|
|
178
182
|
const notices = new WeakMap();
|
|
179
|
-
const noticeDelay = (api, id)=>cachedReadinessRead(api, id)?.pollDelay ?? null;
|
|
180
|
-
export function watchPlacementNotice(api, id, doc) {
|
|
183
|
+
const noticeDelay = (api, id, contentLocale)=>cachedReadinessRead(api, id, contentLocale)?.pollDelay ?? null;
|
|
184
|
+
export function watchPlacementNotice(api, id, doc, contentLocale) {
|
|
181
185
|
let session = notices.get(doc);
|
|
182
186
|
if (!session) {
|
|
183
187
|
const requests = new Map();
|
|
@@ -196,17 +200,17 @@ export function watchPlacementNotice(api, id, doc) {
|
|
|
196
200
|
}
|
|
197
201
|
const eligible = [
|
|
198
202
|
...created.requests.values()
|
|
199
|
-
].filter((request)=>!request.pending && noticeDelay(request.api, request.id) !== null);
|
|
203
|
+
].filter((request)=>!request.pending && noticeDelay(request.api, request.id, request.contentLocale) !== null);
|
|
200
204
|
if (doc.visibilityState !== 'visible' || !eligible.length) return;
|
|
201
205
|
created.timer = setTimeout(()=>{
|
|
202
206
|
created.timer = undefined;
|
|
203
207
|
if (doc.visibilityState !== 'visible') return;
|
|
204
|
-
const due = eligible.filter((request)=>created.requests.get(keyFor(request.api, request.id)) === request && request.nextAt <= Date.now());
|
|
208
|
+
const due = eligible.filter((request)=>created.requests.get(keyFor(request.api, request.id, request.contentLocale)) === request && request.nextAt <= Date.now());
|
|
205
209
|
for (const request of due){
|
|
206
210
|
request.pending = true;
|
|
207
|
-
void refreshPlacements(request.api, request.id).then(()=>{
|
|
211
|
+
void refreshPlacements(request.api, request.id, request.contentLocale).then(()=>{
|
|
208
212
|
request.pending = false;
|
|
209
|
-
request.nextAt = Date.now() + (noticeDelay(request.api, request.id) ?? 0);
|
|
213
|
+
request.nextAt = Date.now() + (noticeDelay(request.api, request.id, request.contentLocale) ?? 0);
|
|
210
214
|
if (notices.get(doc) === created) created.schedule();
|
|
211
215
|
});
|
|
212
216
|
}
|
|
@@ -214,7 +218,7 @@ export function watchPlacementNotice(api, id, doc) {
|
|
|
214
218
|
}, Math.max(0, Math.min(...eligible.map((request)=>request.nextAt)) - Date.now()));
|
|
215
219
|
};
|
|
216
220
|
created.visibility = ()=>{
|
|
217
|
-
for (const request of created.requests.values())request.nextAt = Date.now() + (noticeDelay(request.api, request.id) ?? 0);
|
|
221
|
+
for (const request of created.requests.values())request.nextAt = Date.now() + (noticeDelay(request.api, request.id, request.contentLocale) ?? 0);
|
|
218
222
|
created.schedule();
|
|
219
223
|
};
|
|
220
224
|
session = created;
|
|
@@ -222,24 +226,25 @@ export function watchPlacementNotice(api, id, doc) {
|
|
|
222
226
|
doc.addEventListener('visibilitychange', created.visibility);
|
|
223
227
|
}
|
|
224
228
|
const current = session;
|
|
225
|
-
const key = keyFor(api, id);
|
|
229
|
+
const key = keyFor(api, id, contentLocale);
|
|
226
230
|
const existing = current.requests.get(key);
|
|
227
231
|
const request = existing ?? {
|
|
228
232
|
api,
|
|
229
233
|
id,
|
|
234
|
+
contentLocale,
|
|
230
235
|
subscribers: 0,
|
|
231
|
-
nextAt: Date.now() + (noticeDelay(api, id) ?? 0),
|
|
236
|
+
nextAt: Date.now() + (noticeDelay(api, id, contentLocale) ?? 0),
|
|
232
237
|
pending: false,
|
|
233
238
|
release: ()=>{}
|
|
234
239
|
};
|
|
235
240
|
request.subscribers++;
|
|
236
241
|
current.requests.set(key, request);
|
|
237
242
|
if (!existing) request.release = subscribePlacements(api, id, ()=>{
|
|
238
|
-
if (placementsPending(api, id)) return;
|
|
243
|
+
if (placementsPending(api, id, contentLocale)) return;
|
|
239
244
|
// Manual/focus retries also reset the backoff after recovery.
|
|
240
|
-
request.nextAt = Date.now() + (noticeDelay(api, id) ?? 0);
|
|
245
|
+
request.nextAt = Date.now() + (noticeDelay(api, id, contentLocale) ?? 0);
|
|
241
246
|
current.schedule();
|
|
242
|
-
});
|
|
247
|
+
}, contentLocale);
|
|
243
248
|
if (!existing || current.timer === undefined) current.schedule();
|
|
244
249
|
let active = true;
|
|
245
250
|
return ()=>{
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import type { DocId } from '../../types/contracts.js';
|
|
2
2
|
/** Subscribe only while save/publish guidance or a retryable placement failure is visible. */
|
|
3
|
-
export declare function usePlacementNotice(api: string, id: DocId | undefined, message: string | undefined): void;
|
|
3
|
+
export declare function usePlacementNotice(api: string, id: DocId | undefined, message: string | undefined, contentLocale?: string): void;
|
|
@@ -1,14 +1,15 @@
|
|
|
1
1
|
'use client';
|
|
2
2
|
import { useEffect } from 'react';
|
|
3
3
|
import { watchPlacementNotice } from './placementsCache.js';
|
|
4
|
-
/** Subscribe only while save/publish guidance or a retryable placement failure is visible. */ export function usePlacementNotice(api, id, message) {
|
|
4
|
+
/** Subscribe only while save/publish guidance or a retryable placement failure is visible. */ export function usePlacementNotice(api, id, message, contentLocale) {
|
|
5
5
|
const showing = message !== undefined && id !== undefined;
|
|
6
6
|
useEffect(()=>{
|
|
7
7
|
if (id === undefined || !showing) return;
|
|
8
|
-
return watchPlacementNotice(api, id, document);
|
|
8
|
+
return watchPlacementNotice(api, id, document, contentLocale);
|
|
9
9
|
}, [
|
|
10
10
|
api,
|
|
11
11
|
id,
|
|
12
|
-
showing
|
|
12
|
+
showing,
|
|
13
|
+
contentLocale
|
|
13
14
|
]);
|
|
14
15
|
}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
export declare const nestedTestCopy: {
|
|
2
|
+
start: (outer?: string, inner?: string) => string;
|
|
3
|
+
readinessFallback: string;
|
|
4
|
+
editor: (outer?: string, inner?: string) => string;
|
|
5
|
+
publish: (outer?: string, inner?: string) => string;
|
|
6
|
+
hidden: (outer?: string) => string;
|
|
7
|
+
readiness: (detail: unknown) => string;
|
|
8
|
+
};
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
const innerLabel = (inner)=>inner ? `“${inner}”` : 'An Experiment block with no test chosen';
|
|
2
|
+
const outerLabel = (outer)=>outer ? `“${outer}”` : 'another test';
|
|
3
|
+
const moveLabel = (inner)=>inner ? `“${inner}”` : 'that block';
|
|
4
|
+
const location = (outer, inner)=>`${innerLabel(inner)} is inside a version of ${outerLabel(outer)}.`;
|
|
5
|
+
const start = (outer, inner)=>`${location(outer, inner)} A test can't go inside another test's version. Move ${moveLabel(inner)} out of that version before you start either test.`;
|
|
6
|
+
const readinessFallback = "A test is inside another test's version on this page. A test can't go inside another test's version. Move the inner test out of that version before you start either test.";
|
|
7
|
+
export const nestedTestCopy = {
|
|
8
|
+
start,
|
|
9
|
+
readinessFallback,
|
|
10
|
+
editor: (outer, inner)=>inner ? start(outer, inner) : `This test is inside a version of ${outerLabel(outer)}. A test can't go inside another test's version. Move this test out of that version before you start either test.`,
|
|
11
|
+
publish: (outer, inner)=>`${location(outer, inner)} A test can't go inside another test's version, so this page can't be published. Move ${moveLabel(inner)} out of that version, then publish.`,
|
|
12
|
+
hidden: (outer)=>`This test is inside a version of ${outerLabel(outer)}. It is hidden, so nothing is blocked now. If you show it again, the page can't be published until you move it out of that version.`,
|
|
13
|
+
readiness: (detail)=>(Array.isArray(detail) && detail.length ? detail : [
|
|
14
|
+
{}
|
|
15
|
+
]).map((value)=>{
|
|
16
|
+
const pair = value && typeof value === 'object' ? value : {};
|
|
17
|
+
const text = (value)=>typeof value === 'string' && value.trim() ? value.trim() : undefined;
|
|
18
|
+
const message = typeof pair.outer === 'string' && typeof pair.inner === 'string' ? start(text(pair.outer), text(pair.inner)) : readinessFallback;
|
|
19
|
+
const title = text(pair.title);
|
|
20
|
+
return title ? `On ${title}: ${message}` : message;
|
|
21
|
+
}).join('\n')
|
|
22
|
+
};
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { type PuckBlock } from './visibility.js';
|
|
2
|
+
export interface NestedTest {
|
|
3
|
+
outer: PuckBlock;
|
|
4
|
+
inner: PuckBlock;
|
|
5
|
+
}
|
|
6
|
+
/** The placement traversal owns block shape, legacy zones and inherited visibility.
|
|
7
|
+
* Paste supplies its destination ancestors and includes hidden/unbound blocks.
|
|
8
|
+
*/
|
|
9
|
+
export declare function nestedTests(data: unknown, { includeHidden, ancestors }?: {
|
|
10
|
+
includeHidden?: boolean;
|
|
11
|
+
ancestors?: readonly PuckBlock[];
|
|
12
|
+
}): NestedTest[];
|
|
13
|
+
export declare const nestedTestSlug: (block: PuckBlock) => string | undefined;
|
|
14
|
+
export declare const nestedTestLabel: (block: PuckBlock) => string;
|
|
15
|
+
export declare const nestedTestKey: ({ outer, inner }: NestedTest) => string;
|
|
16
|
+
/** Traversal records all ancestors, from furthest to nearest for each inner block. */
|
|
17
|
+
export declare const nearestOuterTest: (pairs: readonly NestedTest[], innerId: unknown) => PuckBlock | undefined;
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { EXPERIMENT_SLOT_TYPE } from '../types/puck.js';
|
|
2
|
+
import { puckExperimentSlug } from './experimentSlug.js';
|
|
3
|
+
import { walkVisiblePuck } from './visibility.js';
|
|
4
|
+
/** The placement traversal owns block shape, legacy zones and inherited visibility.
|
|
5
|
+
* Paste supplies its destination ancestors and includes hidden/unbound blocks.
|
|
6
|
+
*/ export function nestedTests(data, { includeHidden = false, ancestors = [] } = {}) {
|
|
7
|
+
const result = [];
|
|
8
|
+
walkVisiblePuck(data, (inner, visibility, parents)=>{
|
|
9
|
+
if (!includeHidden && visibility.hidden || inner.type !== EXPERIMENT_SLOT_TYPE) return;
|
|
10
|
+
for (const outer of [
|
|
11
|
+
...ancestors,
|
|
12
|
+
...parents
|
|
13
|
+
]){
|
|
14
|
+
if (outer.type === EXPERIMENT_SLOT_TYPE) result.push({
|
|
15
|
+
outer,
|
|
16
|
+
inner
|
|
17
|
+
});
|
|
18
|
+
}
|
|
19
|
+
});
|
|
20
|
+
return result;
|
|
21
|
+
}
|
|
22
|
+
export const nestedTestSlug = (block)=>puckExperimentSlug(block.props.experiment);
|
|
23
|
+
export const nestedTestLabel = (block)=>nestedTestSlug(block) ?? '';
|
|
24
|
+
export const nestedTestKey = ({ outer, inner })=>JSON.stringify([
|
|
25
|
+
outer.props.id,
|
|
26
|
+
nestedTestSlug(outer),
|
|
27
|
+
inner.props.id,
|
|
28
|
+
nestedTestSlug(inner)
|
|
29
|
+
]);
|
|
30
|
+
/** Traversal records all ancestors, from furthest to nearest for each inner block. */ export const nearestOuterTest = (pairs, innerId)=>pairs.filter((pair)=>pair.inner.props.id === innerId).at(-1)?.outer;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { ComponentConfig } from '@puckeditor/core';
|
|
2
|
-
import type
|
|
2
|
+
import { type ExperimentSlotProps } from '../types/puck.js';
|
|
3
3
|
export declare const experimentSlotLabel = "Experiment block";
|
|
4
4
|
export declare const experimentSlotFields: NonNullable<ComponentConfig<ExperimentSlotProps>['fields']>;
|
|
5
5
|
export declare const experimentSlotDefaultProps: NonNullable<ComponentConfig<ExperimentSlotProps>['defaultProps']>;
|