@mythicalos/preact-ui 0.2.2 → 0.4.0
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/README.md +36 -1
- package/dist/FileExplorer.d.ts +75 -0
- package/dist/FileExplorer.js +59 -0
- package/dist/GitChip.d.ts +18 -0
- package/dist/GitChip.js +25 -0
- package/dist/Input.d.ts +53 -0
- package/dist/Input.js +112 -6
- package/dist/Popover.d.ts +50 -0
- package/dist/Popover.js +167 -0
- package/dist/QueuePanel.d.ts +38 -0
- package/dist/QueuePanel.js +76 -0
- package/dist/SaveBar.d.ts +20 -0
- package/dist/SaveBar.js +11 -0
- package/dist/SendBar.d.ts +26 -0
- package/dist/SendBar.js +62 -0
- package/dist/SessionCard.d.ts +42 -0
- package/dist/SessionCard.js +43 -0
- package/dist/StatTiles.d.ts +10 -0
- package/dist/StatTiles.js +22 -0
- package/dist/Terminal.d.ts +31 -0
- package/dist/Terminal.js +90 -0
- package/dist/index.d.ts +11 -1
- package/dist/index.js +15 -1
- package/package.json +2 -2
package/dist/Terminal.js
ADDED
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "preact/jsx-runtime";
|
|
2
|
+
/** @jsxImportSource preact */
|
|
3
|
+
// @mythicalos/preact-ui — the terminal pane (ds/components-terminal, spec v2). ALWAYS heritage-dark
|
|
4
|
+
// in both themes (token rule 3): the surface is pinned by ui-core's `.my-term` block, never by a
|
|
5
|
+
// theme-conditional class this binding picks.
|
|
6
|
+
//
|
|
7
|
+
// Thin binding: render + wiring only. Every class string (`TERM_CLASSES`), every user-visible
|
|
8
|
+
// string, the six-branch source resolution, the segmentation, the row keying and the Ctrl-C
|
|
9
|
+
// predicate come from `@mythicalos/ui-core` — this file types no class literal and no copy of its
|
|
10
|
+
// own, so it and its React sibling cannot drift.
|
|
11
|
+
//
|
|
12
|
+
// Honesty (binding, inherited from ui-core): the wake-unavailable banner says exactly
|
|
13
|
+
// `wake unavailable` — never "reconnecting", never a retry spinner; the turn caption renders ONLY
|
|
14
|
+
// from a supplied boolean (`undefined` renders nothing, never a guessed "idle"); the six source
|
|
15
|
+
// branches keep loading honesty (`loading` never renders `(no events)`; missing/unaddressable/
|
|
16
|
+
// failed are distinct); foreign transcript segments appear ONLY behind the disclosure, each
|
|
17
|
+
// captioned and separated — never blended into the selected session's log.
|
|
18
|
+
import { useEffect, useRef, useState } from "preact/hooks";
|
|
19
|
+
import { TERM_CLASS, TERM_CLASSES, TERM_NO_EVENTS_COPY, TERM_STALE_COPY, TERM_STOP_KEY_HINT, TERM_STOP_LABEL, TERM_WAKE_UNAVAILABLE_COPY, currentWakeRows, expandLabel, historySegmentCaption, historyToggleLabel, isExpandable, noiseShow, ROW_SCOPE, scopedRowKeys, segmentKeys, shouldStopOnKey, sourceRows, stopButtonClass, termRowClass, termTitleText, transcriptView, turnCaption, visibleRows, } from "@mythicalos/ui-core/logic";
|
|
20
|
+
export { TERM_CLASS, TERM_CLASSES, TERM_STALE_COPY, TERM_WAKE_UNAVAILABLE_COPY, transcriptView, } from "@mythicalos/ui-core/logic";
|
|
21
|
+
function RowView(props) {
|
|
22
|
+
const { row } = props;
|
|
23
|
+
const label = row.label ? _jsx("span", { class: TERM_CLASSES.label, children: row.label }) : null;
|
|
24
|
+
if (!isExpandable(row)) {
|
|
25
|
+
return (_jsxs("div", { class: termRowClass(row.kind), children: [label, label ? " " : null, row.text] }));
|
|
26
|
+
}
|
|
27
|
+
return (_jsxs("div", { class: termRowClass(row.kind), children: [_jsxs("button", { type: "button", class: TERM_CLASSES.head, "aria-expanded": props.expanded, onClick: props.onToggle, children: [label, label ? " " : null, row.text, " ", _jsx("span", { class: TERM_CLASSES.expand, children: expandLabel(props.expanded) })] }), props.expanded ? _jsx("pre", { class: TERM_CLASSES.detail, children: row.detail }) : null] }));
|
|
28
|
+
}
|
|
29
|
+
/**
|
|
30
|
+
* A keyed run of rows. `scopedRowKeys` namespaces every key under its scope, so expand state can
|
|
31
|
+
* never leak between the transcript, the local rows and a history segment — not even when a caller
|
|
32
|
+
* supplies an id that looks like another scope's prefix.
|
|
33
|
+
*/
|
|
34
|
+
function RowList(props) {
|
|
35
|
+
const keys = scopedRowKeys(props.scope, props.rows);
|
|
36
|
+
return (_jsx(_Fragment, { children: props.rows.map((row, i) => {
|
|
37
|
+
const key = keys[i];
|
|
38
|
+
return _jsx(RowView, { row: row, expanded: props.expanded.has(key), onToggle: () => props.onToggle(key) }, key);
|
|
39
|
+
}) }));
|
|
40
|
+
}
|
|
41
|
+
export function Terminal(props) {
|
|
42
|
+
const { source, noiseFilterEnabled = false } = props;
|
|
43
|
+
const history = props.history ?? [];
|
|
44
|
+
const [expanded, setExpanded] = useState(new Set());
|
|
45
|
+
const [showHistory, setShowHistory] = useState(false);
|
|
46
|
+
const paneRef = useRef(null);
|
|
47
|
+
const toggle = (key) => setExpanded((prev) => {
|
|
48
|
+
const next = new Set(prev);
|
|
49
|
+
if (next.has(key))
|
|
50
|
+
next.delete(key);
|
|
51
|
+
else
|
|
52
|
+
next.add(key);
|
|
53
|
+
return next;
|
|
54
|
+
});
|
|
55
|
+
const stopAvailable = props.onStopTurn !== undefined;
|
|
56
|
+
// Focused Ctrl-C → stop-turn. The predicate (key-repeat drop, selection guard, focus guard) is
|
|
57
|
+
// ui-core's; the availability + in-flight guards live here. Effects do not run under SSR.
|
|
58
|
+
useEffect(() => {
|
|
59
|
+
if (!stopAvailable)
|
|
60
|
+
return;
|
|
61
|
+
const onKey = (e) => {
|
|
62
|
+
if (props.stopBusy)
|
|
63
|
+
return;
|
|
64
|
+
const sel = window.getSelection?.()?.toString() ?? "";
|
|
65
|
+
const pane = paneRef.current;
|
|
66
|
+
const focused = !!pane && pane.contains(document.activeElement);
|
|
67
|
+
if (shouldStopOnKey(e, sel, focused)) {
|
|
68
|
+
e.preventDefault();
|
|
69
|
+
props.onStopTurn?.();
|
|
70
|
+
}
|
|
71
|
+
};
|
|
72
|
+
window.addEventListener("keydown", onKey);
|
|
73
|
+
return () => window.removeEventListener("keydown", onKey);
|
|
74
|
+
}, [stopAvailable, props.onStopTurn, props.stopBusy]);
|
|
75
|
+
const view = transcriptView(source);
|
|
76
|
+
const showNoise = noiseShow(noiseFilterEnabled);
|
|
77
|
+
const allRows = props.currentWakeOnly ? currentWakeRows(sourceRows(source)) : sourceRows(source);
|
|
78
|
+
const rows = view.kind === "log" ? visibleRows(allRows, showNoise) : [];
|
|
79
|
+
const localRows = view.kind === "log" ? visibleRows(props.localRows ?? [], showNoise) : [];
|
|
80
|
+
const emptyLog = view.kind === "log" && rows.length === 0 && localRows.length === 0;
|
|
81
|
+
const segKeys = segmentKeys(history);
|
|
82
|
+
const titleText = termTitleText(props.name, noiseFilterEnabled);
|
|
83
|
+
const caption = turnCaption(props.turnInFlight);
|
|
84
|
+
return (_jsxs("div", { class: TERM_CLASS, children: [_jsxs("div", { class: TERM_CLASSES.titlebar, children: [_jsxs("span", { class: TERM_CLASSES.lights, "aria-hidden": "true", children: [_jsx("span", { class: TERM_CLASSES.lightRed }), _jsx("span", { class: TERM_CLASSES.lightAmber }), _jsx("span", { class: TERM_CLASSES.lightGreen })] }), props.onToggleNoise ? (_jsx("button", { type: "button", class: TERM_CLASSES.noiseToggle, "aria-pressed": noiseFilterEnabled, onClick: props.onToggleNoise, children: titleText })) : (_jsx("span", { class: TERM_CLASSES.staticTitle, children: titleText })), _jsxs("span", { class: TERM_CLASSES.titleRight, children: [caption !== null ? (props.turnInFlight ? (_jsxs("span", { class: TERM_CLASSES.turn, children: [_jsx("span", { class: TERM_CLASSES.turnDot, "aria-hidden": "true" }), caption] })) : (_jsx("span", { class: TERM_CLASSES.idle, children: caption }))) : null, stopAvailable ? (_jsxs("button", { type: "button", class: stopButtonClass(!!props.stopProminent), disabled: props.stopBusy, onClick: props.onStopTurn, children: [TERM_STOP_LABEL, " ", _jsx("span", { class: TERM_CLASSES.stopKey, children: TERM_STOP_KEY_HINT })] })) : null] })] }), _jsxs("div", { ref: paneRef, class: TERM_CLASSES.body, tabIndex: 0, children: [props.wakeUnavailable ? (_jsxs("div", { class: TERM_CLASSES.banner, children: [_jsx("span", { class: TERM_CLASSES.bannerDot, "aria-hidden": "true" }), TERM_WAKE_UNAVAILABLE_COPY] })) : null, view.kind === "log" && view.stale ? (_jsxs("div", { class: TERM_CLASSES.banner, children: [_jsx("span", { class: TERM_CLASSES.bannerDot, "aria-hidden": "true" }), TERM_STALE_COPY] })) : null, history.length > 0 ? (_jsx("button", { type: "button", class: TERM_CLASSES.more, onClick: () => setShowHistory((s) => !s), children: historyToggleLabel(showHistory, history.length) })) : null, showHistory
|
|
85
|
+
? history.map((seg, si) => (
|
|
86
|
+
// keyed by the segment's own identity, not its position, so reordering the list moves
|
|
87
|
+
// neither the rendered element nor its rows' expand state
|
|
88
|
+
_jsxs("div", { class: TERM_CLASSES.segment, children: [_jsx("div", { class: TERM_CLASSES.segmentCaption, children: seg.caption ?? historySegmentCaption(seg.id) }), _jsx(RowList, { rows: visibleRows(seg.rows, showNoise), scope: [ROW_SCOPE.history, segKeys[si]], expanded: expanded, onToggle: toggle })] }, segKeys[si])))
|
|
89
|
+
: null, view.kind === "state" ? _jsx("div", { class: TERM_CLASSES.state, children: view.copy }) : null, emptyLog ? _jsx("div", { class: TERM_CLASSES.state, children: TERM_NO_EVENTS_COPY }) : null, _jsx(RowList, { rows: rows, scope: [ROW_SCOPE.transcript], expanded: expanded, onToggle: toggle }), _jsx(RowList, { rows: localRows, scope: [ROW_SCOPE.local], expanded: expanded, onToggle: toggle }), props.caret ? _jsx("span", { class: TERM_CLASSES.caret, "aria-hidden": "true" }) : null] })] }));
|
|
90
|
+
}
|
package/dist/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
export { Button, buttonClass, type ButtonProps, type BtnVariant, type BtnState } from "./Button.js";
|
|
2
|
-
export { Input, Toggle, Checkbox, type InputProps, type ToggleProps, type CheckboxProps } from "./Input.js";
|
|
2
|
+
export { Input, Toggle, Checkbox, REVEAL_SHOW_LABEL, REVEAL_HIDE_LABEL, REVEAL_LABELS, type InputProps, type RevealLabels, type ToggleProps, type CheckboxProps, } from "./Input.js";
|
|
3
3
|
export { MaskedSecretInput, type MaskedSecretInputProps } from "./MaskedSecretInput.js";
|
|
4
4
|
export { EmptyState, type EmptyStateProps } from "./EmptyState.js";
|
|
5
5
|
export { Scrim, ConfirmDialog, typedNameMatches, BULLET_ICON, type DialogBullet, type ConfirmDialogProps, } from "./ConfirmDialog.js";
|
|
@@ -13,3 +13,13 @@ export { StatusLine, statusLineClass, type StatusLineProps, type StatusTone } fr
|
|
|
13
13
|
export { SearchInput, type SearchInputProps } from "./SearchInput.js";
|
|
14
14
|
export { Banner, bannerClass, BANNER_ICON, type BannerProps, type BannerTone } from "./Banner.js";
|
|
15
15
|
export { Gauge, gaugeTone, gaugeGeom, type GaugeProps, type GaugeGeom, type Tone } from "./Gauge.js";
|
|
16
|
+
export { SaveBar, saveBarNote, saveBarDirty, saveBarClass, SAVE_BAR_PARTS, SAVE_BAR_SEP, SAVE_BAR_DISCARD_LABEL, SAVE_BAR_SAVE_LABEL, type SaveBarProps, type SaveBarNote, } from "./SaveBar.js";
|
|
17
|
+
export { StatTiles, statTilesClass, statTileClass, STAT_TILE_PARTS, formatStatCompact, formatStatCount, formatStatUsd, formatStatPercent, STAT_TILE_EMPTY, STAT_TILE_MINUS, type StatTilesProps, type StatTile, type StatTileTone, } from "./StatTiles.js";
|
|
18
|
+
export { GitChip, gitFlags, hasGitStatus, gitBranchLabel, gitChipClass, gitFlagClass, gitChipNote, GIT_CHIP_PARTS, GIT_BRANCH_GLYPH, GIT_BRANCH_UNKNOWN, GIT_DETACHED_LABEL, GIT_CLEAN_LABEL, GIT_LOADING_NOTE, GIT_UNAVAILABLE_NOTE, GIT_STALE_LABEL, GIT_STALE_TITLE, type GitChipProps, type GitStatus, type GitFlag, type GitFlagTone, } from "./GitChip.js";
|
|
19
|
+
export { Popover, POPOVER_CARET, POPOVER_CHECK, POPOVER_EMPTY_VALUE, popoverTriggerClass, popoverPanelClass, popoverItemClass, popoverTriggerText, resolvePopoverPosition, type PopoverProps, type PopoverItem, type PopoverPosition, } from "./Popover.js";
|
|
20
|
+
export { FileTree, FilePreview, FileScopePicker, deriveFileTreeRows, countFileRows, countLoadedFiles, previewMeta, previewBodyMode, buildBreadcrumb, breadcrumbSegments, formatFileSize, formatRelativeTime, type FileTreeProps, type FilePreviewProps, type FileScopePickerProps, type FileTreeMode, type FileTreeRootSpec, type FileTreeRow, type FileScopeOption, type DirState, type FilePreviewState, type PreviewBadgeState, type GitMark, } from "./FileExplorer.js";
|
|
21
|
+
export { SessionCard, ctxBand, ctxReading, ctxBarGeom, normalizeCtxThresholds, ctxMeterClass, ctxNoteText, ctxValueText, sessionAvatarInitial, sessionCardClass, sessionCardIsStale, sessionCardStale, sessionStatusText, sessionSpineSummary, sessionStatus, sessionStatusClass, sessionSubline, spineNodeClass, type SessionCardProps, } from "./SessionCard.js";
|
|
22
|
+
export type { CtxThresholds, CtxBand, CtxBarTick, CtxBarGeom, SessionLifecycle, SessionActivity, SessionStatusTone, SessionStatusKey, SessionStatus, SessionStatusInput, SessionSpine, SpineNode, SpineSummary, } from "@mythicalos/ui-core/logic";
|
|
23
|
+
export { Terminal, TERM_CLASS, TERM_STALE_COPY, TERM_WAKE_UNAVAILABLE_COPY, transcriptView, type TerminalProps, type TranscriptSegment, type TermRow, type TermRowKind, type TermSource, type TermView, } from "./Terminal.js";
|
|
24
|
+
export { QueuePanel, QueueRow, QUEUE_EMPTY_COPY, QUEUE_LOADING_COPY, QUEUE_STALE_COPY, QUEUE_UNAVAILABLE_COPY, canCancelRow, cancelReducer, queueBadgeClass, queueBadgeLabel, queueRowClass, queueView, shouldDisarmCancel, type QueuePanelProps, type QueueRowProps, type CancelEvent, type CancelState, type QueueItem, type QueueItemStatus, type QueueSource, type QueueUnavailableReason, type QueueView, } from "./QueuePanel.js";
|
|
25
|
+
export { SendBar, DELIVERY_CLASSES, DELIVERY_HINT, SEND_DISABLED_FALLBACK, SEND_PLACEHOLDER, canSend, clearDraftOnSend, deliveryClassLabel, keyAction, sendPlaceholder, showDeliveryHint, type SendBarProps, type DeliveryClass, type KeyAction, } from "./SendBar.js";
|
package/dist/index.js
CHANGED
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
// SearchInput, Banner, Gauge — Task 6). Serve `@mythicalos/ui-core/styles.css` (after
|
|
5
5
|
// `@mythicalos/tokens`) so these components' classes resolve — this package ships no CSS of its own.
|
|
6
6
|
export { Button, buttonClass } from "./Button.js";
|
|
7
|
-
export { Input, Toggle, Checkbox } from "./Input.js";
|
|
7
|
+
export { Input, Toggle, Checkbox, REVEAL_SHOW_LABEL, REVEAL_HIDE_LABEL, REVEAL_LABELS, } from "./Input.js";
|
|
8
8
|
export { MaskedSecretInput } from "./MaskedSecretInput.js";
|
|
9
9
|
export { EmptyState } from "./EmptyState.js";
|
|
10
10
|
export { Scrim, ConfirmDialog, typedNameMatches, BULLET_ICON, } from "./ConfirmDialog.js";
|
|
@@ -19,3 +19,17 @@ export { StatusLine, statusLineClass } from "./StatusLine.js";
|
|
|
19
19
|
export { SearchInput } from "./SearchInput.js";
|
|
20
20
|
export { Banner, bannerClass, BANNER_ICON } from "./Banner.js";
|
|
21
21
|
export { Gauge, gaugeTone, gaugeGeom } from "./Gauge.js";
|
|
22
|
+
// ── small atoms graduated out of a single product (save-bar / stat-tiles / git-chip cards) ──
|
|
23
|
+
export { SaveBar, saveBarNote, saveBarDirty, saveBarClass, SAVE_BAR_PARTS, SAVE_BAR_SEP, SAVE_BAR_DISCARD_LABEL, SAVE_BAR_SAVE_LABEL, } from "./SaveBar.js";
|
|
24
|
+
export { StatTiles, statTilesClass, statTileClass, STAT_TILE_PARTS, formatStatCompact, formatStatCount, formatStatUsd, formatStatPercent, STAT_TILE_EMPTY, STAT_TILE_MINUS, } from "./StatTiles.js";
|
|
25
|
+
export { GitChip, gitFlags, hasGitStatus, gitBranchLabel, gitChipClass, gitFlagClass, gitChipNote, GIT_CHIP_PARTS, GIT_BRANCH_GLYPH, GIT_BRANCH_UNKNOWN, GIT_DETACHED_LABEL, GIT_CLEAN_LABEL, GIT_LOADING_NOTE, GIT_UNAVAILABLE_NOTE, GIT_STALE_LABEL, GIT_STALE_TITLE, } from "./GitChip.js";
|
|
26
|
+
// ── dropdown popover (ds/components-popover — registry row `popover` v1) ──
|
|
27
|
+
export { Popover, POPOVER_CARET, POPOVER_CHECK, POPOVER_EMPTY_VALUE, popoverTriggerClass, popoverPanelClass, popoverItemClass, popoverTriggerText, resolvePopoverPosition, } from "./Popover.js";
|
|
28
|
+
// ── file explorer & markdown preview (ds/components-file-explorer) ──
|
|
29
|
+
export { FileTree, FilePreview, FileScopePicker, deriveFileTreeRows, countFileRows, countLoadedFiles, previewMeta, previewBodyMode, buildBreadcrumb, breadcrumbSegments, formatFileSize, formatRelativeTime, } from "./FileExplorer.js";
|
|
30
|
+
// ── session-card (design registry `session-card` v1) ──
|
|
31
|
+
export { SessionCard, ctxBand, ctxReading, ctxBarGeom, normalizeCtxThresholds, ctxMeterClass, ctxNoteText, ctxValueText, sessionAvatarInitial, sessionCardClass, sessionCardIsStale, sessionCardStale, sessionStatusText, sessionSpineSummary, sessionStatus, sessionStatusClass, sessionSubline, spineNodeClass, } from "./SessionCard.js";
|
|
32
|
+
// ── terminal set (ds/components-terminal v2): terminal · queue-row · send-bar ──
|
|
33
|
+
export { Terminal, TERM_CLASS, TERM_STALE_COPY, TERM_WAKE_UNAVAILABLE_COPY, transcriptView, } from "./Terminal.js";
|
|
34
|
+
export { QueuePanel, QueueRow, QUEUE_EMPTY_COPY, QUEUE_LOADING_COPY, QUEUE_STALE_COPY, QUEUE_UNAVAILABLE_COPY, canCancelRow, cancelReducer, queueBadgeClass, queueBadgeLabel, queueRowClass, queueView, shouldDisarmCancel, } from "./QueuePanel.js";
|
|
35
|
+
export { SendBar, DELIVERY_CLASSES, DELIVERY_HINT, SEND_DISABLED_FALLBACK, SEND_PLACEHOLDER, canSend, clearDraftOnSend, deliveryClassLabel, keyAction, sendPlaceholder, showDeliveryHint, } from "./SendBar.js";
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mythicalos/preact-ui",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.4.0",
|
|
4
4
|
"description": "mythicalOS thin Preact bindings over @mythicalos/ui-core — Button, Input/Toggle/Checkbox, MaskedSecretInput, EmptyState, ConfirmDialog/Scrim, Toast/ToastProvider, Chip, Card, Avatar, StatusLine, SearchInput, Banner, Gauge, and the usePoll/useInterval hooks. Render + framework wiring only — every class string, poll-scheduling math, glyph map, and text composition is derived by @mythicalos/ui-core so this binding and its React sibling can never drift. Apache-2.0.",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"type": "module",
|
|
@@ -35,7 +35,7 @@
|
|
|
35
35
|
}
|
|
36
36
|
},
|
|
37
37
|
"dependencies": {
|
|
38
|
-
"@mythicalos/ui-core": "^0.
|
|
38
|
+
"@mythicalos/ui-core": "^0.3.0"
|
|
39
39
|
},
|
|
40
40
|
"scripts": {
|
|
41
41
|
"build": "tsc -p tsconfig.build.json",
|