@sphoro/bugcatch-web-sdk 0.19.0 → 0.21.0

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.
package/src/widget.js CHANGED
@@ -423,7 +423,13 @@ export function mountWidget(client) {
423
423
  open = openPanelWhenLoaded();
424
424
  });
425
425
 
426
+ // Which form the next panel opens on: BugCatch.open({ mode }) sets it just
427
+ // before pressing the launcher, and a person pressing it gets the report form.
428
+ let nextMode = 'report';
429
+
426
430
  function openPanelWhenLoaded() {
431
+ let mode = nextMode;
432
+ nextMode = 'report';
427
433
  hideLoadFailure();
428
434
  // The panel says it again, at the top, with the rest of what is live.
429
435
  hideNotice();
@@ -437,6 +443,8 @@ export function mountWidget(client) {
437
443
  const pending = {
438
444
  close: () => (panel ? panel.close() : cancel()),
439
445
  destroy: () => (panel ? panel.destroy() : cancel()),
446
+ // Asked again while it is on its way, or once it is open.
447
+ setMode: (m) => { if (panel) panel.setMode?.(m); else mode = m; },
440
448
  };
441
449
 
442
450
  launcher.setAttribute('aria-busy', 'true');
@@ -452,6 +460,7 @@ export function mountWidget(client) {
452
460
  client,
453
461
  preloadCall,
454
462
  themeControls,
463
+ mode,
455
464
  onClose: () => {
456
465
  open = null;
457
466
  dock.classList.remove('over');
@@ -558,7 +567,11 @@ export function mountWidget(client) {
558
567
  // Integration hook: BugCatch.open() / close() / isOpen() drive the same
559
568
  // launcher a person would press, so there is one way in to the panel.
560
569
  client.widgetControls = {
561
- open: () => { if (!open) launcher.click(); },
570
+ open: (mode) => {
571
+ if (open) { if (mode) open.setMode(mode); return; }
572
+ nextMode = mode || 'report';
573
+ launcher.click();
574
+ },
562
575
  close: () => { open?.close(); },
563
576
  isOpen: () => Boolean(open),
564
577
  };