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
@@ -20,7 +20,12 @@ export { Toolbar, toolbarContract } from "./toolbar.js";
20
20
  export { ActionRail, actionRailContract } from "./action-rail.js";
21
21
  export { MetaRow, metaRowContract, metaRowOptions, } from "./meta-row.js";
22
22
  export { Input, inputContract } from "./input.js";
23
+ export { NumberInput, numberInputContract, clampNumber, formatNumber, numberPrecision, } from "./number-input.js";
23
24
  export { Checkbox, checkboxContract } from "./checkbox.js";
25
+ export { Slider, sliderContract } from "./slider.js";
26
+ export { Progress, progressContract } from "./progress.js";
27
+ export { Avatar, avatarContract, avatarOptions, initialsFromName, } from "./avatar.js";
28
+ export { Link, linkContract } from "./link.js";
24
29
  export { Switch, switchContract } from "./switch.js";
25
30
  export { Select, selectContract } from "./select.js";
26
31
  export { ChoiceSelect, choiceSelectContract, } from "./choice-select.js";
@@ -28,6 +33,8 @@ export { Popover, popoverContract, } from "./popover.js";
28
33
  export { SearchInput, searchInputContract } from "./search-input.js";
29
34
  export { PathPicker, pathPickerContract } from "./path-picker.js";
30
35
  export { Disclosure, disclosureContract } from "./disclosure.js";
36
+ export { Accordion, accordionContract, } from "./accordion.js";
37
+ export { Table, tableContract, } from "./table.js";
31
38
  export { NavItem, navItemContract } from "./nav-item.js";
32
39
  export { Separator, separatorContract } from "./separator.js";
33
40
  export { Textarea, textareaContract } from "./textarea.js";
@@ -62,6 +69,8 @@ export { PathLabel, pathLabelContract } from "./path-label.js";
62
69
  export { StateDot, stateDotContract } from "./state-dot.js";
63
70
  export { HoverCard, hoverCardContract } from "./hover-card.js";
64
71
  export { Menu, menuContract, } from "./menu.js";
72
+ export { MenuButton } from "./menu-button.js";
73
+ export { ContextMenu, contextMenuContract } from "./context-menu.js";
65
74
  export { Toast, toastContract } from "./toast.js";
66
75
  export { TerminalBlock, terminalBlockContract } from "./terminal-block.js";
67
76
  export { ReadBlock, readBlockContract, } from "./read-block.js";
@@ -0,0 +1,13 @@
1
+ import { type Props } from "meowjsx";
2
+ export declare const linkContract: {
3
+ readonly name: "link";
4
+ readonly parts: readonly ["root"];
5
+ };
6
+ export interface LinkProps extends Props {
7
+ href: string;
8
+ className?: string;
9
+ }
10
+ /**
11
+ * Themed inline text link. Whole-row references to an openable object stay with ResourceLink.
12
+ */
13
+ export declare const Link: import("meowjsx").Component<LinkProps, "link", "root">;
@@ -0,0 +1,9 @@
1
+ import { defineComponent } from "meowjsx";
2
+ export const linkContract = {
3
+ name: "link",
4
+ parts: ["root"],
5
+ };
6
+ /**
7
+ * Themed inline text link. Whole-row references to an openable object stay with ResourceLink.
8
+ */
9
+ export const Link = defineComponent(linkContract, ({ className, children, ...props }, context) => context.part("root", "a", { ...props, className }, children));
@@ -0,0 +1,13 @@
1
+ import { type Child, type MaybeSignal } from "meowjsx";
2
+ import { type ButtonProps } from "./button.js";
3
+ import { type MenuEntry } from "./menu.js";
4
+ export interface MenuButtonProps extends Omit<ButtonProps, "id" | "onClick"> {
5
+ id: string;
6
+ items: readonly MenuEntry[];
7
+ open?: MaybeSignal<boolean>;
8
+ onOpenChange?: (open: boolean) => void;
9
+ align?: "start" | "end";
10
+ children?: Child;
11
+ }
12
+ /** A button that opens the existing Menu below it, including nested items. */
13
+ export declare function MenuButton({ id, items, open, onOpenChange, align, children, ...button }: MenuButtonProps): Child;
@@ -0,0 +1,10 @@
1
+ import { h } from "meowjsx";
2
+ import { Button } from "./button.js";
3
+ import { Icon } from "../icons/icon.js";
4
+ import { Menu } from "./menu.js";
5
+ /** A button that opens the existing Menu below it, including nested items. */
6
+ export function MenuButton({ id, items, open, onOpenChange, align, children, ...button }) {
7
+ return (h(Menu, { id: id, items: items, open: open, onOpenChange: onOpenChange, align: align, trigger: (bindings) => (h(Button, { ...button, ...bindings },
8
+ children,
9
+ h(Icon, { name: "chevron-down", size: 16 }))) }));
10
+ }
@@ -30,6 +30,10 @@ export interface MenuProps extends Props {
30
30
  open?: MaybeSignal<boolean>;
31
31
  onOpenChange?: (open: boolean) => void;
32
32
  align?: "start" | "end";
33
+ /** Position against a point such as a right-click, instead of the trigger box. */
34
+ anchorRect?: () => DOMRect;
35
+ /** Element whose layout defines a custom rect; observed by the same autoUpdate. */
36
+ anchorElement?: () => HTMLElement | null;
33
37
  className?: string;
34
38
  }
35
39
  export declare const menuContract: {
@@ -6,9 +6,9 @@ export const menuContract = {
6
6
  name: "menu",
7
7
  parts: ["root", "item", "icon", "label", "shortcut", "group", "heading", "separator", "branch"],
8
8
  };
9
- export const Menu = defineComponent(menuContract, ({ id, trigger, items, open, onOpenChange, align, className, placement = "bottom", closeAncestors, }, context) => {
9
+ export const Menu = defineComponent(menuContract, ({ id, trigger, items, open, onOpenChange, align, className, placement = "bottom", closeAncestors, anchorRect, anchorElement, }, context) => {
10
10
  const local = context.signal(false);
11
- const state = open ?? local;
11
+ const state = open !== undefined ? open : local;
12
12
  let root;
13
13
  let search = "";
14
14
  let searchTime = 0;
@@ -178,7 +178,7 @@ export const Menu = defineComponent(menuContract, ({ id, trigger, items, open, o
178
178
  rows[next]?.focus();
179
179
  }
180
180
  };
181
- return (h(Popover, { id: id, open: state, align: align, placement: placement, onOpenChange: (next) => {
181
+ return (h(Popover, { id: id, open: state, align: align, placement: placement, anchorRect: anchorRect, anchorElement: anchorElement, onOpenChange: (next) => {
182
182
  request(next);
183
183
  if (next)
184
184
  focusEdge();
@@ -1,5 +1,5 @@
1
1
  import { type ThemedProps } from "meowcss/meowjsx";
2
- import { type Child, type Props } from "meowjsx";
2
+ import { type Child, type MaybeSignal, type Props } from "meowjsx";
3
3
  export declare const metaRowOptions: import("meowcss").Options<{
4
4
  readonly align: readonly ["start", "center"];
5
5
  readonly progressTone: readonly ["neutral", "accent"];
@@ -19,9 +19,10 @@ export interface MetaItem {
19
19
  label: Child;
20
20
  }
21
21
  export interface MetaRowProps extends Props, ThemedProps<typeof metaRowOptions> {
22
- items: readonly MetaItem[];
23
- /** Finite values clamp to 0–100; non-finite values omit the progress segment. */
24
- progress?: number;
22
+ /** Plain arrays are fixed for the mount. A signal keeps the row live. */
23
+ items: MaybeSignal<readonly MetaItem[]>;
24
+ /** Finite values clamp to 0–100; non-finite values omit the progress segment. A signal stays live. */
25
+ progress?: MaybeSignal<number | undefined>;
25
26
  /** Accessible name for the progress segment. */
26
27
  progressLabel?: string;
27
28
  className?: string;
@@ -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, keyed, unwrap, } from "meowjsx";
4
4
  export const metaRowOptions = defineOptions("meta-row", {
5
5
  align: ["start", "center"],
6
6
  progressTone: ["neutral", "accent"],
@@ -18,28 +18,44 @@ export const metaRowContract = {
18
18
  */
19
19
  export const MetaRow = defineComponent(metaRowContract, ({ items, progress, progressLabel = "Progress", children: hostChildren, className, ...props }, context) => {
20
20
  void hostChildren;
21
- const value = progress === undefined || !Number.isFinite(progress)
22
- ? undefined
23
- : Math.max(0, Math.min(100, Math.round(progress)));
24
- const parts = [];
25
- items.forEach((item, index) => {
26
- if (index > 0)
27
- parts.push(context.part("separator", "span", { "aria-hidden": "true" }, "·"));
28
- parts.push(context.part("item", "span", null, item.icon !== undefined && item.icon !== null
29
- ? context.part("icon", "span", null, item.icon)
30
- : null, context.part("label", "span", null, item.label)));
21
+ const entries = derived(() => unwrap(items).map((item, index) => ({ item, key: index })));
22
+ const percent = derived(() => {
23
+ const next = unwrap(progress);
24
+ if (next === undefined || !Number.isFinite(next))
25
+ return undefined;
26
+ return Math.max(0, Math.min(100, Math.round(next)));
31
27
  });
32
- if (value !== undefined) {
33
- if (items.length > 0)
34
- parts.push(context.part("separator", "span", { "aria-hidden": "true" }, "·"));
35
- parts.push(context.part("progress", "span", {
28
+ const rows = keyed(entries, (entry) => entry.key, (entry) => {
29
+ const item = context.part("item", "span", null, derived(() => {
30
+ const icon = entry.value.item.icon;
31
+ if (icon === undefined || icon === null)
32
+ return null;
33
+ return context.part("icon", "span", null, icon);
34
+ }), context.part("label", "span", null, derived(() => entry.value.item.label)));
35
+ // Index keys stay with their position, so the first row never owns a separator.
36
+ if (entry.value.key === 0)
37
+ return item;
38
+ return [
39
+ context.part("separator", "span", { "aria-hidden": "true" }, "·"),
40
+ item,
41
+ ];
42
+ });
43
+ // The segment is omitted until progress is finite, matching the static contract.
44
+ const progressSegment = derived(() => {
45
+ const value = percent.value;
46
+ if (value === undefined)
47
+ return null;
48
+ const bar = context.part("progress", "span", {
36
49
  role: "progressbar",
37
50
  "aria-label": progressLabel,
38
51
  "aria-valuemin": 0,
39
52
  "aria-valuemax": 100,
40
53
  "aria-valuenow": value,
41
54
  style: { "--meta-progress": `${value}%` },
42
- }, h("span", { "aria-hidden": "true" }, `${value}%`)));
43
- }
44
- return context.part("root", "div", { ...props, className }, parts);
55
+ }, h("span", { "aria-hidden": "true" }, `${value}%`));
56
+ return unwrap(items).length > 0
57
+ ? [context.part("separator", "span", { "aria-hidden": "true" }, "·"), bar]
58
+ : bar;
59
+ });
60
+ return context.part("root", "div", { ...props, className }, rows, progressSegment);
45
61
  });
@@ -1,13 +1,10 @@
1
- import { defineComponent, unwrap, } from "meowjsx";
1
+ import { defineComponent, derived, unwrap, } from "meowjsx";
2
2
  export const navItemContract = {
3
3
  name: "nav-item",
4
4
  parts: ["root", "icon", "label", "badge"],
5
5
  };
6
6
  export const NavItem = defineComponent(navItemContract, ({ label, icon, badge, active = false, className, ...props }, context) => {
7
- const current = context.signal(unwrap(active) ? "page" : undefined);
8
- context.effect(() => {
9
- current.value = unwrap(active) ? "page" : undefined;
10
- });
7
+ const current = derived(() => (unwrap(active) ? "page" : undefined));
11
8
  return context.part("root", "button", {
12
9
  ...props,
13
10
  type: props.type ?? "button",
@@ -0,0 +1,29 @@
1
+ import { type MaybeSignal, type Props } from "meowjsx";
2
+ export declare const numberInputContract: {
3
+ readonly name: "number-input";
4
+ readonly parts: readonly ["root", "decrement", "control", "increment"];
5
+ };
6
+ export interface NumberInputProps extends Props {
7
+ value?: MaybeSignal<number | undefined>;
8
+ defaultValue?: number;
9
+ min?: number;
10
+ max?: number;
11
+ step?: number;
12
+ /** Decimal places of a committed value. When omitted, derived from step. */
13
+ precision?: number;
14
+ disabled?: boolean;
15
+ readOnly?: boolean;
16
+ required?: boolean;
17
+ name?: string;
18
+ id?: string;
19
+ onValueChange?: (value: number | undefined) => void;
20
+ onChange?: (event: Event) => void;
21
+ onInput?: (event: Event) => void;
22
+ onBlur?: (event: FocusEvent) => void;
23
+ className?: string;
24
+ }
25
+ export declare function numberPrecision(step: number, precision?: number): number;
26
+ export declare function formatNumber(value: number, precision: number): string;
27
+ export declare function clampNumber(value: number, min: number, max: number, step: number, origin: number): number;
28
+ /** A number the user can type or step. Clamping and formatting happen on commit. */
29
+ export declare const NumberInput: import("meowjsx").Component<NumberInputProps, "number-input", "control" | "decrement" | "increment" | "root">;
@@ -0,0 +1,137 @@
1
+ import { defineComponent, derived, h, unwrap, } from "meowjsx";
2
+ import { Icon } from "../icons/icon.js";
3
+ export const numberInputContract = {
4
+ name: "number-input",
5
+ parts: ["root", "decrement", "control", "increment"],
6
+ };
7
+ export function numberPrecision(step, precision) {
8
+ if (precision !== undefined)
9
+ return Math.max(0, Math.floor(precision));
10
+ if (!Number.isFinite(step) || step <= 0)
11
+ return 0;
12
+ const text = String(step);
13
+ const index = text.indexOf(".");
14
+ return index < 0 ? 0 : text.length - index - 1;
15
+ }
16
+ export function formatNumber(value, precision) {
17
+ if (!Number.isFinite(value))
18
+ return "";
19
+ return value.toFixed(precision);
20
+ }
21
+ export function clampNumber(value, min, max, step, origin) {
22
+ const lo = Number.isFinite(min) ? min : -Infinity;
23
+ const hi = Number.isFinite(max) ? max : Infinity;
24
+ let next = Math.min(hi, Math.max(lo, value));
25
+ if (Number.isFinite(step) && step > 0 && Number.isFinite(origin)) {
26
+ next = origin + Math.round((next - origin) / step) * step;
27
+ next = Math.min(hi, Math.max(lo, next));
28
+ }
29
+ return next;
30
+ }
31
+ function parseInput(text) {
32
+ const trimmed = text.trim();
33
+ if (trimmed === "" || trimmed === "-" || trimmed === "+" || trimmed === ".")
34
+ return undefined;
35
+ const next = Number(trimmed);
36
+ return Number.isFinite(next) ? next : undefined;
37
+ }
38
+ /** A number the user can type or step. Clamping and formatting happen on commit. */
39
+ export const NumberInput = defineComponent(numberInputContract, ({ value, defaultValue, min, max, step = 1, precision, disabled, readOnly, required, name, id, onValueChange, className, onChange, onInput, onBlur, ...props }, context) => {
40
+ const places = numberPrecision(step, precision);
41
+ const lower = min ?? Number.NEGATIVE_INFINITY;
42
+ const upper = max ?? Number.POSITIVE_INFINITY;
43
+ const origin = Number.isFinite(lower) ? lower : 0;
44
+ const local = context.signal(value === undefined ? defaultValue : unwrap(value));
45
+ const current = value !== undefined ? value : local;
46
+ const readValue = () => unwrap(current);
47
+ const editing = context.signal(false);
48
+ const draft = context.signal("");
49
+ const formatted = (next) => next === undefined ? "" : formatNumber(next, places);
50
+ const text = derived(() => (editing.value ? draft.value : formatted(readValue())));
51
+ const assign = (next) => {
52
+ if (value === undefined)
53
+ local.value = next;
54
+ onValueChange?.(next);
55
+ };
56
+ const commit = (raw) => {
57
+ const parsed = parseInput(raw);
58
+ if (parsed === undefined) {
59
+ assign(undefined);
60
+ return undefined;
61
+ }
62
+ const next = clampNumber(parsed, lower, upper, step, origin);
63
+ assign(next);
64
+ return next;
65
+ };
66
+ const nudge = (direction) => {
67
+ if (disabled || readOnly)
68
+ return;
69
+ editing.value = false;
70
+ const base = readValue() ??
71
+ (direction > 0 ? (Number.isFinite(lower) ? lower : 0) : Number.isFinite(upper) ? upper : 0);
72
+ const next = clampNumber(base + direction * step, lower, upper, step, origin);
73
+ assign(next);
74
+ };
75
+ return context.part("root", "div", { className }, context.part("decrement", "button", {
76
+ type: "button",
77
+ disabled: disabled || readOnly,
78
+ tabIndex: -1,
79
+ "aria-label": "Decrease",
80
+ onClick: () => nudge(-1),
81
+ }, h(Icon, { name: "minus", size: 16 })), context.part("control", "input", {
82
+ ...props,
83
+ id,
84
+ name,
85
+ type: "text",
86
+ inputMode: "decimal",
87
+ autoComplete: "off",
88
+ role: "spinbutton",
89
+ disabled,
90
+ readOnly,
91
+ required,
92
+ value: text,
93
+ "aria-valuenow": text,
94
+ "aria-valuemin": Number.isFinite(lower) ? lower : undefined,
95
+ "aria-valuemax": Number.isFinite(upper) ? upper : undefined,
96
+ onInput: (event) => {
97
+ const input = event.currentTarget;
98
+ editing.value = true;
99
+ draft.value = input.value;
100
+ onInput?.(event);
101
+ },
102
+ onChange: (event) => {
103
+ onChange?.(event);
104
+ },
105
+ onBlur: (event) => {
106
+ const input = event.currentTarget;
107
+ const next = commit(input.value);
108
+ editing.value = false;
109
+ // A controlled owner that stays empty must clear a parsed draft immediately.
110
+ if (value !== undefined && next !== undefined && unwrap(value) === undefined)
111
+ input.value = "";
112
+ onBlur?.(event);
113
+ },
114
+ onKeyDown: (event) => {
115
+ if (event.isComposing || disabled || readOnly)
116
+ return;
117
+ if (event.key === "ArrowUp") {
118
+ event.preventDefault();
119
+ nudge(1);
120
+ }
121
+ else if (event.key === "ArrowDown") {
122
+ event.preventDefault();
123
+ nudge(-1);
124
+ }
125
+ else if (event.key === "Enter") {
126
+ commit(event.currentTarget.value);
127
+ editing.value = false;
128
+ }
129
+ },
130
+ }), context.part("increment", "button", {
131
+ type: "button",
132
+ disabled: disabled || readOnly,
133
+ tabIndex: -1,
134
+ "aria-label": "Increase",
135
+ onClick: () => nudge(1),
136
+ }, h(Icon, { name: "plus", size: 16 })));
137
+ });
@@ -1,4 +1,4 @@
1
- import { defineComponent, h, unwrap, } from "meowjsx";
1
+ import { defineComponent, derived, h, unwrap, } from "meowjsx";
2
2
  import { copyTextToClipboard } from "../clipboard.js";
3
3
  export const outputBlockContract = {
4
4
  name: "output-block",
@@ -12,13 +12,6 @@ export function outputWindow(length, maxLines = 16) {
12
12
  return { head, tail, hidden: Math.max(0, length - limit) };
13
13
  }
14
14
  export const OutputBlock = defineComponent(outputBlockContract, ({ title, rows, copyText, maxLines, wrap = false, emptyText = "No content", onCopy, ...props }, context) => {
15
- const derived = (read) => {
16
- const value = context.signal(read());
17
- context.effect(() => {
18
- value.value = read();
19
- });
20
- return value;
21
- };
22
15
  const feedback = context.signal("");
23
16
  const busy = context.signal(false);
24
17
  let disposed = false;
@@ -1,4 +1,4 @@
1
- import { batch, defineComponent, h, unwrap, } from "meowjsx";
1
+ import { batch, defineComponent, derived, h, unwrap, } from "meowjsx";
2
2
  import { Button } from "./button.js";
3
3
  import { Input } from "./input.js";
4
4
  const messages = {
@@ -15,19 +15,14 @@ export const pathPickerContract = {
15
15
  export const PathPicker = defineComponent(pathPickerContract, ({ label, value, onValueChange, onChoose, kind = "file", disabled = false, readOnly = false, className, children: _children, ...props }, context) => {
16
16
  const pending = context.signal(false);
17
17
  const feedback = context.signal("");
18
- const locked = context.signal(false);
19
- const buttonDisabled = context.signal(false);
20
- const buttonLabel = context.signal(messages[kind]);
18
+ const locked = derived(() => unwrap(readOnly) || pending.value);
19
+ const buttonDisabled = derived(() => unwrap(disabled) || unwrap(readOnly) || pending.value);
20
+ const buttonLabel = derived(() => (pending.value ? messages.pending : messages[kind]));
21
21
  let disposed = false;
22
22
  let button;
23
23
  context.onCleanup(() => {
24
24
  disposed = true;
25
25
  });
26
- context.effect(() => {
27
- locked.value = unwrap(readOnly) || pending.value;
28
- buttonDisabled.value = unwrap(disabled) || unwrap(readOnly) || pending.value;
29
- buttonLabel.value = pending.value ? messages.pending : messages[kind];
30
- });
31
26
  const choose = async () => {
32
27
  if (!onChoose || disposed || buttonDisabled.value)
33
28
  return;
@@ -49,7 +44,7 @@ export const PathPicker = defineComponent(pathPickerContract, ({ label, value, o
49
44
  }
50
45
  finally {
51
46
  if (!disposed) {
52
- // Flush derived disabled state before returning focus to the native button.
47
+ // The button's disabled property updates in the signal subscriber, so flush it before focus.
53
48
  batch(() => {
54
49
  pending.value = false;
55
50
  });
@@ -1,11 +1,8 @@
1
- import { defineComponent, unwrap, } from "meowjsx";
1
+ import { defineComponent, derived, unwrap, } from "meowjsx";
2
2
  export const pillContract = { name: "pill", parts: ["root"] };
3
3
  /** A capsule fact, or a native button when supplied an action. Selection belongs to its caller. */
4
4
  export const Pill = defineComponent(pillContract, ({ active = false, onClick, children, ...props }, context) => {
5
- const selected = context.signal("false");
6
- context.effect(() => {
7
- selected.value = String(unwrap(active));
8
- });
5
+ const selected = derived(() => String(unwrap(active)));
9
6
  return context.part("root", onClick ? "button" : "span", {
10
7
  ...props,
11
8
  ...(onClick ? { type: "button", onClick } : {}),
@@ -1,4 +1,4 @@
1
- import { defineComponent, isSignal, unwrap, } from "meowjsx";
1
+ import { defineComponent, derived, isSignal, unwrap, } from "meowjsx";
2
2
  import { autoUpdate, computePosition, offset, flip, shift, size } from "@floating-ui/dom";
3
3
  import { activeElementInRoot, elementByIdInRoot } from "../shared/dom-root.js";
4
4
  export const popoverContract = {
@@ -10,8 +10,9 @@ const layers = new WeakMap();
10
10
  const dismissedEvents = new WeakSet();
11
11
  export const Popover = defineComponent(popoverContract, ({ id, triggerId = `${id}-trigger`, trigger, open, defaultOpen = false, onOpenChange, matchTriggerWidth = false, align = "start", placement = "bottom", anchorRect, anchorElement, role, labelledBy, onKeyDown, children, className, }, context) => {
12
12
  const local = context.signal(defaultOpen);
13
- const state = open ?? local;
14
- const expanded = context.signal(String(unwrap(state)));
13
+ // A signal object is controlled even when its current value is false.
14
+ const state = open !== undefined ? open : local;
15
+ const expanded = derived(() => String(unwrap(state)));
15
16
  let panel;
16
17
  let anchor = null;
17
18
  let restore = true;
@@ -22,7 +23,6 @@ export const Popover = defineComponent(popoverContract, ({ id, triggerId = `${id
22
23
  return;
23
24
  anchor ??= elementByIdInRoot(panel, triggerId);
24
25
  const next = unwrap(state);
25
- expanded.value = String(next);
26
26
  const shown = panel.matches(":popover-open");
27
27
  const stack = layers.get(panel.ownerDocument) ?? [];
28
28
  layers.set(panel.ownerDocument, stack);
@@ -0,0 +1,15 @@
1
+ import { type MaybeSignal, type Props } from "meowjsx";
2
+ export declare const progressContract: {
3
+ readonly name: "progress";
4
+ readonly parts: readonly ["root", "bar"];
5
+ };
6
+ export interface ProgressProps extends Props {
7
+ /** Accessible name. Spinner remains the wait with no known amount. */
8
+ label: MaybeSignal<string>;
9
+ /** Omit for an indeterminate bar. Finite values are handed to the native progress element. */
10
+ value?: MaybeSignal<number>;
11
+ max?: MaybeSignal<number>;
12
+ className?: string;
13
+ }
14
+ /** Native progress: a known amount, or an indeterminate bar when value is omitted. */
15
+ export declare const Progress: import("meowjsx").Component<ProgressProps, "progress", "bar" | "root">;
@@ -0,0 +1,12 @@
1
+ import { defineComponent } from "meowjsx";
2
+ export const progressContract = {
3
+ name: "progress",
4
+ parts: ["root", "bar"],
5
+ };
6
+ /** Native progress: a known amount, or an indeterminate bar when value is omitted. */
7
+ export const Progress = defineComponent(progressContract, ({ label, value, max = 1, className, ...props }, context) => context.part("root", "div", { className }, context.part("bar", "progress", {
8
+ ...props,
9
+ ...(value === undefined ? {} : { value }),
10
+ max,
11
+ "aria-label": label,
12
+ })));
@@ -1,4 +1,4 @@
1
- import { defineComponent, h, isSignal, unwrap, } from "meowjsx";
1
+ import { defineComponent, derived, h, isSignal, unwrap, } from "meowjsx";
2
2
  import { Dialog, DialogPanel, DialogHeader, DialogActions } from "./dialog.js";
3
3
  import { Checkbox } from "./checkbox.js";
4
4
  import { Button } from "./button.js";
@@ -8,10 +8,7 @@ export const riskConfirmationContract = {
8
8
  };
9
9
  /** One host-requested acknowledgement; it never decides which actions need confirmation. */
10
10
  export const RiskConfirmation = defineComponent(riskConfirmationContract, ({ id, open, title, description, acknowledgeLabel, cancelLabel, confirmLabel, acknowledged, disabled = false, onAcknowledgedChange, onCancel, onConfirm, className, }, context) => {
11
- const blocked = context.signal(unwrap(disabled) || !unwrap(acknowledged));
12
- context.effect(() => {
13
- blocked.value = unwrap(disabled) || !unwrap(acknowledged);
14
- });
11
+ const blocked = derived(() => unwrap(disabled) || !unwrap(acknowledged));
15
12
  return context.part("root", "div", { className }, h(Dialog, { labelledBy: `${id}-title`, describedBy: `${id}-description`, onCancel: (event) => {
16
13
  event.preventDefault();
17
14
  onCancel();
@@ -1,4 +1,4 @@
1
- import { defineComponent, unwrap, } from "meowjsx";
1
+ import { defineComponent, derived, unwrap, } from "meowjsx";
2
2
  export const segmentedControlContract = {
3
3
  name: "segmented-control",
4
4
  parts: ["root", "legend", "options", "option", "input", "label"],
@@ -6,12 +6,12 @@ export const segmentedControlContract = {
6
6
  /** A single choice, using native radio keyboard semantics; tabs remain a separate component. */
7
7
  export const SegmentedControl = defineComponent(segmentedControlContract, ({ id, name = id, form, label, value, options, onValueChange, disabled, className }, context) => {
8
8
  const inputs = new Map();
9
+ // Form reset and a rejected change flip the native radio before the signal does.
9
10
  const reconcile = () => {
10
11
  const selected = unwrap(value);
11
12
  for (const [key, input] of inputs)
12
13
  input.checked = selected === key;
13
14
  };
14
- context.effect(reconcile);
15
15
  return context.part("root", "fieldset", {
16
16
  id,
17
17
  form,
@@ -42,7 +42,7 @@ export const SegmentedControl = defineComponent(segmentedControlContract, ({ id,
42
42
  name,
43
43
  form,
44
44
  value: option.value,
45
- checked: unwrap(value) === option.value,
45
+ checked: derived(() => unwrap(value) === option.value),
46
46
  disabled: option.disabled,
47
47
  ref: (input) => {
48
48
  inputs.set(option.value, input);
@@ -1,4 +1,4 @@
1
- import { defineComponent, unwrap, } from "meowjsx";
1
+ import { defineComponent, derived, unwrap, } from "meowjsx";
2
2
  import { createSkeletonController, useWebObservation } from "meowjsx/web";
3
3
  export const skeletonBoundaryContract = {
4
4
  name: "skeleton-boundary",
@@ -8,9 +8,9 @@ export const skeletonBoundaryContract = {
8
8
  export const SkeletonBoundary = defineComponent(skeletonBoundaryContract, ({ active, label, children, ...props }, context) => {
9
9
  const observation = useWebObservation();
10
10
  const mounted = context.signal(null);
11
- const busy = context.signal(false);
12
- const busyAttribute = context.signal("false");
13
- const announcement = context.signal("");
11
+ const busy = derived(() => unwrap(active));
12
+ const busyAttribute = derived(() => String(unwrap(active)));
13
+ const announcement = derived(() => (unwrap(active) ? label : ""));
14
14
  let controller;
15
15
  const clear = () => {
16
16
  controller?.dispose();
@@ -18,9 +18,6 @@ export const SkeletonBoundary = defineComponent(skeletonBoundaryContract, ({ act
18
18
  };
19
19
  context.effect(() => {
20
20
  const loading = unwrap(active);
21
- busy.value = loading;
22
- busyAttribute.value = String(loading);
23
- announcement.value = loading ? label : "";
24
21
  const element = mounted.value;
25
22
  if (!element)
26
23
  return;
@@ -0,0 +1,22 @@
1
+ import { type MaybeSignal, type Props } from "meowjsx";
2
+ export declare const sliderContract: {
3
+ readonly name: "slider";
4
+ readonly parts: readonly ["root", "control", "track", "thumb", "value"];
5
+ };
6
+ export interface SliderProps extends Props {
7
+ /** Accessible name for the native range control. */
8
+ label: string;
9
+ value?: MaybeSignal<number>;
10
+ defaultValue?: number;
11
+ min?: number;
12
+ max?: number;
13
+ step?: number;
14
+ disabled?: boolean;
15
+ name?: string;
16
+ id?: string;
17
+ onValueChange?: (value: number) => void;
18
+ onInput?: (event: Event) => void;
19
+ className?: string;
20
+ }
21
+ /** Native range control. The visible figure is the same value assistive technology reads. */
22
+ export declare const Slider: import("meowjsx").Component<SliderProps, "slider", "control" | "root" | "thumb" | "track" | "value">;