@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
@@ -51,9 +51,20 @@ var import_list_resource = __toESM(require("./list-resource"));
51
51
  var import_preview = require("./preview");
52
52
  var import_swatch = require("./swatch");
53
53
  var import_button = __toESM(require("../shared/button"));
54
- var import_empty = __toESM(require("../shared/empty"));
54
+ var import_lock = __toESM(require("../icons/lock"));
55
55
  var import_plus = __toESM(require("../icons/plus"));
56
+ var import_trash = __toESM(require("../icons/trash"));
57
+ var import_empty = __toESM(require("../shared/empty"));
56
58
  var import_ab_tests = require("./lib/ab-tests");
59
+ var import_loader = require("../shared/loader");
60
+ var import_dynamic = __toESM(require("next/dynamic"));
61
+ const FormOrganizationCampaignPageEdit = (0, import_dynamic.default)(
62
+ () => import("./form-organization-campaign-page").then((mod) => mod.FormOrganizationCampaignPageEdit),
63
+ {
64
+ loading: () => /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_loader.LoaderDynamic, {}),
65
+ ssr: false
66
+ }
67
+ );
57
68
  const SHOWN = [
58
69
  { key: "Page", value: "page" },
59
70
  { key: "Email", value: "email" }
@@ -205,120 +216,147 @@ const Brands = ({
205
216
  ]
206
217
  }
207
218
  );
219
+ const Fill = ({ children }) => {
220
+ const box = (0, import_react.useRef)(null);
221
+ (0, import_preview.useFill)(box, false, 0, "minHeight");
222
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
223
+ "div",
224
+ {
225
+ ...{
226
+ className: "flex flex-col",
227
+ ref: box
228
+ },
229
+ children
230
+ }
231
+ );
232
+ };
208
233
  const Linked = ({
209
- brand,
210
234
  href,
235
+ name,
211
236
  onDisconnect,
212
237
  style
213
238
  }) => {
214
239
  const box = (0, import_react.useRef)(null);
215
- (0, import_preview.useFill)(box);
240
+ (0, import_preview.useFill)(box, false, 25);
216
241
  return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
217
242
  "div",
218
243
  {
219
244
  ...{
220
245
  // Named for a screen reader: the box holds no sentence of its own.
221
246
  "aria-label": "Linked brand",
222
- className: "xl:min-h-[480px]",
247
+ // A grid's one row stretches to the box, so the empty state fills it and
248
+ // centres its content ( Darren, 2026-11-21 ).
249
+ className: "grid xl:min-h-[480px]",
223
250
  ref: box,
224
251
  role: "group"
225
252
  },
226
- children: /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(
227
- import_empty.default,
228
- {
229
- ...{
230
- variant: "primary"
231
- },
232
- children: [
233
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
234
- "div",
235
- {
236
- ...{
237
- className: "relative aspect-square w-24"
238
- },
239
- children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
240
- import_image.default,
241
- {
242
- ...{
243
- // The Brands list's own empty image, beside words that say it all.
244
- alt: "",
245
- className: "rounded overflow-hidden bg-green border border-green",
246
- fill: true,
247
- // The box's largest picture, above the fold.
248
- priority: true,
249
- sizes: "96px",
250
- src: process.env.NEXT_PUBLIC_API_URI + "/images/brands.svg",
251
- unoptimized: true
252
- }
253
- }
254
- )
255
- }
256
- ),
257
- /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(
258
- "div",
259
- {
260
- ...{
261
- className: "flex flex-col items-center w-full max-w-sm space-y-2"
262
- },
263
- children: [
264
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
265
- "p",
266
- {
267
- ...{
268
- className: "text-black text-lg"
269
- },
270
- children: brand == null ? void 0 : brand.title
271
- }
272
- ),
273
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
274
- import_swatch.Swatches,
275
- {
276
- ...{
277
- style
278
- }
279
- }
280
- )
281
- ]
282
- }
283
- ),
284
- (href || onDisconnect) && /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(
285
- "div",
253
+ children: /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_empty.default, { children: [
254
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
255
+ "div",
256
+ {
257
+ ...{
258
+ className: "relative aspect-square w-24"
259
+ },
260
+ children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
261
+ import_image.default,
286
262
  {
287
263
  ...{
288
- className: "flex items-center justify-center space-x-3"
289
- },
290
- children: [
291
- href && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
292
- import_button.default,
293
- {
294
- ...{
295
- element: import_link.default,
296
- href,
297
- inline: true,
298
- size: "small",
299
- variant: "secondary"
300
- },
301
- children: "Edit brand"
302
- }
303
- ),
304
- onDisconnect && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
305
- import_button.default,
306
- {
307
- ...{
308
- inline: true,
309
- onClick: onDisconnect,
310
- size: "small",
311
- variant: "secondary"
312
- },
313
- children: "Disconnect"
314
- }
315
- )
316
- ]
264
+ // The Brands list's own empty image, beside words that say it all.
265
+ alt: "",
266
+ className: "rounded overflow-hidden bg-green border border-green",
267
+ fill: true,
268
+ // The box's largest picture, above the fold.
269
+ priority: true,
270
+ sizes: "96px",
271
+ src: process.env.NEXT_PUBLIC_API_URI + "/images/brands.svg",
272
+ unoptimized: true
273
+ }
317
274
  }
318
275
  )
319
- ]
320
- }
321
- )
276
+ }
277
+ ),
278
+ /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(
279
+ "div",
280
+ {
281
+ ...{
282
+ className: "flex flex-col items-center w-full max-w-sm space-y-2"
283
+ },
284
+ children: [
285
+ /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(
286
+ "p",
287
+ {
288
+ ...{
289
+ className: "flex items-center gap-1 text-black text-lg"
290
+ },
291
+ children: [
292
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
293
+ import_lock.default,
294
+ {
295
+ ...{
296
+ className: "w-4 h-4 shrink-0"
297
+ }
298
+ }
299
+ ),
300
+ "Set by the connected brand"
301
+ ]
302
+ }
303
+ ),
304
+ name && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
305
+ "p",
306
+ {
307
+ ...{
308
+ className: "text-gray-dark"
309
+ },
310
+ children: name
311
+ }
312
+ ),
313
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
314
+ import_swatch.Swatches,
315
+ {
316
+ ...{
317
+ style
318
+ }
319
+ }
320
+ )
321
+ ]
322
+ }
323
+ ),
324
+ (href || onDisconnect) && /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(
325
+ "div",
326
+ {
327
+ ...{
328
+ className: "flex items-center justify-center space-x-3"
329
+ },
330
+ children: [
331
+ href && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
332
+ import_button.default,
333
+ {
334
+ ...{
335
+ element: import_link.default,
336
+ href,
337
+ inline: true,
338
+ size: "small",
339
+ variant: "secondary"
340
+ },
341
+ children: "Edit brand"
342
+ }
343
+ ),
344
+ onDisconnect && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
345
+ import_button.default,
346
+ {
347
+ ...{
348
+ inline: true,
349
+ onClick: onDisconnect,
350
+ size: "small",
351
+ variant: "secondary"
352
+ },
353
+ children: "Disconnect"
354
+ }
355
+ )
356
+ ]
357
+ }
358
+ )
359
+ ] })
322
360
  }
323
361
  );
324
362
  };
@@ -345,6 +383,10 @@ const TemplateDesign = ({
345
383
  const { onError, onSuccess } = (0, import_hooks.useCallbacks)({
346
384
  queryClient
347
385
  });
386
+ const merge = (next) => setUpdate((previous) => ({
387
+ ...previous || {},
388
+ ...next
389
+ }));
348
390
  if (!(campaign == null ? void 0 : campaign.variant)) return null;
349
391
  const page = {
350
392
  campaign: id,
@@ -377,11 +419,12 @@ const TemplateDesign = ({
377
419
  }
378
420
  );
379
421
  };
380
- const confirm = ({ brand, message, title, value }) => modal.open({
422
+ const confirm = ({ action, brand, message, title, type = "warning", value }) => modal.open({
381
423
  message: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
382
424
  import_form_action.default,
383
425
  {
384
426
  ...{
427
+ action,
385
428
  callback: () => (0, import_fetch.request)({
386
429
  body: {
387
430
  brand: value
@@ -401,7 +444,7 @@ const TemplateDesign = ({
401
444
  ...{
402
445
  message,
403
446
  title: brand == null ? void 0 : brand.title,
404
- type: "warning"
447
+ type
405
448
  }
406
449
  }
407
450
  )
@@ -449,10 +492,13 @@ const TemplateDesign = ({
449
492
  ...canAdd && {
450
493
  onAdd: () => add(design)
451
494
  },
495
+ // The design is lost for good here: the warning is red ( Darren, 2026-11-21 ).
452
496
  onUse: (item) => confirm({
497
+ action: "Use brand",
453
498
  brand: item,
454
- message: "This replaces the campaign's logo, preview image and style. Your current design is not kept.",
499
+ message: "This replaces the campaign's logo, preview image and style. Your current design will be lost, and you can't undo this.",
455
500
  title: "Use brand",
501
+ type: "error",
456
502
  value: item.id
457
503
  })
458
504
  }
@@ -461,6 +507,7 @@ const TemplateDesign = ({
461
507
  title: "Brands"
462
508
  });
463
509
  const disconnect = (brand) => confirm({
510
+ action: "Disconnect",
464
511
  brand,
465
512
  message: "Styles will stop updating with brand changes. The current brand styles will be applied.",
466
513
  title: "Disconnect brand",
@@ -478,10 +525,29 @@ const TemplateDesign = ({
478
525
  ...{
479
526
  // @story brands/use
480
527
  // The white Brand button with a plus, top right, only while no
481
- // brand is linked: it opens the drawer to use one or make one.
482
- controls: (data) => canManage && canBrands && !linked(data) ? [
483
- {
484
- onClick: () => brands(update || data),
528
+ // brand is linked: it opens the drawer to use one or make one
529
+ // ( back in the header once Share left it: Darren, 2026-11-20 ).
530
+ // @story brands/use
531
+ // @story brands/disconnect
532
+ // ONE BRAND BUTTON at the top right, white in both states ( Darren,
533
+ // 2026-11-20 ): Brand with a plus while none is linked, opening the
534
+ // drawer to use one or make one; once linked, named for the brand,
535
+ // with a trash icon that disconnects it after the confirmation.
536
+ // Shown to a person who can manage the campaign and has access to
537
+ // Brands.
538
+ controls: (data) => canManage && canBrands ? [
539
+ linked(data) ? {
540
+ "aria-label": "Disconnect brand",
541
+ "data-guide": "button-brand",
542
+ onClick: () => disconnect(linked(data)),
543
+ svg: import_trash.default,
544
+ title: linked(data).title
545
+ } : {
546
+ "data-guide": "button-brand",
547
+ onClick: () => brands(update ? {
548
+ ...data,
549
+ ...update
550
+ } : data),
485
551
  svg: import_plus.default,
486
552
  title: "Brand"
487
553
  }
@@ -492,7 +558,10 @@ const TemplateDesign = ({
492
558
  },
493
559
  children: (data) => {
494
560
  const brand = linked(data);
495
- const design = update || data;
561
+ const design = update ? {
562
+ ...data,
563
+ ...update
564
+ } : data;
496
565
  return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(
497
566
  import_card_section.Beside,
498
567
  {
@@ -517,35 +586,45 @@ const TemplateDesign = ({
517
586
  }
518
587
  }
519
588
  ),
520
- brand ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
521
- Linked,
522
- {
523
- ...{
524
- brand,
525
- ...canBrands && {
526
- href: "/organizations/" + organizationId + "/brands/" + brand.id
527
- },
528
- ...canManage && canBrands && {
529
- onDisconnect: () => disconnect(brand)
530
- },
531
- style: data == null ? void 0 : data.style
532
- }
533
- }
534
- ) : /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_card_section.default, { children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
535
- import_form_organization_campaign_design.FormOrganizationCampaignDesign,
589
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Fill, { children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
590
+ import_card_section.default,
536
591
  {
537
592
  ...{
538
- disabled: !canManage,
539
- onError,
540
- onSuccess: (response) => saved(response),
541
- onUpdate: setUpdate,
542
- organization,
543
- values: {
544
- campaign: id,
545
- organization: organizationId,
546
- ...data
593
+ className: "flex-1"
594
+ },
595
+ children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
596
+ FormOrganizationCampaignPageEdit,
597
+ {
598
+ ...{
599
+ brand,
600
+ disabled: !canManage,
601
+ images: true,
602
+ linked: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
603
+ Linked,
604
+ {
605
+ ...{
606
+ // Its colours: the header's button names the brand and
607
+ // disconnects it ( Darren, 2026-11-21 ). Who has no
608
+ // button reads the name here.
609
+ name: canManage && canBrands ? null : brand == null ? void 0 : brand.title,
610
+ style: data == null ? void 0 : data.style
611
+ }
612
+ }
613
+ ),
614
+ onError,
615
+ onSuccess: (response) => saved(response),
616
+ onUpdate: merge,
617
+ organization,
618
+ tabs: true,
619
+ values: {
620
+ campaign: id,
621
+ id: data == null ? void 0 : data.id,
622
+ organization: organizationId,
623
+ ...data
624
+ }
625
+ }
547
626
  }
548
- }
627
+ )
549
628
  }
550
629
  ) })
551
630
  ]