@wildwinter/app-shell 0.36.0 → 0.37.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
@@ -785,6 +785,25 @@ interface StaleBarOptions {
785
785
  }
786
786
  declare function staleBar(opts: StaleBarOptions): HTMLElement;
787
787
 
788
+ /** What the remark is about. `info` is the plain case; `ok` says a thing you
789
+ * asked for happened; `error` says it did not. */
790
+ type ToastKind = "info" | "ok" | "error";
791
+ interface ToastOptions {
792
+ /** How long it stays, in ms, before the exit plays. Defaults to 4000, or
793
+ * 7000 for an error. */
794
+ duration?: number;
795
+ }
796
+ /**
797
+ * Show a toast. Replaces any toast already showing.
798
+ *
799
+ * `message` is shown as written; a newline breaks the line ("Bundle
800
+ * published\n<path>"), and a long unbroken token such as a path wraps inside
801
+ * the card rather than spilling past it.
802
+ */
803
+ declare function toast(message: string, kind?: ToastKind, opts?: ToastOptions): void;
804
+ /** Dismiss the current toast now, if any. Plays the exit. */
805
+ declare function dismissToast(): void;
806
+
788
807
  interface StepperItem {
789
808
  /**
790
809
  * One word for what kind of thing this is: "error", "comment", "resolved".
@@ -881,4 +900,4 @@ declare function historyNav(onBack: () => void, onForward: () => void): {
881
900
  set(canBack: boolean, canForward: boolean): void;
882
901
  };
883
902
 
884
- 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 NavHistory, type NavHistoryOptions, type Notes, type NotesEditorOptions, PALETTE, PALETTE_SIZE, PROPERTY_NAME_HINT, type PaneShell, type PaneShellOptions, type PaneShellState, type PaneSide, type PaneSideConfig, type PinButton, type PinButtonOptions, type PropertyRefOptions, RESERVED_PROPERTY_NAMES, 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, bindPropertyName, bindPropertyRef, closeAnchoredPanel, closeWithExit, colourFor, colourIndex, confirmDialog, createNavHistory, createSaveController, dupGuard, el, expandableRow, firstIllegalPropertyName, focusNewRow, foldVc, gameIdify, hideTip, historyNav, icon, iconBtn, iconSvg, initTooltips, isCaseOnlyPropertyName, isValidGameId, isValidPropertyName, labelled, lockControls, lockNotice, mountJobProgress, mountPaneShell, mountSettingsDialog, moveItem, openAnchoredPanel, openComments, openGameIdEditor, openNotesEditor, paintVcBadges, pinButton, placeAnchored, propertyNameProblem, propertyNameify, propertyRefProblem, renderStepperBar, revalidatePropertyRefs, saveIndicator, showAbout, staleBar, tagChips, tipAt, tipBold, vcBadgeFor };
903
+ 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 NavHistory, type NavHistoryOptions, type Notes, type NotesEditorOptions, PALETTE, PALETTE_SIZE, PROPERTY_NAME_HINT, type PaneShell, type PaneShellOptions, type PaneShellState, type PaneSide, type PaneSideConfig, type PinButton, type PinButtonOptions, type PropertyRefOptions, RESERVED_PROPERTY_NAMES, 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 ToastKind, type ToastOptions, type TooltipOptions, type VcMap, askIdentity, bindPropertyName, bindPropertyRef, closeAnchoredPanel, closeWithExit, colourFor, colourIndex, confirmDialog, createNavHistory, createSaveController, dismissToast, dupGuard, el, expandableRow, firstIllegalPropertyName, focusNewRow, foldVc, gameIdify, hideTip, historyNav, icon, iconBtn, iconSvg, initTooltips, isCaseOnlyPropertyName, isValidGameId, isValidPropertyName, labelled, lockControls, lockNotice, mountJobProgress, mountPaneShell, mountSettingsDialog, moveItem, openAnchoredPanel, openComments, openGameIdEditor, openNotesEditor, paintVcBadges, pinButton, placeAnchored, propertyNameProblem, propertyNameify, propertyRefProblem, renderStepperBar, revalidatePropertyRefs, saveIndicator, showAbout, staleBar, tagChips, tipAt, tipBold, toast, vcBadgeFor };
package/dist/index.d.ts CHANGED
@@ -785,6 +785,25 @@ interface StaleBarOptions {
785
785
  }
786
786
  declare function staleBar(opts: StaleBarOptions): HTMLElement;
787
787
 
788
+ /** What the remark is about. `info` is the plain case; `ok` says a thing you
789
+ * asked for happened; `error` says it did not. */
790
+ type ToastKind = "info" | "ok" | "error";
791
+ interface ToastOptions {
792
+ /** How long it stays, in ms, before the exit plays. Defaults to 4000, or
793
+ * 7000 for an error. */
794
+ duration?: number;
795
+ }
796
+ /**
797
+ * Show a toast. Replaces any toast already showing.
798
+ *
799
+ * `message` is shown as written; a newline breaks the line ("Bundle
800
+ * published\n<path>"), and a long unbroken token such as a path wraps inside
801
+ * the card rather than spilling past it.
802
+ */
803
+ declare function toast(message: string, kind?: ToastKind, opts?: ToastOptions): void;
804
+ /** Dismiss the current toast now, if any. Plays the exit. */
805
+ declare function dismissToast(): void;
806
+
788
807
  interface StepperItem {
789
808
  /**
790
809
  * One word for what kind of thing this is: "error", "comment", "resolved".
@@ -881,4 +900,4 @@ declare function historyNav(onBack: () => void, onForward: () => void): {
881
900
  set(canBack: boolean, canForward: boolean): void;
882
901
  };
883
902
 
884
- 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 NavHistory, type NavHistoryOptions, type Notes, type NotesEditorOptions, PALETTE, PALETTE_SIZE, PROPERTY_NAME_HINT, type PaneShell, type PaneShellOptions, type PaneShellState, type PaneSide, type PaneSideConfig, type PinButton, type PinButtonOptions, type PropertyRefOptions, RESERVED_PROPERTY_NAMES, 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, bindPropertyName, bindPropertyRef, closeAnchoredPanel, closeWithExit, colourFor, colourIndex, confirmDialog, createNavHistory, createSaveController, dupGuard, el, expandableRow, firstIllegalPropertyName, focusNewRow, foldVc, gameIdify, hideTip, historyNav, icon, iconBtn, iconSvg, initTooltips, isCaseOnlyPropertyName, isValidGameId, isValidPropertyName, labelled, lockControls, lockNotice, mountJobProgress, mountPaneShell, mountSettingsDialog, moveItem, openAnchoredPanel, openComments, openGameIdEditor, openNotesEditor, paintVcBadges, pinButton, placeAnchored, propertyNameProblem, propertyNameify, propertyRefProblem, renderStepperBar, revalidatePropertyRefs, saveIndicator, showAbout, staleBar, tagChips, tipAt, tipBold, vcBadgeFor };
903
+ 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 NavHistory, type NavHistoryOptions, type Notes, type NotesEditorOptions, PALETTE, PALETTE_SIZE, PROPERTY_NAME_HINT, type PaneShell, type PaneShellOptions, type PaneShellState, type PaneSide, type PaneSideConfig, type PinButton, type PinButtonOptions, type PropertyRefOptions, RESERVED_PROPERTY_NAMES, 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 ToastKind, type ToastOptions, type TooltipOptions, type VcMap, askIdentity, bindPropertyName, bindPropertyRef, closeAnchoredPanel, closeWithExit, colourFor, colourIndex, confirmDialog, createNavHistory, createSaveController, dismissToast, dupGuard, el, expandableRow, firstIllegalPropertyName, focusNewRow, foldVc, gameIdify, hideTip, historyNav, icon, iconBtn, iconSvg, initTooltips, isCaseOnlyPropertyName, isValidGameId, isValidPropertyName, labelled, lockControls, lockNotice, mountJobProgress, mountPaneShell, mountSettingsDialog, moveItem, openAnchoredPanel, openComments, openGameIdEditor, openNotesEditor, paintVcBadges, pinButton, placeAnchored, propertyNameProblem, propertyNameify, propertyRefProblem, renderStepperBar, revalidatePropertyRefs, saveIndicator, showAbout, staleBar, tagChips, tipAt, tipBold, toast, vcBadgeFor };
package/dist/index.js CHANGED
@@ -152,23 +152,23 @@ function initTooltips(opts = {}) {
152
152
 
153
153
  // src/dom.ts
154
154
  function el(tag, classNameOrProps, ...children) {
155
- const node = document.createElement(tag);
155
+ const node2 = document.createElement(tag);
156
156
  const props = typeof classNameOrProps === "string" ? { className: classNameOrProps } : classNameOrProps ?? {};
157
- if (props.className) node.className = props.className;
158
- if (props.text !== void 0 && props.text !== null) node.textContent = props.text;
159
- if (props.title !== void 0) node.title = props.title;
157
+ if (props.className) node2.className = props.className;
158
+ if (props.text !== void 0 && props.text !== null) node2.textContent = props.text;
159
+ if (props.title !== void 0) node2.title = props.title;
160
160
  if (props.tip !== void 0) {
161
- node.dataset["tip"] = props.tip;
162
- node.setAttribute("aria-label", props.tip);
161
+ node2.dataset["tip"] = props.tip;
162
+ node2.setAttribute("aria-label", props.tip);
163
163
  ensureTooltipHost();
164
164
  }
165
- if (props.onClick) node.addEventListener("click", props.onClick);
165
+ if (props.onClick) node2.addEventListener("click", props.onClick);
166
166
  for (const child of children) {
167
167
  if (child === null || child === void 0) continue;
168
- node.append(child);
168
+ node2.append(child);
169
169
  }
170
170
  checkTooltipHost();
171
- return node;
171
+ return node2;
172
172
  }
173
173
  function iconBtn(glyph, title, onClick, disabled = false, danger = false) {
174
174
  const b = el("button", `shell-icon${danger ? " danger" : ""}`);
@@ -200,7 +200,7 @@ function tagChips(holder, onChange) {
200
200
  const wrap = el("div", "shell-tags");
201
201
  const input = el("input", "shell-tag-input");
202
202
  input.type = "text";
203
- input.placeholder = "add value";
203
+ input.placeholder = "Add value";
204
204
  input.spellcheck = false;
205
205
  const makeChip = (v) => {
206
206
  const chip = el("span", "shell-tag", v);
@@ -664,14 +664,14 @@ function closeWithExit(element, done) {
664
664
  if (fired) return;
665
665
  fired = true;
666
666
  element.removeEventListener("animationend", onEnd);
667
- clearTimeout(timer2);
667
+ clearTimeout(timer3);
668
668
  done();
669
669
  };
670
670
  const onEnd = (e) => {
671
671
  if (e.target === element) finish();
672
672
  };
673
673
  element.addEventListener("animationend", onEnd);
674
- const timer2 = setTimeout(finish, seconds * 1e3 + 120);
674
+ const timer3 = setTimeout(finish, seconds * 1e3 + 120);
675
675
  }
676
676
 
677
677
  // src/confirm.ts
@@ -1511,7 +1511,7 @@ function createSaveController(opts) {
1511
1511
  let auto = true;
1512
1512
  let dirty = false;
1513
1513
  let dirtySince = 0;
1514
- let timer2;
1514
+ let timer3;
1515
1515
  let inFlight;
1516
1516
  const setStatus = (next) => {
1517
1517
  if (next === status) return;
@@ -1519,17 +1519,17 @@ function createSaveController(opts) {
1519
1519
  opts.onStatus?.(status);
1520
1520
  };
1521
1521
  const clearTimer = () => {
1522
- if (timer2 === void 0) return;
1523
- clearTimeout(timer2);
1524
- timer2 = void 0;
1522
+ if (timer3 === void 0) return;
1523
+ clearTimeout(timer3);
1524
+ timer3 = void 0;
1525
1525
  };
1526
1526
  const arm = () => {
1527
1527
  clearTimer();
1528
1528
  if (!auto) return;
1529
1529
  const deadline = dirtySince + maxWaitMs;
1530
1530
  const wait = Math.max(0, Math.min(delayMs, deadline - Date.now()));
1531
- timer2 = setTimeout(() => {
1532
- timer2 = void 0;
1531
+ timer3 = setTimeout(() => {
1532
+ timer3 = void 0;
1533
1533
  void run();
1534
1534
  }, wait);
1535
1535
  };
@@ -1603,13 +1603,13 @@ var WORDS = {
1603
1603
  unsaved: "Unsaved"
1604
1604
  };
1605
1605
  function saveIndicator(initial = "saved") {
1606
- const node = el("span");
1606
+ const node2 = el("span");
1607
1607
  const set = (status) => {
1608
- node.className = `savestat ${status}`;
1609
- node.textContent = WORDS[status];
1608
+ node2.className = `savestat ${status}`;
1609
+ node2.textContent = WORDS[status];
1610
1610
  };
1611
1611
  set(initial);
1612
- return { el: node, set };
1612
+ return { el: node2, set };
1613
1613
  }
1614
1614
 
1615
1615
  // src/stale.ts
@@ -1630,6 +1630,43 @@ function staleBar(opts) {
1630
1630
  );
1631
1631
  }
1632
1632
 
1633
+ // src/toast.ts
1634
+ var DURATION = { info: 4e3, ok: 4e3, error: 7e3 };
1635
+ var node;
1636
+ var timer2 = 0;
1637
+ var seq = 0;
1638
+ function mount() {
1639
+ if (node && node.isConnected) return node;
1640
+ node = el("div", { className: "shell-toast" });
1641
+ node.setAttribute("role", "status");
1642
+ node.setAttribute("aria-live", "polite");
1643
+ node.hidden = true;
1644
+ document.body.append(node);
1645
+ return node;
1646
+ }
1647
+ function toast(message, kind = "info", opts = {}) {
1648
+ const t = mount();
1649
+ const id = ++seq;
1650
+ t.textContent = message;
1651
+ t.className = `shell-toast ${kind}`;
1652
+ t.hidden = false;
1653
+ window.clearTimeout(timer2);
1654
+ timer2 = window.setTimeout(() => {
1655
+ closeWithExit(t, () => {
1656
+ if (seq === id) t.hidden = true;
1657
+ });
1658
+ }, opts.duration ?? DURATION[kind]);
1659
+ }
1660
+ function dismissToast() {
1661
+ if (!node || node.hidden) return;
1662
+ window.clearTimeout(timer2);
1663
+ const id = seq;
1664
+ const t = node;
1665
+ closeWithExit(t, () => {
1666
+ if (seq === id) t.hidden = true;
1667
+ });
1668
+ }
1669
+
1633
1670
  // src/stepper.ts
1634
1671
  function renderStepperBar(host, opts) {
1635
1672
  const { items } = opts;
@@ -1752,6 +1789,6 @@ function historyNav(onBack, onForward) {
1752
1789
  };
1753
1790
  }
1754
1791
 
1755
- export { PALETTE, PALETTE_SIZE, PROPERTY_NAME_HINT, RESERVED_PROPERTY_NAMES, askIdentity, bindPropertyName, bindPropertyRef, closeAnchoredPanel, closeWithExit, colourFor, colourIndex, confirmDialog, createNavHistory, createSaveController, dupGuard, el, expandableRow, firstIllegalPropertyName, focusNewRow, foldVc, gameIdify, hideTip, historyNav, icon, iconBtn, iconSvg, initTooltips, isCaseOnlyPropertyName, isValidGameId, isValidPropertyName, labelled, lockControls, lockNotice, mountJobProgress, mountPaneShell, mountSettingsDialog, moveItem, openAnchoredPanel, openComments, openGameIdEditor, openNotesEditor, paintVcBadges, pinButton, placeAnchored, propertyNameProblem, propertyNameify, propertyRefProblem, renderStepperBar, revalidatePropertyRefs, saveIndicator, showAbout, staleBar, tagChips, tipAt, tipBold, vcBadgeFor };
1792
+ export { PALETTE, PALETTE_SIZE, PROPERTY_NAME_HINT, RESERVED_PROPERTY_NAMES, askIdentity, bindPropertyName, bindPropertyRef, closeAnchoredPanel, closeWithExit, colourFor, colourIndex, confirmDialog, createNavHistory, createSaveController, dismissToast, dupGuard, el, expandableRow, firstIllegalPropertyName, focusNewRow, foldVc, gameIdify, hideTip, historyNav, icon, iconBtn, iconSvg, initTooltips, isCaseOnlyPropertyName, isValidGameId, isValidPropertyName, labelled, lockControls, lockNotice, mountJobProgress, mountPaneShell, mountSettingsDialog, moveItem, openAnchoredPanel, openComments, openGameIdEditor, openNotesEditor, paintVcBadges, pinButton, placeAnchored, propertyNameProblem, propertyNameify, propertyRefProblem, renderStepperBar, revalidatePropertyRefs, saveIndicator, showAbout, staleBar, tagChips, tipAt, tipBold, toast, vcBadgeFor };
1756
1793
  //# sourceMappingURL=index.js.map
1757
1794
  //# sourceMappingURL=index.js.map