@tooee/layout 0.7.3 → 0.8.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 +3 -0
- package/dist/app-layout.d.ts +11 -1
- package/dist/app-layout.d.ts.map +1 -1
- package/dist/app-layout.js +8 -2
- package/dist/app-layout.js.map +1 -1
- package/dist/close-button.d.ts +18 -0
- package/dist/close-button.d.ts.map +1 -0
- package/dist/close-button.js +23 -0
- package/dist/close-button.js.map +1 -0
- package/dist/index.d.ts +6 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +3 -0
- package/dist/index.js.map +1 -1
- package/dist/overlay-panel.d.ts +31 -0
- package/dist/overlay-panel.d.ts.map +1 -0
- package/dist/overlay-panel.js +30 -0
- package/dist/overlay-panel.js.map +1 -0
- package/dist/react-content.d.ts +17 -0
- package/dist/react-content.d.ts.map +1 -0
- package/dist/react-content.js +12 -0
- package/dist/react-content.js.map +1 -0
- package/dist/status-bar.d.ts +2 -1
- package/dist/status-bar.d.ts.map +1 -1
- package/dist/status-bar.js.map +1 -1
- package/dist/title-bar.d.ts +2 -1
- package/dist/title-bar.d.ts.map +1 -1
- package/dist/title-bar.js.map +1 -1
- package/package.json +7 -6
- package/src/app-layout.tsx +21 -5
- package/src/close-button.tsx +46 -0
- package/src/index.ts +6 -1
- package/src/overlay-panel.tsx +141 -0
- package/src/react-content.ts +31 -0
- package/src/status-bar.tsx +3 -2
- package/src/title-bar.tsx +2 -1
package/README.md
CHANGED
|
@@ -2,6 +2,9 @@
|
|
|
2
2
|
|
|
3
3
|
Standard app chrome (title bar, status bar) for Tooee.
|
|
4
4
|
|
|
5
|
+
Layout is a composition package by design. It combines theme, command,
|
|
6
|
+
overlay, search, and toast primitives into standard application chrome.
|
|
7
|
+
|
|
5
8
|
Part of the [Tooee](https://github.com/gingerhendrix/tooee) monorepo. See the main repo for documentation.
|
|
6
9
|
|
|
7
10
|
## Overlays
|
package/dist/app-layout.d.ts
CHANGED
|
@@ -2,6 +2,12 @@ import type { ReactNode, RefObject } from "react";
|
|
|
2
2
|
import type { ScrollBoxRenderable } from "@opentui/core";
|
|
3
3
|
import type { StatusBarItem } from "./status-bar.js";
|
|
4
4
|
import type { SearchState } from "@tooee/search";
|
|
5
|
+
export interface AppLayoutScroll {
|
|
6
|
+
ref: RefObject<ScrollBoxRenderable | null>;
|
|
7
|
+
stickyScroll?: boolean;
|
|
8
|
+
stickyStart?: "bottom" | "top";
|
|
9
|
+
focused?: boolean;
|
|
10
|
+
}
|
|
5
11
|
export interface AppLayoutProps {
|
|
6
12
|
titleBar?: {
|
|
7
13
|
title: string;
|
|
@@ -10,7 +16,11 @@ export interface AppLayoutProps {
|
|
|
10
16
|
statusBar: {
|
|
11
17
|
items: StatusBarItem[];
|
|
12
18
|
};
|
|
19
|
+
/** Configure the optional scrollbox used for the main content. */
|
|
20
|
+
scroll?: AppLayoutScroll;
|
|
21
|
+
/** @deprecated Use `scroll.ref` instead. */
|
|
13
22
|
scrollRef?: RefObject<ScrollBoxRenderable | null>;
|
|
23
|
+
/** @deprecated Move these options into `scroll`. */
|
|
14
24
|
scrollProps?: {
|
|
15
25
|
stickyScroll?: boolean;
|
|
16
26
|
stickyStart?: "bottom" | "top";
|
|
@@ -19,5 +29,5 @@ export interface AppLayoutProps {
|
|
|
19
29
|
searchBar?: SearchState;
|
|
20
30
|
children: ReactNode;
|
|
21
31
|
}
|
|
22
|
-
export declare const AppLayout: ({ titleBar, statusBar, scrollRef, scrollProps, searchBar, children, }: AppLayoutProps) => ReactNode;
|
|
32
|
+
export declare const AppLayout: ({ titleBar, statusBar, scroll, scrollRef, scrollProps, searchBar, children, }: AppLayoutProps) => ReactNode;
|
|
23
33
|
//# sourceMappingURL=app-layout.d.ts.map
|
package/dist/app-layout.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"app-layout.d.ts","sourceRoot":"","sources":["../src/app-layout.tsx"],"names":[],"mappings":"AAAA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AAK,CAAC;IAC/B,OAAO,CAAC,EAAE,OAAO,CAAC;CACnB;AAED,MAAM,WAAW,cAAc;IAC7B,QAAQ,CAAC,EAAE;QAAE,KAAK,EAAE,MAAM,CAAC;QAAC,QAAQ,CAAC,EAAE,MAAM,CAAA;KAAE,CAAC;IAChD,SAAS,EAAE;QAAE,KAAK,EAAE,aAAa,EAAE,CAAA;KAAE,CAAC;IACtC,kEAAkE;IAClE,MAAM,CAAC,EAAE,eAAe,CAAC;IACzB,4CAA4C;IAC5C,SAAS,CAAC,EAAE,SAAS,CAAC,mBAAmB,GAAG,IAAI,CAAC,CAAC;IAClD,oDAAoD;IACpD,WAAW,CAAC,EAAE;QACZ,YAAY,CAAC,EAAE,OAAO,CAAC;QACvB,WAAW,CAAC,EAAE,QAAQ,GAAG,KAAK,CAAC;QAC/B,OAAO,CAAC,EAAE,OAAO,CAAC;KACnB,CAAC;IACF,SAAS,CAAC,EAAE,WAAW,CAAC;IACxB,QAAQ,EAAE,SAAS,CAAC;CACrB;AAaD,eAAO,MAAM,SAAS,kFAUnB,cAAc,KAAG,SAmDnB,CAAC"}
|
package/dist/app-layout.js
CHANGED
|
@@ -13,16 +13,22 @@ const hasRenderableOverlay = function hasRenderableOverlay(overlay) {
|
|
|
13
13
|
overlay !== 0 &&
|
|
14
14
|
overlay !== 0n);
|
|
15
15
|
};
|
|
16
|
-
export const AppLayout = function AppLayout({ titleBar, statusBar,
|
|
16
|
+
export const AppLayout = function AppLayout({ titleBar, statusBar, scroll,
|
|
17
|
+
// oxlint-disable-next-line typescript/no-deprecated -- compatibility alias remains supported during its deprecation window
|
|
18
|
+
scrollRef,
|
|
19
|
+
// oxlint-disable-next-line typescript/no-deprecated -- compatibility alias remains supported during its deprecation window
|
|
20
|
+
scrollProps, searchBar, children, }) {
|
|
17
21
|
const { theme } = useTheme();
|
|
18
22
|
const contextOverlay = useCurrentOverlay();
|
|
23
|
+
const resolvedScrollRef = scroll?.ref ?? scrollRef;
|
|
24
|
+
const resolvedScrollProps = scroll ?? scrollProps;
|
|
19
25
|
const handleSearchQueryChange = (query) => {
|
|
20
26
|
searchBar?.setSearchQuery(query);
|
|
21
27
|
};
|
|
22
28
|
const handleSearchSubmit = () => {
|
|
23
29
|
searchBar?.submitSearch();
|
|
24
30
|
};
|
|
25
|
-
return (_jsxs("box", { flexDirection: "column", width: "100%", height: "100%", backgroundColor: theme.background, children: [titleBar && _jsx(TitleBar, { title: titleBar.title, subtitle: titleBar.subtitle }), _jsxs("box", { style: { flexGrow: 1, position: "relative" }, children: [
|
|
31
|
+
return (_jsxs("box", { flexDirection: "column", width: "100%", height: "100%", backgroundColor: theme.background, children: [titleBar && _jsx(TitleBar, { title: titleBar.title, subtitle: titleBar.subtitle }), _jsxs("box", { style: { flexGrow: 1, position: "relative" }, children: [resolvedScrollRef ? (_jsx("scrollbox", { ref: resolvedScrollRef, style: { flexGrow: 1 }, stickyScroll: resolvedScrollProps?.stickyScroll, stickyStart: resolvedScrollProps?.stickyStart, focused: resolvedScrollProps?.focused ?? true, children: children })) : (_jsx("box", { style: { flexGrow: 1, overflow: "hidden" }, children: children })), hasRenderableOverlay(contextOverlay) && (_jsx("box", { position: "absolute", left: 0, top: 0, width: "100%", height: "100%", children: contextOverlay })), _jsx(ToastContainer, {})] }), searchBar?.searchActive === true ? (_jsx(SearchBar, { query: searchBar.searchQuery, onQueryChange: handleSearchQueryChange, onSubmit: handleSearchSubmit, onCancel: () => {
|
|
26
32
|
searchBar.setSearchQuery("");
|
|
27
33
|
}, matchCount: searchBar.matchingLines.length, currentMatch: searchBar.currentMatchIndex })) : (_jsx(StatusBar, { items: statusBar.items }))] }));
|
|
28
34
|
};
|
package/dist/app-layout.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"app-layout.js","sourceRoot":"","sources":["../src/app-layout.tsx"],"names":[],"mappings":";AAEA,OAAO,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAC;AAC1C,OAAO,EAAE,SAAS,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AAS,CAAC,WAAW,EAC5B,aAAa,EAAE,uBAAuB,EACtC,QAAQ,EAAE,kBAAkB,EAC5B,QAAQ,EAAE,GAAG,EAAE;oBACb,SAAS,CAAC,cAAc,CAAC,EAAE,CAAC,CAAC;gBAC/B,CAAC,EACD,UAAU,EAAE,SAAS,CAAC,aAAa,CAAC,MAAM,EAC1C,YAAY,EAAE,SAAS,CAAC,iBAAiB,GACzC,CACH,CAAC,CAAC,CAAC,CACF,KAAC,SAAS,IAAC,KAAK,EAAE,SAAS,CAAC,KAAK,GAAI,CACtC,IACG,CACP,CAAC;AACJ,CAAC,CAAC"}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import type { ReactNode } from "react";
|
|
2
|
+
interface CloseButtonProps {
|
|
3
|
+
/** Called when the button is clicked (left mouse button). */
|
|
4
|
+
onClose: () => void;
|
|
5
|
+
/** Glyph to render (default "✕"). */
|
|
6
|
+
glyph?: string;
|
|
7
|
+
/** Foreground colour (defaults to theme.textMuted). */
|
|
8
|
+
color?: string;
|
|
9
|
+
}
|
|
10
|
+
/**
|
|
11
|
+
* Reusable clickable close control for overlays.
|
|
12
|
+
*
|
|
13
|
+
* Renders a small themed glyph that calls `onClose` on left-click. Purely
|
|
14
|
+
* additive — overlays keep their existing Escape / cancel keyboard paths.
|
|
15
|
+
*/
|
|
16
|
+
export declare const CloseButton: ({ onClose, glyph, color, }: CloseButtonProps) => ReactNode;
|
|
17
|
+
export {};
|
|
18
|
+
//# sourceMappingURL=close-button.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"close-button.d.ts","sourceRoot":"","sources":["../src/close-button.tsx"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AAEvC,UAAU,gBAAgB;IACxB,6DAA6D;IAC7D,OAAO,EAAE,MAAM,IAAI,CAAC;IACpB,qCAAqC;IACrC,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,uDAAuD;IACvD,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB;AAED;;;;;GAKG;AACH,eAAO,MAAM,WAAW,+BAIrB,gBAAgB,KAAG,SAqBrB,CAAC"}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { jsx as _jsx } from "@opentui/react/jsx-runtime";
|
|
2
|
+
import { useCallback } from "react";
|
|
3
|
+
import { useTheme } from "@tooee/themes";
|
|
4
|
+
/**
|
|
5
|
+
* Reusable clickable close control for overlays.
|
|
6
|
+
*
|
|
7
|
+
* Renders a small themed glyph that calls `onClose` on left-click. Purely
|
|
8
|
+
* additive — overlays keep their existing Escape / cancel keyboard paths.
|
|
9
|
+
*/
|
|
10
|
+
export const CloseButton = function CloseButton({ onClose, glyph = "✕", color, }) {
|
|
11
|
+
const { theme } = useTheme();
|
|
12
|
+
const handleMouseDown = useCallback((event) => {
|
|
13
|
+
// Left button only; let other buttons bubble.
|
|
14
|
+
if (event.button !== 0) {
|
|
15
|
+
return;
|
|
16
|
+
}
|
|
17
|
+
event.preventDefault();
|
|
18
|
+
event.stopPropagation();
|
|
19
|
+
onClose();
|
|
20
|
+
}, [onClose]);
|
|
21
|
+
return (_jsx("box", { flexShrink: 0, paddingLeft: 1, onMouseDown: handleMouseDown, children: _jsx("text", { content: glyph, fg: color ?? theme.textMuted }) }));
|
|
22
|
+
};
|
|
23
|
+
//# sourceMappingURL=close-button.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"close-button.js","sourceRoot":"","sources":["../src/close-button.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,OAAO,CAAC;AAEpC,OAAO,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAC;AAYzC;;;;;GAKG;AACH,MAAM,CAAC,MAAM,WAAW,GAAG,SAAS,WAAW,CAAC,EAC9C,OAAO,EACP,KAAK,GAAG,GAAG,EACX,KAAK,GACY;IACjB,MAAM,EAAE,KAAK,EAAE,GAAG,QAAQ,EAAE,CAAC;IAE7B,MAAM,eAAe,GAAG,WAAW,CACjC,CAAC,KAAiB,EAAE,EAAE;QACpB,8CAA8C;QAC9C,IAAI,KAAK,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;YACvB,OAAO;QACT,CAAC;QACD,KAAK,CAAC,cAAc,EAAE,CAAC;QACvB,KAAK,CAAC,eAAe,EAAE,CAAC;QACxB,OAAO,EAAE,CAAC;IACZ,CAAC,EACD,CAAC,OAAO,CAAC,CACV,CAAC;IAEF,OAAO,CACL,cAAK,UAAU,EAAE,CAAC,EAAE,WAAW,EAAE,CAAC,EAAE,WAAW,EAAE,eAAe,YAC9D,eAAM,OAAO,EAAE,KAAK,EAAE,EAAE,EAAE,KAAK,IAAI,KAAK,CAAC,SAAS,GAAI,GAClD,CACP,CAAC;AACJ,CAAC,CAAC"}
|
package/dist/index.d.ts
CHANGED
|
@@ -1,5 +1,10 @@
|
|
|
1
1
|
export { AppLayout } from "./app-layout.js";
|
|
2
|
-
export type { AppLayoutProps } from "./app-layout.js";
|
|
2
|
+
export type { AppLayoutProps, AppLayoutScroll } from "./app-layout.js";
|
|
3
|
+
export { CloseButton } from "./close-button.js";
|
|
4
|
+
export { OverlayPanel } from "./overlay-panel.js";
|
|
5
|
+
export type { OverlayPanelProps, PanelInset, PanelInsetValue } from "./overlay-panel.js";
|
|
6
|
+
export { decodeReactContent } from "./react-content.js";
|
|
7
|
+
export type { DecodedReactContent } from "./react-content.js";
|
|
3
8
|
export { StatusBar } from "./status-bar.js";
|
|
4
9
|
export type { StatusBarItem } from "./status-bar.js";
|
|
5
10
|
export { TitleBar } from "./title-bar.js";
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAC5C,YAAY,EAAE,cAAc,EAAE,MAAM,iBAAiB,CAAC;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAC5C,YAAY,EAAE,cAAc,EAAE,eAAe,EAAE,MAAM,iBAAiB,CAAC;AACvE,OAAO,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAChD,OAAO,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAClD,YAAY,EAAE,iBAAiB,EAAE,UAAU,EAAE,eAAe,EAAE,MAAM,oBAAoB,CAAC;AACzF,OAAO,EAAE,kBAAkB,EAAE,MAAM,oBAAoB,CAAC;AACxD,YAAY,EAAE,mBAAmB,EAAE,MAAM,oBAAoB,CAAC;AAC9D,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAC5C,YAAY,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AACrD,OAAO,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAC"}
|
package/dist/index.js
CHANGED
|
@@ -1,4 +1,7 @@
|
|
|
1
1
|
export { AppLayout } from "./app-layout.js";
|
|
2
|
+
export { CloseButton } from "./close-button.js";
|
|
3
|
+
export { OverlayPanel } from "./overlay-panel.js";
|
|
4
|
+
export { decodeReactContent } from "./react-content.js";
|
|
2
5
|
export { StatusBar } from "./status-bar.js";
|
|
3
6
|
export { TitleBar } from "./title-bar.js";
|
|
4
7
|
//# sourceMappingURL=index.js.map
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAE5C,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAE5C,OAAO,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAE5C,OAAO,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAChD,OAAO,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAElD,OAAO,EAAE,kBAAkB,EAAE,MAAM,oBAAoB,CAAC;AAExD,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAE5C,OAAO,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAC"}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import type { ReactNode } from "react";
|
|
2
|
+
import type { MouseEvent } from "@opentui/core";
|
|
3
|
+
export type PanelInsetValue = number | "auto" | `${number}%`;
|
|
4
|
+
export interface PanelInset {
|
|
5
|
+
left?: PanelInsetValue;
|
|
6
|
+
right?: PanelInsetValue;
|
|
7
|
+
top?: PanelInsetValue;
|
|
8
|
+
bottom?: PanelInsetValue;
|
|
9
|
+
}
|
|
10
|
+
export interface OverlayPanelProps {
|
|
11
|
+
/** Title bar content. Primitive text uses the active accent color. */
|
|
12
|
+
title?: ReactNode;
|
|
13
|
+
/** Content between the title bar and main panel body. */
|
|
14
|
+
prompt?: ReactNode;
|
|
15
|
+
children: ReactNode;
|
|
16
|
+
/** Extra row below the body and above the hint bar. */
|
|
17
|
+
footer?: ReactNode;
|
|
18
|
+
/** Left-aligned hint bar content. */
|
|
19
|
+
hints?: ReactNode;
|
|
20
|
+
/** Right-aligned status area in the hint bar. */
|
|
21
|
+
statusRight?: ReactNode;
|
|
22
|
+
/** Overlay geometry when absolutely positioned. Defaults to 20% on all sides. */
|
|
23
|
+
inset?: PanelInset;
|
|
24
|
+
/** Show a title-bar close button. */
|
|
25
|
+
onClose?: () => void;
|
|
26
|
+
/** Mouse handler for the whole panel. */
|
|
27
|
+
onMouseDown?: (event: MouseEvent) => void;
|
|
28
|
+
}
|
|
29
|
+
/** Shared bordered chrome for modal overlay panels. */
|
|
30
|
+
export declare const OverlayPanel: ({ title, prompt, children, footer, hints, statusRight, inset, onClose, onMouseDown, }: OverlayPanelProps) => ReactNode;
|
|
31
|
+
//# sourceMappingURL=overlay-panel.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"overlay-panel.d.ts","sourceRoot":"","sources":["../src/overlay-panel.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AACvC,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AAMhD,MAAM,MAAM,eAAe,GAAG,MAAM,GAAG,MAAM,GAAG,GAAG,MAAM,GAAG,CAAC;AAE7D,MAAM,WAAW,UAAU;IACzB,IAAI,CAAC,EAAE,eAAe,CAAC;IACvB,KAAK,CAAC,EAAE,eAAe,CAAC;IACxB,GAAG,CAAC,EAAE,eAAe,CAAC;IACtB,MAAM,CAAC,EAAE,eAAe,CAAC;CAC1B;AAED,MAAM,WAAW,iBAAiB;IAChC,sEAAsE;IACtE,KAAK,CAAC,EAAE,SAAS,CAAC;IAClB,yDAAyD;IACzD,MAAM,CAAC,EAAE,SAAS,CAAC;IACnB,QAAQ,EAAE,SAAS,CAAC;IACpB,uDAAuD;IACvD,MAAM,CAAC,EAAE,SAAS,CAAC;IACnB,qCAAqC;IACrC,KAAK,CAAC,EAAE,SAAS,CAAC;IAClB,iDAAiD;IACjD,WAAW,CAAC,EAAE,SAAS,CAAC;IACxB,iFAAiF;IACjF,KAAK,CAAC,EAAE,UAAU,CAAC;IACnB,qCAAqC;IACrC,OAAO,CAAC,EAAE,MAAM,IAAI,CAAC;IACrB,yCAAyC;IACzC,WAAW,CAAC,EAAE,CAAC,KAAK,EAAE,UAAU,KAAK,IAAI,CAAC;CAC3C;AA+BD,uDAAuD;AACvD,eAAO,MAAM,YAAY,0FAUtB,iBAAiB,KAAG,SAgEtB,CAAC"}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "@opentui/react/jsx-runtime";
|
|
2
|
+
import { useTheme } from "@tooee/themes";
|
|
3
|
+
import { CloseButton } from "./close-button.js";
|
|
4
|
+
import { decodeReactContent } from "./react-content.js";
|
|
5
|
+
const renderThemedContent = function renderThemedContent(content, color) {
|
|
6
|
+
if (content.kind === "empty") {
|
|
7
|
+
return null;
|
|
8
|
+
}
|
|
9
|
+
return content.kind === "string" ? _jsx("text", { content: content.value, fg: color }) : content.value;
|
|
10
|
+
};
|
|
11
|
+
const renderPrompt = function renderPrompt(prompt, textColor) {
|
|
12
|
+
if (prompt.kind === "empty") {
|
|
13
|
+
return null;
|
|
14
|
+
}
|
|
15
|
+
if (prompt.kind === "node") {
|
|
16
|
+
return prompt.value;
|
|
17
|
+
}
|
|
18
|
+
return (_jsx("box", { paddingLeft: 1, paddingRight: 1, children: _jsx("text", { fg: textColor, children: _jsx("strong", { children: prompt.value }) }) }));
|
|
19
|
+
};
|
|
20
|
+
/** Shared bordered chrome for modal overlay panels. */
|
|
21
|
+
export const OverlayPanel = function OverlayPanel({ title, prompt, children, footer, hints, statusRight, inset, onClose, onMouseDown, }) {
|
|
22
|
+
const { theme } = useTheme();
|
|
23
|
+
const decodedTitle = decodeReactContent(title);
|
|
24
|
+
const decodedPrompt = decodeReactContent(prompt);
|
|
25
|
+
const decodedFooter = decodeReactContent(footer);
|
|
26
|
+
const decodedHints = decodeReactContent(hints);
|
|
27
|
+
const decodedStatus = decodeReactContent(statusRight);
|
|
28
|
+
return (_jsxs("box", { position: "absolute", left: inset?.left ?? "20%", right: inset?.right ?? "20%", top: inset?.top ?? "20%", bottom: inset?.bottom ?? "20%", flexDirection: "column", backgroundColor: theme.backgroundPanel, border: true, borderColor: theme.borderActive, onMouseDown: onMouseDown, children: [decodedTitle.kind !== "empty" && (_jsxs("box", { flexDirection: "row", height: 1, paddingLeft: 1, paddingRight: 1, backgroundColor: theme.backgroundElement, children: [decodedTitle.kind === "string" ? (_jsx("text", { content: decodedTitle.value, fg: theme.accent, style: { flexGrow: 1 } })) : (_jsx("box", { flexDirection: "row", style: { flexGrow: 1 }, children: decodedTitle.value })), onClose && _jsx(CloseButton, { onClose: onClose })] })), renderPrompt(decodedPrompt, theme.text), children, decodedFooter.kind !== "empty" && (_jsx("box", { height: 1, paddingLeft: 1, paddingRight: 1, children: decodedFooter.value })), _jsxs("box", { flexDirection: "row", height: 1, paddingLeft: 1, paddingRight: 1, backgroundColor: theme.backgroundElement, children: [_jsx("box", { flexDirection: "row", style: { flexGrow: 1 }, children: renderThemedContent(decodedHints, theme.textMuted) }), renderThemedContent(decodedStatus, theme.textMuted)] })] }));
|
|
29
|
+
};
|
|
30
|
+
//# sourceMappingURL=overlay-panel.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"overlay-panel.js","sourceRoot":"","sources":["../src/overlay-panel.tsx"],"names":[],"mappings":";AAEA,OAAO,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAC;AACzC,OAAO,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAChD,OAAO,EAAE,kBAAkB,EAAE,MAAM,oBAAoB,CAAC;AAgCxD,MAAM,mBAAmB,GAAG,SAAS,mBAAmB,CACtD,OAA4B,EAC5B,KAAa;IAEb,IAAI,OAAO,CAAC,IAAI,KAAK,OAAO,EAAE,CAAC;QAC7B,OAAO,IAAI,CAAC;IACd,CAAC;IACD,OAAO,OAAO,CAAC,IAAI,KAAK,QAAQ,CAAC,CAAC,CAAC,eAAM,OAAO,EAAE,OAAO,CAAC,KAAK,EAAE,EAAE,EAAE,KAAK,GAAI,CAAC,CAAC,CAAC,OAAO,CAAC,KAAK,CAAC;AACjG,CAAC,CAAC;AAEF,MAAM,YAAY,GAAG,SAAS,YAAY,CACxC,MAA2B,EAC3B,SAAiB;IAEjB,IAAI,MAAM,CAAC,IAAI,KAAK,OAAO,EAAE,CAAC;QAC5B,OAAO,IAAI,CAAC;IACd,CAAC;IACD,IAAI,M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ent {
|
|
6
|
+
kind: "string";
|
|
7
|
+
value: string;
|
|
8
|
+
}
|
|
9
|
+
interface NodeReactContent {
|
|
10
|
+
kind: "node";
|
|
11
|
+
value: ReactNode;
|
|
12
|
+
}
|
|
13
|
+
export type DecodedReactContent = EmptyReactContent | StringReactContent | NodeReactContent;
|
|
14
|
+
/** Decode a public React slot once into its three rendering cases. */
|
|
15
|
+
export declare const decodeReactContent: (content: ReactNode) => DecodedReactContent;
|
|
16
|
+
export {};
|
|
17
|
+
//# sourceMappingURL=react-content.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"react-content.d.ts","sourceRoot":"","sources":["../src/react-content.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AAEvC,UAAU,iBAAiB;IACzB,IAAI,EAAE,OAAO,CAAC;CACf;AAED,UAAU,kBAAkB;IAC1B,IAAI,EAAE,QAAQ,CAAC;IACf,KAAK,EAAE,MAAM,CAAC;CACf;AAED,UAAU,gBAAgB;IACxB,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,EAAE,SAAS,CAAC;CAClB;AAED,MAAM,MAAM,mBAAmB,GAAG,iBAAiB,GAAG,kBAAkB,GAAG,gBAAgB,CAAC;AAE5F,sEAAsE;AACtE,eAAO,MAAM,kBAAkB,YACpB,SAAS,KACjB,mBASF,CAAC"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/** Decode a public React slot once into its three rendering cases. */
|
|
2
|
+
export const decodeReactContent = function decodeReactContent(content) {
|
|
3
|
+
if (content === null || content === undefined) {
|
|
4
|
+
return { kind: "empty" };
|
|
5
|
+
}
|
|
6
|
+
// oxlint-disable-next-line anti-slop/no-runtime-typeof -- ReactNode boundary distinguishes themed primitive text from nodes rendered by React
|
|
7
|
+
if (typeof content === "string") {
|
|
8
|
+
return { kind: "string", value: content };
|
|
9
|
+
}
|
|
10
|
+
return { kind: "node", value: content };
|
|
11
|
+
};
|
|
12
|
+
//# sourceMappingURL=react-content.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"react-content.js","sourceRoot":"","sources":["../src/react-content.ts"],"names":[],"mappings":"AAkBA,sEAAsE;AACtE,MAAM,CAAC,MAAM,kBAAkB,GAAG,SAAS,kBAAkB,CAC3D,OAAkB;IAElB,IAAI,OAAO,KAAK,IAAI,IAAI,OAAO,KAAK,SAAS,EAAE,CAAC;QAC9C,OAAO,EAAE,IAAI,EAAE,OAAO,EAAE,CAAC;IAC3B,CAAC;IACD,8IAA8I;IAC9I,IAAI,OAAO,OAAO,KAAK,QAAQ,EAAE,CAAC;QAChC,OAAO,EAAE,IAAI,EAAE,QAAQ,EAAE,KAAK,EAAE,OAAO,EAAE,CAAC;IAC5C,CAAC;IACD,OAAO,EAAE,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,OAAO,EAAE,CAAC;AAC1C,CAAC,CAAC"}
|
package/dist/status-bar.d.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import type { ReactNode } from "react";
|
|
1
2
|
interface StatusBarProps {
|
|
2
3
|
items: StatusBarItem[];
|
|
3
4
|
}
|
|
@@ -5,6 +6,6 @@ export interface StatusBarItem {
|
|
|
5
6
|
label: string;
|
|
6
7
|
value?: string;
|
|
7
8
|
}
|
|
8
|
-
export declare const StatusBar: ({ items }: StatusBarProps) =>
|
|
9
|
+
export declare const StatusBar: ({ items }: StatusBarProps) => ReactNode;
|
|
9
10
|
export {};
|
|
10
11
|
//# sourceMappingURL=status-bar.d.ts.map
|
package/dist/status-bar.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"status-bar.d.ts","sourceRoot":"","sources":["../src/status-bar.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"status-bar.d.ts","sourceRoot":"","sources":["../src/status-bar.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AAEvC,UAAU,cAAc;IACtB,KAAK,EAAE,aAAa,EAAE,CAAC;CACxB;AAED,MAAM,WAAW,aAAa;IAC5B,KAAK,EAAE,MAAM,CAAC;IACd,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB;AAED,eAAO,MAAM,SAAS,cAAiC,cAAc,KAAG,SAyBvE,CAAC"}
|
package/dist/status-bar.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"status-bar.js","sourceRoot":"","sources":["../src/status-bar.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAC;
|
|
1
|
+
{"version":3,"file":"status-bar.js","sourceRoot":"","sources":["../src/status-bar.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAC;AAYzC,MAAM,CAAC,MAAM,SAAS,GAAG,SAAS,SAAS,CAAC,EAAE,KAAK,EAAkB;IACnE,MAAM,EAAE,KAAK,EAAE,GAAG,QAAQ,EAAE,CAAC;IAC7B,OAAO,CACL,cACE,KAAK,EAAE;YACL,eAAe,EAAE,KAAK,CAAC,eAAe;YACtC,aAAa,EAAE,KAAK;YACpB,UAAU,EAAE,CAAC;YACb,OAAO,EAAE,CAAC;YACV,WAAW,EAAE,CAAC;YACd,YAAY,EAAE,CAAC;SAChB,YAEA,KAAK,CAAC,GAAG,CACR,CAAC,IAAI,EAAE,KAAK,EAAa,EAAE,CAAC,CAC1B,eAAiB,KAAK,EAAE,EAAE,aAAa,EAAE,KAAK,EAAE,WAAW,EAAE,CAAC,EAAE,aAC9D,eAAM,OAAO,EAAE,IAAI,CAAC,KAAK,EAAE,KAAK,EAAE,EAAE,EAAE,EAAE,KAAK,CAAC,SAAS,EAAE,GAAI,EAC5D,CAAC,IAAI,CAAC,KAAK,EAAE,MAAM,IAAI,CAAC,CAAC,GAAG,CAAC,IAAI,CAChC,eAAM,OAAO,EAAE,IAAI,IAAI,CAAC,KAAK,EAAE,EAAE,KAAK,EAAE,EAAE,EAAE,EAAE,KAAK,CAAC,IAAI,EAAE,GAAI,CAC/D,KAJO,KAAK,CAKT,CACP,CACF,GACG,CACP,CAAC;AACJ,CAAC,CAAC"}
|
package/dist/title-bar.d.ts
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
|
+
import type { ReactNode } from "react";
|
|
1
2
|
interface TitleBarProps {
|
|
2
3
|
title: string;
|
|
3
4
|
subtitle?: string;
|
|
4
5
|
}
|
|
5
|
-
export declare const TitleBar: ({ title, subtitle }: TitleBarProps) =>
|
|
6
|
+
export declare const TitleBar: ({ title, subtitle }: TitleBarProps) => ReactNode;
|
|
6
7
|
export {};
|
|
7
8
|
//# sourceMappingURL=title-bar.d.ts.map
|
package/dist/title-bar.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"title-bar.d.ts","sourceRoot":"","sources":["../src/title-bar.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"title-bar.d.ts","sourceRoot":"","sources":["../src/title-bar.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AAEvC,UAAU,aAAa;IACrB,KAAK,EAAE,MAAM,CAAC;IACd,QAAQ,CAAC,EAAE,MAAM,CAAC;CACnB;AAED,eAAO,MAAM,QAAQ,wBAA0C,aAAa,KAAG,SAmB9E,CAAC"}
|
package/dist/title-bar.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"title-bar.js","sourceRoot":"","sources":["../src/title-bar.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAC;
|
|
1
|
+
{"version":3,"file":"title-bar.js","sourceRoot":"","sources":["../src/title-bar.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAC;AAQzC,MAAM,CAAC,MAAM,QAAQ,GAAG,SAAS,QAAQ,CAAC,EAAE,KAAK,EAAE,QAAQ,EAAiB;IAC1E,MAAM,EAAE,KAAK,EAAE,GAAG,QAAQ,EAAE,CAAC;IAC7B,OAAO,CACL,eACE,KAAK,EAAE;YACL,eAAe,EAAE,KAAK,CAAC,eAAe;YACtC,aAAa,EAAE,KAAK;YACpB,UAAU,EAAE,CAAC;YACb,OAAO,EAAE,CAAC;YACV,WAAW,EAAE,CAAC;YACd,YAAY,EAAE,CAAC;SAChB,aAED,eAAM,OAAO,EAAE,KAAK,EAAE,KAAK,EAAE,EAAE,EAAE,EAAE,KAAK,CAAC,OAAO,EAAE,GAAI,EACrD,CAAC,QAAQ,EAAE,MAAM,IAAI,CAAC,CAAC,GAAG,CAAC,IAAI,CAC9B,eAAM,OAAO,EAAE,MAAM,QAAQ,EAAE,EAAE,KAAK,EAAE,EAAE,EAAE,EAAE,KAAK,CAAC,SAAS,EAAE,GAAI,CACpE,IACG,CACP,CAAC;AACJ,CAAC,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tooee/layout",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.8.0",
|
|
4
4
|
"description": "Standard app chrome (title bar, status bar) for Tooee",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"cli",
|
|
@@ -38,15 +38,16 @@
|
|
|
38
38
|
"typecheck": "tsc --noEmit"
|
|
39
39
|
},
|
|
40
40
|
"dependencies": {
|
|
41
|
-
"@tooee/commands": "0.
|
|
42
|
-
"@tooee/overlays": "0.
|
|
43
|
-
"@tooee/search": "0.
|
|
44
|
-
"@tooee/themes": "0.
|
|
45
|
-
"@tooee/toasts": "0.
|
|
41
|
+
"@tooee/commands": "0.8.0",
|
|
42
|
+
"@tooee/overlays": "0.8.0",
|
|
43
|
+
"@tooee/search": "0.8.0",
|
|
44
|
+
"@tooee/themes": "0.8.0",
|
|
45
|
+
"@tooee/toasts": "0.8.0"
|
|
46
46
|
},
|
|
47
47
|
"devDependencies": {
|
|
48
48
|
"@opentui/core": "^0.5.1",
|
|
49
49
|
"@opentui/react": "^0.5.1",
|
|
50
|
+
"@tooee/test-support": "0.7.3",
|
|
50
51
|
"@types/bun": "^1.3.10",
|
|
51
52
|
"@types/react": "^19.2.14",
|
|
52
53
|
"typescript": "^5.9.3"
|
package/src/app-layout.tsx
CHANGED
|
@@ -9,10 +9,21 @@ import { useTheme } from "@tooee/themes";
|
|
|
9
9
|
import { useCurrentOverlay } from "@tooee/overlays";
|
|
10
10
|
import { ToastContainer } from "@tooee/toasts";
|
|
11
11
|
|
|
12
|
+
export interface AppLayoutScroll {
|
|
13
|
+
ref: RefObject<ScrollBoxRenderable | null>;
|
|
14
|
+
stickyScroll?: boolean;
|
|
15
|
+
stickyStart?: "bottom" | "top";
|
|
16
|
+
focused?: boolean;
|
|
17
|
+
}
|
|
18
|
+
|
|
12
19
|
export interface AppLayoutProps {
|
|
13
20
|
titleBar?: { title: string; subtitle?: string };
|
|
14
21
|
statusBar: { items: StatusBarItem[] };
|
|
22
|
+
/** Configure the optional scrollbox used for the main content. */
|
|
23
|
+
scroll?: AppLayoutScroll;
|
|
24
|
+
/** @deprecated Use `scroll.ref` instead. */
|
|
15
25
|
scrollRef?: RefObject<ScrollBoxRenderable | null>;
|
|
26
|
+
/** @deprecated Move these options into `scroll`. */
|
|
16
27
|
scrollProps?: {
|
|
17
28
|
stickyScroll?: boolean;
|
|
18
29
|
stickyStart?: "bottom" | "top";
|
|
@@ -36,13 +47,18 @@ const hasRenderableOverlay = function hasRenderableOverlay(overlay: ReactNode):
|
|
|
36
47
|
export const AppLayout = function AppLayout({
|
|
37
48
|
titleBar,
|
|
38
49
|
statusBar,
|
|
50
|
+
scroll,
|
|
51
|
+
// oxlint-disable-next-line typescript/no-deprecated -- compatibility alias remains supported during its deprecation window
|
|
39
52
|
scrollRef,
|
|
53
|
+
// oxlint-disable-next-line typescript/no-deprecated -- compatibility alias remains supported during its deprecation window
|
|
40
54
|
scrollProps,
|
|
41
55
|
searchBar,
|
|
42
56
|
children,
|
|
43
57
|
}: AppLayoutProps): ReactNode {
|
|
44
58
|
const { theme } = useTheme();
|
|
45
59
|
const contextOverlay = useCurrentOverlay();
|
|
60
|
+
const resolvedScrollRef = scroll?.ref ?? scrollRef;
|
|
61
|
+
const resolvedScrollProps = scroll ?? scrollProps;
|
|
46
62
|
const handleSearchQueryChange = (query: string): void => {
|
|
47
63
|
searchBar?.setSearchQuery(query);
|
|
48
64
|
};
|
|
@@ -53,13 +69,13 @@ export const AppLayout = function AppLayout({
|
|
|
53
69
|
<box flexDirection="column" width="100%" height="100%" backgroundColor={theme.background}>
|
|
54
70
|
{titleBar && <TitleBar title={titleBar.title} subtitle={titleBar.subtitle} />}
|
|
55
71
|
<box style={{ flexGrow: 1, position: "relative" }}>
|
|
56
|
-
{
|
|
72
|
+
{resolvedScrollRef ? (
|
|
57
73
|
<scrollbox
|
|
58
|
-
ref={
|
|
74
|
+
ref={resolvedScrollRef}
|
|
59
75
|
style={{ flexGrow: 1 }}
|
|
60
|
-
stickyScroll={
|
|
61
|
-
stickyStart={
|
|
62
|
-
focused={
|
|
76
|
+
stickyScroll={resolvedScrollProps?.stickyScroll}
|
|
77
|
+
stickyStart={resolvedScrollProps?.stickyStart}
|
|
78
|
+
focused={resolvedScrollProps?.focused ?? true}
|
|
63
79
|
>
|
|
64
80
|
{children}
|
|
65
81
|
</scrollbox>
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import { useCallback } from "react";
|
|
2
|
+
import type { MouseEvent } from "@opentui/core";
|
|
3
|
+
import { useTheme } from "@tooee/themes";
|
|
4
|
+
import type { ReactNode } from "react";
|
|
5
|
+
|
|
6
|
+
interface CloseButtonProps {
|
|
7
|
+
/** Called when the button is clicked (left mouse button). */
|
|
8
|
+
onClose: () => void;
|
|
9
|
+
/** Glyph to render (default "✕"). */
|
|
10
|
+
glyph?: string;
|
|
11
|
+
/** Foreground colour (defaults to theme.textMuted). */
|
|
12
|
+
color?: string;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
/**
|
|
16
|
+
* Reusable clickable close control for overlays.
|
|
17
|
+
*
|
|
18
|
+
* Renders a small themed glyph that calls `onClose` on left-click. Purely
|
|
19
|
+
* additive — overlays keep their existing Escape / cancel keyboard paths.
|
|
20
|
+
*/
|
|
21
|
+
export const CloseButton = function CloseButton({
|
|
22
|
+
onClose,
|
|
23
|
+
glyph = "✕",
|
|
24
|
+
color,
|
|
25
|
+
}: CloseButtonProps): ReactNode {
|
|
26
|
+
const { theme } = useTheme();
|
|
27
|
+
|
|
28
|
+
const handleMouseDown = useCallback(
|
|
29
|
+
(event: MouseEvent) => {
|
|
30
|
+
// Left button only; let other buttons bubble.
|
|
31
|
+
if (event.button !== 0) {
|
|
32
|
+
return;
|
|
33
|
+
}
|
|
34
|
+
event.preventDefault();
|
|
35
|
+
event.stopPropagation();
|
|
36
|
+
onClose();
|
|
37
|
+
},
|
|
38
|
+
[onClose],
|
|
39
|
+
);
|
|
40
|
+
|
|
41
|
+
return (
|
|
42
|
+
<box flexShrink={0} paddingLeft={1} onMouseDown={handleMouseDown}>
|
|
43
|
+
<text content={glyph} fg={color ?? theme.textMuted} />
|
|
44
|
+
</box>
|
|
45
|
+
);
|
|
46
|
+
};
|
package/src/index.ts
CHANGED
|
@@ -1,5 +1,10 @@
|
|
|
1
1
|
export { AppLayout } from "./app-layout.js";
|
|
2
|
-
export type { AppLayoutProps } from "./app-layout.js";
|
|
2
|
+
export type { AppLayoutProps, AppLayoutScroll } from "./app-layout.js";
|
|
3
|
+
export { CloseButton } from "./close-button.js";
|
|
4
|
+
export { OverlayPanel } from "./overlay-panel.js";
|
|
5
|
+
export type { OverlayPanelProps, PanelInset, PanelInsetValue } from "./overlay-panel.js";
|
|
6
|
+
export { decodeReactContent } from "./react-content.js";
|
|
7
|
+
export type { DecodedReactContent } from "./react-content.js";
|
|
3
8
|
export { StatusBar } from "./status-bar.js";
|
|
4
9
|
export type { StatusBarItem } from "./status-bar.js";
|
|
5
10
|
export { TitleBar } from "./title-bar.js";
|
|
@@ -0,0 +1,141 @@
|
|
|
1
|
+
import type { ReactNode } from "react";
|
|
2
|
+
import type { MouseEvent } from "@opentui/core";
|
|
3
|
+
import { useTheme } from "@tooee/themes";
|
|
4
|
+
import { CloseButton } from "./close-button.js";
|
|
5
|
+
import { decodeReactContent } from "./react-content.js";
|
|
6
|
+
import type { DecodedReactContent } from "./react-content.js";
|
|
7
|
+
|
|
8
|
+
export type PanelInsetValue = number | "auto" | `${number}%`;
|
|
9
|
+
|
|
10
|
+
export interface PanelInset {
|
|
11
|
+
left?: PanelInsetValue;
|
|
12
|
+
right?: PanelInsetValue;
|
|
13
|
+
top?: PanelInsetValue;
|
|
14
|
+
bottom?: PanelInsetValue;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
export interface OverlayPanelProps {
|
|
18
|
+
/** Title bar content. Primitive text uses the active accent color. */
|
|
19
|
+
title?: ReactNode;
|
|
20
|
+
/** Content between the title bar and main panel body. */
|
|
21
|
+
prompt?: ReactNode;
|
|
22
|
+
children: ReactNode;
|
|
23
|
+
/** Extra row below the body and above the hint bar. */
|
|
24
|
+
footer?: ReactNode;
|
|
25
|
+
/** Left-aligned hint bar content. */
|
|
26
|
+
hints?: ReactNode;
|
|
27
|
+
/** Right-aligned status area in the hint bar. */
|
|
28
|
+
statusRight?: ReactNode;
|
|
29
|
+
/** Overlay geometry when absolutely positioned. Defaults to 20% on all sides. */
|
|
30
|
+
inset?: PanelInset;
|
|
31
|
+
/** Show a title-bar close button. */
|
|
32
|
+
onClose?: () => void;
|
|
33
|
+
/** Mouse handler for the whole panel. */
|
|
34
|
+
onMouseDown?: (event: MouseEvent) => void;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
const renderThemedContent = function renderThemedContent(
|
|
38
|
+
content: DecodedReactContent,
|
|
39
|
+
color: string,
|
|
40
|
+
): ReactNode {
|
|
41
|
+
if (content.kind === "empty") {
|
|
42
|
+
return null;
|
|
43
|
+
}
|
|
44
|
+
return content.kind === "string" ? <text content={content.value} fg={color} /> : content.value;
|
|
45
|
+
};
|
|
46
|
+
|
|
47
|
+
const renderPrompt = function renderPrompt(
|
|
48
|
+
prompt: DecodedReactContent,
|
|
49
|
+
textColor: string,
|
|
50
|
+
): ReactNode {
|
|
51
|
+
if (prompt.kind === "empty") {
|
|
52
|
+
return null;
|
|
53
|
+
}
|
|
54
|
+
if (prompt.kind === "node") {
|
|
55
|
+
return prompt.value;
|
|
56
|
+
}
|
|
57
|
+
return (
|
|
58
|
+
<box paddingLeft={1} paddingRight={1}>
|
|
59
|
+
<text fg={textColor}>
|
|
60
|
+
<strong>{prompt.value}</strong>
|
|
61
|
+
</text>
|
|
62
|
+
</box>
|
|
63
|
+
);
|
|
64
|
+
};
|
|
65
|
+
|
|
66
|
+
/** Shared bordered chrome for modal overlay panels. */
|
|
67
|
+
export const OverlayPanel = function OverlayPanel({
|
|
68
|
+
title,
|
|
69
|
+
prompt,
|
|
70
|
+
children,
|
|
71
|
+
footer,
|
|
72
|
+
hints,
|
|
73
|
+
statusRight,
|
|
74
|
+
inset,
|
|
75
|
+
onClose,
|
|
76
|
+
onMouseDown,
|
|
77
|
+
}: OverlayPanelProps): ReactNode {
|
|
78
|
+
const { theme } = useTheme();
|
|
79
|
+
const decodedTitle = decodeReactContent(title);
|
|
80
|
+
const decodedPrompt = decodeReactContent(prompt);
|
|
81
|
+
const decodedFooter = decodeReactContent(footer);
|
|
82
|
+
const decodedHints = decodeReactContent(hints);
|
|
83
|
+
const decodedStatus = decodeReactContent(statusRight);
|
|
84
|
+
|
|
85
|
+
return (
|
|
86
|
+
<box
|
|
87
|
+
position="absolute"
|
|
88
|
+
left={inset?.left ?? "20%"}
|
|
89
|
+
right={inset?.right ?? "20%"}
|
|
90
|
+
top={inset?.top ?? "20%"}
|
|
91
|
+
bottom={inset?.bottom ?? "20%"}
|
|
92
|
+
flexDirection="column"
|
|
93
|
+
backgroundColor={theme.backgroundPanel}
|
|
94
|
+
border
|
|
95
|
+
borderColor={theme.borderActive}
|
|
96
|
+
onMouseDown={onMouseDown}
|
|
97
|
+
>
|
|
98
|
+
{decodedTitle.kind !== "empty" && (
|
|
99
|
+
<box
|
|
100
|
+
flexDirection="row"
|
|
101
|
+
height={1}
|
|
102
|
+
paddingLeft={1}
|
|
103
|
+
paddingRight={1}
|
|
104
|
+
backgroundColor={theme.backgroundElement}
|
|
105
|
+
>
|
|
106
|
+
{decodedTitle.kind === "string" ? (
|
|
107
|
+
<text content={decodedTitle.value} fg={theme.accent} style={{ flexGrow: 1 }} />
|
|
108
|
+
) : (
|
|
109
|
+
<box flexDirection="row" style={{ flexGrow: 1 }}>
|
|
110
|
+
{decodedTitle.value}
|
|
111
|
+
</box>
|
|
112
|
+
)}
|
|
113
|
+
{onClose && <CloseButton onClose={onClose} />}
|
|
114
|
+
</box>
|
|
115
|
+
)}
|
|
116
|
+
|
|
117
|
+
{renderPrompt(decodedPrompt, theme.text)}
|
|
118
|
+
|
|
119
|
+
{children}
|
|
120
|
+
|
|
121
|
+
{decodedFooter.kind !== "empty" && (
|
|
122
|
+
<box height={1} paddingLeft={1} paddingRight={1}>
|
|
123
|
+
{decodedFooter.value}
|
|
124
|
+
</box>
|
|
125
|
+
)}
|
|
126
|
+
|
|
127
|
+
<box
|
|
128
|
+
flexDirection="row"
|
|
129
|
+
height={1}
|
|
130
|
+
paddingLeft={1}
|
|
131
|
+
paddingRight={1}
|
|
132
|
+
backgroundColor={theme.backgroundElement}
|
|
133
|
+
>
|
|
134
|
+
<box flexDirection="row" style={{ flexGrow: 1 }}>
|
|
135
|
+
{renderThemedContent(decodedHints, theme.textMuted)}
|
|
136
|
+
</box>
|
|
137
|
+
{renderThemedContent(decodedStatus, theme.textMuted)}
|
|
138
|
+
</box>
|
|
139
|
+
</box>
|
|
140
|
+
);
|
|
141
|
+
};
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import type { ReactNode } from "react";
|
|
2
|
+
|
|
3
|
+
interface EmptyReactContent {
|
|
4
|
+
kind: "empty";
|
|
5
|
+
}
|
|
6
|
+
|
|
7
|
+
interface StringReactContent {
|
|
8
|
+
kind: "string";
|
|
9
|
+
value: string;
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
interface NodeReactContent {
|
|
13
|
+
kind: "node";
|
|
14
|
+
value: ReactNode;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
export type DecodedReactContent = EmptyReactContent | StringReactContent | NodeReactContent;
|
|
18
|
+
|
|
19
|
+
/** Decode a public React slot once into its three rendering cases. */
|
|
20
|
+
export const decodeReactContent = function decodeReactContent(
|
|
21
|
+
content: ReactNode,
|
|
22
|
+
): DecodedReactContent {
|
|
23
|
+
if (content === null || content === undefined) {
|
|
24
|
+
return { kind: "empty" };
|
|
25
|
+
}
|
|
26
|
+
// oxlint-disable-next-line anti-slop/no-runtime-typeof -- ReactNode boundary distinguishes themed primitive text from nodes rendered by React
|
|
27
|
+
if (typeof content === "string") {
|
|
28
|
+
return { kind: "string", value: content };
|
|
29
|
+
}
|
|
30
|
+
return { kind: "node", value: content };
|
|
31
|
+
};
|
package/src/status-bar.tsx
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { useTheme } from "@tooee/themes";
|
|
2
|
+
import type { ReactNode } from "react";
|
|
2
3
|
|
|
3
4
|
interface StatusBarProps {
|
|
4
5
|
items: StatusBarItem[];
|
|
@@ -9,7 +10,7 @@ export interface StatusBarItem {
|
|
|
9
10
|
value?: string;
|
|
10
11
|
}
|
|
11
12
|
|
|
12
|
-
export const StatusBar = function StatusBar({ items }: StatusBarProps):
|
|
13
|
+
export const StatusBar = function StatusBar({ items }: StatusBarProps): ReactNode {
|
|
13
14
|
const { theme } = useTheme();
|
|
14
15
|
return (
|
|
15
16
|
<box
|
|
@@ -23,7 +24,7 @@ export const StatusBar = function StatusBar({ items }: StatusBarProps): React.Re
|
|
|
23
24
|
}}
|
|
24
25
|
>
|
|
25
26
|
{items.map(
|
|
26
|
-
(item, index):
|
|
27
|
+
(item, index): ReactNode => (
|
|
27
28
|
<box key={index} style={{ flexDirection: "row", marginRight: 2 }}>
|
|
28
29
|
<text content={item.label} style={{ fg: theme.textMuted }} />
|
|
29
30
|
{(item.value?.length ?? 0) > 0 && (
|
package/src/title-bar.tsx
CHANGED
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
import { useTheme } from "@tooee/themes";
|
|
2
|
+
import type { ReactNode } from "react";
|
|
2
3
|
|
|
3
4
|
interface TitleBarProps {
|
|
4
5
|
title: string;
|
|
5
6
|
subtitle?: string;
|
|
6
7
|
}
|
|
7
8
|
|
|
8
|
-
export const TitleBar = function TitleBar({ title, subtitle }: TitleBarProps):
|
|
9
|
+
export const TitleBar = function TitleBar({ title, subtitle }: TitleBarProps): ReactNode {
|
|
9
10
|
const { theme } = useTheme();
|
|
10
11
|
return (
|
|
11
12
|
<box
|