@delmaredigital/payload-experiments 0.4.0-rc.5 → 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.
Files changed (164) hide show
  1. package/dist/admin/blocks/BlockPanel.js +6 -4
  2. package/dist/admin/blocks/inject.js +1 -0
  3. package/dist/admin/blocks/model.d.ts +3 -2
  4. package/dist/admin/blocks/model.js +8 -4
  5. package/dist/admin/copy/blocks.d.ts +3 -2
  6. package/dist/admin/copy/blocks.js +7 -6
  7. package/dist/admin/copy/newTest.d.ts +1 -1
  8. package/dist/admin/copy/newTest.js +1 -1
  9. package/dist/admin/surface/ResultsRoute.js +2 -1
  10. package/dist/admin/surface/TestsHome.d.ts +2 -1
  11. package/dist/admin/surface/TestsHome.js +91 -37
  12. package/dist/admin/surface/TestsSurface.js +3 -0
  13. package/dist/admin/surface/home.model.d.ts +2 -0
  14. package/dist/admin/surface/newTest/NewTest.js +16 -18
  15. package/dist/admin/surface/newTest/PageWizard.js +1 -0
  16. package/dist/admin/surface/newTest/newTest.css +3 -1
  17. package/dist/admin/views/TestsSurfaceClient.d.ts +3 -0
  18. package/dist/admin/views/TestsSurfaceClient.js +11 -0
  19. package/dist/admin/views/buildSurfaceProps.js +10 -3
  20. package/dist/blocks/bindings.js +8 -14
  21. package/dist/blocks/placementLanguages.d.ts +7 -0
  22. package/dist/blocks/placementLanguages.js +27 -0
  23. package/dist/blocks/placementLocale.d.ts +23 -7
  24. package/dist/blocks/placementLocale.js +221 -66
  25. package/dist/db/appends.d.ts +13 -0
  26. package/dist/db/appends.js +49 -0
  27. package/dist/db/bulkPlacementRemoval.js +8 -4
  28. package/dist/endpoints/contentLocale.d.ts +6 -0
  29. package/dist/endpoints/contentLocale.js +15 -0
  30. package/dist/endpoints/deleteImpact.d.ts +6 -0
  31. package/dist/endpoints/deleteImpact.js +206 -0
  32. package/dist/endpoints/index.js +7 -0
  33. package/dist/endpoints/pages.js +7 -3
  34. package/dist/endpoints/placementStatus.js +6 -1
  35. package/dist/endpoints/preflight.d.ts +1 -1
  36. package/dist/endpoints/preflight.js +17 -2
  37. package/dist/exports/adminClient.d.ts +1 -1
  38. package/dist/exports/adminClient.js +1 -1
  39. package/dist/exports/index.d.ts +1 -1
  40. package/dist/goals/fairness.js +43 -34
  41. package/dist/hooks/blockRemovalRule.d.ts +4 -3
  42. package/dist/hooks/blockRemovalRule.js +33 -9
  43. package/dist/hooks/pageGuard.d.ts +3 -0
  44. package/dist/hooks/pageGuard.js +34 -24
  45. package/dist/hooks/puckNestedTests.d.ts +8 -0
  46. package/dist/hooks/puckNestedTests.js +36 -0
  47. package/dist/lib/placementPages.d.ts +2 -1
  48. package/dist/lib/placementPages.js +10 -2
  49. package/dist/manifest/compile.d.ts +2 -1
  50. package/dist/manifest/compile.js +5 -1
  51. package/dist/puck/ExperimentPicker.d.ts +2 -1
  52. package/dist/puck/ExperimentPicker.js +37 -30
  53. package/dist/puck/ExperimentSlot.js +3 -1
  54. package/dist/puck/copy.d.ts +1 -0
  55. package/dist/puck/copy.js +1 -0
  56. package/dist/puck/editor/ConfigureTestDrawer.d.ts +8 -4
  57. package/dist/puck/editor/ConfigureTestDrawer.js +4 -2
  58. package/dist/puck/editor/CreateExperimentDrawer.d.ts +2 -1
  59. package/dist/puck/editor/CreateExperimentDrawer.js +24 -20
  60. package/dist/puck/editor/EditorControls.d.ts +1 -1
  61. package/dist/puck/editor/EditorControls.js +1 -1
  62. package/dist/puck/editor/ExperimentSlotEditor.js +405 -394
  63. package/dist/puck/editor/LeftoverVersions.d.ts +4 -2
  64. package/dist/puck/editor/LeftoverVersions.js +23 -44
  65. package/dist/puck/editor/QuickTestActions.js +2 -2
  66. package/dist/puck/editor/VersionBuilder.d.ts +41 -13
  67. package/dist/puck/editor/VersionBuilder.js +461 -224
  68. package/dist/puck/editor/armWrites.d.ts +9 -2
  69. package/dist/puck/editor/armWrites.js +40 -2
  70. package/dist/puck/editor/armsCache.d.ts +1 -1
  71. package/dist/puck/editor/armsCache.js +2 -1
  72. package/dist/puck/editor/blockClipboard.d.ts +16 -0
  73. package/dist/puck/editor/blockClipboard.js +20 -0
  74. package/dist/puck/editor/copy.d.ts +27 -26
  75. package/dist/puck/editor/copy.js +28 -26
  76. package/dist/puck/editor/createTest.d.ts +3 -0
  77. package/dist/puck/editor/createTest.js +33 -0
  78. package/dist/puck/editor/editor.chrome.css +138 -17
  79. package/dist/puck/editor/editor.css +156 -22
  80. package/dist/puck/editor/editor.model.d.ts +2 -1
  81. package/dist/puck/editor/editor.model.js +3 -3
  82. package/dist/puck/editor/experimentOutlinePlugin.js +1 -1
  83. package/dist/puck/editor/localPlacements.d.ts +5 -2
  84. package/dist/puck/editor/localPlacements.js +32 -18
  85. package/dist/puck/editor/placementsCache.d.ts +18 -12
  86. package/dist/puck/editor/placementsCache.js +52 -47
  87. package/dist/puck/editor/sidebar.d.ts +2 -6
  88. package/dist/puck/editor/sidebar.js +3 -6
  89. package/dist/puck/editor/usePlacementNotice.d.ts +1 -1
  90. package/dist/puck/editor/usePlacementNotice.js +4 -3
  91. package/dist/puck/experimentSlug.d.ts +2 -0
  92. package/dist/puck/experimentSlug.js +3 -0
  93. package/dist/puck/nestedTestCopy.d.ts +8 -0
  94. package/dist/puck/nestedTestCopy.js +22 -0
  95. package/dist/puck/nestedTests.d.ts +17 -0
  96. package/dist/puck/nestedTests.js +30 -0
  97. package/dist/puck/slotConfig.d.ts +1 -1
  98. package/dist/puck/slotConfig.js +17 -4
  99. package/dist/puck/visibility.d.ts +20 -0
  100. package/dist/puck/visibility.js +81 -0
  101. package/dist/server/recordContentChange.js +37 -20
  102. package/dist/server/resolveExperimentData.js +6 -3
  103. package/dist/testSurface/PreviewLinks.js +6 -2
  104. package/dist/testSurface/api.d.ts +6 -3
  105. package/dist/testSurface/api.js +10 -6
  106. package/dist/testSurface/contentLocaleURL.d.ts +2 -0
  107. package/dist/testSurface/contentLocaleURL.js +3 -0
  108. package/dist/testSurface/copy/common.d.ts +4 -0
  109. package/dist/testSurface/copy/common.js +8 -4
  110. package/dist/testSurface/copy/languages.d.ts +11 -0
  111. package/dist/testSurface/copy/languages.js +7 -0
  112. package/dist/testSurface/copy/readiness.d.ts +2 -1
  113. package/dist/testSurface/copy/readiness.js +2 -1
  114. package/dist/testSurface/copy/testPage.d.ts +28 -6
  115. package/dist/testSurface/copy/testPage.js +28 -6
  116. package/dist/testSurface/placementLabel.d.ts +8 -0
  117. package/dist/testSurface/placementLabel.js +24 -0
  118. package/dist/testSurface/placements/placementLabels.d.ts +2 -0
  119. package/dist/testSurface/placements/placementLabels.js +2 -1
  120. package/dist/testSurface/results/results.css +1 -1
  121. package/dist/testSurface/results/results.model.d.ts +1 -1
  122. package/dist/testSurface/surface/contracts.d.ts +2 -0
  123. package/dist/testSurface/surface/editorPlacement.d.ts +5 -0
  124. package/dist/testSurface/surface/editorPlacement.js +18 -0
  125. package/dist/testSurface/surface/pageBlock/pageBlock.model.js +2 -1
  126. package/dist/testSurface/surface/pageBlock/parts.js +24 -6
  127. package/dist/testSurface/surface/readiness/ActionDialogs.js +28 -34
  128. package/dist/testSurface/surface/readiness/readiness.model.js +9 -2
  129. package/dist/testSurface/surface/results/useResults.d.ts +4 -1
  130. package/dist/testSurface/surface/test/DeleteTest.d.ts +15 -0
  131. package/dist/testSurface/surface/test/DeleteTest.js +171 -0
  132. package/dist/testSurface/surface/test/GoalSection.js +101 -74
  133. package/dist/testSurface/surface/test/TestSurface.js +29 -9
  134. package/dist/testSurface/surface/test/fields.d.ts +1 -3
  135. package/dist/testSurface/surface/test/fields.js +5 -35
  136. package/dist/testSurface/surface/useTestDocument.d.ts +2 -1
  137. package/dist/testSurface/surface/useTestDocument.js +20 -4
  138. package/dist/testSurface/useApi.d.ts +4 -1
  139. package/dist/transitions/checkStart.d.ts +4 -1
  140. package/dist/transitions/checkStart.js +117 -14
  141. package/dist/transitions/contentFields.js +9 -5
  142. package/dist/transitions/makeContent.js +29 -9
  143. package/dist/transitions/nestedPlacementNames.d.ts +5 -0
  144. package/dist/transitions/nestedPlacementNames.js +33 -0
  145. package/dist/transitions/pageVersions.js +3 -1
  146. package/dist/transitions/placementInteractions.js +7 -4
  147. package/dist/transitions/placements.d.ts +26 -1
  148. package/dist/transitions/placements.js +239 -87
  149. package/dist/transitions/preflightData.d.ts +2 -1
  150. package/dist/transitions/preflightData.js +66 -3
  151. package/dist/transitions/start.js +4 -1
  152. package/dist/types/endpoints.d.ts +35 -1
  153. package/dist/types/endpoints.js +1 -1
  154. package/dist/types/puck.d.ts +1 -0
  155. package/dist/types/surface.d.ts +2 -0
  156. package/dist/ui/Button.js +2 -2
  157. package/dist/ui/Inputs.d.ts +4 -3
  158. package/dist/ui/Inputs.js +7 -4
  159. package/dist/ui/SelectControl.d.ts +33 -0
  160. package/dist/ui/SelectControl.js +504 -0
  161. package/dist/ui/Tabs.d.ts +0 -1
  162. package/dist/ui/Tabs.js +28 -40
  163. package/dist/ui/ui.css +18 -5
  164. package/package.json +3 -2
@@ -1,3 +1,5 @@
1
+ import { nestedPlacementNames, nameNestedPlacements } from './nestedPlacementNames.js';
2
+ import { nestedTestCopy } from '../puck/nestedTestCopy.js';
1
3
  import { goalContent } from '../goals/fairness.js';
2
4
  import { detached } from './placementInteractions.js';
3
5
  import { lockAndRescanPlacements, placementInteractions } from './placementInteractions.js';
@@ -35,6 +37,7 @@ export async function readExperiment(req, id) {
35
37
  }
36
38
  export function refuse(code, detail) {
37
39
  const messages = {
40
+ 'nested-tests': nestedTestCopy.readiness(detail),
38
41
  'goal-in-some-versions': asymmetricGoalsCopy(detail),
39
42
  'placements-changed': "This test's pages changed while it was starting. Try again.",
40
43
  'page-busy': "One of this test's pages is being saved right now. Try again in a moment.",
@@ -137,7 +140,7 @@ export async function start(req, { experimentId, options }) {
137
140
  const failure = checkStart({
138
141
  ...input,
139
142
  experiment: current,
140
- placements: rescan.placements
143
+ placements: nameNestedPlacements(rescan.placements, await nestedPlacementNames(req, rescan.placements))
141
144
  }).find((check)=>!check.ok);
142
145
  if (failure && failure.code !== 'page-targets-unchecked' && failure.code !== 'make-content-unsupported') refuse(failure.code, failure.detail);
143
146
  }
@@ -7,7 +7,7 @@ import type { Snapshot, VerdictCode } from './snapshot.js';
7
7
  export type ArmIssueCode = 'weights-total' | 'control-count' | 'control-first' | 'holdout-last' | 'holdout-count' | 'variant-count' | 'duplicate-key' | 'duplicate-slot' | 'slot-required' | 'invalid-key';
8
8
  /** Content-report dismiss/restore refusals (CORE-44). */
9
9
  export type ContentEntryRefusal = 'not-decided' | 'entry-not-found' | 'entry-ok' | 'entry-dismissed' | 'entry-not-dismissed';
10
- export type RefusalCode = ArmIssueCode | 'goal-in-some-versions' | 'placement-unchecked' | 'placement-unpublished' | 'duplicate-version-row' | 'interacting-tests' | 'placements-changed' | 'page-busy' | 'wrap-target-missing' | 'version-identical' | 'version-same-address' | 'unknown-collection' | 'not-found' | ContentEntryRefusal | 'no-planned-duration' | 'no-primary-metric' | 'no-placements' | 'placement-removed' | 'empty-slot' | 'page-in-use' | 'page-no-targets' | 'page-target-unpublished' | 'page-user-unit' | 'version-page-unavailable' | 'version-page-unchecked' | 'flag-no-point' | 'flag-params-invalid' | 'flag-point-busy' | 'flag-placement-missing' | 'layer-full' | 'layer-unit-mismatch' | 'unknown-metric-source' | 'unit-source-mismatch' | 'no-reach-per-day' | 'invalid-status' | 'stale-draft' | 'stale-edit' | 'commit-unverified' | 'allocation-lower' | 'confirmation-required' | 'invalid-winner' | 'slices-taken' | 'locked-placement' | 'not-implemented' | 'forbidden' | 'unauthenticated' | 'body-too-large' | 'invalid-body' | 'too-many-ids' | 'invalid-phase' | 'invalid-ids' | 'recompute-failed' | 'analysis-failed' | 'undeclared-targeting-key' | 'invalid-targeting-rule' | 'block-path-rule' | 'duplicate-metric';
10
+ export type RefusalCode = ArmIssueCode | 'nested-tests' | 'goal-in-some-versions' | 'placement-unchecked' | 'placement-unpublished' | 'duplicate-version-row' | 'interacting-tests' | 'placements-changed' | 'page-busy' | 'wrap-target-missing' | 'version-identical' | 'version-same-address' | 'unknown-collection' | 'not-found' | ContentEntryRefusal | 'no-planned-duration' | 'no-primary-metric' | 'no-placements' | 'placement-removed' | 'empty-slot' | 'page-in-use' | 'page-no-targets' | 'page-target-unpublished' | 'page-user-unit' | 'version-page-unavailable' | 'version-page-unchecked' | 'flag-no-point' | 'flag-params-invalid' | 'flag-point-busy' | 'flag-placement-missing' | 'layer-full' | 'layer-unit-mismatch' | 'unknown-metric-source' | 'unit-source-mismatch' | 'no-reach-per-day' | 'invalid-status' | 'stale-draft' | 'stale-edit' | 'commit-unverified' | 'allocation-lower' | 'confirmation-required' | 'invalid-winner' | 'slices-taken' | 'locked-placement' | 'not-implemented' | 'forbidden' | 'unauthenticated' | 'body-too-large' | 'invalid-body' | 'too-many-ids' | 'invalid-phase' | 'invalid-ids' | 'recompute-failed' | 'analysis-failed' | 'undeclared-targeting-key' | 'invalid-targeting-rule' | 'block-path-rule' | 'duplicate-metric';
11
11
  export type ErrorEnvelope = {
12
12
  errors: Array<{
13
13
  code: RefusalCode;
@@ -89,6 +89,9 @@ export type PreflightResult = {
89
89
  collection: string;
90
90
  id: DocId;
91
91
  title: string;
92
+ locales?: string[];
93
+ allLocales?: true;
94
+ slotCount?: number;
92
95
  url?: string;
93
96
  editorUrl?: string;
94
97
  slots?: Record<ArmSlot, number>;
@@ -251,6 +254,7 @@ export type PlacementStatusResult = {
251
254
  slot?: string;
252
255
  }>;
253
256
  winnerArm?: string;
257
+ discarded?: boolean;
254
258
  rollout: boolean;
255
259
  }>;
256
260
  };
@@ -261,3 +265,33 @@ export type WrapBlockBody = {
261
265
  blockId: string;
262
266
  experiment: string;
263
267
  };
268
+ /** Current visitor effect of deleting a draft or archived test; independent of its stored content report. */
269
+ export type DeleteImpactResult = {
270
+ effect: 'none';
271
+ } | {
272
+ effect: 'block';
273
+ controlLabel: string;
274
+ unreadablePages: number;
275
+ pageCount: number;
276
+ placements: Array<{
277
+ collection: string;
278
+ id: DocId;
279
+ title: string;
280
+ path: string | null;
281
+ locales?: string[];
282
+ allLocales?: true;
283
+ before: {
284
+ key: string;
285
+ label: string;
286
+ };
287
+ after: {
288
+ key: string;
289
+ label: string;
290
+ };
291
+ }>;
292
+ } | {
293
+ effect: 'page';
294
+ winnerPath: string;
295
+ addresses: string[];
296
+ afterPaths?: Record<string, string>;
297
+ };
@@ -1 +1 @@
1
- export { };
1
+ /** Current visitor effect of deleting a draft or archived test; independent of its stored content report. */ export { };
@@ -12,6 +12,7 @@ export type ExperimentSlotProps = {
12
12
  variantA: Slot;
13
13
  variantB: Slot;
14
14
  variantC: Slot;
15
+ _visibility?: unknown;
15
16
  xpArm?: string;
16
17
  xpSlot?: ArmSlot;
17
18
  xpExpose?: {
@@ -7,6 +7,8 @@ export interface TestsSurfaceProps {
7
7
  returnToTest?: string;
8
8
  adminRoute: string;
9
9
  apiRoute: string;
10
+ contentLanguageLabels?: string[];
11
+ contentLocale?: string;
10
12
  collectionTitles?: Record<string, string>;
11
13
  userId?: string | number;
12
14
  userCollection?: string;
package/dist/ui/Button.js CHANGED
@@ -12,7 +12,7 @@ export function Button({ variant = 'secondary', size = 'md', disabled, busy, cla
12
12
  href: blocked ? undefined : href,
13
13
  role: blocked ? 'link' : undefined,
14
14
  "aria-disabled": blocked || undefined,
15
- "aria-busy": busy || undefined,
15
+ "aria-busy": busy || props['aria-busy'] || undefined,
16
16
  tabIndex: blocked ? -1 : rest.tabIndex,
17
17
  onClick: (event)=>{
18
18
  if (blocked) event.preventDefault();
@@ -26,7 +26,7 @@ export function Button({ variant = 'secondary', size = 'md', disabled, busy, cla
26
26
  type: props.type ?? 'button',
27
27
  className: classes,
28
28
  disabled: blocked,
29
- "aria-busy": busy || undefined,
29
+ "aria-busy": busy || props['aria-busy'] || undefined,
30
30
  children: children
31
31
  });
32
32
  }
@@ -1,4 +1,5 @@
1
- import type { InputHTMLAttributes, SelectHTMLAttributes, TextareaHTMLAttributes, ReactNode } from 'react';
1
+ import type { InputHTMLAttributes, TextareaHTMLAttributes, ReactNode } from 'react';
2
+ import type { SelectControlProps } from './SelectControl.js';
2
3
  import './ui.css';
3
4
  export interface FieldProps {
4
5
  id: string;
@@ -12,8 +13,8 @@ export declare function NumberInput(props: TextInputProps): import("react").JSX.
12
13
  export declare function SearchInput(props: TextInputProps): import("react").JSX.Element;
13
14
  export type SelectProps = FieldProps & {
14
15
  labelAction?: ReactNode;
15
- } & Omit<SelectHTMLAttributes<HTMLSelectElement>, 'id'>;
16
- export declare function Select({ label, labelAction, help, error, className, ...props }: SelectProps): import("react").JSX.Element;
16
+ } & Omit<SelectControlProps, 'id'>;
17
+ export declare function Select({ label, labelAction, help, error, ...props }: SelectProps): import("react").JSX.Element;
17
18
  export declare function Toggle({ label, help, error, className, ...props }: Omit<TextInputProps, 'type'>): import("react").JSX.Element;
18
19
  export type TextareaProps = FieldProps & Omit<TextareaHTMLAttributes<HTMLTextAreaElement>, 'id'>;
19
20
  export declare function Textarea({ label, help, error, className, ...props }: TextareaProps): import("react").JSX.Element;
package/dist/ui/Inputs.js CHANGED
@@ -1,5 +1,6 @@
1
1
  'use client';
2
2
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
3
+ import { SelectControl } from './SelectControl.js';
3
4
  import './ui.css';
4
5
  function described(props, extra) {
5
6
  return [
@@ -16,12 +17,14 @@ function Field({ id, label, labelAction, help, error, children }) {
16
17
  className: "xp-ui-field-label",
17
18
  children: [
18
19
  /*#__PURE__*/ _jsx("label", {
20
+ id: `${id}-label`,
19
21
  htmlFor: id,
20
22
  children: label
21
23
  }),
22
24
  labelAction
23
25
  ]
24
26
  }) : /*#__PURE__*/ _jsx("label", {
27
+ id: `${id}-label`,
25
28
  htmlFor: id,
26
29
  children: label
27
30
  }),
@@ -70,7 +73,7 @@ export function SearchInput(props) {
70
73
  type: "search"
71
74
  });
72
75
  }
73
- export function Select({ label, labelAction, help, error, className = '', ...props }) {
76
+ export function Select({ label, labelAction, help, error, ...props }) {
74
77
  const field = {
75
78
  id: props.id,
76
79
  label,
@@ -80,10 +83,10 @@ export function Select({ label, labelAction, help, error, className = '', ...pro
80
83
  return /*#__PURE__*/ _jsx(Field, {
81
84
  ...field,
82
85
  labelAction: labelAction,
83
- children: /*#__PURE__*/ _jsx("select", {
86
+ children: /*#__PURE__*/ _jsx(SelectControl, {
84
87
  ...props,
85
- className: `xp-ui-input xp-ui-select ${className}`,
86
- "aria-invalid": Boolean(error) || undefined,
88
+ "aria-labelledby": props['aria-labelledby'] ?? (props['aria-label'] ? undefined : `${props.id}-label`),
89
+ "aria-invalid": Boolean(error) || props['aria-invalid'] || undefined,
87
90
  "aria-describedby": described(field, props['aria-describedby'])
88
91
  })
89
92
  });
@@ -0,0 +1,33 @@
1
+ import type { ButtonHTMLAttributes, ReactNode } from 'react';
2
+ export interface SelectOption {
3
+ value: string;
4
+ label: string;
5
+ disabled?: boolean;
6
+ group?: string;
7
+ }
8
+ export interface SelectChange {
9
+ target: {
10
+ value: string;
11
+ name?: string;
12
+ };
13
+ currentTarget: {
14
+ value: string;
15
+ name?: string;
16
+ };
17
+ }
18
+ export interface SelectControlProps extends Omit<ButtonHTMLAttributes<HTMLButtonElement>, 'onChange' | 'value' | 'defaultValue' | 'children'> {
19
+ id: string;
20
+ value?: string | number | readonly string[];
21
+ defaultValue?: string | number | readonly string[];
22
+ options?: readonly SelectOption[];
23
+ children?: ReactNode;
24
+ onChange?: (event: SelectChange) => void;
25
+ name?: string;
26
+ form?: string;
27
+ required?: boolean;
28
+ }
29
+ /** Select-only combobox: DOM focus stays on the button while active-descendant
30
+ * focus explores the list. The manual popover lives in the trigger's document
31
+ * and inherits its theme; the browser's top layer escapes scroll/iframe drawers.
32
+ */
33
+ export declare function SelectControl({ id, value, defaultValue, options: supplied, children, onChange, name, form, required, disabled, className, onKeyDown, onBlur, ...props }: SelectControlProps): import("react").JSX.Element;