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.
- package/ASSISTANT.md +2 -2
- package/AUTHORING.md +268 -0
- package/CHANGELOG.md +116 -0
- package/COMPONENTS.md +182 -140
- package/README.md +145 -34
- package/dist/src/chat/assistant-content.js +3 -1
- package/dist/src/chat/assistant-markdown.d.ts +8 -5
- package/dist/src/chat/assistant-markdown.js +11 -26
- package/dist/src/components/autocomplete.d.ts +47 -0
- package/dist/src/components/autocomplete.js +169 -0
- package/dist/src/components/card-title.d.ts +1 -0
- package/dist/src/components/card-title.js +2 -1
- package/dist/src/components/chart-scale.d.ts +46 -0
- package/dist/src/components/chart-scale.js +118 -0
- package/dist/src/components/chart.d.ts +38 -0
- package/dist/src/components/chart.js +210 -0
- package/dist/src/components/choice-group.js +2 -2
- package/dist/src/components/choice-select.js +2 -2
- package/dist/src/components/code-block.d.ts +3 -1
- package/dist/src/components/code-block.js +75 -16
- package/dist/src/components/command-palette.d.ts +44 -0
- package/dist/src/components/command-palette.js +198 -0
- package/dist/src/components/context-menu.d.ts +2 -1
- package/dist/src/components/context-menu.js +2 -1
- package/dist/src/components/credential-source.d.ts +2 -1
- package/dist/src/components/credential-source.js +2 -1
- package/dist/src/components/detail-section.d.ts +2 -1
- package/dist/src/components/detail-section.js +8 -3
- package/dist/src/components/dialog.d.ts +4 -1
- package/dist/src/components/dialog.js +7 -2
- package/dist/src/components/entry.d.ts +45 -0
- package/dist/src/components/entry.js +38 -0
- package/dist/src/components/entry.options.d.ts +4 -0
- package/dist/src/components/entry.options.js +3 -0
- package/dist/src/components/field-group.js +2 -2
- package/dist/src/components/field.d.ts +4 -0
- package/dist/src/components/field.js +15 -3
- package/dist/src/components/form.d.ts +34 -0
- package/dist/src/components/form.js +58 -0
- package/dist/src/components/heading-level.d.ts +9 -0
- package/dist/src/components/heading-level.js +12 -0
- package/dist/src/components/hover-card.d.ts +3 -2
- package/dist/src/components/hover-card.js +50 -15
- package/dist/src/components/index.d.ts +11 -1
- package/dist/src/components/index.js +11 -1
- package/dist/src/components/markdown-blocks.d.ts +27 -0
- package/dist/src/components/markdown-blocks.js +141 -0
- package/dist/src/components/markdown.d.ts +35 -0
- package/dist/src/components/markdown.js +35 -0
- package/dist/src/components/menu-button.d.ts +2 -1
- package/dist/src/components/menu.d.ts +2 -1
- package/dist/src/components/menu.js +2 -1
- package/dist/src/components/modal.js +2 -2
- package/dist/src/components/page.js +1 -1
- package/dist/src/components/pagination.d.ts +52 -0
- package/dist/src/components/pagination.js +89 -0
- package/dist/src/components/path-label.js +5 -27
- package/dist/src/components/popover.d.ts +2 -1
- package/dist/src/components/popover.js +33 -6
- package/dist/src/components/resource-card.d.ts +4 -1
- package/dist/src/components/resource-card.js +7 -2
- package/dist/src/components/risk-confirmation.d.ts +2 -1
- package/dist/src/components/risk-confirmation.js +2 -1
- package/dist/src/components/section.d.ts +1 -7
- package/dist/src/components/section.js +3 -8
- package/dist/src/components/segmented-control.d.ts +2 -1
- package/dist/src/components/segmented-control.js +2 -1
- package/dist/src/components/tabs.d.ts +2 -1
- package/dist/src/components/tabs.js +2 -1
- package/dist/src/components/token-field.d.ts +45 -0
- package/dist/src/components/token-field.js +175 -0
- package/dist/src/components/tooltip.d.ts +2 -1
- package/dist/src/components/tooltip.js +2 -1
- package/dist/src/components/tree-view.d.ts +39 -0
- package/dist/src/components/tree-view.js +244 -0
- package/dist/src/components/tree-view.options.d.ts +2 -0
- package/dist/src/components/tree-view.options.js +3 -0
- package/dist/src/icons/README.md +11 -10
- package/dist/src/icons/icon.d.ts +1 -0
- package/dist/src/icons/icon.js +2 -1
- package/dist/src/icons/index.d.ts +0 -1
- package/dist/src/icons/index.js +0 -1
- package/dist/src/registry/index.d.ts +41 -1
- package/dist/src/registry/index.js +20 -0
- package/dist/src/shared/element-id.d.ts +6 -0
- package/dist/src/shared/element-id.js +10 -0
- package/dist/src/shared/page-attribute.d.ts +5 -0
- package/dist/src/shared/page-attribute.js +5 -0
- package/dist/src/theme/base.styles.d.ts +2 -0
- package/dist/src/theme/base.styles.js +41 -4
- package/dist/src/theme/chat/assistant.styles.js +21 -1
- package/dist/src/theme/chat/attachments.styles.js +35 -6
- package/dist/src/theme/chat/composer.styles.js +30 -3
- package/dist/src/theme/chat/conversation.styles.js +13 -1
- package/dist/src/theme/chat/records.styles.js +10 -5
- package/dist/src/theme/components/autocomplete.styles.d.ts +1 -0
- package/dist/src/theme/components/autocomplete.styles.js +68 -0
- package/dist/src/theme/components/button.styles.js +0 -1
- package/dist/src/theme/components/card.styles.js +2 -1
- package/dist/src/theme/components/chart.styles.d.ts +1 -0
- package/dist/src/theme/components/chart.styles.js +173 -0
- package/dist/src/theme/components/code-block.styles.js +79 -38
- package/dist/src/theme/components/command-palette.styles.d.ts +1 -0
- package/dist/src/theme/components/command-palette.styles.js +143 -0
- package/dist/src/theme/components/dialog.styles.js +2 -1
- package/dist/src/theme/components/empty-state.styles.js +2 -1
- package/dist/src/theme/components/entry.styles.d.ts +1 -0
- package/dist/src/theme/components/entry.styles.js +86 -0
- package/dist/src/theme/components/form.styles.d.ts +1 -0
- package/dist/src/theme/components/form.styles.js +32 -0
- package/dist/src/theme/components/hover-card.styles.js +57 -12
- package/dist/src/theme/components/image-preview.styles.js +25 -0
- package/dist/src/theme/components/layout.styles.js +6 -0
- package/dist/src/theme/components/markdown.styles.d.ts +1 -0
- package/dist/src/theme/components/markdown.styles.js +10 -0
- package/dist/src/theme/components/nav-list.styles.js +6 -7
- package/dist/src/theme/components/pagination.styles.d.ts +1 -0
- package/dist/src/theme/components/pagination.styles.js +103 -0
- package/dist/src/theme/components/path-label.styles.js +19 -6
- package/dist/src/theme/components/resource-card.styles.js +2 -1
- package/dist/src/theme/components/search-input.styles.js +23 -0
- package/dist/src/theme/components/slider.styles.js +4 -0
- package/dist/src/theme/components/token-field.styles.d.ts +1 -0
- package/dist/src/theme/components/token-field.styles.js +109 -0
- package/dist/src/theme/components/tree-view.styles.d.ts +1 -0
- package/dist/src/theme/components/tree-view.styles.js +104 -0
- package/dist/src/theme/icons/icons.styles.js +0 -18
- package/dist/src/theme/index.d.ts +446 -9
- package/dist/src/theme/index.js +58 -1
- package/dist/src/theme/journal.tokens.d.ts +389 -0
- package/dist/src/theme/journal.tokens.js +181 -0
- package/dist/src/theme/meow.tokens.d.ts +362 -0
- package/dist/src/theme/meow.tokens.js +91 -0
- package/dist/src/theme/shared/field-surface.styles.js +11 -7
- package/dist/src/theme/shared/prose.styles.js +12 -4
- package/dist/src/theme/tokens.d.ts +286 -7
- package/dist/src/theme/tokens.js +15 -2
- package/dist/src/theme/utilities.js +4 -4
- package/dist/src/web/focus-modality.d.ts +20 -0
- package/dist/src/web/focus-modality.js +72 -0
- package/dist/src/web/index.d.ts +2 -0
- package/dist/src/web/index.js +2 -0
- package/dist/src/web/theme-plugin.d.ts +33 -0
- package/dist/src/web/theme-plugin.js +93 -0
- package/package.json +14 -6
- package/dist/src/icons/doodle-cat.d.ts +0 -5
- package/dist/src/icons/doodle-cat.js +0 -8
|
@@ -25,7 +25,8 @@ export interface MenuTriggerBindings extends PopoverTriggerBindings {
|
|
|
25
25
|
onKeyDown: (event: KeyboardEvent) => void;
|
|
26
26
|
}
|
|
27
27
|
export interface MenuProps extends Props {
|
|
28
|
-
id
|
|
28
|
+
/** Base id for the ARIA references this component wires; generated when omitted. */
|
|
29
|
+
id?: string;
|
|
29
30
|
trigger: (bindings: MenuTriggerBindings) => Child;
|
|
30
31
|
items: readonly MenuEntry[];
|
|
31
32
|
open?: MaybeSignal<boolean>;
|
|
@@ -3,8 +3,9 @@ import { signal, unwrap } from "meowjsx/signal";
|
|
|
3
3
|
import { Popover } from "./popover.js";
|
|
4
4
|
import { Icon } from "../icons/icon.js";
|
|
5
5
|
import { activeElementInRoot, elementByIdInRoot } from "../shared/dom-root.js";
|
|
6
|
+
import { elementId } from "../shared/element-id.js";
|
|
6
7
|
/** A list of actions in a popover, with keyboard navigation and nested submenus. */
|
|
7
|
-
export function Menu({ id, trigger, items, open, onOpenChange, align, className, placement = "bottom", closeAncestors, anchorRect, anchorElement, }, context) {
|
|
8
|
+
export function Menu({ id = elementId("menu"), trigger, items, open, onOpenChange, align, className, placement = "bottom", closeAncestors, anchorRect, anchorElement, }, context) {
|
|
8
9
|
const local = signal(false);
|
|
9
10
|
const state = open !== undefined ? open : local;
|
|
10
11
|
let root;
|
|
@@ -4,7 +4,7 @@ import { activeElementInRoot } from "../shared/dom-root.js";
|
|
|
4
4
|
import { Icon } from "../icons/icon.js";
|
|
5
5
|
import { Dialog, DialogActions, DialogHeader, DialogPanel } from "./dialog.js";
|
|
6
6
|
import { IconButton } from "./icon-button.js";
|
|
7
|
-
|
|
7
|
+
import { elementId } from "../shared/element-id.js";
|
|
8
8
|
/** True when a slot was given; `false` and `null` mean the slot is omitted. */
|
|
9
9
|
function hasSlot(slot) {
|
|
10
10
|
return slot !== undefined && slot !== null && slot !== false;
|
|
@@ -16,7 +16,7 @@ function hasSlot(slot) {
|
|
|
16
16
|
* the generated title/description ids.
|
|
17
17
|
*/
|
|
18
18
|
export function Modal({ open, onOpenChange, title, description, actions, dismissible = true, closeLabel = "Close", id, className, children, ref, ...props }, context) {
|
|
19
|
-
const baseId = id ??
|
|
19
|
+
const baseId = id ?? elementId("modal");
|
|
20
20
|
const titleId = `${baseId}-title`;
|
|
21
21
|
const descriptionId = `${baseId}-description`;
|
|
22
22
|
// DialogHeader renders its description on truthiness; match it so the id never dangles.
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { h } from "meowjsx";
|
|
2
2
|
import { Container } from "./container.js";
|
|
3
3
|
import { PageHeader } from "./page-header.js";
|
|
4
|
-
import { sectionLevelContext } from "./
|
|
4
|
+
import { sectionLevelContext } from "./heading-level.js";
|
|
5
5
|
/** True when a slot was given; `false` and `null` mean the slot is omitted. */
|
|
6
6
|
function hasSlot(slot) {
|
|
7
7
|
return slot !== undefined && slot !== null && slot !== false;
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import { type Context, type Props } from "meowjsx";
|
|
2
|
+
import { type MaybeSignal } from "meowjsx/signal";
|
|
3
|
+
export type PaginationEntry = {
|
|
4
|
+
kind: "page";
|
|
5
|
+
page: number;
|
|
6
|
+
} | {
|
|
7
|
+
kind: "gap";
|
|
8
|
+
side: "start" | "end";
|
|
9
|
+
};
|
|
10
|
+
export interface PaginationProps extends Props {
|
|
11
|
+
/** The current 1-based page. The host owns it: a click only calls onPageChange. */
|
|
12
|
+
page: MaybeSignal<number>;
|
|
13
|
+
/**
|
|
14
|
+
* Total pages when the host knows it; numbered pages are shown. Omit it for an unknown total:
|
|
15
|
+
* Previous/Next and the page fact remain, and hasNext decides whether Next acts.
|
|
16
|
+
*/
|
|
17
|
+
pageCount?: MaybeSignal<number>;
|
|
18
|
+
/** Whether a later page exists when pageCount is omitted. Ignored when pageCount is given. */
|
|
19
|
+
hasNext?: MaybeSignal<boolean>;
|
|
20
|
+
onPageChange: (page: number) => void;
|
|
21
|
+
/** The host is loading a page: controls keep focus and place but do not act. */
|
|
22
|
+
busy?: MaybeSignal<boolean>;
|
|
23
|
+
disabled?: MaybeSignal<boolean>;
|
|
24
|
+
/** Pages kept on each side of the current one. Fixed for the mount. */
|
|
25
|
+
siblings?: number;
|
|
26
|
+
/** Accessible name of the navigation landmark. */
|
|
27
|
+
label?: string;
|
|
28
|
+
previousLabel?: string;
|
|
29
|
+
nextLabel?: string;
|
|
30
|
+
/** Accessible name of a numbered page. */
|
|
31
|
+
pageLabel?: (page: number) => string;
|
|
32
|
+
/**
|
|
33
|
+
* The page fact: shown for an unknown total, and in place of the numbered pages when the bar is
|
|
34
|
+
* too narrow for them. pageCount is undefined when the total is unknown.
|
|
35
|
+
*/
|
|
36
|
+
pageStatus?: (page: number, pageCount: number | undefined) => string;
|
|
37
|
+
className?: Props["className"];
|
|
38
|
+
}
|
|
39
|
+
/**
|
|
40
|
+
* The entries a known total shows: always the first and last page, the current page with its
|
|
41
|
+
* siblings, and a gap where pages are skipped. The count of entries stays constant once the total
|
|
42
|
+
* exceeds it, so the row does not change width while the reader steps through pages.
|
|
43
|
+
*/
|
|
44
|
+
export declare function paginationEntries(page: number, pageCount: number, siblings?: number): readonly PaginationEntry[];
|
|
45
|
+
/** Moves through pages of a host-owned record set, with a known or unknown total. */
|
|
46
|
+
export declare function Pagination({ page, pageCount, hasNext, onPageChange, busy, disabled, siblings, label, previousLabel, nextLabel, pageLabel, pageStatus, className, ref, ...props }: PaginationProps, context: Context<typeof Pagination>): import("meowjsx").VNode;
|
|
47
|
+
export declare namespace Pagination {
|
|
48
|
+
var meta: {
|
|
49
|
+
readonly name: "pagination";
|
|
50
|
+
readonly parts: readonly ["root", "previous", "list", "item", "page", "gap", "status", "next"];
|
|
51
|
+
};
|
|
52
|
+
}
|
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
import { h, keyed } from "meowjsx";
|
|
2
|
+
import { derived, unwrap } from "meowjsx/signal";
|
|
3
|
+
import { Icon } from "../icons/icon.js";
|
|
4
|
+
function checkPage(page) {
|
|
5
|
+
if (!Number.isInteger(page) || page < 1)
|
|
6
|
+
throw new RangeError("Pagination page must be ≥ 1");
|
|
7
|
+
return page;
|
|
8
|
+
}
|
|
9
|
+
function checkPageCount(count) {
|
|
10
|
+
if (!Number.isInteger(count) || count < 0)
|
|
11
|
+
throw new RangeError("Pagination pageCount must be a whole number ≥ 0");
|
|
12
|
+
return count;
|
|
13
|
+
}
|
|
14
|
+
/**
|
|
15
|
+
* The entries a known total shows: always the first and last page, the current page with its
|
|
16
|
+
* siblings, and a gap where pages are skipped. The count of entries stays constant once the total
|
|
17
|
+
* exceeds it, so the row does not change width while the reader steps through pages.
|
|
18
|
+
*/
|
|
19
|
+
export function paginationEntries(page, pageCount, siblings = 1) {
|
|
20
|
+
checkPage(page);
|
|
21
|
+
checkPageCount(pageCount);
|
|
22
|
+
if (!Number.isInteger(siblings) || siblings < 0)
|
|
23
|
+
throw new RangeError("Pagination siblings must be a whole number ≥ 0");
|
|
24
|
+
const pages = (from, to) => Array.from({ length: to - from + 1 }, (_, index) => ({ kind: "page", page: from + index }));
|
|
25
|
+
// first + last + current + siblings on both sides + two gaps
|
|
26
|
+
const slots = 2 * siblings + 5;
|
|
27
|
+
if (pageCount <= slots)
|
|
28
|
+
return pages(1, pageCount);
|
|
29
|
+
// A page past the end (the host shrank the total) keeps the window at the last pages.
|
|
30
|
+
const current = Math.min(page, pageCount);
|
|
31
|
+
const start = Math.max(current - siblings, 1);
|
|
32
|
+
const end = Math.min(current + siblings, pageCount);
|
|
33
|
+
const startGap = start > 3;
|
|
34
|
+
const endGap = end < pageCount - 2;
|
|
35
|
+
const edge = slots - 2;
|
|
36
|
+
if (!startGap)
|
|
37
|
+
return [...pages(1, edge), { kind: "gap", side: "end" }, ...pages(pageCount, pageCount)];
|
|
38
|
+
if (!endGap)
|
|
39
|
+
return [
|
|
40
|
+
...pages(1, 1),
|
|
41
|
+
{ kind: "gap", side: "start" },
|
|
42
|
+
...pages(pageCount - edge + 1, pageCount),
|
|
43
|
+
];
|
|
44
|
+
return [
|
|
45
|
+
...pages(1, 1),
|
|
46
|
+
{ kind: "gap", side: "start" },
|
|
47
|
+
...pages(start, end),
|
|
48
|
+
{ kind: "gap", side: "end" },
|
|
49
|
+
...pages(pageCount, pageCount),
|
|
50
|
+
];
|
|
51
|
+
}
|
|
52
|
+
/** Moves through pages of a host-owned record set, with a known or unknown total. */
|
|
53
|
+
export function Pagination({ page, pageCount, hasNext = false, onPageChange, busy = false, disabled = false, siblings = 1, label = "Pagination", previousLabel = "Previous", nextLabel = "Next", pageLabel = (value) => `Page ${value}`, pageStatus = (value, total) => total === undefined ? `Page ${value}` : `Page ${value} of ${total}`, className, ref, ...props }, context) {
|
|
54
|
+
const known = pageCount !== undefined;
|
|
55
|
+
const current = derived(() => checkPage(unwrap(page)));
|
|
56
|
+
const count = derived(() => (known ? checkPageCount(unwrap(pageCount)) : undefined));
|
|
57
|
+
const inert = derived(() => unwrap(busy) || unwrap(disabled));
|
|
58
|
+
const canPrevious = derived(() => current.value > 1);
|
|
59
|
+
const canNext = derived(() => count.value === undefined ? unwrap(hasNext) : current.value < count.value);
|
|
60
|
+
// aria-disabled keeps focus on a control that reaches a boundary or waits for the host.
|
|
61
|
+
const blocked = (available) => derived(() => (inert.value || !available.value ? "true" : undefined));
|
|
62
|
+
const go = (target, available) => {
|
|
63
|
+
if (unwrap(busy) || unwrap(disabled) || !available || target === current.value)
|
|
64
|
+
return;
|
|
65
|
+
onPageChange(target);
|
|
66
|
+
};
|
|
67
|
+
const entries = derived(() => count.value === undefined ? [] : paginationEntries(current.value, count.value, siblings));
|
|
68
|
+
return (h("nav", { ...props, className: className, "aria-label": label, "aria-busy": derived(() => (unwrap(busy) ? "true" : undefined)), ref: [context.parts.root, ref] },
|
|
69
|
+
h("button", { type: "button", "aria-disabled": blocked(canPrevious), onClick: () => go(current.value - 1, canPrevious.value), ref: context.parts.previous },
|
|
70
|
+
h(Icon, { name: "chevron-left" }),
|
|
71
|
+
h("span", null, previousLabel)),
|
|
72
|
+
known ? (h("ul", { ref: context.parts.list }, keyed(entries, (entry) => (entry.kind === "page" ? entry.page : `gap-${entry.side}`), (entry) => {
|
|
73
|
+
const value = entry.value;
|
|
74
|
+
if (value.kind === "gap")
|
|
75
|
+
return (h("li", { ref: context.parts.item },
|
|
76
|
+
h("span", { "aria-hidden": "true", ref: context.parts.gap }, "…")));
|
|
77
|
+
const isCurrent = derived(() => current.value === value.page);
|
|
78
|
+
return (h("li", { ref: context.parts.item },
|
|
79
|
+
h("button", { type: "button", "aria-label": pageLabel(value.page), "aria-current": derived(() => (isCurrent.value ? "page" : undefined)), "aria-disabled": derived(() => (inert.value ? "true" : undefined)), onClick: () => go(value.page, true), ref: context.parts.page }, String(value.page))));
|
|
80
|
+
}))) : null,
|
|
81
|
+
h("span", { ref: context.parts.status }, derived(() => pageStatus(current.value, count.value))),
|
|
82
|
+
h("button", { type: "button", "aria-disabled": blocked(canNext), onClick: () => go(current.value + 1, canNext.value), ref: context.parts.next },
|
|
83
|
+
h("span", null, nextLabel),
|
|
84
|
+
h(Icon, { name: "chevron-right" }))));
|
|
85
|
+
}
|
|
86
|
+
Pagination.meta = {
|
|
87
|
+
name: "pagination",
|
|
88
|
+
parts: ["root", "previous", "list", "item", "page", "gap", "status", "next"],
|
|
89
|
+
};
|
|
@@ -5,34 +5,12 @@ import { h } from "meowjsx";
|
|
|
5
5
|
*/
|
|
6
6
|
export function PathLabel({ path, className, ...props }, context) {
|
|
7
7
|
const split = Math.max(path.lastIndexOf("/"), path.lastIndexOf("\\")) + 1;
|
|
8
|
-
return (h("span", { ...props, className: className, title: path, ref: [
|
|
9
|
-
context.parts.root,
|
|
10
|
-
(element) => {
|
|
11
|
-
let alive = true;
|
|
12
|
-
let observer;
|
|
13
|
-
queueMicrotask(() => {
|
|
14
|
-
if (!alive)
|
|
15
|
-
return;
|
|
16
|
-
const text = element.firstElementChild;
|
|
17
|
-
if (!text)
|
|
18
|
-
return;
|
|
19
|
-
const update = () => element.toggleAttribute("data-path-clipped", text.offsetWidth > element.clientWidth);
|
|
20
|
-
update();
|
|
21
|
-
const Observer = element.ownerDocument.defaultView?.ResizeObserver;
|
|
22
|
-
if (Observer) {
|
|
23
|
-
observer = new Observer(update);
|
|
24
|
-
observer.observe(element);
|
|
25
|
-
observer.observe(text);
|
|
26
|
-
}
|
|
27
|
-
});
|
|
28
|
-
return () => {
|
|
29
|
-
alive = false;
|
|
30
|
-
observer?.disconnect();
|
|
31
|
-
};
|
|
32
|
-
},
|
|
33
|
-
] },
|
|
8
|
+
return (h("span", { ...props, className: className, title: path, ref: [context.parts.root] },
|
|
34
9
|
h("span", { ref: [context.parts.text] },
|
|
35
10
|
split ? h("span", { ref: [context.parts.directory] }, path.slice(0, split)) : null,
|
|
36
11
|
h("span", { ref: [context.parts.name] }, path.slice(split)))));
|
|
37
12
|
}
|
|
38
|
-
PathLabel.meta = {
|
|
13
|
+
PathLabel.meta = {
|
|
14
|
+
name: "path-label",
|
|
15
|
+
parts: ["root", "text", "directory", "name"],
|
|
16
|
+
};
|
|
@@ -7,7 +7,8 @@ export interface PopoverTriggerBindings {
|
|
|
7
7
|
onClick: (event: MouseEvent) => void;
|
|
8
8
|
}
|
|
9
9
|
export interface PopoverProps extends Props {
|
|
10
|
-
id
|
|
10
|
+
/** Base id for the ARIA references this component wires; generated when omitted. */
|
|
11
|
+
id?: string;
|
|
11
12
|
triggerId?: string;
|
|
12
13
|
trigger: (bindings: PopoverTriggerBindings) => Child;
|
|
13
14
|
open?: MaybeSignal<boolean>;
|
|
@@ -2,11 +2,12 @@ import { h } from "meowjsx";
|
|
|
2
2
|
import { derived, isSignal, signal, unwrap } from "meowjsx/signal";
|
|
3
3
|
import { autoUpdate, computePosition, offset, flip, shift, size } from "@floating-ui/dom";
|
|
4
4
|
import { activeElementInRoot, elementByIdInRoot } from "../shared/dom-root.js";
|
|
5
|
+
import { elementId } from "../shared/element-id.js";
|
|
5
6
|
// Opening order, rather than DOM order, determines which nested layer dismisses.
|
|
6
7
|
const layers = new WeakMap();
|
|
7
8
|
const dismissedEvents = new WeakSet();
|
|
8
9
|
/** A floating panel anchored to a trigger, in the top layer. */
|
|
9
|
-
export function Popover({ id, triggerId = `${id}-trigger`, trigger, open, defaultOpen = false, onOpenChange, matchTriggerWidth = false, align = "start", placement = "bottom", anchorRect, anchorElement, role, labelledBy, onKeyDown, children, className, }, context) {
|
|
10
|
+
export function Popover({ id = elementId("popover"), triggerId = `${id}-trigger`, trigger, open, defaultOpen = false, onOpenChange, matchTriggerWidth = false, align = "start", placement = "bottom", anchorRect, anchorElement, role, labelledBy, onKeyDown, children, className, }, context) {
|
|
10
11
|
const local = signal(defaultOpen);
|
|
11
12
|
// A signal object is controlled even when its current value is false.
|
|
12
13
|
const state = open !== undefined ? open : local;
|
|
@@ -29,9 +30,32 @@ export function Popover({ id, triggerId = `${id}-trigger`, trigger, open, defaul
|
|
|
29
30
|
throw new Error("Popover requires the browser Popover API");
|
|
30
31
|
panel.showPopover();
|
|
31
32
|
stack.push(panel);
|
|
32
|
-
|
|
33
|
+
const stopAuto = autoUpdate(anchorRect
|
|
33
34
|
? { getBoundingClientRect: anchorRect, contextElement: anchorElement?.() ?? anchor }
|
|
34
|
-
: anchor, panel, position);
|
|
35
|
+
: anchor, panel, position, { elementResize: false });
|
|
36
|
+
// A resize is answered on the next frame: fitting the pane inside the observer callback
|
|
37
|
+
// resizes it again, which the browser reports as a ResizeObserver loop error.
|
|
38
|
+
const view = panel.ownerDocument.defaultView;
|
|
39
|
+
let frame = 0;
|
|
40
|
+
const resized = view?.ResizeObserver
|
|
41
|
+
? new view.ResizeObserver(() => {
|
|
42
|
+
if (frame)
|
|
43
|
+
return;
|
|
44
|
+
frame = view.requestAnimationFrame(() => {
|
|
45
|
+
frame = 0;
|
|
46
|
+
position();
|
|
47
|
+
});
|
|
48
|
+
})
|
|
49
|
+
: undefined;
|
|
50
|
+
resized?.observe(panel);
|
|
51
|
+
resized?.observe(anchorElement?.() ?? anchor);
|
|
52
|
+
stopPosition = () => {
|
|
53
|
+
stopAuto();
|
|
54
|
+
resized?.disconnect();
|
|
55
|
+
if (frame)
|
|
56
|
+
view?.cancelAnimationFrame(frame);
|
|
57
|
+
frame = 0;
|
|
58
|
+
};
|
|
35
59
|
}
|
|
36
60
|
else if (!next && shown) {
|
|
37
61
|
const hadFocus = panel.contains(activeElementInRoot(panel));
|
|
@@ -103,10 +127,13 @@ export function Popover({ id, triggerId = `${id}-trigger`, trigger, open, defaul
|
|
|
103
127
|
apply({ availableWidth, availableHeight, rects }) {
|
|
104
128
|
if (!alive)
|
|
105
129
|
return;
|
|
106
|
-
|
|
107
|
-
|
|
130
|
+
// Whole pixels: a fraction that drifts between passes resizes the pane
|
|
131
|
+
// inside its own resize observer, which the browser reports as a loop.
|
|
132
|
+
const width = Math.max(0, Math.floor(availableWidth));
|
|
133
|
+
element.style.maxWidth = `${width}px`;
|
|
134
|
+
element.style.maxHeight = `${Math.max(0, Math.floor(availableHeight))}px`;
|
|
108
135
|
if (matchTriggerWidth)
|
|
109
|
-
element.style.width = `${Math.min(rects.reference.width,
|
|
136
|
+
element.style.width = `${Math.min(Math.floor(rects.reference.width), width)}px`;
|
|
110
137
|
},
|
|
111
138
|
}),
|
|
112
139
|
],
|
|
@@ -14,7 +14,10 @@ export interface ResourceCardProps extends Props {
|
|
|
14
14
|
tone?: "default" | "muted";
|
|
15
15
|
className?: Props["className"];
|
|
16
16
|
}
|
|
17
|
-
/**
|
|
17
|
+
/**
|
|
18
|
+
* One prepared capability on an overview page: what it is, whether it runs, what to do next.
|
|
19
|
+
* The title sits one heading level below the surrounding `Page` or `Section`.
|
|
20
|
+
*/
|
|
18
21
|
export declare function ResourceCard({ title, subtitle, icon, status, description, actions, identity, tone, className, children, ...props }: ResourceCardProps, context: Context<typeof ResourceCard>): import("meowjsx").VNode;
|
|
19
22
|
export declare namespace ResourceCard {
|
|
20
23
|
var meta: {
|
|
@@ -1,11 +1,16 @@
|
|
|
1
1
|
import { h } from "meowjsx";
|
|
2
|
-
|
|
2
|
+
import { nestedHeadingLevel } from "./heading-level.js";
|
|
3
|
+
/**
|
|
4
|
+
* One prepared capability on an overview page: what it is, whether it runs, what to do next.
|
|
5
|
+
* The title sits one heading level below the surrounding `Page` or `Section`.
|
|
6
|
+
*/
|
|
3
7
|
export function ResourceCard({ title, subtitle, icon, status, description, actions, identity, tone = "default", className, children, ...props }, context) {
|
|
8
|
+
const Heading = `h${nestedHeadingLevel()}`;
|
|
4
9
|
return (h("article", { ...props, className: className, "data-tone": tone, ref: [context.parts.root, props.ref] },
|
|
5
10
|
h("div", { ref: [context.parts.head] },
|
|
6
11
|
icon ? (h("span", { "aria-hidden": "true", ref: [context.parts.icon] }, icon)) : null,
|
|
7
12
|
h("div", { ref: [context.parts.copy] },
|
|
8
|
-
h(
|
|
13
|
+
h(Heading, { ref: [context.parts.title] }, title),
|
|
9
14
|
subtitle ? h("span", { ref: [context.parts.subtitle] }, subtitle) : null),
|
|
10
15
|
status ? h("span", { ref: [context.parts.status] }, status) : null),
|
|
11
16
|
description ? h("p", { ref: [context.parts.description] }, description) : null,
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import { type Props, type Context } from "meowjsx";
|
|
2
2
|
import { type MaybeSignal } from "meowjsx/signal";
|
|
3
3
|
export interface RiskConfirmationProps extends Props {
|
|
4
|
-
id
|
|
4
|
+
/** Base id for the ARIA references this component wires; generated when omitted. */
|
|
5
|
+
id?: string;
|
|
5
6
|
open: MaybeSignal<boolean>;
|
|
6
7
|
title: string;
|
|
7
8
|
description: string;
|
|
@@ -3,8 +3,9 @@ import { derived, isSignal, unwrap } from "meowjsx/signal";
|
|
|
3
3
|
import { Dialog, DialogPanel, DialogHeader, DialogActions } from "./dialog.js";
|
|
4
4
|
import { Checkbox } from "./checkbox.js";
|
|
5
5
|
import { Button } from "./button.js";
|
|
6
|
+
import { elementId } from "../shared/element-id.js";
|
|
6
7
|
/** One host-requested acknowledgement; it never decides which actions need confirmation. */
|
|
7
|
-
export function RiskConfirmation({ id, open, title, description, acknowledgeLabel, cancelLabel, confirmLabel, acknowledged, disabled = false, onAcknowledgedChange, onCancel, onConfirm, className, }, context) {
|
|
8
|
+
export function RiskConfirmation({ id = elementId("risk-confirmation"), open, title, description, acknowledgeLabel, cancelLabel, confirmLabel, acknowledged, disabled = false, onAcknowledgedChange, onCancel, onConfirm, className, }, context) {
|
|
8
9
|
const blocked = derived(() => unwrap(disabled) || !unwrap(acknowledged));
|
|
9
10
|
return (h("div", { className: className, ref: [context.parts.root] }, h(Dialog, { labelledBy: `${id}-title`, describedBy: `${id}-description`, onCancel: (event) => {
|
|
10
11
|
event.preventDefault();
|
|
@@ -1,11 +1,5 @@
|
|
|
1
1
|
import { type Child, type Props, type Context } from "meowjsx";
|
|
2
|
-
|
|
3
|
-
* The authoring region's heading depth. `Page` provides 1, so a direct `Section`
|
|
4
|
-
* with a title renders h2; each titled `Section` provides the level it rendered,
|
|
5
|
-
* so a nested one renders h3. A title-less grouping section passes the level
|
|
6
|
-
* through unchanged, and a section mounted outside a page falls back to 1.
|
|
7
|
-
*/
|
|
8
|
-
export declare const sectionLevelContext: import("meowjsx").ContextValue<number>;
|
|
2
|
+
export { sectionLevelContext } from "./heading-level.js";
|
|
9
3
|
export type SectionVariant = "plain" | "card";
|
|
10
4
|
export interface SectionProps extends Props {
|
|
11
5
|
/**
|
|
@@ -1,12 +1,7 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { h, useContext } from "meowjsx";
|
|
2
2
|
import { Card } from "./card.js";
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
* with a title renders h2; each titled `Section` provides the level it rendered,
|
|
6
|
-
* so a nested one renders h3. A title-less grouping section passes the level
|
|
7
|
-
* through unchanged, and a section mounted outside a page falls back to 1.
|
|
8
|
-
*/
|
|
9
|
-
export const sectionLevelContext = createContext(1);
|
|
3
|
+
import { sectionLevelContext } from "./heading-level.js";
|
|
4
|
+
export { sectionLevelContext } from "./heading-level.js";
|
|
10
5
|
/** True when a slot was given; `false` and `null` mean the slot is omitted. */
|
|
11
6
|
function hasSlot(slot) {
|
|
12
7
|
return slot !== undefined && slot !== null && slot !== false;
|
|
@@ -7,7 +7,8 @@ export interface SegmentedControlOption {
|
|
|
7
7
|
title?: string;
|
|
8
8
|
}
|
|
9
9
|
export interface SegmentedControlProps extends Props {
|
|
10
|
-
id
|
|
10
|
+
/** Base id for the ARIA references this component wires; generated when omitted. */
|
|
11
|
+
id?: string;
|
|
11
12
|
name?: string;
|
|
12
13
|
form?: string;
|
|
13
14
|
label: string;
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import { h } from "meowjsx";
|
|
2
2
|
import { derived, unwrap } from "meowjsx/signal";
|
|
3
|
+
import { elementId } from "../shared/element-id.js";
|
|
3
4
|
/** A single choice, using native radio keyboard semantics; tabs remain a separate component. */
|
|
4
|
-
export function SegmentedControl({ id, name = id, form, label, value, options, onValueChange, disabled, className, }, context) {
|
|
5
|
+
export function SegmentedControl({ id = elementId("segmented-control"), name = id, form, label, value, options, onValueChange, disabled, className, }, context) {
|
|
5
6
|
const inputs = new Map();
|
|
6
7
|
// Form reset and a rejected change flip the native radio before the signal does.
|
|
7
8
|
const reconcile = () => {
|
|
@@ -8,7 +8,8 @@ export interface TabItem {
|
|
|
8
8
|
disabled?: boolean;
|
|
9
9
|
}
|
|
10
10
|
export interface TabsProps extends Props {
|
|
11
|
-
id
|
|
11
|
+
/** Base id for the ARIA references this component wires; generated when omitted. */
|
|
12
|
+
id?: string;
|
|
12
13
|
label: string;
|
|
13
14
|
items: readonly TabItem[];
|
|
14
15
|
value?: MaybeSignal<string>;
|
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
import { h } from "meowjsx";
|
|
2
2
|
import { derived, signal, unwrap } from "meowjsx/signal";
|
|
3
3
|
import { tabsCount, tabsIndex } from "./tabs.options.js";
|
|
4
|
+
import { elementId } from "../shared/element-id.js";
|
|
4
5
|
export { tabsCount, tabsIndex } from "./tabs.options.js";
|
|
5
6
|
/** Horizontal tabs with automatic keyboard activation. Items are fixed for the mount, and panels stay mounted to preserve drafts. */
|
|
6
|
-
export function Tabs({ id, label, items, value, defaultValue, onValueChange, className, children, ref, ...props }, context) {
|
|
7
|
+
export function Tabs({ id = elementId("tabs"), label, items, value, defaultValue, onValueChange, className, children, ref, ...props }, context) {
|
|
7
8
|
void children;
|
|
8
9
|
const enabled = items.flatMap((item, index) => (item.disabled ? [] : [index]));
|
|
9
10
|
const local = signal(defaultValue ?? items[enabled[0] ?? -1]?.value ?? "");
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import { type Context, type Props } from "meowjsx";
|
|
2
|
+
import { type MaybeSignal } from "meowjsx/signal";
|
|
3
|
+
export interface TokenFieldToken {
|
|
4
|
+
/** Unique in the list; also the submitted form value. */
|
|
5
|
+
id: string;
|
|
6
|
+
label: string;
|
|
7
|
+
/** The host could not resolve this token; its name says so. */
|
|
8
|
+
invalid?: boolean;
|
|
9
|
+
}
|
|
10
|
+
export interface TokenFieldProps extends Props {
|
|
11
|
+
/** Id of the draft input; also the base for the token ids. Generated when omitted. */
|
|
12
|
+
id?: string;
|
|
13
|
+
/** The host owns the tokens; a Signal keeps them live. */
|
|
14
|
+
tokens: MaybeSignal<readonly TokenFieldToken[]>;
|
|
15
|
+
/**
|
|
16
|
+
* Called with trimmed, non-empty draft text on Enter, a separator or a paste. The host resolves,
|
|
17
|
+
* deduplicates or rejects it and updates `tokens`. Return false to keep the draft for correction.
|
|
18
|
+
*/
|
|
19
|
+
onAdd: (text: string) => boolean | void;
|
|
20
|
+
/** Called when the reader removes a token; the host decides. */
|
|
21
|
+
onRemove: (id: string) => void;
|
|
22
|
+
/** Characters that end a token as they are typed or pasted. */
|
|
23
|
+
separators?: readonly string[];
|
|
24
|
+
/** Accessible name of the token list. */
|
|
25
|
+
listLabel?: string;
|
|
26
|
+
removeLabel?: (label: string) => string;
|
|
27
|
+
/** Read after a token's name when the host marked it invalid. */
|
|
28
|
+
invalidMessage?: string;
|
|
29
|
+
/** Submits one value per token under this name. */
|
|
30
|
+
name?: string;
|
|
31
|
+
/** At least one token; enforced through the draft's custom validity. */
|
|
32
|
+
required?: boolean;
|
|
33
|
+
requiredMessage?: string;
|
|
34
|
+
disabled?: MaybeSignal<boolean>;
|
|
35
|
+
placeholder?: string;
|
|
36
|
+
className?: Props["className"];
|
|
37
|
+
}
|
|
38
|
+
/** Several values entered as text: tokens the host resolves, removable while the reader types. */
|
|
39
|
+
export declare function TokenField({ id, tokens, onAdd, onRemove, separators, listLabel, removeLabel, invalidMessage, name, required, requiredMessage, disabled, placeholder, className, ref, ...props }: TokenFieldProps, context: Context<typeof TokenField>): import("meowjsx").VNode;
|
|
40
|
+
export declare namespace TokenField {
|
|
41
|
+
var meta: {
|
|
42
|
+
readonly name: "token-field";
|
|
43
|
+
readonly parts: readonly ["root", "control", "list", "token", "label", "invalid", "remove", "input"];
|
|
44
|
+
};
|
|
45
|
+
}
|