@drawbridge/components 0.1.45 → 0.1.47

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 (63) hide show
  1. package/dist/bridge/form-subdomain-shop.js +4 -1
  2. package/dist/bridge/form-subdomain-shop.mjs +4 -1
  3. package/dist/bridge/form-subdomain.js +23 -5
  4. package/dist/bridge/form-subdomain.mjs +23 -5
  5. package/dist/bridge/lib/entry.js +41 -0
  6. package/dist/bridge/lib/entry.mjs +40 -0
  7. package/dist/bridge/product-tile.js +4 -0
  8. package/dist/bridge/product-tile.mjs +4 -0
  9. package/dist/bridge/template-layout.js +27 -8
  10. package/dist/bridge/template-layout.mjs +28 -9
  11. package/dist/bridge/template-modal.js +11 -1
  12. package/dist/bridge/template-modal.mjs +11 -1
  13. package/dist/dashboard/avatar.js +2 -3
  14. package/dist/dashboard/avatar.mjs +2 -3
  15. package/dist/dashboard/campaign-form.js +172 -153
  16. package/dist/dashboard/campaign-form.mjs +172 -153
  17. package/dist/dashboard/campaign-share.js +347 -0
  18. package/dist/dashboard/campaign-share.mjs +314 -0
  19. package/dist/dashboard/card-affiliate.js +1 -1
  20. package/dist/dashboard/card-affiliate.mjs +1 -1
  21. package/dist/dashboard/card-campaign-switch.js +4 -1
  22. package/dist/dashboard/card-campaign-switch.mjs +4 -1
  23. package/dist/dashboard/form-organization-campaign-field-item.js +4 -1
  24. package/dist/dashboard/form-organization-campaign-field-item.mjs +4 -1
  25. package/dist/dashboard/form-organization-campaign-page.js +73 -39
  26. package/dist/dashboard/form-organization-campaign-page.mjs +73 -39
  27. package/dist/dashboard/input-combobox.js +6 -0
  28. package/dist/dashboard/input-combobox.mjs +6 -0
  29. package/dist/dashboard/input-fields.js +26 -3
  30. package/dist/dashboard/input-fields.mjs +26 -3
  31. package/dist/dashboard/input-font.js +2 -0
  32. package/dist/dashboard/input-font.mjs +2 -0
  33. package/dist/dashboard/input-group-ai.js +15 -3
  34. package/dist/dashboard/input-group-ai.mjs +15 -3
  35. package/dist/dashboard/lib/ab-tests.js +2 -2
  36. package/dist/dashboard/lib/ab-tests.mjs +2 -2
  37. package/dist/dashboard/lib/menu.js +19 -0
  38. package/dist/dashboard/lib/menu.mjs +18 -0
  39. package/dist/dashboard/menu.js +13 -2
  40. package/dist/dashboard/menu.mjs +13 -2
  41. package/dist/dashboard/preview.js +119 -52
  42. package/dist/dashboard/preview.mjs +119 -52
  43. package/dist/dashboard/recharts.js +10 -4
  44. package/dist/dashboard/recharts.mjs +10 -4
  45. package/dist/dashboard/template-dashboard.js +11 -1
  46. package/dist/dashboard/template-dashboard.mjs +11 -1
  47. package/dist/dashboard/template-design.js +209 -130
  48. package/dist/dashboard/template-design.mjs +210 -131
  49. package/dist/dashboard/template-ui.js +157 -55
  50. package/dist/dashboard/template-ui.mjs +158 -56
  51. package/dist/icons/flags.js +134 -0
  52. package/dist/icons/flags.mjs +115 -0
  53. package/dist/shared/carousel.js +14 -5
  54. package/dist/shared/carousel.mjs +14 -5
  55. package/package.json +11 -1
  56. package/types/bridge/form-subdomain.d.ts +13 -0
  57. package/types/bridge/lib/entry.d.ts +5 -0
  58. package/types/bridge/product-tile.d.ts +2 -0
  59. package/types/dashboard/campaign-share.d.ts +16 -0
  60. package/types/dashboard/form-organization-campaign-page.d.ts +8 -1
  61. package/types/dashboard/input-combobox.d.ts +2 -0
  62. package/types/dashboard/preview.d.ts +11 -3
  63. package/types/icons/flags.d.ts +5 -0
@@ -124,6 +124,11 @@ const States = ({
124
124
  title: option.key
125
125
  }))
126
126
  ] : options.map((option) => nests(option) ? {
127
+ // Impeccable audit, 2026-11-21: the option shown is marked at the top too,
128
+ // as a nested one is, so the menu says what the preview holds.
129
+ ...option.value === top && {
130
+ "aria-current": true
131
+ },
127
132
  "aria-haspopup": "menu",
128
133
  element: "button",
129
134
  icon: ChevronRight,
@@ -138,6 +143,10 @@ const States = ({
138
143
  }
139
144
  )
140
145
  } : {
146
+ ...option.value === top && {
147
+ "aria-current": true,
148
+ icon: Check
149
+ },
141
150
  element: "button",
142
151
  onClick: () => onChange(nested ? [option.value] : option.value),
143
152
  title: option.key
@@ -426,7 +435,7 @@ const scrollerOf = (node) => {
426
435
  return page || null;
427
436
  };
428
437
  const fillHeight = ({ foot, gap, top }) => Math.max(0, Math.floor(foot - top - gap));
429
- const useFill = (box, open) => useEffect(() => {
438
+ const useFill = (box, open, inset = 0, property = "height") => useEffect(() => {
430
439
  const node = box.current;
431
440
  const page = scrollerOf(node);
432
441
  if (open || !node || !page) return void 0;
@@ -434,9 +443,9 @@ const useFill = (box, open) => useEffect(() => {
434
443
  const gap = parseFloat(getComputedStyle(page).paddingBottom) || 0;
435
444
  let frame;
436
445
  const read = () => {
437
- node.style.height = wide.matches ? fillHeight({
446
+ node.style[property] = wide.matches ? fillHeight({
438
447
  foot: page.getBoundingClientRect().bottom,
439
- gap,
448
+ gap: gap + inset,
440
449
  top: node.getBoundingClientRect().top
441
450
  }) + "px" : "";
442
451
  };
@@ -457,9 +466,9 @@ const useFill = (box, open) => useEffect(() => {
457
466
  observer.disconnect();
458
467
  wide.removeEventListener("change", measure);
459
468
  page.removeEventListener("scroll", measure);
460
- node.style.height = "";
469
+ node.style[property] = "";
461
470
  };
462
- }, [open]);
471
+ }, [open, inset, property]);
463
472
  const Slider = createContext(null);
464
473
  const useCard = (id) => {
465
474
  const slider = useContext(Slider);
@@ -484,14 +493,16 @@ const SliderLayout = ({
484
493
  blank,
485
494
  children,
486
495
  last,
496
+ page,
487
497
  plain,
488
498
  slides = [],
489
499
  style,
490
500
  zooms = ZOOMS
491
501
  }) => {
492
- var _a, _b, _c, _d, _e, _f, _g, _h, _i;
502
+ var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k;
493
503
  const [nodes, setNodes] = useState({});
494
504
  const [picked, setPicked] = useState(null);
505
+ const paged = Boolean(page);
495
506
  const [states, setStates] = useState({});
496
507
  const [zoom, setZoom] = useState(zooms[0].value);
497
508
  const peek = usePeek();
@@ -502,25 +513,48 @@ const SliderLayout = ({
502
513
  const select = (id, node, target) => {
503
514
  if (!slides.some((slide) => slide.id === id)) return;
504
515
  setPicked(id);
505
- const page = scrollerOf(node);
506
- if (!page || !node || !pressScrolls(target, node) || !window.matchMedia(WIDE).matches) return;
507
- page.scrollTo({
516
+ const page2 = scrollerOf(node);
517
+ if (!page2 || !node || !pressScrolls(target, node) || !window.matchMedia(WIDE).matches) return;
518
+ page2.scrollTo({
508
519
  behavior: "smooth",
509
520
  top: scrollTarget({
510
521
  node: node.getBoundingClientRect().top,
511
- page: page.getBoundingClientRect().top,
512
- scrollTop: page.scrollTop
522
+ page: page2.getBoundingClientRect().top,
523
+ scrollTop: page2.scrollTop
513
524
  })
514
525
  });
515
526
  };
527
+ const picker = slides.length > 0 && /* @__PURE__ */ jsx(
528
+ States,
529
+ {
530
+ ...{
531
+ align: "start",
532
+ onChange: (path) => {
533
+ var _a2, _b2;
534
+ const [id, state] = [].concat(path);
535
+ select(id, (_a2 = layout.current) == null ? void 0 : _a2.querySelector('[data-slide="' + id + '"]'));
536
+ if (state !== void 0) (_b2 = states[id]) == null ? void 0 : _b2.onChange(state);
537
+ },
538
+ options: slides.map((slide) => {
539
+ var _a2;
540
+ return {
541
+ key: slide.title,
542
+ options: (_a2 = states[slide.id]) == null ? void 0 : _a2.options,
543
+ value: slide.id
544
+ };
545
+ }),
546
+ value: [current == null ? void 0 : current.id, (_a = states[current == null ? void 0 : current.id]) == null ? void 0 : _a.value]
547
+ }
548
+ }
549
+ );
516
550
  useFill(peek.pane, peek.open);
517
551
  useFit(blank ? null : shown, zoom);
518
552
  useEffect(() => {
519
553
  if (cards.current) cards.current.inert = peek.open;
520
554
  }, [peek.open]);
521
555
  const register = useCallback((id, own) => setStates((list) => {
522
- var _a2, _b2;
523
- return ((_a2 = list[id]) == null ? void 0 : _a2.value) === (own == null ? void 0 : own.value) && ((_b2 = list[id]) == null ? void 0 : _b2.options) === (own == null ? void 0 : own.options) ? list : {
556
+ var _a2, _b2, _c2;
557
+ return ((_a2 = list[id]) == null ? void 0 : _a2.value) === (own == null ? void 0 : own.value) && ((_b2 = list[id]) == null ? void 0 : _b2.options) === (own == null ? void 0 : own.options) && ((_c2 = list[id]) == null ? void 0 : _c2.page) === (own == null ? void 0 : own.page) ? list : {
524
558
  ...list,
525
559
  [id]: own
526
560
  };
@@ -558,32 +592,7 @@ const SliderLayout = ({
558
592
  // cards; drawn on the right, in view as the page scrolls ( useFill ).
559
593
  "data-preview-panel": true,
560
594
  className: "xl:sticky xl:top-0 xl:order-last min-w-0 xl:min-h-[480px] xl:rounded",
561
- // The one step picker, each step's own states nested under it ( Darren,
562
- // 2026-11-15 ). No steps yet ( a chain with none ): no chips, and the
563
- // panel says there is nothing to preview.
564
- left: slides.length > 0 && /* @__PURE__ */ jsx(
565
- States,
566
- {
567
- ...{
568
- align: "start",
569
- onChange: (path) => {
570
- var _a2, _b2;
571
- const [id, state] = [].concat(path);
572
- select(id, (_a2 = layout.current) == null ? void 0 : _a2.querySelector('[data-slide="' + id + '"]'));
573
- if (state !== void 0) (_b2 = states[id]) == null ? void 0 : _b2.onChange(state);
574
- },
575
- options: slides.map((slide) => {
576
- var _a2;
577
- return {
578
- key: slide.title,
579
- options: (_a2 = states[slide.id]) == null ? void 0 : _a2.options,
580
- value: slide.id
581
- };
582
- }),
583
- value: [current == null ? void 0 : current.id, (_a = states[current == null ? void 0 : current.id]) == null ? void 0 : _a.value]
584
- }
585
- }
586
- ),
595
+ left: picker,
587
596
  peek,
588
597
  right: slides.length > 0 && /* @__PURE__ */ jsx(
589
598
  View,
@@ -597,7 +606,11 @@ const SliderLayout = ({
597
606
  ),
598
607
  style: {
599
608
  backgroundColor: plain ? void 0 : ((_c = (_b = style == null ? void 0 : style.background) == null ? void 0 : _b.color) == null ? void 0 : _c.rgb) || ((_e = (_d = style == null ? void 0 : style.background) == null ? void 0 : _d.color) == null ? void 0 : _e.hex),
600
- color: plain ? void 0 : ((_g = (_f = style == null ? void 0 : style.text) == null ? void 0 : _f.color) == null ? void 0 : _g.rgb) || ((_i = (_h = style == null ? void 0 : style.text) == null ? void 0 : _h.color) == null ? void 0 : _i.hex)
609
+ color: plain ? void 0 : ((_g = (_f = style == null ? void 0 : style.text) == null ? void 0 : _f.color) == null ? void 0 : _g.rgb) || ((_i = (_h = style == null ? void 0 : style.text) == null ? void 0 : _h.color) == null ? void 0 : _i.hex),
610
+ // Hidden under the real page; the steps still register their states in it.
611
+ ...paged && {
612
+ display: "none"
613
+ }
601
614
  }
602
615
  },
603
616
  children: [
@@ -623,6 +636,31 @@ const SliderLayout = ({
623
636
  ]
624
637
  }
625
638
  ),
639
+ paged && /* @__PURE__ */ jsx(
640
+ "div",
641
+ {
642
+ ...{
643
+ className: "min-w-0 xl:sticky xl:top-0 xl:order-last"
644
+ },
645
+ children: /* @__PURE__ */ jsx(
646
+ PreviewPage,
647
+ {
648
+ ...{
649
+ left: picker,
650
+ open: {
651
+ ...((_j = states[current == null ? void 0 : current.id]) == null ? void 0 : _j.page) && {
652
+ panel: JSON.parse(states[current.id].page)
653
+ },
654
+ state: (_k = states[current == null ? void 0 : current.id]) == null ? void 0 : _k.value,
655
+ step: current == null ? void 0 : current.id
656
+ },
657
+ url: page.url,
658
+ version: page.version
659
+ }
660
+ }
661
+ )
662
+ }
663
+ ),
626
664
  /* @__PURE__ */ jsxs(
627
665
  "div",
628
666
  {
@@ -631,7 +669,7 @@ const SliderLayout = ({
631
669
  className: "min-w-0"
632
670
  },
633
671
  children: [
634
- /* @__PURE__ */ jsx(
672
+ !paged && /* @__PURE__ */ jsx(
635
673
  PeekButton,
636
674
  {
637
675
  ...{
@@ -660,13 +698,18 @@ const SliderLayout = ({
660
698
  const Preview = ({
661
699
  children,
662
700
  id,
701
+ page,
663
702
  states
664
703
  }) => {
665
704
  const slider = useContext(Slider);
666
705
  const register = slider == null ? void 0 : slider.register;
706
+ const drawn = page ? JSON.stringify(page) : void 0;
667
707
  useEffect(() => {
668
- register == null ? void 0 : register(id, states);
669
- }, [id, register, states == null ? void 0 : states.onChange, states == null ? void 0 : states.options, states == null ? void 0 : states.value]);
708
+ register == null ? void 0 : register(id, {
709
+ ...states,
710
+ page: drawn
711
+ });
712
+ }, [drawn, id, register, states == null ? void 0 : states.onChange, states == null ? void 0 : states.options, states == null ? void 0 : states.value]);
670
713
  if (!slider) return null;
671
714
  return slider.nodes[id] && createPortal(
672
715
  /* @__PURE__ */ jsx("div", { children: /* @__PURE__ */ jsx("div", { children }) }),
@@ -725,8 +768,10 @@ const PreviewPage = ({
725
768
  fill = true,
726
769
  html,
727
770
  left,
771
+ open,
728
772
  update,
729
773
  url,
774
+ version,
730
775
  zooms = ZOOMS
731
776
  }) => {
732
777
  const area = useRef(null);
@@ -742,17 +787,32 @@ const PreviewPage = ({
742
787
  const [zoom, setZoom] = useState(zooms[0].value);
743
788
  const peek = usePeek();
744
789
  const [previous, setPrevious] = useState(url);
790
+ const [loaded, setLoaded] = useState(version);
745
791
  if (previous !== url) {
746
792
  setPrevious(url);
747
793
  setLoading(true);
748
794
  }
795
+ if (loaded !== version) {
796
+ setLoaded(version);
797
+ setLoading(true);
798
+ }
799
+ const applied = useRef(version);
800
+ useEffect(() => {
801
+ if (applied.current === version) return;
802
+ applied.current = version;
803
+ if (frame.current && url) frame.current.src = url;
804
+ }, [version]);
749
805
  const { height, width } = url ? SIZES.find((item) => item.key === size) : {
750
806
  height: tall,
751
- width: MAIL
807
+ width: size === "phone" ? SIZES[0].width : MAIL
752
808
  };
753
809
  const scale = zoom === "fit" ? fitScale(space, { height, width }) : zoom;
754
- const origin = url ? new URL(url).origin : null;
755
- const message = JSON.stringify({ update });
810
+ const origin = url && URL.canParse(url) ? new URL(url).origin : null;
811
+ const none = Boolean(url) ? !origin : typeof html !== "string";
812
+ const message = JSON.stringify({
813
+ open,
814
+ update
815
+ });
756
816
  const post = () => {
757
817
  var _a, _b;
758
818
  return origin && origin !== "null" && ((_b = (_a = frame.current) == null ? void 0 : _a.contentWindow) == null ? void 0 : _b.postMessage(JSON.parse(message), origin));
@@ -810,9 +870,7 @@ const PreviewPage = ({
810
870
  View,
811
871
  {
812
872
  ...{
813
- ...url && {
814
- onSize: setSize
815
- },
873
+ onSize: setSize,
816
874
  onZoom: setZoom,
817
875
  size,
818
876
  zoom,
@@ -829,7 +887,16 @@ const PreviewPage = ({
829
887
  ref: area
830
888
  },
831
889
  children: [
832
- url && loading && /* @__PURE__ */ jsx(
890
+ none && /* @__PURE__ */ jsx(
891
+ "div",
892
+ {
893
+ ...{
894
+ className: "absolute inset-0 flex items-center justify-center"
895
+ },
896
+ children: /* @__PURE__ */ jsx(NoPreview, {})
897
+ }
898
+ ),
899
+ url && !none && loading && /* @__PURE__ */ jsx(
833
900
  LoaderComponent,
834
901
  {
835
902
  ...{
@@ -841,7 +908,7 @@ const PreviewPage = ({
841
908
  "div",
842
909
  {
843
910
  ...{
844
- className: "origin-top-left",
911
+ className: "origin-top-left" + (none ? " hidden" : ""),
845
912
  ref: screen,
846
913
  style: {
847
914
  ...url && {
@@ -856,7 +923,7 @@ const PreviewPage = ({
856
923
  width
857
924
  }
858
925
  },
859
- children: url ? /* @__PURE__ */ jsx(
926
+ children: url && !none ? /* @__PURE__ */ jsx(
860
927
  "iframe",
861
928
  {
862
929
  ...{
@@ -218,7 +218,10 @@ const ChartBar = ({ data, empty }) => {
218
218
  /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
219
219
  import_recharts.YAxis,
220
220
  {
221
- ...options.axisY
221
+ ...{
222
+ ...options.axisY,
223
+ allowDecimals: false
224
+ }
222
225
  }
223
226
  ),
224
227
  /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
@@ -256,7 +259,7 @@ const ChartLine = ({
256
259
  "shortcodes"
257
260
  ],
258
261
  empty,
259
- format = (value) => value,
262
+ format,
260
263
  labels: given = {},
261
264
  legend = true,
262
265
  zeros = false
@@ -451,7 +454,10 @@ const ChartLine = ({
451
454
  /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
452
455
  import_recharts.YAxis,
453
456
  {
454
- ...options.axisY
457
+ ...{
458
+ ...options.axisY,
459
+ allowDecimals: Boolean(format)
460
+ }
455
461
  }
456
462
  ),
457
463
  /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
@@ -462,7 +468,7 @@ const ChartLine = ({
462
468
  // A money chart passes `format` so a day's summed gross reads
463
469
  // "$12.50", not 12.500000000000002; counts pass nothing.
464
470
  formatter: (value, key) => [
465
- format(value),
471
+ format ? format(value) : value,
466
472
  name(key)
467
473
  ]
468
474
  }
@@ -185,7 +185,10 @@ const ChartBar = ({ data, empty }) => {
185
185
  /* @__PURE__ */ jsx(
186
186
  YAxis,
187
187
  {
188
- ...options.axisY
188
+ ...{
189
+ ...options.axisY,
190
+ allowDecimals: false
191
+ }
189
192
  }
190
193
  ),
191
194
  /* @__PURE__ */ jsx(
@@ -223,7 +226,7 @@ const ChartLine = ({
223
226
  "shortcodes"
224
227
  ],
225
228
  empty,
226
- format = (value) => value,
229
+ format,
227
230
  labels: given = {},
228
231
  legend = true,
229
232
  zeros = false
@@ -418,7 +421,10 @@ const ChartLine = ({
418
421
  /* @__PURE__ */ jsx(
419
422
  YAxis,
420
423
  {
421
- ...options.axisY
424
+ ...{
425
+ ...options.axisY,
426
+ allowDecimals: Boolean(format)
427
+ }
422
428
  }
423
429
  ),
424
430
  /* @__PURE__ */ jsx(
@@ -429,7 +435,7 @@ const ChartLine = ({
429
435
  // A money chart passes `format` so a day's summed gross reads
430
436
  // "$12.50", not 12.500000000000002; counts pass nothing.
431
437
  formatter: (value, key) => [
432
- format(value),
438
+ format ? format(value) : value,
433
439
  name(key)
434
440
  ]
435
441
  }
@@ -349,7 +349,17 @@ const TemplateDashboardError = ({
349
349
  className: "w-full max-w-lg space-y-3"
350
350
  },
351
351
  children: [
352
- title && /* @__PURE__ */ (0, import_jsx_runtime.jsx)("h1", { children: title }),
352
+ title && // Impeccable audit, 2026-11-21: the page's own title is its h1, so
353
+ // the empty state's is an h2, drawn at the same size.
354
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
355
+ "h2",
356
+ {
357
+ ...{
358
+ className: "text-2xl leading-tight"
359
+ },
360
+ children: title
361
+ }
362
+ ),
353
363
  (error == null ? void 0 : error.message) && /* @__PURE__ */ (0, import_jsx_runtime.jsx)("p", { children: error.message })
354
364
  ]
355
365
  }
@@ -311,7 +311,17 @@ const TemplateDashboardError = ({
311
311
  className: "w-full max-w-lg space-y-3"
312
312
  },
313
313
  children: [
314
- title && /* @__PURE__ */ jsx("h1", { children: title }),
314
+ title && // Impeccable audit, 2026-11-21: the page's own title is its h1, so
315
+ // the empty state's is an h2, drawn at the same size.
316
+ /* @__PURE__ */ jsx(
317
+ "h2",
318
+ {
319
+ ...{
320
+ className: "text-2xl leading-tight"
321
+ },
322
+ children: title
323
+ }
324
+ ),
315
325
  (error == null ? void 0 : error.message) && /* @__PURE__ */ jsx("p", { children: error.message })
316
326
  ]
317
327
  }