@fungi.computer/caps 0.9.0 → 0.10.1

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.
@@ -20,6 +20,8 @@ export type SetupNoticeProps = Omit<HTMLAttributes<HTMLElement>, "title" | "chil
20
20
  secondary?: SetupNoticeAction;
21
21
  /** What still works meanwhile, such as "Uploads work now". */
22
22
  available?: ReactNode;
23
+ /** The panel's own glyph (an App icon, say) in place of the warning bead; ignored by `banner` and `inline`. */
24
+ visual?: Exclude<ReactNode, string>;
23
25
  /** Names what is awaited while pending, after "Waiting for". */
24
26
  waitingFor?: string;
25
27
  /** `panel` replaces an empty state; `banner` and `inline` sit above or in content. */
@@ -29,4 +31,4 @@ export type SetupNoticeProps = Omit<HTMLAttributes<HTMLElement>, "title" | "chil
29
31
  * Missing setup, named with its fix. Render it only while the setup fact is
30
32
  * missing; when the fact turns ready the host unmounts it (and may toast).
31
33
  */
32
- export declare function SetupNotice({ available, cause, className, fix, need, secondary, variant, waitingFor, ...props }: SetupNoticeProps): import("react/jsx-runtime").JSX.Element;
34
+ export declare function SetupNotice({ available, cause, className, fix, need, secondary, variant, visual, waitingFor, ...props }: SetupNoticeProps): import("react/jsx-runtime").JSX.Element;
@@ -8,7 +8,7 @@ import { EmptyState } from "./empty-state.js";
8
8
  * Missing setup, named with its fix. Render it only while the setup fact is
9
9
  * missing; when the fact turns ready the host unmounts it (and may toast).
10
10
  */
11
- export function SetupNotice({ available, cause, className, fix, need, secondary, variant, waitingFor = "setup", ...props }) {
11
+ export function SetupNotice({ available, cause, className, fix, need, secondary, variant, visual, waitingFor = "setup", ...props }) {
12
12
  const pending = fix.pending === true;
13
13
  const label = pending ? `Waiting for ${waitingFor}…` : fix.label;
14
14
  const detail = available ? (_jsxs(_Fragment, { children: [cause, " ", _jsx("span", { className: "caps-setup-notice-available", children: available })] })) : (cause);
@@ -17,7 +17,7 @@ export function SetupNotice({ available, cause, className, fix, need, secondary,
17
17
  label,
18
18
  onSelect: fix.onSelect,
19
19
  pending,
20
- }, title: need, variant: "panel", visual: _jsx(Status, { className: "caps-setup-notice-dot", glyph: "dot", tone: "warning" }) }));
20
+ }, title: need, variant: "panel", visual: visual ?? (_jsx(Status, { className: "caps-setup-notice-dot", glyph: "dot", tone: "warning" })) }));
21
21
  }
22
22
  return (_jsx("div", { className: "caps-setup-notice-frame", children: _jsx(Alert, { ...props, action: _jsxs("span", { className: "caps-setup-notice-actions", children: [secondary ? (_jsx(Button, { size: "sm", variant: "ghost", onClick: secondary.onSelect, children: secondary.label })) : null, _jsx(Button, { loading: pending, size: "sm", variant: "outline", onClick: fix.onSelect, children: label })] }), className: cn("caps-setup-notice", className), "data-variant": variant, description: detail, role: "status", title: _jsxs("span", { className: "caps-setup-notice-title", children: [_jsx(Status, { glyph: "dot", tone: "warning" }), need] }), tone: "warning" }) }));
23
23
  }
@@ -1,5 +1,14 @@
1
1
  import { type ToasterProps } from "sonner";
2
- export { toast } from "sonner";
2
+ import { toast } from "sonner";
3
+ export { toast };
4
+ /**
5
+ * Show a notice a hosted App asked for, on one named Toaster, with the
6
+ * notice's tone choosing the Caps status dot.
7
+ */
8
+ export declare function showNotice(notice: Readonly<{
9
+ message: string;
10
+ tone?: "error" | "info" | "success" | "warning";
11
+ }>, toasterId: string): void;
3
12
  /**
4
13
  * Sonner owns gestures, stacking, focus and lifetime; Caps owns the surface.
5
14
  * Colors come from the Stipe tokens in the cascade, so a `data-theme` switch
@@ -6,7 +6,19 @@ import { Loader } from "./loader.js";
6
6
  import { Status } from "./status.js";
7
7
  import { createPortal } from "react-dom";
8
8
  import { useOverlayRoot } from "./overlay-root.js";
9
- export { toast } from "sonner";
9
+ import { toast } from "sonner";
10
+ export { toast };
11
+ /**
12
+ * Show a notice a hosted App asked for, on one named Toaster, with the
13
+ * notice's tone choosing the Caps status dot.
14
+ */
15
+ export function showNotice(notice, toasterId) {
16
+ const options = { toasterId, closeButton: true };
17
+ if (notice.tone === undefined)
18
+ toast(notice.message, options);
19
+ else
20
+ toast[notice.tone](notice.message, options);
21
+ }
10
22
  /**
11
23
  * Sonner owns gestures, stacking, focus and lifetime; Caps owns the surface.
12
24
  * Colors come from the Stipe tokens in the cascade, so a `data-theme` switch
@@ -50,15 +50,16 @@ Props accepted by SetupNotice.
50
50
 
51
51
  #### Type Declaration
52
52
 
53
- | Name | Type | Description |
54
- | ------------- | ----------------------------------------- | ------------------------------------------------------------------------------- |
55
- | `need` | `ReactNode` | The title, such as "Connect a model to start chatting". |
56
- | `cause` | `ReactNode` | One sentence naming the real cause. |
57
- | `fix` | [`SetupNoticeFix`](#setupnoticefix) | The one primary fix; never a dead CTA. |
58
- | `secondary?` | [`SetupNoticeAction`](#setupnoticeaction) | - |
59
- | `available?` | `ReactNode` | What still works meanwhile, such as "Uploads work now". |
60
- | `waitingFor?` | `string` | Names what is awaited while pending, after "Waiting for". |
61
- | `variant` | `"panel"` \| `"inline"` \| `"banner"` | `panel` replaces an empty state; `banner` and `inline` sit above or in content. |
53
+ | Name | Type | Description |
54
+ | ------------- | ----------------------------------------- | -------------------------------------------------------------------------------------------------------- |
55
+ | `need` | `ReactNode` | The title, such as "Connect a model to start chatting". |
56
+ | `cause` | `ReactNode` | One sentence naming the real cause. |
57
+ | `fix` | [`SetupNoticeFix`](#setupnoticefix) | The one primary fix; never a dead CTA. |
58
+ | `secondary?` | [`SetupNoticeAction`](#setupnoticeaction) | - |
59
+ | `available?` | `ReactNode` | What still works meanwhile, such as "Uploads work now". |
60
+ | `visual?` | `Exclude`\<`ReactNode`, `string`\> | The panel's own glyph (an App icon, say) in place of the warning bead; ignored by `banner` and `inline`. |
61
+ | `waitingFor?` | `string` | Names what is awaited while pending, after "Waiting for". |
62
+ | `variant` | `"panel"` \| `"inline"` \| `"banner"` | `panel` replaces an empty state; `banner` and `inline` sit above or in content. |
62
63
 
63
64
  ## Functions
64
65
 
@@ -10,6 +10,28 @@
10
10
 
11
11
  ## Functions
12
12
 
13
+ ### showNotice()
14
+
15
+ ```ts
16
+ function showNotice(notice, toasterId): void;
17
+ ```
18
+
19
+ Show a notice a hosted App asked for, on one named Toaster, with the notice's
20
+ tone choosing the Caps status dot.
21
+
22
+ #### Parameters
23
+
24
+ | Parameter | Type |
25
+ | ----------- | ------------------------------------------------------------------------------------------------------ |
26
+ | `notice` | `Readonly`\<\{ `message`: `string`; `tone?`: `"error"` \| `"info"` \| `"success"` \| `"warning"`; \}\> |
27
+ | `toasterId` | `string` |
28
+
29
+ #### Returns
30
+
31
+ `void`
32
+
33
+ ---
34
+
13
35
  ### Toaster()
14
36
 
15
37
  ```ts
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@fungi.computer/caps",
3
- "version": "0.9.0",
3
+ "version": "0.10.1",
4
4
  "author": "Levi <levi@technomancy.dev>",
5
5
  "description": "Product-neutral React primitives and blocks for Fungi interfaces",
6
6
  "type": "module",