@drawbridge/components 0.1.41 → 0.1.42

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.
@@ -110,6 +110,7 @@ const field = ({
110
110
  control,
111
111
  input,
112
112
  label,
113
+ message,
113
114
  name,
114
115
  rules
115
116
  }) => /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
@@ -127,7 +128,8 @@ const field = ({
127
128
  onChange,
128
129
  value
129
130
  }),
130
- label
131
+ label,
132
+ message
131
133
  }
132
134
  }
133
135
  ),
@@ -136,7 +138,7 @@ const field = ({
136
138
  },
137
139
  name
138
140
  );
139
- const title = (control) => field({
141
+ const title = (control, message) => field({
140
142
  control,
141
143
  input: (props) => /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
142
144
  import_input_text.default,
@@ -148,6 +150,7 @@ const title = (control) => field({
148
150
  }
149
151
  ),
150
152
  label: "Title",
153
+ message,
151
154
  name: "title",
152
155
  rules: {
153
156
  required: "Title is required"
@@ -192,7 +195,7 @@ const FormTest = ({
192
195
  }
193
196
  }
194
197
  ),
195
- title(control)
198
+ title(control, values.title ? void 0 : 'Name it for what you are testing, such as "Video first"')
196
199
  ]
197
200
  }
198
201
  );
@@ -227,7 +230,7 @@ const FormVariant = ({
227
230
  }
228
231
  }
229
232
  ),
230
- title(control),
233
+ title(control, 'Name it for the one thing you will change, such as "No video"'),
231
234
  pages.length > 1 && field({
232
235
  control,
233
236
  input: (props) => /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
@@ -442,6 +445,7 @@ const RowVariant = ({
442
445
  const FormTestRail = ({
443
446
  addReason,
444
447
  disabled,
448
+ draft,
445
449
  notice,
446
450
  onAdd,
447
451
  onDates,
@@ -491,6 +495,29 @@ const FormTestRail = ({
491
495
  });
492
496
  }
493
497
  );
498
+ const next = notice || (!draft ? null : startsAt && endsAt ? {
499
+ button: {
500
+ disabled,
501
+ element: "button",
502
+ loading: formState.isSubmitting,
503
+ onClick: () => {
504
+ },
505
+ text: "Schedule",
506
+ type: "submit"
507
+ },
508
+ message: "Your test starts on " + (0, import_ab_tests.short)(startsAt),
509
+ title: "Ready to schedule"
510
+ } : {
511
+ button: {
512
+ disabled,
513
+ element: "button",
514
+ onClick: dates,
515
+ text: "Set dates",
516
+ type: "button"
517
+ },
518
+ message: "A test runs from its start date to its end date",
519
+ title: "Set your dates"
520
+ });
494
521
  return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
495
522
  import_form2.default,
496
523
  {
@@ -526,10 +553,10 @@ const FormTestRail = ({
526
553
  }
527
554
  }
528
555
  ) }),
529
- notice && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
556
+ next && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
530
557
  import_card_task.default,
531
558
  {
532
- ...notice
559
+ ...next
533
560
  }
534
561
  ),
535
562
  title(control),
@@ -541,6 +568,7 @@ const FormTestRail = ({
541
568
  import_button.default,
542
569
  {
543
570
  ...{
571
+ "data-guide": "test-dates",
544
572
  icon: import_calendar.default,
545
573
  justify: "between",
546
574
  onClick: dates,
@@ -580,6 +608,7 @@ const FormTestRail = ({
580
608
  {
581
609
  ...{
582
610
  "aria-label": "Add variant",
611
+ "data-guide": "test-add",
583
612
  disabled: Boolean(disabled || addReason),
584
613
  icon: import_plus.default,
585
614
  inline: true,
@@ -608,7 +637,8 @@ const FormTestRail = ({
608
637
  "div",
609
638
  {
610
639
  ...{
611
- className: "divide-y divide-gray"
640
+ className: "divide-y divide-gray",
641
+ "data-guide": "test-split"
612
642
  },
613
643
  children: pages.map((page) => /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
614
644
  RowVariant,
@@ -656,6 +686,7 @@ const FormTestRail = ({
656
686
  import_button.default,
657
687
  {
658
688
  ...{
689
+ "data-guide": "test-submit",
659
690
  loading: formState.isSubmitting,
660
691
  type: "submit"
661
692
  },
@@ -17,7 +17,7 @@ import Dropdown from "./dropdown.mjs";
17
17
  import Calendar from "../icons/calendar.mjs";
18
18
  import Ellipsis from "../icons/ellipsis.mjs";
19
19
  import Plus from "../icons/plus.mjs";
20
- import { even, move, span, WEEK } from "./lib/ab-tests.mjs";
20
+ import { even, move, short, span, WEEK } from "./lib/ab-tests.mjs";
21
21
  const Shell = ({
22
22
  children,
23
23
  disabled,
@@ -74,6 +74,7 @@ const field = ({
74
74
  control,
75
75
  input,
76
76
  label,
77
+ message,
77
78
  name,
78
79
  rules
79
80
  }) => /* @__PURE__ */ jsx(
@@ -91,7 +92,8 @@ const field = ({
91
92
  onChange,
92
93
  value
93
94
  }),
94
- label
95
+ label,
96
+ message
95
97
  }
96
98
  }
97
99
  ),
@@ -100,7 +102,7 @@ const field = ({
100
102
  },
101
103
  name
102
104
  );
103
- const title = (control) => field({
105
+ const title = (control, message) => field({
104
106
  control,
105
107
  input: (props) => /* @__PURE__ */ jsx(
106
108
  InputText,
@@ -112,6 +114,7 @@ const title = (control) => field({
112
114
  }
113
115
  ),
114
116
  label: "Title",
117
+ message,
115
118
  name: "title",
116
119
  rules: {
117
120
  required: "Title is required"
@@ -156,7 +159,7 @@ const FormTest = ({
156
159
  }
157
160
  }
158
161
  ),
159
- title(control)
162
+ title(control, values.title ? void 0 : 'Name it for what you are testing, such as "Video first"')
160
163
  ]
161
164
  }
162
165
  );
@@ -191,7 +194,7 @@ const FormVariant = ({
191
194
  }
192
195
  }
193
196
  ),
194
- title(control),
197
+ title(control, 'Name it for the one thing you will change, such as "No video"'),
195
198
  pages.length > 1 && field({
196
199
  control,
197
200
  input: (props) => /* @__PURE__ */ jsx(
@@ -406,6 +409,7 @@ const RowVariant = ({
406
409
  const FormTestRail = ({
407
410
  addReason,
408
411
  disabled,
412
+ draft,
409
413
  notice,
410
414
  onAdd,
411
415
  onDates,
@@ -455,6 +459,29 @@ const FormTestRail = ({
455
459
  });
456
460
  }
457
461
  );
462
+ const next = notice || (!draft ? null : startsAt && endsAt ? {
463
+ button: {
464
+ disabled,
465
+ element: "button",
466
+ loading: formState.isSubmitting,
467
+ onClick: () => {
468
+ },
469
+ text: "Schedule",
470
+ type: "submit"
471
+ },
472
+ message: "Your test starts on " + short(startsAt),
473
+ title: "Ready to schedule"
474
+ } : {
475
+ button: {
476
+ disabled,
477
+ element: "button",
478
+ onClick: dates,
479
+ text: "Set dates",
480
+ type: "button"
481
+ },
482
+ message: "A test runs from its start date to its end date",
483
+ title: "Set your dates"
484
+ });
458
485
  return /* @__PURE__ */ jsx(
459
486
  Form,
460
487
  {
@@ -490,10 +517,10 @@ const FormTestRail = ({
490
517
  }
491
518
  }
492
519
  ) }),
493
- notice && /* @__PURE__ */ jsx(
520
+ next && /* @__PURE__ */ jsx(
494
521
  CardTask,
495
522
  {
496
- ...notice
523
+ ...next
497
524
  }
498
525
  ),
499
526
  title(control),
@@ -505,6 +532,7 @@ const FormTestRail = ({
505
532
  Button,
506
533
  {
507
534
  ...{
535
+ "data-guide": "test-dates",
508
536
  icon: Calendar,
509
537
  justify: "between",
510
538
  onClick: dates,
@@ -544,6 +572,7 @@ const FormTestRail = ({
544
572
  {
545
573
  ...{
546
574
  "aria-label": "Add variant",
575
+ "data-guide": "test-add",
547
576
  disabled: Boolean(disabled || addReason),
548
577
  icon: Plus,
549
578
  inline: true,
@@ -572,7 +601,8 @@ const FormTestRail = ({
572
601
  "div",
573
602
  {
574
603
  ...{
575
- className: "divide-y divide-gray"
604
+ className: "divide-y divide-gray",
605
+ "data-guide": "test-split"
576
606
  },
577
607
  children: pages.map((page) => /* @__PURE__ */ jsx(
578
608
  RowVariant,
@@ -620,6 +650,7 @@ const FormTestRail = ({
620
650
  Button,
621
651
  {
622
652
  ...{
653
+ "data-guide": "test-submit",
623
654
  loading: formState.isSubmitting,
624
655
  type: "submit"
625
656
  },
@@ -23,6 +23,7 @@ __export(ab_tests_exports, {
23
23
  lines: () => lines,
24
24
  move: () => move,
25
25
  scale: () => scale,
26
+ short: () => short,
26
27
  signed: () => signed,
27
28
  span: () => span,
28
29
  variantAction: () => variantAction,
@@ -119,6 +120,7 @@ const variantPreview = (campaign) => {
119
120
  lines,
120
121
  move,
121
122
  scale,
123
+ short,
122
124
  signed,
123
125
  span,
124
126
  variantAction,
@@ -83,6 +83,7 @@ export {
83
83
  lines,
84
84
  move,
85
85
  scale,
86
+ short,
86
87
  signed,
87
88
  span,
88
89
  variantAction,
@@ -403,6 +403,9 @@ const TemplateTest = ({
403
403
  ...{
404
404
  addReason: running ? "Pause the test to add a variant" : pages.length - 1 >= CAP ? "A test holds five variants" : null,
405
405
  disabled,
406
+ // @story ab-tests/schedule
407
+ // A draft with two pages: the form leads it to its dates, then to Schedule.
408
+ draft: status === "drafted" && enabled.length > 1,
406
409
  notice,
407
410
  onAdd,
408
411
  onDates,
@@ -371,6 +371,9 @@ const TemplateTest = ({
371
371
  ...{
372
372
  addReason: running ? "Pause the test to add a variant" : pages.length - 1 >= CAP ? "A test holds five variants" : null,
373
373
  disabled,
374
+ // @story ab-tests/schedule
375
+ // A draft with two pages: the form leads it to its dates, then to Schedule.
376
+ draft: status === "drafted" && enabled.length > 1,
374
377
  notice,
375
378
  onAdd,
376
379
  onDates,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@drawbridge/components",
3
- "version": "0.1.41",
3
+ "version": "0.1.42",
4
4
  "exports": {
5
5
  "./advertisement": {
6
6
  "types": "./types/advertisement.d.ts",
@@ -56,6 +56,8 @@ export interface FormTestRailProps {
56
56
  // Why the + is disabled, said when it is pointed at.
57
57
  addReason?: string | null;
58
58
  disabled?: boolean;
59
+ // A drafted test with two pages: with no notice, the form shows "Set your dates", then "Ready to schedule".
60
+ draft?: boolean;
59
61
  // The one card at the top: what the test needs next.
60
62
  notice?: CardTaskProps | null;
61
63
  onAdd?: () => void;
@@ -13,6 +13,9 @@ export declare const even: ( ids: string[] ) => Shares;
13
13
  export declare const move: ( shares: Shares, ids: string[], id: string, value: number ) => Shares;
14
14
 
15
15
  // "Nov 9 – Nov 23", or null without both dates.
16
+ // "Nov 9".
17
+ export declare const short: ( value: string | Date ) => string;
18
+
16
19
  export declare const span: ( dates?: { endsAt?: string | Date | null; startsAt?: string | Date | null } ) => string | null;
17
20
 
18
21
  // Whole days until `endsAt`, at least 0.