@delmaredigital/payload-experiments 0.5.3 → 0.5.4

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.
@@ -1,6 +1,7 @@
1
1
  import { type ReactNode } from 'react';
2
2
  import type { DocId } from '../../../types/contracts.js';
3
3
  import type { SurfaceProps } from '../../../testSurface/surface/contracts.js';
4
+ import '../../../testSurface/surface/test/testPage.css';
4
5
  import './newTest.css';
5
6
  /** One session stays mounted across Collection, all page steps and Review. */
6
7
  export declare function PageWizard({ id, surface, kindChip }: {
@@ -24,6 +24,7 @@ import { LifecycleDialog } from '../../../testSurface/actions/LifecycleAction.js
24
24
  import { Button } from '../../../ui/Button.js';
25
25
  import { Banner } from '../../../ui/Feedback.js';
26
26
  import { Select } from '../../../ui/Select.js';
27
+ import '../../../testSurface/surface/test/testPage.css';
27
28
  import './newTest.css';
28
29
  /** One session stays mounted across Collection, all page steps and Review. */ export function PageWizard({ id, surface, kindChip }) {
29
30
  const router = useRouter();
@@ -155,6 +156,7 @@ import './newTest.css';
155
156
  surface: surface
156
157
  }),
157
158
  /*#__PURE__*/ _jsx("ul", {
159
+ className: "xp-page-wizard-checks",
158
160
  children: test.preflight?.checks.map((check, index)=>{
159
161
  if (!Object.hasOwn(READINESS, check.code)) return check.ok ? null : /*#__PURE__*/ _jsx("li", {
160
162
  children: SURFACE_COPY.next
@@ -162,14 +164,19 @@ import './newTest.css';
162
164
  const row = READINESS[check.code];
163
165
  const sentence = row.next(check.detail, ctx);
164
166
  const label = typeof row.nextStep === 'function' ? row.nextStep(check.detail, ctx) : row.nextStep;
165
- return sentence && !check.ok ? /*#__PURE__*/ _jsxs("li", {
166
- children: [
167
- sentence,
168
- label ? /*#__PURE__*/ _jsx(Button, {
169
- onClick: ()=>jump(row.section, readinessArm(check.code, check.detail, ctx)),
170
- children: label
171
- }) : null
172
- ]
167
+ return sentence && !check.ok ? /*#__PURE__*/ _jsx("li", {
168
+ children: /*#__PURE__*/ _jsxs("div", {
169
+ className: "xp-ui-button-group",
170
+ children: [
171
+ /*#__PURE__*/ _jsx("span", {
172
+ children: sentence
173
+ }),
174
+ label ? /*#__PURE__*/ _jsx(Button, {
175
+ onClick: ()=>jump(row.section, readinessArm(check.code, check.detail, ctx)),
176
+ children: label
177
+ }) : null
178
+ ]
179
+ })
173
180
  }, `${check.code}/${index}`) : null;
174
181
  })
175
182
  }),
@@ -16,6 +16,7 @@
16
16
  .xp-new-test-choice span { display: block; margin-inline-start: var(--xp-space-6); color: var(--xp-text-2); }
17
17
  .xp-new-test summary { cursor: pointer; margin-bottom: var(--xp-space-2); }
18
18
  .xp-new-test-kind, .xp-new-test-actions { display: flex; gap: var(--xp-space-2); align-items: center; }
19
+ .xp-new-test-actions { flex-wrap: wrap; }
19
20
  .xp-new-test-actions > .xp-ui-button--primary { margin-inline-start: auto; }
20
21
  .xp-new-test-collection { max-width: 16rem; }
21
22
  .xp-new-test-help { color: var(--xp-text-2); max-width: 65ch; }
@@ -26,3 +27,6 @@
26
27
  .xp-page-wizard .xp-copy-route ol { margin-block: 0; }
27
28
  .xp-page-wizard-review { display: grid; gap: var(--xp-space-3); }
28
29
  .xp-page-wizard-review > .xp-ui-button { justify-self: start; }
30
+ .xp-page-wizard-checks { display: grid; gap: var(--xp-space-2); margin-block: 0; overflow-wrap: anywhere; }
31
+ .xp-page-wizard-checks:empty { display: none; }
32
+ .xp-page-wizard-checks > li > .xp-ui-button-group { align-items: center; gap: var(--xp-space-2); }
@@ -8,7 +8,7 @@ export declare function isValidTimeZone(tz: string): boolean;
8
8
  export declare function isActive(spec: ActiveSpec, pauses: PauseInterval[], now: Date): boolean;
9
9
  export declare function inactiveIntervals(spec: ActiveSpec, pauses: Pauses, range: DateRange): DateRange[];
10
10
  export declare function activeDays(spec: ActiveSpec, pauses: Pauses, range: DateRange): number;
11
- /** Wall-clock input for an instant, independent of the browser's time zone. */
11
+ /** Wall-clock input to the minute, independent of the browser's time zone. */
12
12
  export declare function formatLocalDateTime(value: string | null | undefined, timeZone: string): string;
13
13
  /** Choose the first occurrence of a repeated clock time and refuse nonexistent times. */
14
14
  export declare function parseLocalDateTime(value: string, timeZone: string): string | null;
@@ -222,10 +222,10 @@ function localDateSpans(timeZone, date) {
222
222
  to: date + DAY - segment.offset
223
223
  })).filter((span)=>span.from < span.to);
224
224
  }
225
- /** Wall-clock input for an instant, independent of the browser's time zone. */ export function formatLocalDateTime(value, timeZone) {
225
+ /** Wall-clock input to the minute, independent of the browser's time zone. */ export function formatLocalDateTime(value, timeZone) {
226
226
  const instant = Date.parse(value ?? '');
227
227
  if (!Number.isFinite(instant)) return '';
228
- return new Date(instant + offsetAt(formatterFor(timeZone), instant)).toISOString().slice(0, -1);
228
+ return new Date(instant + offsetAt(formatterFor(timeZone), instant)).toISOString().slice(0, -8);
229
229
  }
230
230
  /** Choose the first occurrence of a repeated clock time and refuse nonexistent times. */ export function parseLocalDateTime(value, timeZone) {
231
231
  const clock = Date.parse(`${value}Z`);
@@ -114,6 +114,7 @@ export declare const TEST_PAGE: {
114
114
  readonly endDate: "Planned end date";
115
115
  readonly noSuggestion: "Enter a daily number above to get a suggestion. 4 weeks is a safe default.";
116
116
  readonly chooseGoalSuggestion: "Choose a goal to get a suggestion.";
117
+ readonly insufficientGoalData: "There isn't enough past data for this goal to suggest a length yet. 4 weeks is a safe default.";
117
118
  readonly required: "(required)";
118
119
  readonly apply: "Apply";
119
120
  readonly infeasible: "This may need more people than are available.";
@@ -116,6 +116,7 @@ export const TEST_PAGE = {
116
116
  endDate: 'Planned end date',
117
117
  noSuggestion: 'Enter a daily number above to get a suggestion. 4 weeks is a safe default.',
118
118
  chooseGoalSuggestion: 'Choose a goal to get a suggestion.',
119
+ insufficientGoalData: "There isn't enough past data for this goal to suggest a length yet. 4 weeks is a safe default.",
119
120
  required: '(required)',
120
121
  apply: 'Apply',
121
122
  infeasible: 'This may need more people than are available.'
@@ -30,12 +30,12 @@ export function ReadinessReadStatus({ test, messageInBlockerList = false }) {
30
30
  const read = test.preflightRead ?? (test.preflightError ? readinessRead(test) : undefined);
31
31
  return /*#__PURE__*/ _jsx(_Fragment, {
32
32
  children: read?.message ? /*#__PURE__*/ _jsxs("div", {
33
+ className: "xp-ui-button-group",
33
34
  children: [
34
35
  !messageInBlockerList ? /*#__PURE__*/ _jsx("span", {
35
36
  role: "alert",
36
37
  children: read.message
37
38
  }) : null,
38
- ' ',
39
39
  read.retry ? /*#__PURE__*/ _jsx(Button, {
40
40
  disabled: retrying || test.preflightPending,
41
41
  onClick: ()=>{
@@ -465,11 +465,12 @@ export function CohortRuleEditor({ test, surface, index, pending = false, draftI
465
465
  role: "status",
466
466
  children: C.loading
467
467
  }) : !result.rows ? /*#__PURE__*/ _jsxs("div", {
468
- className: "xp-page-message",
468
+ className: "xp-page-message xp-ui-button-group",
469
469
  role: "alert",
470
470
  children: [
471
- C.searchError,
472
- ' ',
471
+ /*#__PURE__*/ _jsx("span", {
472
+ children: C.searchError
473
+ }),
473
474
  /*#__PURE__*/ _jsx(Button, {
474
475
  size: "sm",
475
476
  onClick: ()=>{
@@ -219,17 +219,16 @@ export function GoalSection({ test, surface, embedded = false }) {
219
219
  test: test,
220
220
  sectionId: "win",
221
221
  children: [
222
- failed ? /*#__PURE__*/ _jsxs("p", {
222
+ failed ? /*#__PURE__*/ _jsxs("div", {
223
223
  role: "alert",
224
+ className: "xp-goal-retry xp-ui-button-group",
224
225
  children: [
225
- C.goalsError,
226
- " ",
227
226
  /*#__PURE__*/ _jsx("span", {
228
- className: "xp-ui-button-group",
229
- children: /*#__PURE__*/ _jsx(Button, {
230
- onClick: ()=>setAttempt((n)=>n + 1),
231
- children: C.retry
232
- })
227
+ children: C.goalsError
228
+ }),
229
+ /*#__PURE__*/ _jsx(Button, {
230
+ onClick: ()=>setAttempt((n)=>n + 1),
231
+ children: C.retry
233
232
  })
234
233
  ]
235
234
  }) : null,
@@ -15,6 +15,7 @@ export function LengthSection({ test, surface }) {
15
15
  const reason = reasonFor(test, 'analysis');
16
16
  const days = doc.analysis?.plannedDurationDays ?? 28;
17
17
  const suggestion = !reason ? durationSuggestion(test.preflight, days) : null;
18
+ const noEstimateHint = doc.analysis?.reachPerDay == null ? C.noSuggestion : doc.metrics?.primary == null ? C.chooseGoalSuggestion : C.insufficientGoalData;
18
19
  const windows = doc.schedule?.windows ?? [];
19
20
  const week = activeWeek(windows);
20
21
  const zone = doc.schedule?.timeZone || surface.timeZone || test.preflight?.scheduleTimeZone;
@@ -61,13 +62,10 @@ export function LengthSection({ test, surface }) {
61
62
  type: "number",
62
63
  min: 1,
63
64
  reason: reason,
65
+ help: !reason ? C.reachHelp : undefined,
64
66
  required: required && !reason,
65
67
  onCommit: (value)=>change('reachPerDay', value)
66
68
  }),
67
- !reason ? /*#__PURE__*/ _jsx("p", {
68
- className: "xp-ui-help",
69
- children: C.reachHelp
70
- }) : null,
71
69
  /*#__PURE__*/ _jsx(FieldErrors, {
72
70
  test: test,
73
71
  path: "analysis.reachPerDay"
@@ -120,7 +118,7 @@ export function LengthSection({ test, surface }) {
120
118
  }) : null
121
119
  ]
122
120
  }) : !reason && !test.preflight?.estimate ? /*#__PURE__*/ _jsx("p", {
123
- children: doc.analysis?.reachPerDay == null ? C.noSuggestion : C.chooseGoalSuggestion
121
+ children: noEstimateHint
124
122
  }) : null,
125
123
  test.errors.analysis ? /*#__PURE__*/ _jsx("p", {
126
124
  role: "alert",
@@ -14,6 +14,7 @@ import { Button } from '../../../ui/Button.js';
14
14
  const reason = reasonFor(test, 'arms');
15
15
  if (reason && !arm) return null;
16
16
  return /*#__PURE__*/ _jsxs("div", {
17
+ className: "xp-page-holdout",
17
18
  children: [
18
19
  arm ? /*#__PURE__*/ _jsxs(_Fragment, {
19
20
  children: [
@@ -9,7 +9,7 @@ export function ScheduleDateInput({ timeZone, ...props }) {
9
9
  ...props,
10
10
  id: id,
11
11
  type: "datetime-local",
12
- step: "0.001",
12
+ step: "60",
13
13
  help: timeZone || C.noZone
14
14
  });
15
15
  }
@@ -24,19 +24,34 @@
24
24
  :where(.xp-test-surface) .xp-traffic-bar > span { display: block; }
25
25
  :where(.xp-test-surface) .xp-split-legend { display: flex; flex-wrap: wrap; gap: var(--xp-space-4); font: var(--xp-text-small); color: var(--xp-text-2); }
26
26
  :where(.xp-test-surface) .xp-split-legend i { display: inline-block; width: var(--xp-legend-key-size); height: var(--xp-legend-key-size); border-radius: var(--xp-legend-key-radius); margin-right: var(--xp-space-one-half); }
27
- :where(.xp-test-surface) .xp-field-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--xp-space-4); }
27
+ :where(.xp-test-surface, #section-schedule) .xp-field-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--xp-space-4); }
28
28
  :where(.xp-test-surface) .xp-test-advanced .xp-field-grid { padding-top: var(--xp-space-4); }
29
- :where(.xp-test-surface) .xp-field-grid > div { min-width: 0; }
29
+ :where(.xp-test-surface, #section-schedule) .xp-field-grid > div { min-width: 0; }
30
30
  :where(.xp-test-surface) .xp-field-grid p, :where(.xp-test-surface) .xp-page-binding p { color: var(--xp-text-2); font: var(--xp-text-small); }
31
31
  :where(.xp-test-surface) .xp-read-only code { font-family: var(--xp-mono); overflow-wrap: anywhere; }
32
32
  :where(.xp-test-surface) .xp-ui-checkbox-list { display: flex; flex-wrap: wrap; gap: var(--xp-space-2) var(--xp-space-4); }
33
33
  :where(.xp-test-surface) .xp-duration-suggestion { align-items: center; margin-top: var(--xp-space-4); }
34
34
  :where(.xp-test-surface) .xp-read-only { padding-block: .5rem; }
35
35
  :where(.xp-test-surface) .xp-read-only p { margin-block: .5rem; color: var(--xp-text); font: var(--xp-text-body); }
36
- :where(.xp-test-surface) .xp-section-lock { margin-block: 0; }
36
+ :where(.xp-test-surface) .xp-section-lock { margin-block: 0 var(--xp-space-2); }
37
+ :where(#section-what, #section-schedule) > .xp-ui-section-body { display: grid; grid-template-columns: minmax(0, 1fr); gap: var(--xp-space-4); }
38
+ :where(#section-what, #section-schedule) > .xp-ui-section-body > p { margin-block: 0; }
39
+ :where(.xp-test-surface) .xp-field-draft-notice { margin-block-start: var(--xp-space-2); }
40
+ :where(.xp-test-surface) .xp-test-blocker:not(:first-child) { margin-block-start: var(--xp-space-2); }
41
+ :where(#section-what, #section-schedule) > .xp-ui-section-body > .xp-test-blocker { margin-block: 0; }
37
42
  :where(.xp-test-surface) .xp-page-binding-row { align-items: center; }
38
- :where(.xp-test-surface) .xp-page-binding { margin-block-end: var(--xp-space-4); }
39
- :where(.xp-test-surface) .xp-page-binding > .xp-ui-help { margin-block: var(--xp-space-2) 0; }
43
+ :where(.xp-test-surface) .xp-page-binding, :where(.xp-test-surface) .xp-page-holdout { display: grid; gap: var(--xp-space-2); }
44
+ :where(.xp-test-surface) .xp-page-binding:empty { display: none; }
45
+ :where(.xp-test-surface) .xp-page-binding > p { margin-block: 0; }
46
+ :where(.xp-test-surface) .xp-page-holdout > .xp-ui-button { justify-self: start; }
47
+ :where(.xp-test-surface) .xp-split-legend + .xp-ui-help,
48
+ :where(.xp-test-surface) .xp-section-actions ~ .xp-ui-help + :is(.xp-ui-field, .xp-read-only),
49
+ :where(#section-who) > .xp-ui-section-body > .xp-ui-help + .xp-ui-button-group,
50
+ :where(#section-length) .xp-field-grid + p,
51
+ :where(.xp-test-surface) .xp-ui-dialog > .xp-ui-field + .xp-ui-field { margin-block-start: var(--xp-space-2); }
52
+ :where(.xp-test-surface) .xp-goal-retry, :where(.xp-test-surface) .xp-cohort-row .xp-page-message[role='alert'] { align-items: center; }
53
+ :where(.xp-test-surface) .xp-goal-retry { margin-block-end: var(--xp-space-2); }
54
+ :where(.xp-test-surface) .xp-other-goals { margin-block-start: var(--xp-space-4); }
40
55
  :where(.xp-test-surface) .xp-field-error { color: var(--xp-error-text); }
41
56
 
42
57
  :where(.xp-test-surface) .xp-targeting-row { display: grid; grid-template-columns: var(--xp-targeting-attribute-width) var(--xp-targeting-comparison-width) minmax(0, 1fr); align-items: start; gap: var(--xp-space-3); border: 1px solid var(--xp-border); border-radius: var(--xp-radius-control); padding: var(--xp-space-4); margin-bottom: var(--xp-space-4); }
@@ -47,7 +62,7 @@
47
62
  :where(.xp-test-surface) .xp-version-remove:empty { display: none; }
48
63
  :where(.xp-test-surface) .xp-version-content, :where(.xp-test-surface) .xp-setting-values, :where(.xp-test-surface) .xp-version-remove { grid-column: 1 / -1; }
49
64
  :where(.xp-test-surface) .xp-version-grid-head > :nth-child(n+3) { display: none; }
50
- :where(.xp-test-surface) .xp-targeting-row, :where(.xp-test-surface) .xp-field-grid { grid-template-columns: 1fr; }
65
+ :where(.xp-test-surface) .xp-targeting-row, :where(.xp-test-surface, #section-schedule) .xp-field-grid { grid-template-columns: minmax(0, 1fr); }
51
66
  }
52
67
 
53
68
  :where(.xp-test-surface) .xp-version-rows.xp-version-rows--setting { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); align-items: start; }
@@ -77,6 +92,9 @@
77
92
  :where(.xp-test-surface) .xp-readiness__state { display: flex; align-items: center; flex-wrap: wrap; gap: var(--xp-space-2); min-width: 0; }
78
93
  :where(.xp-test-surface) .xp-readiness__state p, :where(.xp-test-surface) .xp-readiness--bar > p { margin: 0; }
79
94
  :where(.xp-test-surface) .xp-readiness__state > p { font-weight: 500; white-space: pre-line; }
95
+ :where(.xp-test-surface) .xp-readiness__blockers ul { display: grid; gap: var(--xp-space-1); margin-block-start: var(--xp-space-1); }
96
+ .xp-save-status > .xp-ui-button-group { align-items: center; }
97
+ .xp-save-status > .xp-ui-button-group:not(:first-child):not(:empty) { margin-block-start: var(--xp-space-1); }
80
98
  :where(.xp-test-surface) .xp-readiness--bar .xp-save-status, :where(.xp-test-surface) .xp-readiness__separator { color: var(--xp-text-3); font: var(--xp-text-small); }
81
99
  :where(.xp-test-surface) .xp-readiness__actions { display: flex; flex-wrap: wrap; align-items: center; gap: var(--xp-space-2); }
82
100
  :where(.xp-test-surface) .xp-readiness--bar > .xp-readiness__actions { grid-column: 2; grid-row: 1 / span 3; justify-content: flex-end; }
@@ -115,6 +133,7 @@
115
133
  justify-items: start;
116
134
  min-inline-size: 0;
117
135
  }
136
+ .xp-schedule-windows > h3 { margin: 0; font: var(--xp-text-body); font-weight: 600; }
118
137
  .xp-schedule-window {
119
138
  width: 100%;
120
139
  padding: .875rem;
@@ -132,6 +151,7 @@
132
151
  .xp-cohort-row p { margin-block: 0; }
133
152
  .xp-cohort-row .xp-cohort-options { border: 0; padding: 0; margin: 0; min-inline-size: 0; }
134
153
  .xp-cohort-options legend { padding: 0; margin-block-end: var(--xp-space-2); }
154
+ .xp-cohort-options > .xp-ui-button-group + p { margin-block-start: var(--xp-space-2); }
135
155
  .xp-cohort-row .xp-ui-button[aria-pressed] { border-radius: 999px; }
136
156
  .xp-cohort-row .xp-ui-button[aria-pressed='true'] { background: var(--xp-text); border-color: var(--xp-text); color: var(--xp-surface); }
137
157
  .xp-cohort-row .xp-page-option { flex-wrap: wrap; }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@delmaredigital/payload-experiments",
3
- "version": "0.5.3",
3
+ "version": "0.5.4",
4
4
  "description": "No-code A/B testing for Payload CMS and Next.js: block, page and flag experiments with holdouts, layers, exposure logging and honest statistics inside the admin — no vendor",
5
5
  "type": "module",
6
6
  "license": "MIT",
@@ -149,7 +149,7 @@
149
149
  "yaml": "2.9.1"
150
150
  },
151
151
  "scripts": {
152
- "build": "swc ./src -d ./dist --strip-leading-paths --config-file ../../.swcrc && tsc -p tsconfig.build.json && copyfiles -u 1 \"src/**/*.css\" dist",
152
+ "build": "swc ./src -d ./dist --strip-leading-paths --config-file ../../.swcrc && tsc -p tsconfig.build.json && node scripts/copy-css.mjs",
153
153
  "dev": "swc ./src -d ./dist --strip-leading-paths --config-file ../../.swcrc --watch",
154
154
  "typecheck": "tsc -p tsconfig.json && tsc -p tsconfig.test.json",
155
155
  "check:esm": "node scripts/check-node-esm.mjs",