@wildwinter/app-shell 0.18.0 → 0.19.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;
@@ -452,6 +462,19 @@ interface CommentsOptions {
452
462
  deleteMessage?: (threadId: string, index: number) => void;
453
463
  /** Where the panel sits: "centre" for a point on a canvas (see anchored.ts). */
454
464
  prefer?: "left" | "below" | "centre";
465
+ /**
466
+ * The text a thread is pinned to, shown above it as a quotation.
467
+ *
468
+ * A callback rather than a field on `Comment`, because resolving an anchor is
469
+ * the APP's half of the seam and this is only that resolution rendered: an app
470
+ * that pins threads to a span of prose can quote it, one that pins them to a
471
+ * whole card has nothing to quote and passes nothing. Keeping it out of the
472
+ * thread type also means no change to what is written to disk, which matters
473
+ * for files living in version control.
474
+ *
475
+ * Return undefined (or "") for a thread with no quotable anchor.
476
+ */
477
+ quoteFor?: (thread: Comment) => string | undefined;
455
478
  }
456
479
  declare function openComments(opts: CommentsOptions): void;
457
480
 
@@ -647,4 +670,4 @@ interface StepperBarOptions {
647
670
  /** Draw (or hide) the bar in `host`. Idempotent: call it again with new state. */
648
671
  declare function renderStepperBar(host: HTMLElement, opts: StepperBarOptions): void;
649
672
 
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 };
673
+ 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;
@@ -452,6 +462,19 @@ interface CommentsOptions {
452
462
  deleteMessage?: (threadId: string, index: number) => void;
453
463
  /** Where the panel sits: "centre" for a point on a canvas (see anchored.ts). */
454
464
  prefer?: "left" | "below" | "centre";
465
+ /**
466
+ * The text a thread is pinned to, shown above it as a quotation.
467
+ *
468
+ * A callback rather than a field on `Comment`, because resolving an anchor is
469
+ * the APP's half of the seam and this is only that resolution rendered: an app
470
+ * that pins threads to a span of prose can quote it, one that pins them to a
471
+ * whole card has nothing to quote and passes nothing. Keeping it out of the
472
+ * thread type also means no change to what is written to disk, which matters
473
+ * for files living in version control.
474
+ *
475
+ * Return undefined (or "") for a thread with no quotable anchor.
476
+ */
477
+ quoteFor?: (thread: Comment) => string | undefined;
455
478
  }
456
479
  declare function openComments(opts: CommentsOptions): void;
457
480
 
@@ -647,4 +670,4 @@ interface StepperBarOptions {
647
670
  /** Draw (or hide) the bar in `host`. Idempotent: call it again with new state. */
648
671
  declare function renderStepperBar(host: HTMLElement, opts: StepperBarOptions): void;
649
672
 
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 };
673
+ 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) => {
@@ -1025,6 +1038,10 @@ function openComments(opts) {
1025
1038
  }
1026
1039
  const thread = open;
1027
1040
  if (thread) {
1041
+ const quote = opts.quoteFor?.(thread);
1042
+ if (quote !== void 0 && quote !== "") {
1043
+ body.append(el("blockquote", { className: "shell-cmt-quote", text: quote }));
1044
+ }
1028
1045
  const list = el("div", { className: `shell-cmt-list${thread.resolved === true ? " resolved" : ""}` });
1029
1046
  thread.messages.forEach((message, index) => {
1030
1047
  const head = el(
@@ -1466,6 +1483,6 @@ function renderStepperBar(host, opts) {
1466
1483
  );
1467
1484
  }
1468
1485
 
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 };
1486
+ 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
1487
  //# sourceMappingURL=index.js.map
1471
1488
  //# sourceMappingURL=index.js.map