@wildwinter/app-shell 0.18.0 → 0.20.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/dist/index.d.cts CHANGED
@@ -237,6 +237,16 @@ interface ConfirmOptions {
237
237
  /** Resolves true on confirm; false on Cancel / Esc / backdrop. */
238
238
  declare function confirmDialog(opts: ConfirmOptions): Promise<boolean>;
239
239
 
240
+ /**
241
+ * Play the close animation on `element`, then run `done` exactly once.
242
+ *
243
+ * `done` does the real teardown: remove the node, drop listeners, unmount
244
+ * whatever was inside it. Under `prefers-reduced-motion` the duration reads 0
245
+ * and `done` runs synchronously, so reduced motion means instant rather than
246
+ * an invisible wait.
247
+ */
248
+ declare function closeWithExit(element: HTMLElement, done: () => void): void;
249
+
240
250
  interface AboutOptions {
241
251
  /** The product's name, large. */
242
252
  appName: string;
@@ -324,6 +334,11 @@ interface GameIdEditorOptions {
324
334
  validate?: (gameId: string) => boolean;
325
335
  /** Where the panel goes, for hosts that anchor it somewhere tight. */
326
336
  prefer?: "left" | "below" | "centre";
337
+ /** Chrome the panel must not cover, passed through to the anchored panel: an
338
+ * app with a problems bar along the bottom wants it usable while an address
339
+ * is being edited. Without this the editor is the one panel in a host that
340
+ * can land on top of its own bars. */
341
+ keepClear?: string[];
327
342
  }
328
343
  /**
329
344
  * Open it. Returns false when that click TOGGLED the panel shut, which is the
@@ -452,6 +467,25 @@ interface CommentsOptions {
452
467
  deleteMessage?: (threadId: string, index: number) => void;
453
468
  /** Where the panel sits: "centre" for a point on a canvas (see anchored.ts). */
454
469
  prefer?: "left" | "below" | "centre";
470
+ /**
471
+ * Chrome the panel must not cover. Defaults to `[".problembar"]`, which was
472
+ * hardcoded here and should not have been: one app's class name in shared
473
+ * code, and it misses any OTHER bar a host has. A second app arrived with two.
474
+ */
475
+ keepClear?: string[];
476
+ /**
477
+ * The text a thread is pinned to, shown above it as a quotation.
478
+ *
479
+ * A callback rather than a field on `Comment`, because resolving an anchor is
480
+ * the APP's half of the seam and this is only that resolution rendered: an app
481
+ * that pins threads to a span of prose can quote it, one that pins them to a
482
+ * whole card has nothing to quote and passes nothing. Keeping it out of the
483
+ * thread type also means no change to what is written to disk, which matters
484
+ * for files living in version control.
485
+ *
486
+ * Return undefined (or "") for a thread with no quotable anchor.
487
+ */
488
+ quoteFor?: (thread: Comment) => string | undefined;
455
489
  }
456
490
  declare function openComments(opts: CommentsOptions): void;
457
491
 
@@ -647,4 +681,4 @@ interface StepperBarOptions {
647
681
  /** Draw (or hide) the bar in `host`. Idempotent: call it again with new state. */
648
682
  declare function renderStepperBar(host: HTMLElement, opts: StepperBarOptions): void;
649
683
 
650
- export { type AboutOptions, type AnchoredPanel, type AnchoredPanelOptions, type Child, type Comment, type CommentMessage, type CommentsOptions, type ConfirmOptions, type DocLine, type DupGuard, type ElProps, type GameIdEditorOptions, type IconName, type IconSvgName, type Identity, type IdentityOptions, type JobProgressOptions, type JobProgressView, type Notes, type NotesEditorOptions, PALETTE, PALETTE_SIZE, type PaneShell, type PaneShellOptions, type PaneShellState, type PaneSide, type PaneSideConfig, type PinButtonOptions, type SaveController, type SaveControllerOptions, type SaveIndicator, type SaveStatus, type SettingsDialog, type SettingsDialogOptions, type SettingsSection, type SettingsSectionHandle, type ShardVc, type StaleBarOptions, type StepperBarOptions, type StepperItem, type StepperTone, type TipRect, type TooltipOptions, type VcMap, askIdentity, closeAnchoredPanel, colourFor, colourIndex, confirmDialog, createSaveController, dupGuard, el, expandableRow, focusNewRow, foldVc, gameIdify, hideTip, icon, iconBtn, iconSvg, initTooltips, isValidGameId, labelled, lockControls, lockNotice, mountJobProgress, mountPaneShell, mountSettingsDialog, moveItem, openAnchoredPanel, openComments, openGameIdEditor, openNotesEditor, paintVcBadges, pinButton, placeAnchored, renderStepperBar, saveIndicator, showAbout, staleBar, tagChips, tipAt, tipBold, vcBadgeFor };
684
+ export { type AboutOptions, type AnchoredPanel, type AnchoredPanelOptions, type Child, type Comment, type CommentMessage, type CommentsOptions, type ConfirmOptions, type DocLine, type DupGuard, type ElProps, type GameIdEditorOptions, type IconName, type IconSvgName, type Identity, type IdentityOptions, type JobProgressOptions, type JobProgressView, type Notes, type NotesEditorOptions, PALETTE, PALETTE_SIZE, type PaneShell, type PaneShellOptions, type PaneShellState, type PaneSide, type PaneSideConfig, type PinButtonOptions, type SaveController, type SaveControllerOptions, type SaveIndicator, type SaveStatus, type SettingsDialog, type SettingsDialogOptions, type SettingsSection, type SettingsSectionHandle, type ShardVc, type StaleBarOptions, type StepperBarOptions, type StepperItem, type StepperTone, type TipRect, type TooltipOptions, type VcMap, askIdentity, closeAnchoredPanel, closeWithExit, colourFor, colourIndex, confirmDialog, createSaveController, dupGuard, el, expandableRow, focusNewRow, foldVc, gameIdify, hideTip, icon, iconBtn, iconSvg, initTooltips, isValidGameId, labelled, lockControls, lockNotice, mountJobProgress, mountPaneShell, mountSettingsDialog, moveItem, openAnchoredPanel, openComments, openGameIdEditor, openNotesEditor, paintVcBadges, pinButton, placeAnchored, renderStepperBar, saveIndicator, showAbout, staleBar, tagChips, tipAt, tipBold, vcBadgeFor };
package/dist/index.d.ts CHANGED
@@ -237,6 +237,16 @@ interface ConfirmOptions {
237
237
  /** Resolves true on confirm; false on Cancel / Esc / backdrop. */
238
238
  declare function confirmDialog(opts: ConfirmOptions): Promise<boolean>;
239
239
 
240
+ /**
241
+ * Play the close animation on `element`, then run `done` exactly once.
242
+ *
243
+ * `done` does the real teardown: remove the node, drop listeners, unmount
244
+ * whatever was inside it. Under `prefers-reduced-motion` the duration reads 0
245
+ * and `done` runs synchronously, so reduced motion means instant rather than
246
+ * an invisible wait.
247
+ */
248
+ declare function closeWithExit(element: HTMLElement, done: () => void): void;
249
+
240
250
  interface AboutOptions {
241
251
  /** The product's name, large. */
242
252
  appName: string;
@@ -324,6 +334,11 @@ interface GameIdEditorOptions {
324
334
  validate?: (gameId: string) => boolean;
325
335
  /** Where the panel goes, for hosts that anchor it somewhere tight. */
326
336
  prefer?: "left" | "below" | "centre";
337
+ /** Chrome the panel must not cover, passed through to the anchored panel: an
338
+ * app with a problems bar along the bottom wants it usable while an address
339
+ * is being edited. Without this the editor is the one panel in a host that
340
+ * can land on top of its own bars. */
341
+ keepClear?: string[];
327
342
  }
328
343
  /**
329
344
  * Open it. Returns false when that click TOGGLED the panel shut, which is the
@@ -452,6 +467,25 @@ interface CommentsOptions {
452
467
  deleteMessage?: (threadId: string, index: number) => void;
453
468
  /** Where the panel sits: "centre" for a point on a canvas (see anchored.ts). */
454
469
  prefer?: "left" | "below" | "centre";
470
+ /**
471
+ * Chrome the panel must not cover. Defaults to `[".problembar"]`, which was
472
+ * hardcoded here and should not have been: one app's class name in shared
473
+ * code, and it misses any OTHER bar a host has. A second app arrived with two.
474
+ */
475
+ keepClear?: string[];
476
+ /**
477
+ * The text a thread is pinned to, shown above it as a quotation.
478
+ *
479
+ * A callback rather than a field on `Comment`, because resolving an anchor is
480
+ * the APP's half of the seam and this is only that resolution rendered: an app
481
+ * that pins threads to a span of prose can quote it, one that pins them to a
482
+ * whole card has nothing to quote and passes nothing. Keeping it out of the
483
+ * thread type also means no change to what is written to disk, which matters
484
+ * for files living in version control.
485
+ *
486
+ * Return undefined (or "") for a thread with no quotable anchor.
487
+ */
488
+ quoteFor?: (thread: Comment) => string | undefined;
455
489
  }
456
490
  declare function openComments(opts: CommentsOptions): void;
457
491
 
@@ -647,4 +681,4 @@ interface StepperBarOptions {
647
681
  /** Draw (or hide) the bar in `host`. Idempotent: call it again with new state. */
648
682
  declare function renderStepperBar(host: HTMLElement, opts: StepperBarOptions): void;
649
683
 
650
- export { type AboutOptions, type AnchoredPanel, type AnchoredPanelOptions, type Child, type Comment, type CommentMessage, type CommentsOptions, type ConfirmOptions, type DocLine, type DupGuard, type ElProps, type GameIdEditorOptions, type IconName, type IconSvgName, type Identity, type IdentityOptions, type JobProgressOptions, type JobProgressView, type Notes, type NotesEditorOptions, PALETTE, PALETTE_SIZE, type PaneShell, type PaneShellOptions, type PaneShellState, type PaneSide, type PaneSideConfig, type PinButtonOptions, type SaveController, type SaveControllerOptions, type SaveIndicator, type SaveStatus, type SettingsDialog, type SettingsDialogOptions, type SettingsSection, type SettingsSectionHandle, type ShardVc, type StaleBarOptions, type StepperBarOptions, type StepperItem, type StepperTone, type TipRect, type TooltipOptions, type VcMap, askIdentity, closeAnchoredPanel, colourFor, colourIndex, confirmDialog, createSaveController, dupGuard, el, expandableRow, focusNewRow, foldVc, gameIdify, hideTip, icon, iconBtn, iconSvg, initTooltips, isValidGameId, labelled, lockControls, lockNotice, mountJobProgress, mountPaneShell, mountSettingsDialog, moveItem, openAnchoredPanel, openComments, openGameIdEditor, openNotesEditor, paintVcBadges, pinButton, placeAnchored, renderStepperBar, saveIndicator, showAbout, staleBar, tagChips, tipAt, tipBold, vcBadgeFor };
684
+ export { type AboutOptions, type AnchoredPanel, type AnchoredPanelOptions, type Child, type Comment, type CommentMessage, type CommentsOptions, type ConfirmOptions, type DocLine, type DupGuard, type ElProps, type GameIdEditorOptions, type IconName, type IconSvgName, type Identity, type IdentityOptions, type JobProgressOptions, type JobProgressView, type Notes, type NotesEditorOptions, PALETTE, PALETTE_SIZE, type PaneShell, type PaneShellOptions, type PaneShellState, type PaneSide, type PaneSideConfig, type PinButtonOptions, type SaveController, type SaveControllerOptions, type SaveIndicator, type SaveStatus, type SettingsDialog, type SettingsDialogOptions, type SettingsSection, type SettingsSectionHandle, type ShardVc, type StaleBarOptions, type StepperBarOptions, type StepperItem, type StepperTone, type TipRect, type TooltipOptions, type VcMap, askIdentity, closeAnchoredPanel, closeWithExit, colourFor, colourIndex, confirmDialog, createSaveController, dupGuard, el, expandableRow, focusNewRow, foldVc, gameIdify, hideTip, icon, iconBtn, iconSvg, initTooltips, isValidGameId, labelled, lockControls, lockNotice, mountJobProgress, mountPaneShell, mountSettingsDialog, moveItem, openAnchoredPanel, openComments, openGameIdEditor, openNotesEditor, paintVcBadges, pinButton, placeAnchored, renderStepperBar, saveIndicator, showAbout, staleBar, tagChips, tipAt, tipBold, vcBadgeFor };
package/dist/index.js CHANGED
@@ -476,6 +476,29 @@ function pinButton(opts) {
476
476
  return b;
477
477
  }
478
478
 
479
+ // src/exit.ts
480
+ function closeWithExit(element, done) {
481
+ element.classList.add("closing");
482
+ const seconds = parseFloat(getComputedStyle(element).animationDuration) || 0;
483
+ if (seconds === 0) {
484
+ done();
485
+ return;
486
+ }
487
+ let fired = false;
488
+ const finish = () => {
489
+ if (fired) return;
490
+ fired = true;
491
+ element.removeEventListener("animationend", onEnd);
492
+ clearTimeout(timer2);
493
+ done();
494
+ };
495
+ const onEnd = (e) => {
496
+ if (e.target === element) finish();
497
+ };
498
+ element.addEventListener("animationend", onEnd);
499
+ const timer2 = setTimeout(finish, seconds * 1e3 + 120);
500
+ }
501
+
479
502
  // src/confirm.ts
480
503
  function confirmDialog(opts) {
481
504
  return new Promise((resolve) => {
@@ -497,21 +520,9 @@ function confirmDialog(opts) {
497
520
  if (done) return;
498
521
  done = true;
499
522
  resolve(ok);
500
- dlg.classList.add("closing");
501
- const dur = parseFloat(getComputedStyle(dlg).animationDuration) || 0;
502
- const teardown = () => {
523
+ closeWithExit(dlg, () => {
503
524
  dlg.close();
504
525
  dlg.remove();
505
- };
506
- if (dur === 0) {
507
- teardown();
508
- return;
509
- }
510
- const timer2 = setTimeout(teardown, dur * 1e3 + 120);
511
- dlg.addEventListener("animationend", (e) => {
512
- if (e.target !== dlg) return;
513
- clearTimeout(timer2);
514
- teardown();
515
526
  });
516
527
  };
517
528
  cancel.addEventListener("click", () => finish(false));
@@ -604,8 +615,10 @@ function openAnchoredPanel(opts) {
604
615
  if (current?.panel === panel) current = null;
605
616
  document.removeEventListener("pointerdown", onDown, true);
606
617
  document.removeEventListener("keydown", onKey, true);
607
- panel.remove();
608
- opts.onClose?.();
618
+ closeWithExit(panel, () => {
619
+ opts.onClose?.();
620
+ panel.remove();
621
+ });
609
622
  };
610
623
  closeBtn.addEventListener("click", close);
611
624
  const onDown = (e) => {
@@ -692,7 +705,8 @@ function openGameIdEditor(opts) {
692
705
  className: "shell-id-editor",
693
706
  title: opts.title ?? "Game ID",
694
707
  width: 260,
695
- ...opts.prefer !== void 0 ? { prefer: opts.prefer } : {}
708
+ ...opts.prefer !== void 0 ? { prefer: opts.prefer } : {},
709
+ ...opts.keepClear !== void 0 ? { keepClear: opts.keepClear } : {}
696
710
  });
697
711
  if (!panel) return false;
698
712
  const input = el("input", "shell-id-input");
@@ -991,7 +1005,7 @@ function openComments(opts) {
991
1005
  // want it to the left; and never over the problems bar, which an author may
992
1006
  // be stepping through while reading the thread.
993
1007
  prefer: opts.prefer ?? "below",
994
- keepClear: [".problembar"]
1008
+ keepClear: opts.keepClear ?? [".problembar"]
995
1009
  });
996
1010
  if (!panel) return;
997
1011
  const { body, close } = panel;
@@ -1025,6 +1039,10 @@ function openComments(opts) {
1025
1039
  }
1026
1040
  const thread = open;
1027
1041
  if (thread) {
1042
+ const quote = opts.quoteFor?.(thread);
1043
+ if (quote !== void 0 && quote !== "") {
1044
+ body.append(el("blockquote", { className: "shell-cmt-quote", text: quote }));
1045
+ }
1028
1046
  const list = el("div", { className: `shell-cmt-list${thread.resolved === true ? " resolved" : ""}` });
1029
1047
  thread.messages.forEach((message, index) => {
1030
1048
  const head = el(
@@ -1466,6 +1484,6 @@ function renderStepperBar(host, opts) {
1466
1484
  );
1467
1485
  }
1468
1486
 
1469
- export { PALETTE, PALETTE_SIZE, askIdentity, closeAnchoredPanel, colourFor, colourIndex, confirmDialog, createSaveController, dupGuard, el, expandableRow, focusNewRow, foldVc, gameIdify, hideTip, icon, iconBtn, iconSvg, initTooltips, isValidGameId, labelled, lockControls, lockNotice, mountJobProgress, mountPaneShell, mountSettingsDialog, moveItem, openAnchoredPanel, openComments, openGameIdEditor, openNotesEditor, paintVcBadges, pinButton, placeAnchored, renderStepperBar, saveIndicator, showAbout, staleBar, tagChips, tipAt, tipBold, vcBadgeFor };
1487
+ export { PALETTE, PALETTE_SIZE, askIdentity, closeAnchoredPanel, closeWithExit, colourFor, colourIndex, confirmDialog, createSaveController, dupGuard, el, expandableRow, focusNewRow, foldVc, gameIdify, hideTip, icon, iconBtn, iconSvg, initTooltips, isValidGameId, labelled, lockControls, lockNotice, mountJobProgress, mountPaneShell, mountSettingsDialog, moveItem, openAnchoredPanel, openComments, openGameIdEditor, openNotesEditor, paintVcBadges, pinButton, placeAnchored, renderStepperBar, saveIndicator, showAbout, staleBar, tagChips, tipAt, tipBold, vcBadgeFor };
1470
1488
  //# sourceMappingURL=index.js.map
1471
1489
  //# sourceMappingURL=index.js.map