meowtail 0.2.0-alpha.1 → 0.2.0-alpha.2

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.
Files changed (88) hide show
  1. package/README.md +24 -8
  2. package/dist/src/chat/assistant-composer.js +58 -98
  3. package/dist/src/chat/assistant-content.d.ts +1 -3
  4. package/dist/src/chat/assistant-content.js +36 -44
  5. package/dist/src/chat/assistant-markdown.js +4 -8
  6. package/dist/src/chat/assistant-question.js +13 -14
  7. package/dist/src/chat/assistant.js +27 -26
  8. package/dist/src/chat/attachments.d.ts +3 -2
  9. package/dist/src/chat/attachments.js +39 -34
  10. package/dist/src/chat/composer-panel.d.ts +2 -3
  11. package/dist/src/chat/composer-panel.js +3 -4
  12. package/dist/src/chat/composer.d.ts +5 -3
  13. package/dist/src/chat/composer.js +67 -21
  14. package/dist/src/chat/task.js +9 -15
  15. package/dist/src/chat/tool-call.js +1 -8
  16. package/dist/src/components/accordion.d.ts +24 -0
  17. package/dist/src/components/accordion.js +50 -0
  18. package/dist/src/components/avatar.d.ts +22 -0
  19. package/dist/src/components/avatar.js +44 -0
  20. package/dist/src/components/checkbox.d.ts +6 -2
  21. package/dist/src/components/checkbox.js +36 -8
  22. package/dist/src/components/choice-group.d.ts +1 -0
  23. package/dist/src/components/choice-group.js +12 -17
  24. package/dist/src/components/choice-select.d.ts +3 -1
  25. package/dist/src/components/choice-select.js +56 -54
  26. package/dist/src/components/code-block.d.ts +3 -3
  27. package/dist/src/components/code-block.js +27 -23
  28. package/dist/src/components/context-menu.d.ts +16 -0
  29. package/dist/src/components/context-menu.js +49 -0
  30. package/dist/src/components/disclosure.d.ts +2 -2
  31. package/dist/src/components/disclosure.js +1 -1
  32. package/dist/src/components/index.d.ts +9 -0
  33. package/dist/src/components/index.js +9 -0
  34. package/dist/src/components/link.d.ts +13 -0
  35. package/dist/src/components/link.js +9 -0
  36. package/dist/src/components/menu-button.d.ts +13 -0
  37. package/dist/src/components/menu-button.js +10 -0
  38. package/dist/src/components/menu.d.ts +4 -0
  39. package/dist/src/components/menu.js +3 -3
  40. package/dist/src/components/meta-row.d.ts +5 -4
  41. package/dist/src/components/meta-row.js +34 -18
  42. package/dist/src/components/nav-item.js +2 -5
  43. package/dist/src/components/number-input.d.ts +29 -0
  44. package/dist/src/components/number-input.js +137 -0
  45. package/dist/src/components/output-block.js +1 -8
  46. package/dist/src/components/path-picker.js +5 -10
  47. package/dist/src/components/pill.js +2 -5
  48. package/dist/src/components/popover.js +4 -4
  49. package/dist/src/components/progress.d.ts +15 -0
  50. package/dist/src/components/progress.js +12 -0
  51. package/dist/src/components/risk-confirmation.js +2 -5
  52. package/dist/src/components/segmented-control.js +3 -3
  53. package/dist/src/components/skeleton-boundary.js +4 -7
  54. package/dist/src/components/slider.d.ts +22 -0
  55. package/dist/src/components/slider.js +49 -0
  56. package/dist/src/components/table.d.ts +41 -0
  57. package/dist/src/components/table.js +146 -0
  58. package/dist/src/components/tabs.d.ts +1 -1
  59. package/dist/src/components/tabs.js +11 -20
  60. package/dist/src/components/text-shimmer.js +2 -5
  61. package/dist/src/registry/index.d.ts +62 -3
  62. package/dist/src/registry/index.js +18 -2
  63. package/dist/src/theme/chat/composer-panel.styles.js +4 -1
  64. package/dist/src/theme/chat/composer.styles.js +45 -67
  65. package/dist/src/theme/chat/task.styles.js +5 -6
  66. package/dist/src/theme/components/accordion.styles.d.ts +1 -0
  67. package/dist/src/theme/components/accordion.styles.js +63 -0
  68. package/dist/src/theme/components/avatar.styles.d.ts +1 -0
  69. package/dist/src/theme/components/avatar.styles.js +52 -0
  70. package/dist/src/theme/components/button.styles.js +9 -0
  71. package/dist/src/theme/components/card.styles.js +2 -0
  72. package/dist/src/theme/components/context-menu.styles.d.ts +1 -0
  73. package/dist/src/theme/components/context-menu.styles.js +14 -0
  74. package/dist/src/theme/components/link.styles.d.ts +1 -0
  75. package/dist/src/theme/components/link.styles.js +33 -0
  76. package/dist/src/theme/components/menu.styles.js +9 -3
  77. package/dist/src/theme/components/number-input.styles.d.ts +1 -0
  78. package/dist/src/theme/components/number-input.styles.js +106 -0
  79. package/dist/src/theme/components/progress.styles.d.ts +1 -0
  80. package/dist/src/theme/components/progress.styles.js +71 -0
  81. package/dist/src/theme/components/slider.styles.d.ts +1 -0
  82. package/dist/src/theme/components/slider.styles.js +129 -0
  83. package/dist/src/theme/components/table.styles.d.ts +1 -0
  84. package/dist/src/theme/components/table.styles.js +156 -0
  85. package/dist/src/theme/components/toggle.styles.js +10 -0
  86. package/dist/src/theme/index.d.ts +1 -1
  87. package/dist/src/theme/index.js +16 -0
  88. package/package.json +3 -3
@@ -1,4 +1,4 @@
1
- import { defineComponent, h, keyed, unwrap } from "meowjsx";
1
+ import { defineComponent, derived, h, keyed, unwrap } from "meowjsx";
2
2
  import { PageFrame } from "../components/page-frame.js";
3
3
  import { Button } from "../components/button.js";
4
4
  import { WorkCard } from "../components/work-card.js";
@@ -7,7 +7,7 @@ import { Dialog } from "../components/dialog.js";
7
7
  import { ChatHeader } from "./header.js";
8
8
  import { ChatMessageList } from "./message-list.js";
9
9
  import { AssistantComposer } from "./assistant-composer.js";
10
- import { AssistantMessageView, AssistantSteps, assistantDerived } from "./assistant-content.js";
10
+ import { AssistantMessageView, AssistantSteps } from "./assistant-content.js";
11
11
  import { AssistantQuestionView } from "./assistant-question.js";
12
12
  import { AssistantMarkdown } from "./assistant-markdown.js";
13
13
  import { assistantScroll } from "./assistant-scroll.js";
@@ -32,18 +32,18 @@ export const assistantViewContract = {
32
32
  "status",
33
33
  ],
34
34
  };
35
- const AssistantWorkRow = defineComponent({ name: "assistant-work-row", parts: ["root"] }, ({ value, onOpen, actionLabel }, context) => h(WorkCard, {
35
+ const AssistantWorkRow = defineComponent({ name: "assistant-work-row", parts: ["root"] }, ({ value, onOpen, actionLabel }) => h(WorkCard, {
36
36
  action: actionLabel,
37
- title: assistantDerived(context, () => value.value.title),
38
- state: assistantDerived(context, () => value.value.tone ?? "unknown"),
39
- status: assistantDerived(context, () => value.value.statusText),
40
- detail: assistantDerived(context, () => [value.value.executionText, value.value.replyText].filter(Boolean).join(" · ")),
37
+ title: derived(() => value.value.title),
38
+ state: derived(() => value.value.tone ?? "unknown"),
39
+ status: derived(() => value.value.statusText),
40
+ detail: derived(() => [value.value.executionText, value.value.replyText].filter(Boolean).join(" · ")),
41
41
  onClick: (event) => onOpen(value.value.id, event.currentTarget),
42
42
  }));
43
43
  const AssistantWorkDetail = defineComponent({ name: "assistant-work-detail", parts: ["root", "feedback", "facts"] }, ({ value, options }, context) => {
44
44
  const assistantCopy = { ...defaultAssistantCopy, ...options.labels };
45
- const hidden = assistantDerived(context, () => value.value?.readState === "unavailable");
46
- const feedback = assistantDerived(context, () => {
45
+ const hidden = derived(() => value.value?.readState === "unavailable");
46
+ const feedback = derived(() => {
47
47
  const work = value.value;
48
48
  return (work?.feedback ||
49
49
  (work?.readState === "unavailable"
@@ -55,16 +55,17 @@ const AssistantWorkDetail = defineComponent({ name: "assistant-work-detail", par
55
55
  : ""));
56
56
  });
57
57
  const detail = h(AssistantMarkdown, {
58
- text: assistantDerived(context, () => value.value?.readState === "unavailable"
58
+ text: derived(() => value.value?.readState === "unavailable"
59
59
  ? ""
60
60
  : (value.value?.detail ?? value.value?.summary ?? "")),
61
61
  });
62
+ // The host detail slot may return a node. The default markdown view stays mounted otherwise.
62
63
  const custom = options.renderWorkDetail
63
- ? assistantDerived(context, () => value.value && value.value.readState !== "unavailable"
64
+ ? derived(() => value.value && value.value.readState !== "unavailable"
64
65
  ? (options.renderWorkDetail(value.value) ?? detail)
65
66
  : null)
66
67
  : detail;
67
- return context.part("root", "section", null, context.part("feedback", "p", { role: "status", hidden: assistantDerived(context, () => !feedback.value) }, feedback), context.part("facts", "div", { hidden }, h("h3", null, assistantDerived(context, () => value.value?.title ?? "")), h("p", null, h(StatusDot, { state: assistantDerived(context, () => value.value?.tone ?? "unknown") }), " ", assistantDerived(context, () => value.value?.statusText ?? "")), h("p", null, assistantDerived(context, () => value.value?.executionText ?? "")), h("p", null, assistantDerived(context, () => value.value?.replyText ?? "")), custom, h(AssistantSteps, { steps: assistantDerived(context, () => value.value?.steps ?? []) })), options.onRefreshWork
68
+ return context.part("root", "section", null, context.part("feedback", "p", { role: "status", hidden: derived(() => !feedback.value) }, feedback), context.part("facts", "div", { hidden }, h("h3", null, derived(() => value.value?.title ?? "")), h("p", null, h(StatusDot, { state: derived(() => value.value?.tone ?? "unknown") }), " ", derived(() => value.value?.statusText ?? "")), h("p", null, derived(() => value.value?.executionText ?? "")), h("p", null, derived(() => value.value?.replyText ?? "")), custom, h(AssistantSteps, { steps: derived(() => value.value?.steps ?? []) })), options.onRefreshWork
68
69
  ? h(Button, {
69
70
  variant: "outline",
70
71
  size: "small",
@@ -79,16 +80,16 @@ const AssistantWorkDetail = defineComponent({ name: "assistant-work-detail", par
79
80
  /** A complete default Assistant surface. Data, permissions, network and business lifetime stay with the host. */
80
81
  export const AssistantView = defineComponent(assistantViewContract, (options, context) => {
81
82
  const assistantCopy = { ...defaultAssistantCopy, ...options.labels };
82
- const messages = assistantDerived(context, () => unwrap(options.messages));
83
- const work = assistantDerived(context, () => unwrap(options.work ?? []));
84
- const questions = assistantDerived(context, () => unwrap(options.questions ?? []));
85
- const activity = assistantDerived(context, () => unwrap(options.activity));
83
+ const messages = derived(() => unwrap(options.messages));
84
+ const work = derived(() => unwrap(options.work ?? []));
85
+ const questions = derived(() => unwrap(options.questions ?? []));
86
+ const activity = derived(() => unwrap(options.activity));
86
87
  const panelOpen = context.signal(false);
87
88
  const selected = context.signal("");
88
- const selectedWork = assistantDerived(context, () => work.value.find((item) => item.id === selected.value));
89
+ const selectedWork = derived(() => work.value.find((item) => item.id === selected.value));
89
90
  const latestHidden = context.signal(true);
90
- const bodyHidden = assistantDerived(context, () => !!selected.value);
91
- const detailHidden = assistantDerived(context, () => !selected.value);
91
+ const bodyHidden = derived(() => !!selected.value);
92
+ const detailHidden = derived(() => !selected.value);
92
93
  let content;
93
94
  let scroll;
94
95
  let dialog;
@@ -189,19 +190,19 @@ export const AssistantView = defineComponent(assistantViewContract, (options, co
189
190
  })
190
191
  : null, context.part("feedback", "p", {
191
192
  role: "status",
192
- hidden: assistantDerived(context, () => unwrap(options.readState ?? "ready") === "ready"),
193
- }, assistantDerived(context, () => unwrap(options.readFeedback ?? "") ||
193
+ hidden: derived(() => unwrap(options.readState ?? "ready") === "ready"),
194
+ }, derived(() => unwrap(options.readFeedback ?? "") ||
194
195
  (unwrap(options.readState ?? "ready") === "loading"
195
196
  ? assistantCopy.loading
196
197
  : assistantCopy.readError))), context.part("empty", "div", {
197
- hidden: assistantDerived(context, () => messages.value.length > 0 || unwrap(options.readState ?? "ready") !== "ready"),
198
+ hidden: derived(() => messages.value.length > 0 || unwrap(options.readState ?? "ready") !== "ready"),
198
199
  }, h("h2", null, assistantCopy.empty), h("p", null, assistantCopy.emptyDescription)), h(ChatMessageList, { ariaLabel: assistantCopy.messages, children: transcript }))), context.part("latest", "div", { hidden: latestHidden }, h(Button, {
199
200
  variant: "outline",
200
201
  size: "small",
201
202
  onClick: () => scroll?.latest(),
202
203
  children: assistantCopy.latest,
203
204
  })));
204
- const activityList = context.part("activityBody", "div", { hidden: bodyHidden }, context.part("section", "section", null, h("h3", null, assistantCopy.current), context.part("status", "p", null, h(StatusDot, { state: assistantDerived(context, () => activity.value?.tone ?? "idle") }), assistantDerived(context, () => activity.value?.statusText ?? assistantCopy.noActivity)), h("strong", null, assistantDerived(context, () => activity.value?.title ?? "")), h("p", null, assistantDerived(context, () => activity.value?.description ?? "")), h(AssistantSteps, { steps: assistantDerived(context, () => activity.value?.steps ?? []) })), context.part("section", "section", null, h("h3", null, assistantCopy.background), h("p", { hidden: assistantDerived(context, () => work.value.length > 0) }, assistantCopy.noWork), keyed(work, (item) => item.id, (value) => h(AssistantWorkRow, {
205
+ const activityList = context.part("activityBody", "div", { hidden: bodyHidden }, context.part("section", "section", null, h("h3", null, assistantCopy.current), context.part("status", "p", null, h(StatusDot, { state: derived(() => activity.value?.tone ?? "idle") }), derived(() => activity.value?.statusText ?? assistantCopy.noActivity)), h("strong", null, derived(() => activity.value?.title ?? "")), h("p", null, derived(() => activity.value?.description ?? "")), h(AssistantSteps, { steps: derived(() => activity.value?.steps ?? []) })), context.part("section", "section", null, h("h3", null, assistantCopy.background), h("p", { hidden: derived(() => work.value.length > 0) }, assistantCopy.noWork), keyed(work, (item) => item.id, (value) => h(AssistantWorkRow, {
205
206
  value,
206
207
  actionLabel: assistantCopy.details,
207
208
  onOpen: (id, button) => {
@@ -212,7 +213,7 @@ export const AssistantView = defineComponent(assistantViewContract, (options, co
212
213
  dialog?.querySelector("[data-assistant-back]")?.focus();
213
214
  });
214
215
  },
215
- }))), context.part("section", "section", { hidden: assistantDerived(context, () => questions.value.length === 0) }, h("h3", null, assistantCopy.questions), keyed(questions, (question) => question.id, (value) => h(AssistantQuestionView, {
216
+ }))), context.part("section", "section", { hidden: derived(() => questions.value.length === 0) }, h("h3", null, assistantCopy.questions), keyed(questions, (question) => question.id, (value) => h(AssistantQuestionView, {
216
217
  value,
217
218
  labels: options.labels,
218
219
  onAnswer: options.onAnswer,
@@ -260,7 +261,7 @@ export const AssistantView = defineComponent(assistantViewContract, (options, co
260
261
  style: options.style,
261
262
  "aria-label": options["aria-label"],
262
263
  className: options.className,
263
- "data-activity-open": assistantDerived(context, () => String(panelOpen.value)),
264
+ "data-activity-open": derived(() => String(panelOpen.value)),
264
265
  ref: (element) => {
265
266
  root = element;
266
267
  const observer = new ResizeObserver(syncDialog);
@@ -280,7 +281,7 @@ export const AssistantView = defineComponent(assistantViewContract, (options, co
280
281
  h(Button, {
281
282
  variant: "quiet",
282
283
  size: "small",
283
- "aria-expanded": assistantDerived(context, () => String(panelOpen.value)),
284
+ "aria-expanded": derived(() => String(panelOpen.value)),
284
285
  ref: (element) => {
285
286
  activityTrigger = element;
286
287
  },
@@ -1,4 +1,4 @@
1
- import { type Props } from "meowjsx";
1
+ import { type MaybeSignal, type Props } from "meowjsx";
2
2
  export declare const chatAttachmentsContract: {
3
3
  readonly name: "chat-attachments";
4
4
  readonly parts: readonly ["root", "image", "preview", "file", "icon", "details", "name", "size", "entry", "previewButton", "remove"];
@@ -16,7 +16,8 @@ export interface ChatAttachmentItem {
16
16
  onRemove?: () => void;
17
17
  }
18
18
  export interface ChatAttachmentsProps extends Props {
19
- items: readonly ChatAttachmentItem[];
19
+ /** Plain arrays are fixed for the mount. A signal updates rows in place. */
20
+ items: MaybeSignal<readonly ChatAttachmentItem[]>;
20
21
  label?: string;
21
22
  className?: string;
22
23
  }
@@ -1,4 +1,4 @@
1
- import { defineComponent, h } from "meowjsx";
1
+ import { defineComponent, derived, h, keyed, } from "meowjsx";
2
2
  import { Icon } from "../icons/icon.js";
3
3
  import { FileTypeIcon, fileExtension } from "../icons/file-type-icon.js";
4
4
  import { ImagePreview } from "../components/image-preview.js";
@@ -23,51 +23,56 @@ export const ChatAttachments = defineComponent(chatAttachmentsContract, ({ items
23
23
  className,
24
24
  role: "group",
25
25
  "aria-label": label,
26
- }, items.map((item) => {
27
- const remove = item.onRemove
26
+ }, keyed(items, (item) => [
27
+ item.id,
28
+ item.mediaType.startsWith("image/") ? "image" : "file",
29
+ item.onRemove ? "remove" : "keep",
30
+ item.onPreview ? "preview" : "plain",
31
+ ].join(":"), (item) => {
32
+ const current = item.value;
33
+ const remove = current.onRemove
28
34
  ? context.part("remove", "button", {
29
35
  type: "button",
30
- onClick: item.onRemove,
31
- "aria-label": `Remove ${item.name}`,
36
+ onClick: () => item.value.onRemove?.(),
37
+ "aria-label": derived(() => `Remove ${item.value.name}`),
32
38
  }, h(Icon, { name: "x" }))
33
39
  : null;
34
- return item.mediaType.startsWith("image/")
35
- ? context.part("entry", "div", { key: item.id, "data-kind": "image" }, context.part("image", item.onPreview ? "button" : "a", item.onPreview
40
+ const size = derived(() => {
41
+ const bytes = item.value.sizeBytes;
42
+ if (bytes === undefined || !Number.isFinite(bytes) || bytes < 0)
43
+ return null;
44
+ return context.part("size", "small", null, [fileExtension(item.value.name).toUpperCase().slice(0, 8), formatBytes(bytes)]
45
+ .filter(Boolean)
46
+ .join(" "));
47
+ });
48
+ return current.mediaType.startsWith("image/")
49
+ ? context.part("entry", "div", { "data-kind": "image" }, context.part("image", current.onPreview ? "button" : "a", current.onPreview
36
50
  ? {
37
51
  type: "button",
38
- onClick: item.onPreview,
39
- "aria-label": `Preview ${item.name}`,
52
+ onClick: () => item.value.onPreview?.(),
53
+ "aria-label": derived(() => `Preview ${item.value.name}`),
40
54
  }
41
55
  : {
42
- href: item.url,
56
+ href: derived(() => item.value.url),
43
57
  target: "_blank",
44
58
  rel: "noreferrer",
45
- "aria-label": `Open image ${item.name}`,
46
- }, context.part("preview", "span", null, h(ImagePreview, { src: item.url, alt: item.name }))), remove)
47
- : context.part("entry", "div", { key: item.id, "data-kind": "file" }, context.part("file", "a", {
48
- key: item.id,
49
- href: item.url,
50
- download: item.name,
51
- onClick: item.onDownload
52
- ? (event) => {
53
- event.preventDefault();
54
- item.onDownload();
55
- }
56
- : undefined,
57
- }, context.part("icon", "span", { "aria-hidden": "true" }, h(FileTypeIcon, { path: item.name })), context.part("details", "span", null, context.part("name", "strong", null, item.name), item.sizeBytes !== undefined &&
58
- Number.isFinite(item.sizeBytes) &&
59
- item.sizeBytes >= 0
60
- ? context.part("size", "small", null, [
61
- fileExtension(item.name).toUpperCase().slice(0, 8),
62
- formatBytes(item.sizeBytes),
63
- ]
64
- .filter(Boolean)
65
- .join(" "))
66
- : null)), item.onPreview
59
+ "aria-label": derived(() => `Open image ${item.value.name}`),
60
+ }, context.part("preview", "span", null, h(ImagePreview, { src: current.url, alt: current.name }))), remove)
61
+ : context.part("entry", "div", { "data-kind": "file" }, context.part("file", "a", {
62
+ href: derived(() => item.value.url),
63
+ download: derived(() => item.value.name),
64
+ onClick: (event) => {
65
+ const download = item.value.onDownload;
66
+ if (!download)
67
+ return;
68
+ event.preventDefault();
69
+ download();
70
+ },
71
+ }, context.part("icon", "span", { "aria-hidden": "true" }, h(FileTypeIcon, { path: current.name })), context.part("details", "span", null, context.part("name", "strong", null, derived(() => item.value.name)), size)), current.onPreview
67
72
  ? context.part("previewButton", "button", {
68
73
  type: "button",
69
- onClick: item.onPreview,
70
- "aria-label": `Preview ${item.name}`,
74
+ onClick: () => item.value.onPreview?.(),
75
+ "aria-label": derived(() => `Preview ${item.value.name}`),
71
76
  }, "Preview")
72
77
  : null, remove);
73
78
  })));
@@ -10,8 +10,7 @@ export interface ComposerPanelProps extends Omit<ChatComposerProps, "surface" |
10
10
  className?: string;
11
11
  }
12
12
  /**
13
- * Composer chrome: one surface around a bare ChatComposer, plus an optional
14
- * page-level meta row below it. Behavior, draft and submission stay in
15
- * ChatComposer; this component only owns the surrounding composition.
13
+ * A ChatComposer and optional page-level meta row. The composer keeps its single
14
+ * writing surface and external hint; this panel owns the surrounding composition.
16
15
  */
17
16
  export declare const ComposerPanel: import("meowjsx").Component<ComposerPanelProps, "composer-panel", "meta" | "root" | "surface">;
@@ -5,8 +5,7 @@ export const composerPanelContract = {
5
5
  parts: ["root", "surface", "meta"],
6
6
  };
7
7
  /**
8
- * Composer chrome: one surface around a bare ChatComposer, plus an optional
9
- * page-level meta row below it. Behavior, draft and submission stay in
10
- * ChatComposer; this component only owns the surrounding composition.
8
+ * A ChatComposer and optional page-level meta row. The composer keeps its single
9
+ * writing surface and external hint; this panel owns the surrounding composition.
11
10
  */
12
- export const ComposerPanel = defineComponent(composerPanelContract, ({ meta, className, ...props }, context) => context.part("root", "div", { className, "data-pattern": "composer-panel" }, context.part("surface", "div", null, h(ChatComposer, { ...props, surface: "none" })), meta !== undefined && meta !== null ? context.part("meta", "div", null, meta) : null));
11
+ export const ComposerPanel = defineComponent(composerPanelContract, ({ meta, className, ...props }, context) => context.part("root", "div", { className, "data-pattern": "composer-panel" }, context.part("surface", "div", null, h(ChatComposer, props)), meta !== undefined && meta !== null ? context.part("meta", "div", null, meta) : null));
@@ -6,7 +6,7 @@ export declare const chatComposerOptions: import("meowcss").Options<{
6
6
  }>;
7
7
  export declare const chatComposerContract: {
8
8
  readonly name: "chat-composer";
9
- readonly parts: readonly ["root", "attachments", "field", "input", "hint", "actions", "trailing", "submit"];
9
+ readonly parts: readonly ["root", "surface", "attachments", "field", "input", "hint", "actions", "trailing", "submit"];
10
10
  readonly styleProps: import("meowcss/meowjsx").StylePropsBinding<import("meowcss").Options<{
11
11
  readonly layout: readonly ["stacked", "inline", "hero"];
12
12
  readonly surface: readonly ["default", "none"];
@@ -23,16 +23,18 @@ export interface ChatComposerProps extends Props, ThemedProps<typeof chatCompose
23
23
  attachments?: Child;
24
24
  /** Model/provider selection beside the send action; options and state belong to the host. */
25
25
  trailing?: Child;
26
+ /** Supporting instructions below the writing surface, associated through hintId. */
26
27
  hint?: Child;
27
28
  hintId?: string;
28
29
  submitLabel?: string;
29
30
  /** Visible action content; the accessible name always comes from submitLabel. */
30
31
  submitContent?: Child;
31
- disabled?: boolean;
32
+ disabled?: MaybeSignal<boolean>;
33
+ readOnly?: MaybeSignal<boolean>;
32
34
  /** Prevent another submission while keeping the draft editable. */
33
35
  submitDisabled?: MaybeSignal<boolean>;
34
36
  onSubmit?: ChatComposerSubmit;
35
37
  onInput?: ChatComposerInput;
36
38
  className?: string;
37
39
  }
38
- export declare const ChatComposer: import("meowjsx").Component<ChatComposerProps, "chat-composer", "actions" | "attachments" | "field" | "hint" | "input" | "root" | "submit" | "trailing">;
40
+ export declare const ChatComposer: import("meowjsx").Component<ChatComposerProps, "chat-composer", "actions" | "attachments" | "field" | "hint" | "input" | "root" | "submit" | "surface" | "trailing">;
@@ -1,6 +1,6 @@
1
1
  import { defineOptions } from "meowcss";
2
2
  import { defineStyleProps } from "meowcss/meowjsx";
3
- import { defineComponent, h } from "meowjsx";
3
+ import { defineComponent, derived, h, unwrap, } from "meowjsx";
4
4
  import { Icon } from "../icons/icon.js";
5
5
  export const chatComposerOptions = defineOptions("chat-composer", {
6
6
  layout: ["stacked", "inline", "hero"],
@@ -8,27 +8,73 @@ export const chatComposerOptions = defineOptions("chat-composer", {
8
8
  });
9
9
  export const chatComposerContract = {
10
10
  name: "chat-composer",
11
- parts: ["root", "attachments", "field", "input", "hint", "actions", "trailing", "submit"],
11
+ parts: [
12
+ "root",
13
+ "surface",
14
+ "attachments",
15
+ "field",
16
+ "input",
17
+ "hint",
18
+ "actions",
19
+ "trailing",
20
+ "submit",
21
+ ],
12
22
  styleProps: defineStyleProps(chatComposerOptions, {
13
23
  defaults: { layout: "stacked", surface: "default" },
14
24
  }),
15
25
  };
16
- export const ChatComposer = defineComponent(chatComposerContract, ({ value = "", placeholder = "Write a message…", inputLabel = "Message", attachments, trailing, hint, hintId, submitLabel = "Send", submitContent, disabled = false, submitDisabled = false, onSubmit, onInput, children, className, ...props }, context) => context.part("root", "form", {
17
- ...props,
18
- className,
19
- onSubmit,
20
- }, attachments ? context.part("attachments", "div", null, attachments) : null, context.part("field", "div", null, context.part("input", "textarea", {
21
- "data-chat-input": true,
22
- name: "message",
23
- rows: 1,
24
- value,
25
- placeholder,
26
- "aria-label": inputLabel,
27
- "aria-describedby": hint && hintId ? hintId : undefined,
28
- disabled,
29
- onInput,
30
- }), hint ? context.part("hint", "span", hintId ? { id: hintId } : null, hint) : null), context.part("actions", "div", null, children, trailing ? context.part("trailing", "div", null, trailing) : null, context.part("submit", "button", {
31
- type: "submit",
32
- disabled: disabled ? true : submitDisabled,
33
- "aria-label": submitLabel,
34
- }, submitContent ?? h(Icon, { name: "arrow-up" })))));
26
+ export const ChatComposer = defineComponent(chatComposerContract, ({ value = "", placeholder = "Write a message…", inputLabel = "Message", attachments, trailing, hint, hintId, submitLabel = "Send", submitContent, disabled = false, readOnly = false, submitDisabled = false, onSubmit, onInput, children, className, ...props }, context) => {
27
+ const submitBlocked = disabled === true
28
+ ? true
29
+ : typeof disabled === "boolean"
30
+ ? submitDisabled
31
+ : derived(() => Boolean(unwrap(disabled)) || Boolean(unwrap(submitDisabled)));
32
+ let field;
33
+ const resize = () => {
34
+ if (!field?.isConnected)
35
+ return;
36
+ field.style.height = "auto";
37
+ field.style.height = `${field.scrollHeight}px`;
38
+ };
39
+ return context.part("root", "form", {
40
+ ...props,
41
+ className,
42
+ onSubmit,
43
+ }, context.part("surface", "div", null, attachments ? context.part("attachments", "div", null, attachments) : null, context.part("field", "div", null, context.part("input", "textarea", {
44
+ "data-chat-input": true,
45
+ name: "message",
46
+ rows: 1,
47
+ value,
48
+ placeholder,
49
+ "aria-label": inputLabel,
50
+ "aria-describedby": hint && hintId ? hintId : undefined,
51
+ disabled,
52
+ readOnly,
53
+ onInput,
54
+ ref: (textarea) => {
55
+ field = textarea;
56
+ const stop = context.effect(() => {
57
+ unwrap(value);
58
+ resize();
59
+ });
60
+ const onResizeInput = () => resize();
61
+ textarea.addEventListener("input", onResizeInput);
62
+ const observer = typeof ResizeObserver === "function" ? new ResizeObserver(resize) : undefined;
63
+ observer?.observe(textarea);
64
+ queueMicrotask(() => {
65
+ if (textarea.isConnected)
66
+ resize();
67
+ });
68
+ return () => {
69
+ stop();
70
+ textarea.removeEventListener("input", onResizeInput);
71
+ observer?.disconnect();
72
+ field = undefined;
73
+ };
74
+ },
75
+ })), context.part("actions", "div", null, children, trailing ? context.part("trailing", "div", null, trailing) : null, context.part("submit", "button", {
76
+ type: "submit",
77
+ disabled: submitBlocked,
78
+ "aria-label": submitLabel,
79
+ }, submitContent ?? h(Icon, { name: "arrow-up" })))), hint ? context.part("hint", "span", hintId ? { id: hintId } : null, hint) : null);
80
+ });
@@ -1,4 +1,5 @@
1
- import { defineComponent, h, unwrap, } from "meowjsx";
1
+ import { defineComponent, derived, h, unwrap, } from "meowjsx";
2
+ import { Progress } from "../components/progress.js";
2
3
  import { StatusDot } from "../components/status-dot.js";
3
4
  import { executionStateLabel, executionStateTone, } from "../shared/execution-state.js";
4
5
  export const chatTaskContract = {
@@ -31,23 +32,16 @@ function checkedProgress(value) {
31
32
  }
32
33
  /** A task record, not an executable task or a whole-card control. */
33
34
  export const ChatTask = defineComponent(chatTaskContract, ({ title, state = "unknown", statusLabel, description, executionText, replyText, progress, footer, children, className, ...props }, context) => {
34
- const derive = (read) => {
35
- const result = context.signal(read());
36
- context.effect(() => {
37
- result.value = read();
38
- });
39
- return result;
40
- };
41
- const currentProgress = derive(() => checkedProgress(unwrap(progress)));
42
- const text = (part, value) => context.part(part, "p", { hidden: derive(() => !unwrap(value)) }, derive(() => unwrap(value) ?? ""));
35
+ const currentProgress = derived(() => checkedProgress(unwrap(progress)));
36
+ const text = (part, value) => context.part(part, "p", { hidden: derived(() => !unwrap(value)) }, derived(() => unwrap(value) ?? ""));
43
37
  return context.part("root", "section", {
44
38
  ...props,
45
39
  className,
46
40
  "aria-label": props["aria-label"] ?? title,
47
41
  "data-execution-state": state,
48
- }, context.part("header", "div", null, context.part("title", "strong", null, title), context.part("status", "span", null, h(StatusDot, { state: derive(() => executionStateTone(unwrap(state))) }), derive(() => unwrap(statusLabel) ?? executionStateLabel(unwrap(state))))), text("description", description), text("execution", executionText), text("reply", replyText), context.part("progress", "div", { hidden: derive(() => currentProgress.value === undefined) }, context.part("progressLabel", "span", null, derive(() => currentProgress.value?.label ?? "")), context.part("progressBar", "progress", {
49
- value: derive(() => currentProgress.value?.value ?? 0),
50
- max: derive(() => currentProgress.value?.max ?? 1),
51
- "aria-label": derive(() => currentProgress.value?.label ?? ""),
52
- })), context.part("body", "div", null, children), context.part("footer", "div", null, footer));
42
+ }, context.part("header", "div", null, context.part("title", "strong", null, title), context.part("status", "span", null, h(StatusDot, { state: derived(() => executionStateTone(unwrap(state))) }), derived(() => unwrap(statusLabel) ?? executionStateLabel(unwrap(state))))), text("description", description), text("execution", executionText), text("reply", replyText), context.part("progress", "div", { hidden: derived(() => currentProgress.value === undefined) }, context.part("progressLabel", "span", null, derived(() => currentProgress.value?.label ?? "")), context.part("progressBar", "div", null, h(Progress, {
43
+ value: derived(() => currentProgress.value?.value ?? 0),
44
+ max: derived(() => currentProgress.value?.max ?? 1),
45
+ label: derived(() => currentProgress.value?.label ?? ""),
46
+ }))), context.part("body", "div", null, children), context.part("footer", "div", null, footer));
53
47
  });
@@ -1,4 +1,4 @@
1
- import { defineComponent, h, unwrap, } from "meowjsx";
1
+ import { defineComponent, derived, h, unwrap, } from "meowjsx";
2
2
  import { Icon } from "../icons/icon.js";
3
3
  import { Button } from "../components/button.js";
4
4
  import { OutputBlock } from "../components/output-block.js";
@@ -22,13 +22,6 @@ export const chatToolCallContract = {
22
22
  ],
23
23
  };
24
24
  export const ChatToolCall = defineComponent(chatToolCallContract, ({ children, label, summary, state = "complete", statusLabel, detail, icon, input, output, outputSummary, maxLines, collapsible = false, onActivate, onRetry, onCancel, canRetry = true, canCancel = true, retryDisabled = false, cancelDisabled = false, labels, className, ...props }, context) => {
25
- const derived = (read) => {
26
- const value = context.signal(read());
27
- context.effect(() => {
28
- value.value = read();
29
- });
30
- return value;
31
- };
32
25
  const copy = {
33
26
  input: "Input",
34
27
  output: "Output",
@@ -0,0 +1,24 @@
1
+ import { type Child, type MaybeSignal, type Props } from "meowjsx";
2
+ export declare const accordionContract: {
3
+ readonly name: "accordion";
4
+ readonly parts: readonly ["root", "item"];
5
+ };
6
+ export interface AccordionItem {
7
+ id: string;
8
+ summary: Child;
9
+ content: Child;
10
+ }
11
+ export type AccordionType = "single" | "multiple";
12
+ export type AccordionValue = string | readonly string[];
13
+ export interface AccordionProps extends Props {
14
+ items: readonly AccordionItem[];
15
+ /** `single` keeps one section open; `multiple` lets several stay open. */
16
+ type?: AccordionType;
17
+ value?: MaybeSignal<AccordionValue>;
18
+ defaultValue?: AccordionValue;
19
+ onValueChange?: (value: AccordionValue) => void;
20
+ label?: string;
21
+ className?: string;
22
+ }
23
+ /** Grouped disclosures. Items are fixed for the mount. Expansion is handed to the caller when `value` is set. */
24
+ export declare const Accordion: import("meowjsx").Component<AccordionProps, "accordion", "item" | "root">;
@@ -0,0 +1,50 @@
1
+ import { defineComponent, derived, h, unwrap, } from "meowjsx";
2
+ import { Disclosure } from "./disclosure.js";
3
+ export const accordionContract = {
4
+ name: "accordion",
5
+ parts: ["root", "item"],
6
+ };
7
+ function asList(value, type) {
8
+ if (value === undefined)
9
+ return [];
10
+ if (typeof value === "string")
11
+ return type === "single" && value === "" ? [] : [value];
12
+ return [...value];
13
+ }
14
+ function isOpen(value, type, id) {
15
+ return asList(value, type).includes(id);
16
+ }
17
+ function nextValue(current, type, id, open) {
18
+ if (type === "single") {
19
+ if (open)
20
+ return id;
21
+ const currentId = asList(current, type)[0] ?? "";
22
+ return currentId === id ? "" : currentId;
23
+ }
24
+ const list = new Set(asList(current, type));
25
+ if (open)
26
+ list.add(id);
27
+ else
28
+ list.delete(id);
29
+ return [...list];
30
+ }
31
+ /** Grouped disclosures. Items are fixed for the mount. Expansion is handed to the caller when `value` is set. */
32
+ export const Accordion = defineComponent(accordionContract, ({ items, type = "single", value, defaultValue, onValueChange, label, className, ...props }, context) => {
33
+ const local = context.signal(defaultValue ?? (type === "single" ? "" : []));
34
+ const current = value !== undefined ? value : local;
35
+ const readValue = () => unwrap(current);
36
+ const opened = items.map((item) => derived(() => isOpen(readValue(), type, item.id)));
37
+ const request = (id, open) => {
38
+ const next = nextValue(readValue(), type, id, open);
39
+ if (value === undefined)
40
+ local.value = next;
41
+ onValueChange?.(next);
42
+ };
43
+ return context.part("root", "div", {
44
+ ...props,
45
+ className,
46
+ "aria-label": label,
47
+ }, ...items.map((item, index) => context.part("item", "div", { "data-accordion-id": item.id }, h(Disclosure, { summary: item.summary, open: opened[index], name: type === "single" ? props.id : undefined, onToggle: (event) => {
48
+ request(item.id, event.currentTarget.open);
49
+ } }, item.content))));
50
+ });
@@ -0,0 +1,22 @@
1
+ import { type ThemedProps } from "meowcss/meowjsx";
2
+ import { type Props } from "meowjsx";
3
+ export declare const avatarOptions: import("meowcss").Options<{
4
+ readonly size: readonly ["small", "default", "large"];
5
+ }>;
6
+ export declare const avatarContract: {
7
+ readonly name: "avatar";
8
+ readonly parts: readonly ["root", "image", "initials"];
9
+ readonly styleProps: import("meowcss/meowjsx").StylePropsBinding<import("meowcss").Options<{
10
+ readonly size: readonly ["small", "default", "large"];
11
+ }>>;
12
+ };
13
+ export interface AvatarProps extends Props, ThemedProps<typeof avatarOptions> {
14
+ /** Used for initials and the accessible name. */
15
+ name: string;
16
+ src?: string;
17
+ alt?: string;
18
+ className?: string;
19
+ }
20
+ export declare function initialsFromName(name: string): string;
21
+ /** A face or the initials that remain when the image is missing. */
22
+ export declare const Avatar: import("meowjsx").Component<AvatarProps, "avatar", "image" | "initials" | "root">;
@@ -0,0 +1,44 @@
1
+ import { defineOptions } from "meowcss";
2
+ import { defineStyleProps } from "meowcss/meowjsx";
3
+ import { defineComponent } from "meowjsx";
4
+ export const avatarOptions = defineOptions("avatar", {
5
+ size: ["small", "default", "large"],
6
+ });
7
+ export const avatarContract = {
8
+ name: "avatar",
9
+ parts: ["root", "image", "initials"],
10
+ styleProps: defineStyleProps(avatarOptions, { defaults: { size: "default" } }),
11
+ };
12
+ export function initialsFromName(name) {
13
+ const parts = name.trim().split(/\s+/).filter(Boolean);
14
+ if (parts.length === 0)
15
+ return "?";
16
+ if (parts.length === 1) {
17
+ const word = parts[0];
18
+ const first = Array.from(word);
19
+ return first.slice(0, 2).join("").toUpperCase();
20
+ }
21
+ const leading = Array.from(parts[0])[0];
22
+ const next = Array.from(parts[1])[0];
23
+ return `${leading ?? ""}${next ?? ""}`.toUpperCase() || "?";
24
+ }
25
+ /** A face or the initials that remain when the image is missing. */
26
+ export const Avatar = defineComponent(avatarContract, ({ name, src, alt, className, ...props }, context) => {
27
+ const failed = context.signal(false);
28
+ return context.part("root", "span", {
29
+ ...props,
30
+ className,
31
+ role: "img",
32
+ "aria-label": name,
33
+ }, context.part("initials", "span", { "aria-hidden": "true" }, initialsFromName(name)), src
34
+ ? context.part("image", "img", {
35
+ src,
36
+ alt: alt ?? "",
37
+ hidden: failed,
38
+ referrerPolicy: "no-referrer",
39
+ onError: () => {
40
+ failed.value = true;
41
+ },
42
+ })
43
+ : null);
44
+ });