meowtail 0.4.0-alpha.0 → 0.4.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 (147) hide show
  1. package/ASSISTANT.md +2 -2
  2. package/AUTHORING.md +268 -0
  3. package/CHANGELOG.md +116 -0
  4. package/COMPONENTS.md +182 -140
  5. package/README.md +145 -34
  6. package/dist/src/chat/assistant-content.js +3 -1
  7. package/dist/src/chat/assistant-markdown.d.ts +8 -5
  8. package/dist/src/chat/assistant-markdown.js +11 -26
  9. package/dist/src/components/autocomplete.d.ts +47 -0
  10. package/dist/src/components/autocomplete.js +169 -0
  11. package/dist/src/components/card-title.d.ts +1 -0
  12. package/dist/src/components/card-title.js +2 -1
  13. package/dist/src/components/chart-scale.d.ts +46 -0
  14. package/dist/src/components/chart-scale.js +118 -0
  15. package/dist/src/components/chart.d.ts +38 -0
  16. package/dist/src/components/chart.js +210 -0
  17. package/dist/src/components/choice-group.js +2 -2
  18. package/dist/src/components/choice-select.js +2 -2
  19. package/dist/src/components/code-block.d.ts +3 -1
  20. package/dist/src/components/code-block.js +75 -16
  21. package/dist/src/components/command-palette.d.ts +44 -0
  22. package/dist/src/components/command-palette.js +198 -0
  23. package/dist/src/components/context-menu.d.ts +2 -1
  24. package/dist/src/components/context-menu.js +2 -1
  25. package/dist/src/components/credential-source.d.ts +2 -1
  26. package/dist/src/components/credential-source.js +2 -1
  27. package/dist/src/components/detail-section.d.ts +2 -1
  28. package/dist/src/components/detail-section.js +8 -3
  29. package/dist/src/components/dialog.d.ts +4 -1
  30. package/dist/src/components/dialog.js +7 -2
  31. package/dist/src/components/entry.d.ts +45 -0
  32. package/dist/src/components/entry.js +38 -0
  33. package/dist/src/components/entry.options.d.ts +4 -0
  34. package/dist/src/components/entry.options.js +3 -0
  35. package/dist/src/components/field-group.js +2 -2
  36. package/dist/src/components/field.d.ts +4 -0
  37. package/dist/src/components/field.js +15 -3
  38. package/dist/src/components/form.d.ts +34 -0
  39. package/dist/src/components/form.js +58 -0
  40. package/dist/src/components/heading-level.d.ts +9 -0
  41. package/dist/src/components/heading-level.js +12 -0
  42. package/dist/src/components/hover-card.d.ts +3 -2
  43. package/dist/src/components/hover-card.js +50 -15
  44. package/dist/src/components/index.d.ts +11 -1
  45. package/dist/src/components/index.js +11 -1
  46. package/dist/src/components/markdown-blocks.d.ts +27 -0
  47. package/dist/src/components/markdown-blocks.js +141 -0
  48. package/dist/src/components/markdown.d.ts +35 -0
  49. package/dist/src/components/markdown.js +35 -0
  50. package/dist/src/components/menu-button.d.ts +2 -1
  51. package/dist/src/components/menu.d.ts +2 -1
  52. package/dist/src/components/menu.js +2 -1
  53. package/dist/src/components/modal.js +2 -2
  54. package/dist/src/components/page.js +1 -1
  55. package/dist/src/components/pagination.d.ts +52 -0
  56. package/dist/src/components/pagination.js +89 -0
  57. package/dist/src/components/path-label.js +5 -27
  58. package/dist/src/components/popover.d.ts +2 -1
  59. package/dist/src/components/popover.js +33 -6
  60. package/dist/src/components/resource-card.d.ts +4 -1
  61. package/dist/src/components/resource-card.js +7 -2
  62. package/dist/src/components/risk-confirmation.d.ts +2 -1
  63. package/dist/src/components/risk-confirmation.js +2 -1
  64. package/dist/src/components/section.d.ts +1 -7
  65. package/dist/src/components/section.js +3 -8
  66. package/dist/src/components/segmented-control.d.ts +2 -1
  67. package/dist/src/components/segmented-control.js +2 -1
  68. package/dist/src/components/tabs.d.ts +2 -1
  69. package/dist/src/components/tabs.js +2 -1
  70. package/dist/src/components/token-field.d.ts +45 -0
  71. package/dist/src/components/token-field.js +175 -0
  72. package/dist/src/components/tooltip.d.ts +2 -1
  73. package/dist/src/components/tooltip.js +2 -1
  74. package/dist/src/components/tree-view.d.ts +39 -0
  75. package/dist/src/components/tree-view.js +244 -0
  76. package/dist/src/components/tree-view.options.d.ts +2 -0
  77. package/dist/src/components/tree-view.options.js +3 -0
  78. package/dist/src/icons/README.md +11 -10
  79. package/dist/src/icons/icon.d.ts +1 -0
  80. package/dist/src/icons/icon.js +2 -1
  81. package/dist/src/icons/index.d.ts +0 -1
  82. package/dist/src/icons/index.js +0 -1
  83. package/dist/src/registry/index.d.ts +41 -1
  84. package/dist/src/registry/index.js +20 -0
  85. package/dist/src/shared/element-id.d.ts +6 -0
  86. package/dist/src/shared/element-id.js +10 -0
  87. package/dist/src/shared/page-attribute.d.ts +5 -0
  88. package/dist/src/shared/page-attribute.js +5 -0
  89. package/dist/src/theme/base.styles.d.ts +2 -0
  90. package/dist/src/theme/base.styles.js +41 -4
  91. package/dist/src/theme/chat/assistant.styles.js +21 -1
  92. package/dist/src/theme/chat/attachments.styles.js +35 -6
  93. package/dist/src/theme/chat/composer.styles.js +30 -3
  94. package/dist/src/theme/chat/conversation.styles.js +13 -1
  95. package/dist/src/theme/chat/records.styles.js +10 -5
  96. package/dist/src/theme/components/autocomplete.styles.d.ts +1 -0
  97. package/dist/src/theme/components/autocomplete.styles.js +68 -0
  98. package/dist/src/theme/components/button.styles.js +0 -1
  99. package/dist/src/theme/components/card.styles.js +2 -1
  100. package/dist/src/theme/components/chart.styles.d.ts +1 -0
  101. package/dist/src/theme/components/chart.styles.js +173 -0
  102. package/dist/src/theme/components/code-block.styles.js +79 -38
  103. package/dist/src/theme/components/command-palette.styles.d.ts +1 -0
  104. package/dist/src/theme/components/command-palette.styles.js +143 -0
  105. package/dist/src/theme/components/dialog.styles.js +2 -1
  106. package/dist/src/theme/components/empty-state.styles.js +2 -1
  107. package/dist/src/theme/components/entry.styles.d.ts +1 -0
  108. package/dist/src/theme/components/entry.styles.js +86 -0
  109. package/dist/src/theme/components/form.styles.d.ts +1 -0
  110. package/dist/src/theme/components/form.styles.js +32 -0
  111. package/dist/src/theme/components/hover-card.styles.js +57 -12
  112. package/dist/src/theme/components/image-preview.styles.js +25 -0
  113. package/dist/src/theme/components/layout.styles.js +6 -0
  114. package/dist/src/theme/components/markdown.styles.d.ts +1 -0
  115. package/dist/src/theme/components/markdown.styles.js +10 -0
  116. package/dist/src/theme/components/nav-list.styles.js +6 -7
  117. package/dist/src/theme/components/pagination.styles.d.ts +1 -0
  118. package/dist/src/theme/components/pagination.styles.js +103 -0
  119. package/dist/src/theme/components/path-label.styles.js +19 -6
  120. package/dist/src/theme/components/resource-card.styles.js +2 -1
  121. package/dist/src/theme/components/search-input.styles.js +23 -0
  122. package/dist/src/theme/components/slider.styles.js +4 -0
  123. package/dist/src/theme/components/token-field.styles.d.ts +1 -0
  124. package/dist/src/theme/components/token-field.styles.js +109 -0
  125. package/dist/src/theme/components/tree-view.styles.d.ts +1 -0
  126. package/dist/src/theme/components/tree-view.styles.js +104 -0
  127. package/dist/src/theme/icons/icons.styles.js +0 -18
  128. package/dist/src/theme/index.d.ts +446 -9
  129. package/dist/src/theme/index.js +58 -1
  130. package/dist/src/theme/journal.tokens.d.ts +389 -0
  131. package/dist/src/theme/journal.tokens.js +181 -0
  132. package/dist/src/theme/meow.tokens.d.ts +362 -0
  133. package/dist/src/theme/meow.tokens.js +91 -0
  134. package/dist/src/theme/shared/field-surface.styles.js +11 -7
  135. package/dist/src/theme/shared/prose.styles.js +12 -4
  136. package/dist/src/theme/tokens.d.ts +286 -7
  137. package/dist/src/theme/tokens.js +15 -2
  138. package/dist/src/theme/utilities.js +4 -4
  139. package/dist/src/web/focus-modality.d.ts +20 -0
  140. package/dist/src/web/focus-modality.js +72 -0
  141. package/dist/src/web/index.d.ts +2 -0
  142. package/dist/src/web/index.js +2 -0
  143. package/dist/src/web/theme-plugin.d.ts +33 -0
  144. package/dist/src/web/theme-plugin.js +93 -0
  145. package/package.json +14 -6
  146. package/dist/src/icons/doodle-cat.d.ts +0 -5
  147. package/dist/src/icons/doodle-cat.js +0 -8
@@ -0,0 +1,175 @@
1
+ import { h, keyed } from "meowjsx";
2
+ import { derived, signal, unwrap } from "meowjsx/signal";
3
+ import { Icon } from "../icons/icon.js";
4
+ import { elementId } from "../shared/element-id.js";
5
+ /** Several values entered as text: tokens the host resolves, removable while the reader types. */
6
+ export function TokenField({ id = elementId("token-field"), tokens, onAdd, onRemove, separators = [","], listLabel = "Added items", removeLabel = (label) => `Remove ${label}`, invalidMessage = "Needs attention", name, required = false, requiredMessage = "Add at least one item.", disabled = false, placeholder, className, ref, ...props }, context) {
7
+ const list = () => unwrap(tokens);
8
+ let input;
9
+ const buttons = new Map();
10
+ // The token the reader last stood on keeps the single tab stop among tokens.
11
+ const stop = signal(undefined);
12
+ const tabStop = derived(() => {
13
+ const items = list();
14
+ return items.some((item) => item.id === stop.value) ? stop.value : items.at(-1)?.id;
15
+ });
16
+ let focused;
17
+ // Focus to restore once the host has actually removed this token.
18
+ let pending;
19
+ let alive = true;
20
+ context.onCleanup(() => {
21
+ alive = false;
22
+ });
23
+ const tokenId = (key) => `${id}-token-${key}`;
24
+ const focusToken = (key) => {
25
+ if (key === undefined)
26
+ return input?.focus();
27
+ stop.value = key;
28
+ buttons.get(key)?.focus();
29
+ };
30
+ const validate = () => {
31
+ input?.setCustomValidity(required && list().length === 0 ? requiredMessage : "");
32
+ };
33
+ context.effect(() => {
34
+ list();
35
+ validate();
36
+ });
37
+ const add = (text) => {
38
+ const trimmed = text.trim();
39
+ if (!trimmed || unwrap(disabled))
40
+ return true;
41
+ return onAdd(trimmed) !== false;
42
+ };
43
+ const remove = (key, back) => {
44
+ if (unwrap(disabled))
45
+ return;
46
+ pending = { id: key, index: list().findIndex((item) => item.id === key), back };
47
+ onRemove(key);
48
+ };
49
+ const repair = (removed) => {
50
+ if (focused !== removed && pending?.id !== removed)
51
+ return;
52
+ const index = pending?.id === removed ? pending.index : 0;
53
+ const back = pending?.id === removed && pending.back;
54
+ pending = undefined;
55
+ focused = undefined;
56
+ queueMicrotask(() => {
57
+ if (!alive)
58
+ return;
59
+ const items = list();
60
+ const next = back ? (items[index - 1] ?? items[index]) : items[index];
61
+ focusToken(next?.id);
62
+ });
63
+ };
64
+ const draftKeydown = (event) => {
65
+ if (event.isComposing)
66
+ return;
67
+ const element = event.currentTarget;
68
+ const atStart = element.selectionStart === 0 && element.selectionEnd === 0;
69
+ if (event.key === "Enter") {
70
+ // An empty draft leaves Enter to the form.
71
+ if (!element.value.trim())
72
+ return;
73
+ event.preventDefault();
74
+ if (add(element.value))
75
+ element.value = "";
76
+ }
77
+ else if (separators.includes(event.key)) {
78
+ event.preventDefault();
79
+ if (add(element.value))
80
+ element.value = "";
81
+ }
82
+ else if ((event.key === "Backspace" || event.key === "ArrowLeft") && atStart) {
83
+ const last = list().at(-1);
84
+ if (!last)
85
+ return;
86
+ // The first Backspace only moves to the last token, so a token is never lost by accident.
87
+ event.preventDefault();
88
+ focusToken(last.id);
89
+ }
90
+ };
91
+ const paste = (event) => {
92
+ const text = event.clipboardData?.getData("text") ?? "";
93
+ if (!separators.some((separator) => text.includes(separator)))
94
+ return;
95
+ event.preventDefault();
96
+ const element = event.currentTarget;
97
+ const start = element.selectionStart ?? element.value.length;
98
+ const end = element.selectionEnd ?? start;
99
+ const combined = element.value.slice(0, start) + text + element.value.slice(end);
100
+ const pieces = combined.split(new RegExp(`[${separators.map(escape).join("")}]`));
101
+ const rest = pieces.pop() ?? "";
102
+ const kept = pieces.filter((piece) => !add(piece));
103
+ element.value = [...kept, rest].filter((piece) => piece.trim()).join(separators[0] ?? ",");
104
+ };
105
+ const tokenKeydown = (event, key) => {
106
+ const items = list();
107
+ const index = items.findIndex((item) => item.id === key);
108
+ if (event.key === "ArrowLeft" || event.key === "ArrowRight") {
109
+ event.preventDefault();
110
+ const next = items[index + (event.key === "ArrowLeft" ? -1 : 1)];
111
+ if (event.key === "ArrowLeft" && !next)
112
+ return;
113
+ focusToken(next?.id);
114
+ }
115
+ else if (event.key === "Home") {
116
+ event.preventDefault();
117
+ focusToken(items[0]?.id);
118
+ }
119
+ else if (event.key === "End") {
120
+ event.preventDefault();
121
+ focusToken(undefined);
122
+ }
123
+ else if (event.key === "Backspace" || event.key === "Delete") {
124
+ event.preventDefault();
125
+ remove(key, event.key === "Backspace");
126
+ }
127
+ };
128
+ return (h("div", { className: className, ref: [context.parts.root] },
129
+ h("div", { ref: context.parts.control, onClick: (event) => {
130
+ if (event.target === event.currentTarget)
131
+ input?.focus();
132
+ } },
133
+ h("ul", { role: "list", "aria-label": listLabel, ref: context.parts.list }, keyed(tokens, (item) => item.id, (item) => {
134
+ const key = item.value.id;
135
+ const invalid = derived(() => Boolean(item.value.invalid));
136
+ return (h("li", { "data-invalid": derived(() => (invalid.value ? "true" : undefined)), ref: [context.parts.token, () => () => repair(key)] },
137
+ h("span", { ref: context.parts.label }, derived(() => item.value.label)),
138
+ h("span", { id: `${tokenId(key)}-invalid`, hidden: derived(() => !invalid.value), ref: context.parts.invalid }, invalidMessage),
139
+ h("button", { type: "button", tabIndex: derived(() => (tabStop.value === key ? 0 : -1)), disabled: disabled, "aria-label": derived(() => removeLabel(item.value.label)), "aria-describedby": derived(() => invalid.value ? `${tokenId(key)}-invalid` : undefined), onFocus: () => {
140
+ focused = key;
141
+ stop.value = key;
142
+ }, onBlur: () => {
143
+ if (focused === key)
144
+ focused = undefined;
145
+ }, onKeyDown: (event) => tokenKeydown(event, key), onClick: () => remove(key, false), ref: [
146
+ context.parts.remove,
147
+ (element) => {
148
+ buttons.set(key, element);
149
+ return () => {
150
+ if (buttons.get(key) === element)
151
+ buttons.delete(key);
152
+ };
153
+ },
154
+ ] },
155
+ h(Icon, { name: "x" }))));
156
+ })),
157
+ h("input", { ...props, id: id, type: "text", placeholder: placeholder, disabled: disabled, autoComplete: "off", onKeyDown: draftKeydown, onPaste: paste, ref: [
158
+ context.parts.input,
159
+ ref,
160
+ (element) => {
161
+ input = element;
162
+ validate();
163
+ },
164
+ ] })),
165
+ name
166
+ ? keyed(tokens, (item) => item.id, (item) => h("input", { type: "hidden", name: name, value: derived(() => item.value.id) }))
167
+ : null));
168
+ }
169
+ TokenField.meta = {
170
+ name: "token-field",
171
+ parts: ["root", "control", "list", "token", "label", "invalid", "remove", "input"],
172
+ };
173
+ function escape(character) {
174
+ return character.replace(/[\\\]^-]/g, "\\$&");
175
+ }
@@ -4,7 +4,8 @@ export interface TooltipTriggerBindings {
4
4
  "aria-describedby": string;
5
5
  }
6
6
  export interface TooltipProps extends Props {
7
- id: string;
7
+ /** Base id for the ARIA references this component wires; generated when omitted. */
8
+ id?: string;
8
9
  content: string;
9
10
  /** Use a focusable control with its own accessible name; this is supplementary text. */
10
11
  trigger: (bindings: TooltipTriggerBindings) => Child;
@@ -1,8 +1,9 @@
1
1
  import { h } from "meowjsx";
2
2
  import { signal } from "meowjsx/signal";
3
3
  import { Popover } from "./popover.js";
4
+ import { elementId } from "../shared/element-id.js";
4
5
  /** Non-interactive help. Popover owns positioning, top-layer dismissal and cleanup. */
5
- export function Tooltip({ id, content, trigger, delay = 350, className, ref }, context) {
6
+ export function Tooltip({ id = elementId("tooltip"), content, trigger, delay = 350, className, ref }, context) {
6
7
  const open = signal(false);
7
8
  let timer;
8
9
  let hovered = false;
@@ -0,0 +1,39 @@
1
+ import { type Context, type Props } from "meowjsx";
2
+ import { type MaybeSignal } from "meowjsx/signal";
3
+ import { type IconName } from "../icons/icon.js";
4
+ export { treeViewLevel } from "./tree-view.options.js";
5
+ export interface TreeViewItem {
6
+ /** Unique across the whole tree. */
7
+ id: string;
8
+ label: string;
9
+ /** A neutral leading icon naming the item's type. Fixed for the item's mount. */
10
+ icon?: IconName;
11
+ description?: string;
12
+ /** Focusable but not selectable. */
13
+ disabled?: boolean;
14
+ /** Present, even empty, for a branch. */
15
+ children?: readonly TreeViewItem[];
16
+ }
17
+ export interface TreeViewProps extends Props {
18
+ /** Accessible name of the tree. */
19
+ label: string;
20
+ /** The host owns the hierarchy; a Signal keeps it live and rows keep their DOM by id. */
21
+ items: MaybeSignal<readonly TreeViewItem[]>;
22
+ /** Controlled open branches. Omit it to keep them locally from defaultExpanded. */
23
+ expanded?: MaybeSignal<readonly string[]>;
24
+ defaultExpanded?: readonly string[];
25
+ onExpandedChange?: (ids: readonly string[]) => void;
26
+ /** Controlled selection. Omit it to keep it locally from defaultSelected. */
27
+ selected?: MaybeSignal<string | undefined>;
28
+ defaultSelected?: string;
29
+ onSelectedChange?: (id: string) => void;
30
+ className?: Props["className"];
31
+ }
32
+ /** A hierarchy to explore and select from, with the tree keyboard model. */
33
+ export declare function TreeView({ label, items, expanded, defaultExpanded, onExpandedChange, selected, defaultSelected, onSelectedChange, className, ref, ...props }: TreeViewProps, context: Context<typeof TreeView>): import("meowjsx").VNode;
34
+ export declare namespace TreeView {
35
+ var meta: {
36
+ readonly name: "tree-view";
37
+ readonly parts: readonly ["root", "item", "row", "toggle", "icon", "label", "description", "group"];
38
+ };
39
+ }
@@ -0,0 +1,244 @@
1
+ import { h, keyed } from "meowjsx";
2
+ import { derived, signal, unwrap } from "meowjsx/signal";
3
+ import { Icon } from "../icons/icon.js";
4
+ import { activeElementInRoot } from "../shared/dom-root.js";
5
+ import { elementId } from "../shared/element-id.js";
6
+ import { treeViewLevel } from "./tree-view.options.js";
7
+ export { treeViewLevel } from "./tree-view.options.js";
8
+ /** Ids of the items a reader can reach: every root, and the children of each open branch. */
9
+ function visibleIds(items, open) {
10
+ return items.flatMap((item) => [
11
+ item.id,
12
+ ...(item.children && open.has(item.id) ? visibleIds(item.children, open) : []),
13
+ ]);
14
+ }
15
+ /** The ancestors of an item, nearest first; undefined when the item is not in the tree. */
16
+ function ancestorsOf(items, id) {
17
+ for (const item of items) {
18
+ if (item.id === id)
19
+ return [];
20
+ const below = item.children ? ancestorsOf(item.children, id) : undefined;
21
+ if (below)
22
+ return [...below, item.id];
23
+ }
24
+ return undefined;
25
+ }
26
+ function find(items, id) {
27
+ for (const item of items) {
28
+ if (item.id === id)
29
+ return item;
30
+ const below = item.children ? find(item.children, id) : undefined;
31
+ if (below)
32
+ return below;
33
+ }
34
+ return undefined;
35
+ }
36
+ /** A hierarchy to explore and select from, with the tree keyboard model. */
37
+ export function TreeView({ label, items, expanded, defaultExpanded = [], onExpandedChange, selected, defaultSelected, onSelectedChange, className, ref, ...props }, context) {
38
+ const base = elementId("tree");
39
+ const localExpanded = signal(defaultExpanded);
40
+ const openIds = expanded !== undefined ? expanded : localExpanded;
41
+ const localSelected = signal(defaultSelected);
42
+ const current = selected !== undefined ? selected : localSelected;
43
+ const openSet = derived(() => new Set(unwrap(openIds)));
44
+ const visible = derived(() => visibleIds(unwrap(items), openSet.value));
45
+ const stop = signal(undefined);
46
+ // The single tab stop: where the reader last stood, else the selection, else the first item.
47
+ const tabStop = derived(() => {
48
+ const ids = visible.value;
49
+ const wanted = [stop.value, unwrap(current)].find((id) => id !== undefined && ids.includes(id));
50
+ return wanted ?? ids[0];
51
+ });
52
+ const elements = new Map();
53
+ let root;
54
+ // The item that holds focus and its ancestors, kept to repair focus if it disappears.
55
+ let holder;
56
+ let alive = true;
57
+ context.onCleanup(() => {
58
+ alive = false;
59
+ });
60
+ const domId = (id) => `${base}-${id}`;
61
+ const focusItem = (id) => {
62
+ if (id === undefined)
63
+ return;
64
+ stop.value = id;
65
+ const element = elements.get(id);
66
+ element?.focus();
67
+ element?.scrollIntoView?.({ block: "nearest" });
68
+ };
69
+ const setOpen = (id, open) => {
70
+ const ids = unwrap(openIds);
71
+ if (ids.includes(id) === open)
72
+ return;
73
+ const next = open ? [...ids, id] : ids.filter((value) => value !== id);
74
+ if (expanded === undefined)
75
+ localExpanded.value = next;
76
+ onExpandedChange?.(next);
77
+ };
78
+ const select = (id) => {
79
+ const item = find(unwrap(items), id);
80
+ if (!item || item.disabled)
81
+ return;
82
+ if (selected === undefined)
83
+ localSelected.value = id;
84
+ onSelectedChange?.(id);
85
+ };
86
+ // Focus that was inside the tree and lost its item moves to the nearest visible ancestor.
87
+ const repair = () => {
88
+ if (!holder || !root)
89
+ return;
90
+ const ids = visible.value;
91
+ if (ids.includes(holder.id))
92
+ return;
93
+ const active = activeElementInRoot(root);
94
+ if (active && active !== root.ownerDocument.body && !root.contains(active))
95
+ return;
96
+ focusItem(holder.ancestors.find((id) => ids.includes(id)) ?? ids[0]);
97
+ };
98
+ context.effect(() => {
99
+ void visible.value;
100
+ queueMicrotask(() => {
101
+ if (alive)
102
+ repair();
103
+ });
104
+ });
105
+ const keydown = (event) => {
106
+ const element = event.target.closest('[role="treeitem"]');
107
+ const id = element?.dataset.treeId;
108
+ if (!element || id === undefined || event.altKey || event.ctrlKey || event.metaKey)
109
+ return;
110
+ const ids = visible.value;
111
+ const index = ids.indexOf(id);
112
+ const item = find(unwrap(items), id);
113
+ const branch = item?.children !== undefined;
114
+ const open = openSet.value.has(id);
115
+ const handled = () => event.preventDefault();
116
+ switch (event.key) {
117
+ case "ArrowDown":
118
+ handled();
119
+ focusItem(ids[index + 1]);
120
+ break;
121
+ case "ArrowUp":
122
+ handled();
123
+ focusItem(ids[index - 1]);
124
+ break;
125
+ case "Home":
126
+ handled();
127
+ focusItem(ids[0]);
128
+ break;
129
+ case "End":
130
+ handled();
131
+ focusItem(ids.at(-1));
132
+ break;
133
+ case "ArrowRight":
134
+ handled();
135
+ if (branch && !open)
136
+ setOpen(id, true);
137
+ else if (branch && item.children.length > 0)
138
+ focusItem(item.children[0].id);
139
+ break;
140
+ case "ArrowLeft":
141
+ handled();
142
+ if (branch && open)
143
+ setOpen(id, false);
144
+ else
145
+ focusItem(ancestorsOf(unwrap(items), id)?.[0]);
146
+ break;
147
+ case "Enter":
148
+ case " ":
149
+ handled();
150
+ select(id);
151
+ break;
152
+ case "*": {
153
+ handled();
154
+ const parent = ancestorsOf(unwrap(items), id)?.[0];
155
+ const siblings = parent === undefined ? unwrap(items) : (find(unwrap(items), parent)?.children ?? []);
156
+ const add = siblings
157
+ .filter((sibling) => sibling.children !== undefined)
158
+ .map((sibling) => sibling.id);
159
+ const next = [...new Set([...unwrap(openIds), ...add])];
160
+ if (expanded === undefined)
161
+ localExpanded.value = next;
162
+ onExpandedChange?.(next);
163
+ break;
164
+ }
165
+ default:
166
+ if (event.key.length === 1 && event.key !== " ") {
167
+ const letter = event.key.toLocaleLowerCase();
168
+ const order = [...ids.slice(index + 1), ...ids.slice(0, index + 1)];
169
+ const match = order.find((candidate) => find(unwrap(items), candidate)?.label.toLocaleLowerCase().startsWith(letter));
170
+ if (match !== undefined) {
171
+ handled();
172
+ focusItem(match);
173
+ }
174
+ }
175
+ }
176
+ };
177
+ const renderLevel = (level, siblings) => keyed(siblings, (item) => item.id, (item) => {
178
+ const id = item.value.id;
179
+ const branch = derived(() => item.value.children !== undefined);
180
+ const open = derived(() => branch.value && openSet.value.has(id));
181
+ const disabled = derived(() => Boolean(item.value.disabled));
182
+ const children = derived(() => item.value.children ?? []);
183
+ const position = derived(() => unwrap(siblings).findIndex((entry) => entry.id === id) + 1);
184
+ const icon = item.value.icon;
185
+ return (h("li", { id: domId(id), role: "treeitem", "data-tree-id": id, "aria-level": String(level), "aria-setsize": derived(() => String(unwrap(siblings).length)), "aria-posinset": derived(() => String(position.value)), "aria-expanded": derived(() => (branch.value ? String(open.value) : undefined)), "aria-selected": derived(() => disabled.value ? undefined : String(unwrap(current) === id)), "aria-disabled": derived(() => (disabled.value ? "true" : undefined)), tabIndex: derived(() => (tabStop.value === id ? 0 : -1)), onFocus: (event) => {
186
+ if (event.target !== event.currentTarget)
187
+ return;
188
+ stop.value = id;
189
+ holder = { id, ancestors: ancestorsOf(unwrap(items), id) ?? [] };
190
+ }, ref: [
191
+ context.parts.item,
192
+ (element) => {
193
+ elements.set(id, element);
194
+ return () => {
195
+ if (elements.get(id) === element)
196
+ elements.delete(id);
197
+ queueMicrotask(() => {
198
+ if (alive)
199
+ repair();
200
+ });
201
+ };
202
+ },
203
+ ] },
204
+ h("div", { style: { [treeViewLevel.name]: level }, onClick: (event) => {
205
+ // A click inside a nested row belongs to that row.
206
+ if (event.target.closest('[role="treeitem"]') !== elements.get(id))
207
+ return;
208
+ focusItem(id);
209
+ select(id);
210
+ }, ref: context.parts.row },
211
+ h("span", { "aria-hidden": "true", "data-open": derived(() => String(open.value)), hidden: derived(() => !branch.value), onClick: (event) => {
212
+ event.stopPropagation();
213
+ focusItem(id);
214
+ setOpen(id, !open.value);
215
+ }, ref: context.parts.toggle },
216
+ h(Icon, { name: "chevron-right" })),
217
+ icon ? (h("span", { "aria-hidden": "true", ref: context.parts.icon },
218
+ h(Icon, { name: icon }))) : null,
219
+ h("span", { ref: context.parts.label }, derived(() => item.value.label)),
220
+ h("span", { hidden: derived(() => !item.value.description), ref: context.parts.description }, derived(() => item.value.description ?? ""))),
221
+ h("ul", { role: derived(() => (branch.value ? "group" : undefined)), hidden: derived(() => !open.value), ref: context.parts.group }, renderLevel(level + 1, children))));
222
+ });
223
+ return (h("ul", { ...props, role: "tree", "aria-label": label, className: className, onKeyDown: keydown, onFocusOut: (event) => {
224
+ const left = event.target;
225
+ queueMicrotask(() => {
226
+ // Focus the reader moved elsewhere on purpose is not repaired later.
227
+ const active = root && activeElementInRoot(root);
228
+ if (left.isConnected &&
229
+ left.getClientRects().length > 0 &&
230
+ !root?.contains(active ?? null))
231
+ holder = undefined;
232
+ });
233
+ }, ref: [
234
+ context.parts.root,
235
+ ref,
236
+ (element) => {
237
+ root = element;
238
+ },
239
+ ] }, renderLevel(1, items)));
240
+ }
241
+ TreeView.meta = {
242
+ name: "tree-view",
243
+ parts: ["root", "item", "row", "toggle", "icon", "label", "description", "group"],
244
+ };
@@ -0,0 +1,2 @@
1
+ /** The depth of a tree row, one-based; the theme indents by it. */
2
+ export declare const treeViewLevel: import("meowcss").TokenRef;
@@ -0,0 +1,3 @@
1
+ import { tokenRef } from "meowcss";
2
+ /** The depth of a tree row, one-based; the theme indents by it. */
3
+ export const treeViewLevel = tokenRef("tree-view", "level");
@@ -2,7 +2,7 @@
2
2
 
3
3
  `Icon` renders meowtail's finite semantic icon set through native MeowJSX. The SVG geometry is imported from the pinned `lucide` dependency; no paths are copied into this package, except the optical override documented below. Upstream is ISC with inherited Feather MIT icons: the license is preserved in `LUCIDE-LICENSE` and summarized in `THIRD_PARTY_NOTICES.md`.
4
4
 
5
- Use `<Icon name="copy" size={16} />` beside a text label. An icon-only button needs an accessible label on the button. For a standalone meaningful image, provide `label`; otherwise the SVG is decorative. All functional icons use a 24-unit viewBox, currentColor and round joins. SVG presentation attributes provide an 18px size and 2-unit stroke when unthemed; the active theme can override sizing and optical stroke weight through CSS templates using `uiTokens.iconSize` and `uiTokens.iconStroke`. There is no inline style locking these values. Keep brand artwork separate (`MeowlandMark`, `GithubIcon`, `DoodleCat`, `EmptyStack`).
5
+ Use `<Icon name="copy" size={16} />` beside a text label. An icon-only button needs an accessible label on the button. For a standalone meaningful image, provide `label`; otherwise the SVG is decorative. All functional icons use a 24-unit viewBox, currentColor and round joins. SVG presentation attributes provide an 18px size and 2-unit stroke when unthemed; the active theme can override sizing and optical stroke weight through CSS templates using `uiTokens.iconSize` and `uiTokens.iconStroke`. There is no inline style locking these values. Keep brand artwork separate (`MeowlandMark`, `GithubIcon`, `EmptyStack`).
6
6
 
7
7
  ## Which icon where
8
8
 
@@ -54,8 +54,9 @@ new icon joins the set together with its row, and a unit test keeps the two in s
54
54
  | -------------------------------------------------------- | ---------------- |
55
55
  | Add | `plus` |
56
56
  | Decrease one step | `minus` |
57
- | Close, dismiss, remove an attachment | `x` |
57
+ | Close, dismiss, remove an attachment or a token | `x` |
58
58
  | Copy | `copy` |
59
+ | Wrap long lines in place (soft wrap) | `text-wrap` |
59
60
  | Done or chosen: copied, a checked menu item | `check` |
60
61
  | Retry, reload, refresh | `refresh-cw` |
61
62
  | Attach files | `paperclip` |
@@ -75,14 +76,14 @@ new icon joins the set together with its row, and a unit test keeps the two in s
75
76
 
76
77
  ### Disclosure and feedback
77
78
 
78
- | Intent | Icon |
79
- | --------------------------------------------------------------- | --------------- |
80
- | Disclose content; the theme rotates it when open | `chevron-right` |
81
- | Open a select or menu trigger | `chevron-down` |
82
- | Collapse upward, step up | `chevron-up` |
83
- | Step back in a pager or carousel | `chevron-left` |
84
- | Work in progress inside a control, where a dot cannot sit | `loader-circle` |
85
- | A problem beside its words: a failed load, a field error notice | `circle-alert` |
79
+ | Intent | Icon |
80
+ | -------------------------------------------------------------------------- | --------------- |
81
+ | Disclose content (the theme rotates it when open); step forward in a pager | `chevron-right` |
82
+ | Open a select or menu trigger | `chevron-down` |
83
+ | Collapse upward, step up | `chevron-up` |
84
+ | Step back in a pager or carousel | `chevron-left` |
85
+ | Work in progress inside a control, where a dot cannot sit | `loader-circle` |
86
+ | A problem beside its words: a failed load, a field error notice | `circle-alert` |
86
87
 
87
88
  `IconName` and `iconNames` are the finite semantic inventory used by this library and its JSON contracts. For application icons outside that set, `IconSource` renders caller-supplied structural `IconNode` data through the same frame, size, and accessibility rules:
88
89
 
@@ -21,6 +21,7 @@ declare const shapes: {
21
21
  folder: () => Child;
22
22
  "folder-open": () => Child;
23
23
  copy: () => Child;
24
+ "text-wrap": () => Child;
24
25
  x: () => Child;
25
26
  "chevron-down": () => Child;
26
27
  "chevron-left": () => Child;
@@ -1,7 +1,7 @@
1
1
  // Fragment is required by the classic JSX transform for the local settings group.
2
2
  // eslint-disable-next-line no-unused-vars
3
3
  import { h, Fragment } from "meowjsx";
4
- import { ArrowDown, ArrowLeft, ArrowRight, ArrowUp, ArrowUpRight, Box, Brain, ChevronDown, ChevronLeft, ChevronRight, Check, ChevronUp, CircleAlert, CirclePause, Copy, Eye, File, FileText, Folder, FolderOpen, Gauge, History, List, ListChecks, LoaderCircle, Map, Mic, Menu, MessageSquare, Minus, Network, NotebookTabs, PanelLeft, Paperclip, Plus, RefreshCw, Search, ShieldCheck, Square, Terminal, ThumbsDown, ThumbsUp, Timer, UserRound, Wrench, X, Database, } from "lucide";
4
+ import { ArrowDown, ArrowLeft, ArrowRight, ArrowUp, ArrowUpRight, Box, Brain, ChevronDown, ChevronLeft, ChevronRight, Check, ChevronUp, CircleAlert, CirclePause, Copy, Eye, File, FileText, Folder, FolderOpen, Gauge, History, List, ListChecks, LoaderCircle, Map, Mic, Menu, MessageSquare, Minus, Network, NotebookTabs, PanelLeft, Paperclip, Plus, RefreshCw, Search, ShieldCheck, Square, Terminal, ThumbsDown, ThumbsUp, Timer, UserRound, Wrench, X, Database, TextWrap, } from "lucide";
5
5
  import { IconFrame } from "./icon-frame.js";
6
6
  function renderNodes(nodes) {
7
7
  return nodes.map(([tag, attrs]) => h(tag, attrs));
@@ -32,6 +32,7 @@ const shapes = {
32
32
  folder: () => renderNodes(Folder),
33
33
  "folder-open": () => renderNodes(FolderOpen),
34
34
  copy: () => renderNodes(Copy),
35
+ "text-wrap": () => renderNodes(TextWrap),
35
36
  x: () => renderNodes(X),
36
37
  "chevron-down": () => renderNodes(ChevronDown),
37
38
  "chevron-left": () => renderNodes(ChevronLeft),
@@ -1,5 +1,4 @@
1
1
  export { AssistantMark, type AssistantMarkProps } from "./assistant-mark.js";
2
- export { DoodleCat, type DoodleCatProps } from "./doodle-cat.js";
3
2
  export { EmptyStack, type EmptyStackProps } from "./empty-stack.js";
4
3
  export { ExternalArrowIcon } from "./external-arrow.js";
5
4
  export { GithubIcon } from "./github.js";
@@ -1,5 +1,4 @@
1
1
  export { AssistantMark } from "./assistant-mark.js";
2
- export { DoodleCat } from "./doodle-cat.js";
3
2
  export { EmptyStack } from "./empty-stack.js";
4
3
  export { ExternalArrowIcon } from "./external-arrow.js";
5
4
  export { GithubIcon } from "./github.js";