@cmodjs/core 8.6.0 → 8.7.1

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/docs/ui.md CHANGED
@@ -85,7 +85,7 @@ An element built outside a render, at module load or in a hook, holds its props
85
85
  type Tone = 'neutral' | 'info' | 'success' | 'warning' | 'critical'
86
86
  Tabs(props: { tabs: readonly { key: string; label: string; hotkey?: string }[]; selected: string; onSelect(key: string): void; children? })
87
87
  Split(props: { children: readonly JSX.Element[] })
88
- Panel(props: { title: string; children? })
88
+ Panel(props: { title: string; description?: string; actions?; children? })
89
89
  List(props: { label: string; children? })
90
90
  ListItem(props: { key: string; label: string; leading?: string; description?: string; trailing?; tone?: Tone | 'off'; isSelected?: boolean; onPress?(): void; depth?: number; isOpen?: boolean; onOpenChange?(isOpen: boolean): void })
91
91
  Badge(props: { tone?: Tone; children })
@@ -99,8 +99,8 @@ Progress(props: { value: number; width?: number; label?: string })
99
99
  ```
100
100
 
101
101
  - `Tabs` draws a row of tabs over `children`. The selected tab's label is bold and underlined. Each other tab is a `Button`, so a part that holds the keyboard switches tabs by Tab and Enter or a click. A tab given a `hotkey`, one digit or one lowercase letter, draws it before its label, as `o: Open`, and that key switches to it. Leave the Sidebar's digits to the Sidebar: inside a page, a tab's hotkey that matches one replaces it.
102
- - `Split` lays its children side by side in equal widths. `Panel` frames one part of a page or pane in a rounded border with its bold title in the top border, as `╭─ Changed files ──╮`, grows to fill the room its parent gives it, and is never narrower than its title.
103
- - `List` holds `ListItem` rows, and `label` names the list for a screen reader. A `ListItem` draws `● leading label` with the dot in its `tone`'s color, `○` for `'off'`, `leading` and `description` dim before and after the label, and `trailing`, such as a `Badge`, last. The selected row draws on the highlight background in bold, and any other row with `onPress` is a quiet `Button` keyed `key`. A row given a `depth` is a row of a tree: it is indented two columns a level, keeps a column for `▸`, and puts `trailing` at the right edge. Give it `isOpen` and `onOpenChange` too, and that column is a `▸` or `▾` Button keyed `<key>:toggle`.
102
+ - `Split` lays its children side by side in equal widths. `Panel` frames one part of a page or pane in a rounded border with its bold title in the top border, as `╭─ Changed files ──╮`, grows to fill the room its parent gives it, and is never narrower than its title. Its `description` and `actions`, the buttons, draw on its first line, the description dim at the left and the actions at the right, as the header of a page about one thing.
103
+ - `List` holds `ListItem` rows, and `label` names the list for a screen reader. A `ListItem` draws `● leading label` with the dot in its `tone`'s color, `○` for `'off'`, `leading` and `description` dim before and after the label, and `trailing`, such as a `Badge`, last. The selected row draws on the highlight background in bold, and any other row with `onPress` is a quiet `Button` keyed `key`. A row given a `depth` is a row of a tree: it is indented two columns a level, keeps a column for `▸`, and puts `description` and `trailing` at the right edge. Give it `isOpen` and `onOpenChange` too, and that column is a `▸` or `▾` Button keyed `<key>:toggle`.
104
104
  - `Badge` draws a short status, such as `warning`, in its `tone`'s color. `Banner` draws a notice that needs the person: its `title` and text in its `tone`'s color, and its `actions`, the buttons, in a row under them.
105
105
  - `Toggle` draws `[x] label` or `[ ] label` as a `Button`. Enter or a click calls `onChange` with the other value.
106
106
  - `Tooltip` shows `text` in an inverted card above its children while the pointer rests on them. The card opens upward, because Claude Code paints a card over the rows drawn before it and under the rows drawn after it. It has no border, so a one-line card needs one free row above its children. The pointer alone opens it, so put nothing only a tooltip says.
@@ -240,11 +240,11 @@ It shows the session of the focused terminal: the terminal's foreground process,
240
240
 
241
241
  It never docks itself, because Herdr writes a dock into whichever layout file shows when it first sees the mod, once per Herdr home, and a layout another mod rewrites loses it for good. Herdr shows it in two ways. `mod.open` with `{ "name": "cmod" }` opens the dock as a window over any layout, Herdr's own included, and closes it when run again: from `herdr-app do mod.open:cmod`, a `keys.json` binding such as `"ctrl-shift-m": "mod.open:cmod"`, or another mod's `run`. The window takes no keyboard, so the dock keeps following the focused terminal, and Herdr remembers where it was dragged. A layout author places it anywhere a mod goes instead, with the `props` that say what it shows:
242
242
 
243
- - `{ "mod": "cmod" }`, or `{ "show": "views" }`, shows the focused session's views as tabs, and hosts the focused session, in a layout and in the `mod.open` window alike: its `show` carries `isHost`, so the session opens no Sidebar of its own. An `Open` with `isAsked` selects the view's tab, and a dock in a layout also shows its own block: it selects the block's branch of each stack above it and shows each hidden node on the way, with `layout.select` and `layout.show`, wherever the layout puts it. It shows the views in the order `views` lists them, the cmod plugin's own `dashboard`, `history`, and `settings` among them, and the session's open pages after them in the same row, which scrolls. A page opens as a Herdr tab, `tab.new` with `{ "show": "page", "session", "mod", "id", "title" }`. A page a mod opens itself opens the same way on `Open`, and its tab closes on `Close`. A view a mod opens becomes the shown tab, and a `Close` of the shown view goes back to the first one, as the Sidebar takes a closed view away.
243
+ - `{ "mod": "cmod" }`, or `{ "show": "views" }`, shows the focused session's views as tabs, and hosts the focused session, in a layout and in the `mod.open` window alike: its `show` carries `isHost`, so the session opens no Sidebar of its own. An `Open` with `isAsked` selects the view's tab, and a dock in a layout also shows its own block: it selects the block's branch of each stack above it and shows each hidden node on the way, with `layout.select` and `layout.show`, wherever the layout puts it. It shows the views in the order `views` lists them, the cmod plugin's own `history` and `settings` among them, with `dashboard` only while a widget is on the Dashboard, each label starting with a capital, and the session's open pages after them in the same row, which scrolls. It draws every view the session lists once, then draws again only the view it shows, on its `Redraw` and each time its tab is chosen, so a switch of tab shows the view's last drawing at once and a fresh one behind it, and a view out of sight costs Herdr nothing. A `Redraw` that comes while the shown view's drawing is on its way draws it once more after it lands. Every redraw of a Herdr mod redraws Herdr's whole window, so the dock redraws only when what it shows changed. A page opens as a Herdr tab, `tab.new` with `{ "show": "page", "session", "mod", "id", "title" }`. A page a mod opens itself opens the same way on `Open`, and its tab closes on `Close`. A view a mod opens becomes the shown tab, and a `Close` of the shown view goes back to the first one, as the Sidebar takes a closed view away.
244
244
  - `{ "show": "widgets", "area": "belowPrompt" }` draws in a row each widget that lists that area, drawn for that area, for a status bar block. `area` is the value of an area constant: `abovePrompt`, `belowPrompt`, `working`, `turnEnd`, or `dashboard`, the default. In a pane header Herdr gives `props().terminal`, so each pane's header draws its own session's widgets.
245
245
  - `{ "show": "page", "session": "<id>", "mod": "<mod>", "id": "<page>" }` draws one page of one session, as a page in the dock's row opens it.
246
246
 
247
- Each dock and page tab tells `show` the view or page it draws, under a client name it makes once, so the mod's view or page counts as `isShown` while Herdr shows it. It tells again when its shown tab or its focused session changes, renews the list every 5 seconds, and clears it when its focused session changes or the placement closes. A `{ "show": "widgets" }` block tells nothing, because `isShown` is about views and pages.
247
+ Each dock and page tab tells `show` the views or page it draws, under a client name it makes once: a dock tells the one view it shows. It tells again when its tab or its focused session changes, renews the list every 5 seconds, and clears it when its focused session changes or the placement closes. A `{ "show": "widgets" }` block tells nothing, because `isShown` is about views and pages.
248
248
 
249
249
  ```json
250
250
  { "id": "cmod", "type": "block", "size": { "px": 360 }, "content": { "mod": "cmod", "props": { "show": "views" } } }
@@ -254,11 +254,11 @@ Each dock and page tab tells `show` the view or page it draws, under a client na
254
254
  Each element draws as Herdr's own, and each `label`, or a `Text`'s text, is its accessible name:
255
255
 
256
256
  - `Box` draws a flex row or column with its gap, padding, margin, sizes, and background, a column as 8 pixels across, a row as 20 pixels down, and a space step as 8 pixels. A `borderStyle` draws a card.
257
- - Each component of `ui/components.js` draws as Herdr's control of the same job: `Tabs` as its tabs, `Panel` as a section under its title, with no card, and as the bare view when it is the view's outermost element, since the tab names it, `List` and `ListItem` as a list of rows with a status dot and, given a `depth`, as an indented tree row with its disclosure button, `Toggle` as its switch, `Progress` as its progress bar, `Pagination` with a disabled end, `Badge` and `Banner` tinted in their tone's color, `Tooltip` and `Help` as its tooltip, and `Split` as equal columns.
257
+ - Each component of `ui/components.js` draws as Herdr's control of the same job: `Tabs` as its tabs, `Panel` as a section under its title, with no card, as a page header with its title, `description`, and `actions` when it has either, and as the bare view when it is the view's outermost element with neither, since the tab names it, `List` and `ListItem` as a list of rows with a status dot and, given a `depth`, as an indented tree row with its disclosure button, `Toggle` as its switch, `Progress` as its progress bar, `Pagination` with a disabled end, `Badge` and `Banner` tinted in their tone's color, `Tooltip` and `Help` as its tooltip, and `Split` as equal columns.
258
258
  - `Text` draws its text with its color, weight, and style. A theme color such as `'success'` draws in the Herdr theme's color of the same meaning. A `Text` with a `backgroundColor` draws as a chip, and text that lays out in cells, with block or box-drawing characters or a run of spaces, keeps the terminal font so its columns line up.
259
- - `Button` draws Herdr's button: `variant: 'primary'` as its solid button, a `plain` and `dimColor` one as a quiet row of a list, and any other as an outlined one, with its `label` and its `hotkey`. A press runs its handler, and a `Button` with `href` opens an `http:` or `https:` page in the browser, and copies any other link.
260
- - `Input` draws a field with its `label` inside it, before the text, and `rows` above 1 a text area. Each change runs `onInput`, and Enter runs `onSubmit`.
261
- - `Select` draws a button with its `label` and the chosen option, which opens a menu of the options with the chosen one checked.
259
+ - `Button` draws Herdr's button: `variant: 'primary'` as its solid button, a `plain` and `dimColor` one as a quiet button, and any other as an outlined one, with its `label`. A press runs its handler, and a `Button` with `href` opens an `http:` or `https:` page in the browser, and copies any other link.
260
+ - `Input` draws a field across the row with its `placeholder`, or, given a `label`, a settings row with the label at the left and the field at the right, and `rows` above 1 a text area. Each change runs `onInput`, and Enter runs `onSubmit`.
261
+ - `Select` draws a button with the chosen option, or its `label` while none is chosen, which opens a menu of the options with the chosen one checked.
262
262
  - `Markdown` draws Herdr's Markdown text. A link it lists in `pressableLinks`, or any link without them, runs `onLinkPress`, and with no `onLinkPress` it opens as a `Button`'s `href` does.
263
263
  - `Code` draws a read-only code view with the language's colors.
264
264
  - `Image` and `Svg` draw the picture, which the mod writes under `mods/cmod/.drawn/` first, because Herdr draws only a picture in its home. An image from shared memory draws its `label`.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cmodjs/core",
3
- "version": "8.6.0",
3
+ "version": "8.7.1",
4
4
  "description": "Build Claude Code mods: hooks, panes, checks, and an install that just works.",
5
5
  "license": "MIT",
6
6
  "type": "module",
package/records.d.ts CHANGED
@@ -194,7 +194,7 @@ export declare function newestLog(entries: readonly LogEntry[]): LogEntry[];
194
194
  export declare function versionsLine({ mod, core, cmod, program, claudeCode }: LogVersions): string;
195
195
  export declare function logReport(entry: LogEntry): string;
196
196
  export declare function parseConsent(value: unknown, path: string): Record<string, string[]>;
197
- export declare const coreVersion = "8.6.0";
197
+ export declare const coreVersion = "8.7.1";
198
198
  export declare const oldestCmodVersion = "8.0.0";
199
199
  export declare function hotkeyCommand(mod: string, hotkey: string): string;
200
200
  export declare function hotkeyBindings(mod: string, hotkeys: Hotkeys | undefined): Record<string, string>;
package/records.js CHANGED
@@ -405,7 +405,7 @@ function readHotkeys(hotkeys) {
405
405
  throw new Error(`package.json "cmod.hotkeys" is not a map of hotkeys to their title and optional default combo. ${fix}`);
406
406
  return { hotkeys: checkHotkeys('package.json "cmod"', hotkeys) };
407
407
  }
408
- export const coreVersion = '8.6.0';
408
+ export const coreVersion = '8.7.1';
409
409
  export const oldestCmodVersion = '8.0.0';
410
410
  export function hotkeyCommand(mod, hotkey) {
411
411
  return `${mod}--${hotkey}`;
package/runtime/web.js CHANGED
@@ -134,7 +134,11 @@ const elements = {
134
134
  return `<div class="tabs"><div role="tablist" class="tablist">${buttons.join('')}</div><div role="tabpanel" class="tabpanel">${nodeHtml(props['children'], drawing)}</div></div>`;
135
135
  },
136
136
  Split: (props, drawing) => `<div class="split">${(Array.isArray(props['children']) ? props['children'] : [props['children']]).map((child) => `<div class="split-part">${nodeHtml(child, drawing)}</div>`).join('')}</div>`,
137
- Panel: (props, drawing) => `<section class="panel"><h3 class="panel-title">${escaped(textOr(props['title'], ''))}</h3><div class="panel-body">${nodeHtml(props['children'], drawing)}</div></section>`,
137
+ Panel: (props, drawing) => {
138
+ const description = typeof props['description'] === 'string' ? `<p class="panel-description">${escaped(props['description'])}</p>` : '';
139
+ const actions = props['actions'] === undefined ? '' : `<div class="actions">${nodeHtml(props['actions'], drawing)}</div>`;
140
+ return `<section class="panel"><header class="panel-header"><h3 class="panel-title">${escaped(textOr(props['title'], ''))}</h3>${actions}</header>${description}<div class="panel-body">${nodeHtml(props['children'], drawing)}</div></section>`;
141
+ },
138
142
  Toggle: (props) => {
139
143
  const label = textOr(props['label'], '');
140
144
  return `<button type="button" role="switch" class="switch" aria-checked="${props['checked'] === true}"${attribute('data-key', `${textOr(props['key'], '')}toggle:${label}`)}${handlerAttribute('data-press', props['onToggle'])}><span class="switch-track"></span>${escaped(label)}</button>`;
@@ -34,6 +34,7 @@ export type Widgets = {
34
34
  recheck(): Promise<void>;
35
35
  rows(area: Area, at: StyledAt): RenderElement[];
36
36
  draw(area: Area, table: ElementTable, at: StyledAt, turn?: TurnData): Promise<RenderElement[]>;
37
+ onChange(listener: () => void): void;
37
38
  };
38
39
  export declare function layoutOf(value: unknown): WidgetLayout;
39
40
  export declare function placedIn(layout: WidgetLayout, key: string): Area | undefined;
@@ -1 +1 @@
1
- {"version":3,"file":"widgets.d.ts","sourceRoot":"","sources":["../src/runtime/widgets.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,aAAa,EAAE,eAAe,EAAE,aAAa,EAAE,MAAM,aAAa,CAAA;AAE9F,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,4BAA4B,CAAA;AAC1D,OAAO,EAAqD,KAAK,IAAI,EAAE,MAAM,gBAAgB,CAAA;AAE7F,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,iBAAiB,CAAA;AAG/C,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,aAAa,CAAA;AAEzC,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,YAAY,CAAA;AAC5C,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,aAAa,CAAA;AACzC,OAAO,EAA0C,KAAK,WAAW,EAAE,KAAK,iBAAiB,EAAE,MAAM,SAAS,CAAA;AAE1G,MAAM,MAAM,SAAS,GAAG;IAAE,QAAQ,CAAC,IAAI,EAAE,SAAS,MAAM,EAAE,CAAC;IAAC,QAAQ,CAAC,KAAK,EAAE,SAAS,MAAM,EAAE,CAAA;CAAE,CAAA;AAE/F,MA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M,EAAE,YAAY,EAAE,GAAG,EAAE,MAAM,GAAG,IAAI,GAAG,SAAS,CAE5E;AAED,wBAAgB,OAAO,CAAC,MAAM,EAAE,YAAY,EAAE,GAAG,EAAE,MAAM,GAAG,YAAY,CAEvE;AAED,wBAAgB,KAAK,CAAC,MAAM,EAAE,YAAY,EAAE,MAAM,EAAE,YAAY,EAAE,IAAI,EAAE,IAAI,GAAG,YAAY,CA2B1F;AAED,wBAAgB,SAAS,CAAC,KAAK,EAAE,OAAO,GAAG,iBAAiB,EAAE,CAQ7D;AAED,wBAAgB,YAAY,CAAC,EAC3B,MAAM,EACN,MAAM,EACN,KAAK,EACL,MAAM,EACN,YAAY,EACZ,KAAK,EACL,UAAU,GACX,EAAE;IACD,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAA;IACvB,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAA;IACvB,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAA;IACtB,QAAQ,CAAC,MAAM,EAAE,CAAC,EAAE,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,EAAE,KAAK,EAAE,OAAO,KAAK,IAAI,CAAA;IACtE,QAAQ,CAAC,YAAY,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,QAAQ,GAAG,SAAS,CAAA;IAC9D,QAAQ,CAAC,KAAK,EAAE,UAAU,CAAA;IAC1B,QAAQ,CAAC,UAAU,EAAE,CAAC,KAAK,EAAE,YAAY,EAAE,EAAE,EAAE,QAAQ,KAAK,CAAC,CAAC,KAAK,EAAE,aAAa,KAAK,aAAa,CAAC,GAAG,SAAS,CAAA;CAClH,GAAG,OAAO,CAiLV"}
@@ -105,9 +105,12 @@ export function serveWidgets({ claude, router, store, report, turnClosedBy, part
105
105
  .catch((error) => report('widgets:layout', 'Could not save the widget layout', error));
106
106
  return saving;
107
107
  };
108
+ const listeners = new Set();
108
109
  const place = () => {
109
110
  layout = withNewWidgets(stored);
110
111
  redraw();
112
+ for (const listener of listeners)
113
+ listener();
111
114
  };
112
115
  const withNewWidgets = (current) => placed()
113
116
  .filter(({ key, mod }) => mod !== 'claude' && placedIn(current, key) === undefined && !placedKeys.has(key))
@@ -227,5 +230,6 @@ export function serveWidgets({ claude, router, store, report, turnClosedBy, part
227
230
  recheck,
228
231
  rows,
229
232
  draw,
233
+ onChange: (listener) => void listeners.add(listener),
230
234
  };
231
235
  }
package/src/records.ts CHANGED
@@ -499,7 +499,7 @@ function readHotkeys(hotkeys: unknown): Steps {
499
499
  return { hotkeys: checkHotkeys('package.json "cmod"', hotkeys as Record<string, HotkeyInit>) }
500
500
  }
501
501
 
502
- export const coreVersion = '8.6.0'
502
+ export const coreVersion = '8.7.1'
503
503
 
504
504
  export const oldestCmodVersion = '8.0.0'
505
505
 
@@ -151,7 +151,11 @@ const elements: Readonly<Record<string, (props: Props, drawing: Drawing) => stri
151
151
  return `<div class="tabs"><div role="tablist" class="tablist">${buttons.join('')}</div><div role="tabpanel" class="tabpanel">${nodeHtml(props['children'], drawing)}</div></div>`
152
152
  },
153
153
  Split: (props, drawing) => `<div class="split">${(Array.isArray(props['children']) ? props['children'] : [props['children']]).map((child: unknown) => `<div class="split-part">${nodeHtml(child, drawing)}</div>`).join('')}</div>`,
154
- Panel: (props, drawing) => `<section class="panel"><h3 class="panel-title">${escaped(textOr(props['title'], ''))}</h3><div class="panel-body">${nodeHtml(props['children'], drawing)}</div></section>`,
154
+ Panel: (props, drawing) => {
155
+ const description = typeof props['description'] === 'string' ? `<p class="panel-description">${escaped(props['description'])}</p>` : ''
156
+ const actions = props['actions'] === undefined ? '' : `<div class="actions">${nodeHtml(props['actions'], drawing)}</div>`
157
+ return `<section class="panel"><header class="panel-header"><h3 class="panel-title">${escaped(textOr(props['title'], ''))}</h3>${actions}</header>${description}<div class="panel-body">${nodeHtml(props['children'], drawing)}</div></section>`
158
+ },
155
159
  Toggle: (props) => {
156
160
  const label = textOr(props['label'], '')
157
161
  return `<button type="button" role="switch" class="switch" aria-checked="${props['checked'] === true}"${attribute('data-key', `${textOr(props['key'], '')}toggle:${label}`)}${handlerAttribute('data-press', props['onToggle'])}><span class="switch-track"></span>${escaped(label)}</button>`
@@ -49,6 +49,7 @@ export type Widgets = {
49
49
  recheck(): Promise<void>
50
50
  rows(area: Area, at: StyledAt): RenderElement[]
51
51
  draw(area: Area, table: ElementTable, at: StyledAt, turn?: TurnData): Promise<RenderElement[]>
52
+ onChange(listener: () => void): void
52
53
  }
53
54
 
54
55
  export function layoutOf(value: unknown): WidgetLayout {
@@ -165,9 +166,12 @@ export function serveWidgets({
165
166
  return saving
166
167
  }
167
168
 
169
+ const listeners = new Set<() => void>()
170
+
168
171
  const place = () => {
169
172
  layout = withNewWidgets(stored)
170
173
  redraw()
174
+ for (const listener of listeners) listener()
171
175
  }
172
176
 
173
177
  const withNewWidgets = (current: WidgetLayout) =>
@@ -297,5 +301,6 @@ export function serveWidgets({
297
301
  recheck,
298
302
  rows,
299
303
  draw,
304
+ onChange: (listener) => void listeners.add(listener),
300
305
  }
301
306
  }
@@ -39,18 +39,22 @@ export const Split = hostComponent(
39
39
  },
40
40
  )
41
41
 
42
+ type PanelProps = { readonly title: string; readonly description?: string; readonly actions?: JSX.Children; readonly children?: JSX.Children }
43
+
42
44
  export const Panel = hostComponent(
43
45
  'Panel',
44
- ({ title, children }: { readonly title: string; readonly children?: JSX.Children }) => ({ title, ...(children === undefined ? {} : { children }) }),
45
- ({ title, children }: { readonly title: string; readonly children?: JSX.Children }) =>
46
- Box({
46
+ ({ title, description, actions, children }: PanelProps): PanelProps => ({ title, ...(description === undefined ? {} : { description }), ...(actions === undefined ? {} : { actions }), ...(children === undefined ? {} : { children }) }),
47
+ ({ title, description, actions, children }: PanelProps) => {
48
+ const header = description === undefined && actions === undefined ? [] : [Box({ justifyContent: 'space-between', columnGap: 2, flexWrap: 'wrap', children: [Text({ dimColor: true, wrap: 'wrap', children: description ?? '' }), ...(actions === undefined ? [] : [Box({ gap: 2, flexShrink: 0, children: actions })])] })]
49
+ return Box({
47
50
  flexDirection: 'column',
48
51
  flexGrow: 1,
49
52
  children: [
50
- Box({ flexDirection: 'column', flexGrow: 1, minWidth: [...title].length + 6, borderStyle: 'round', borderColor: 'subtle', paddingX: 1, children }),
53
+ Box({ flexDirection: 'column', flexGrow: 1, gap: header.length === 0 ? 0 : 1, minWidth: [...title].length + 6, borderStyle: 'round', borderColor: 'subtle', paddingX: 1, children: [...header, children] }),
51
54
  Box({ position: 'absolute', top: 0, left: 2, children: Text({ bold: true, wrap: 'truncate-end', children: ` ${title} ` }) }),
52
55
  ],
53
- }),
56
+ })
57
+ },
54
58
  )
55
59
 
56
60
  export const Toggle = hostComponent(
@@ -136,12 +140,13 @@ type ListItemData = ListItemShared & { readonly onToggle?: Pressed }
136
140
 
137
141
  const statusOf = (tone: ListItemProps['tone']) => (tone === undefined ? [] : [tone === 'off' ? Text({ dimColor: true, children: '○ ' }) : Text({ ...textOf(tone), children: '● ' })])
138
142
 
139
- function treeRow({ key, label, leading, trailing, tone, isSelected, depth = 0, isOpen, onToggle, onPress }: ListItemData): JSX.Element {
143
+ function treeRow({ key, label, description, leading, trailing, tone, isSelected, depth = 0, isOpen, onToggle, onPress }: ListItemData): JSX.Element {
140
144
  const opener = isOpen !== undefined && onToggle !== undefined ? Button({ plain: true, key: `${key}:toggle`, onPress: onToggle, children: Text({ dimColor: true, children: isOpen ? '▾' : '▸' }) }) : Text({ children: ' ' })
141
145
  const shown = Text({ wrap: 'truncate-end', ...(isSelected === true ? { bold: true } : {}), children: [...statusOf(tone), ...(leading === undefined ? [] : [Text({ dimColor: true, children: `${leading} ` })]), label] })
142
- const row = Box({ columnGap: 1, children: [opener, onPress === undefined ? shown : Button({ plain: true, key, onPress, children: shown })] })
143
- if (trailing === undefined) return Box({ paddingLeft: depth * 2, children: row })
144
- return Box({ width: '100%', paddingLeft: depth * 2, columnGap: 1, justifyContent: 'space-between', children: [row, Box({ flexShrink: 0, children: trailing })] })
146
+ const row = Box({ columnGap: 1, minWidth: 0, children: [opener, onPress === undefined ? shown : Button({ plain: true, key, onPress, children: shown })] })
147
+ const end = [...(description === undefined ? [] : [Text({ dimColor: true, children: description })]), ...(trailing === undefined ? [] : [trailing])]
148
+ if (end.length === 0) return Box({ paddingLeft: depth * 2, children: row })
149
+ return Box({ width: '100%', paddingLeft: depth * 2, columnGap: 1, justifyContent: 'space-between', children: [row, Box({ flexShrink: 0, columnGap: 1, children: end })] })
145
150
  }
146
151
 
147
152
  export const ListItem = hostComponent(
@@ -14,10 +14,13 @@ export declare const Tabs: (props: {
14
14
  export declare const Split: (props: {
15
15
  readonly children: readonly JSX.Element[];
16
16
  }) => JSX.Element;
17
- export declare const Panel: (props: {
17
+ type PanelProps = {
18
18
  readonly title: string;
19
+ readonly description?: string;
20
+ readonly actions?: JSX.Children;
19
21
  readonly children?: JSX.Children;
20
- }) => JSX.Element;
22
+ };
23
+ export declare const Panel: (props: PanelProps) => JSX.Element;
21
24
  export declare const Toggle: (props: {
22
25
  readonly label: string;
23
26
  readonly checked: boolean;
@@ -1 +1 @@
1
- {"version":3,"file":"components.d.ts","sourceRoot":"","sources":["../src/ui/components.ts"],"names":[],"mappings":"AAEA,MAAM,MAAM,GAAG,GAAG;IAAE,QAAQ,CAAC,GAAG,EAAE,MAAM,CAAC;IAAC,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;IAAC,QAAQ,CAAC,MAAM,CAAC,EAAE,MAAM,CAAA;CAAE,CAAA;AAE5F,MAAM,MAAM,IAAI,GAAG,SAAS,GAAG,MAAM,GAAG,SAAS,GAAG,SAAS,GAAG,UAAU,CAAA;AAE1E,KAAK,OAAO,GAAG,MAAM,IAAI,CAAA;AASzB,eAAO,MAAM,IAAI;mBAE2C,SAAS,GAAG,EAAE;uBAAqB,MAAM;uBAAqB,CAAC,GAAG,EAAE,MAAM,KAAK,IAAI;wBAAsB,GAAG,CAAC,QAAQ;iBAahL,CAAA;AAED,eAAO,MAAM,KAAK;uBAEoB,SAAS,GAAG,CAAC,OAAO,EAA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AM,CAAC;IAAC,QAAQ,CAAC,MAAM,CAAC,EAAE,OAAO,CAAC;IAAC,QAAQ,CAAC,OAAO,CAAC,EAAE,OAAO,CAAA;CAAE,CAAA;AAE/S,KAAK,aAAa,GAAG,cAAc,GAAG;IAAE,QAAQ,CAAC,YAAY,CAAC,EAAE,CAAC,MAAM,EAAE,OAAO,KAAK,IAAI,CAAA;CAAE,CAAA;AAe3F,eAAO,MAAM,QAAQ,uCAUpB,CAAA;AAED,eAAO,MAAM,KAAK;oBAEmC,IAAI;uBAAqB,GAAG,CAAC,QAAQ;iBAEzF,CAAA;AAOD,eAAO,MAAM,MAAM;oBAE+C,IAAI;qBAAmB,MAAM;wBAAsB,GAAG,CAAC,QAAQ;uBAAqB,GAAG,CAAC,QAAQ;iBAUjK,CAAA"}
package/ui/components.js CHANGED
@@ -18,14 +18,17 @@ export const Split = hostComponent('Split', ({ children }) => ({ children }), ({
18
18
  const width = `${Math.floor(100 / Math.max(children.length, 1))}%`;
19
19
  return Box({ gap: 1, children: children.map((child) => Box({ width, children: child })) });
20
20
  });
21
- export const Panel = hostComponent('Panel', ({ title, children }) => ({ title, ...(children === undefined ? {} : { children }) }), ({ title, children }) => Box({
22
- flexDirection: 'column',
23
- flexGrow: 1,
24
- children: [
25
- Box({ flexDirection: 'column', flexGrow: 1, minWidth: [...title].length + 6, borderStyle: 'round', borderColor: 'subtle', paddingX: 1, children }),
26
- Box({ position: 'absolute', top: 0, left: 2, children: Text({ bold: true, wrap: 'truncate-end', children: ` ${title} ` }) }),
27
- ],
28
- }));
21
+ export const Panel = hostComponent('Panel', ({ title, description, actions, children }) => ({ title, ...(description === undefined ? {} : { description }), ...(actions === undefined ? {} : { actions }), ...(children === undefined ? {} : { children }) }), ({ title, description, actions, children }) => {
22
+ const header = description === undefined && actions === undefined ? [] : [Box({ justifyContent: 'space-between', columnGap: 2, flexWrap: 'wrap', children: [Text({ dimColor: true, wrap: 'wrap', children: description ?? '' }), ...(actions === undefined ? [] : [Box({ gap: 2, flexShrink: 0, children: actions })])] })];
23
+ return Box({
24
+ flexDirection: 'column',
25
+ flexGrow: 1,
26
+ children: [
27
+ Box({ flexDirection: 'column', flexGrow: 1, gap: header.length === 0 ? 0 : 1, minWidth: [...title].length + 6, borderStyle: 'round', borderColor: 'subtle', paddingX: 1, children: [...header, children] }),
28
+ Box({ position: 'absolute', top: 0, left: 2, children: Text({ bold: true, wrap: 'truncate-end', children: ` ${title} ` }) }),
29
+ ],
30
+ });
31
+ });
29
32
  export const Toggle = hostComponent('Toggle', ({ label, checked, onChange }) => ({ key: '', label, checked, onToggle: () => onChange(!checked) }), ({ key, label, checked, onToggle }) => Button({ plain: true, key: `${key}toggle:${label}`, label: `${checked ? '[x]' : '[ ]'} ${label}`, onPress: onToggle }));
30
33
  const cardColumns = 36;
31
34
  function card(text, isShown) {
@@ -62,13 +65,14 @@ export const Progress = hostComponent('Progress', ({ value, width = 24, label })
62
65
  });
63
66
  export const List = hostComponent('List', ({ label, children }) => ({ label, ...(children === undefined ? {} : { children }) }), ({ children }) => Box({ flexDirection: 'column', children }));
64
67
  const statusOf = (tone) => (tone === undefined ? [] : [tone === 'off' ? Text({ dimColor: true, children: '○ ' }) : Text({ ...textOf(tone), children: '● ' })]);
65
- function treeRow({ key, label, leading, trailing, tone, isSelected, depth = 0, isOpen, onToggle, onPress }) {
68
+ function treeRow({ key, label, description, leading, trailing, tone, isSelected, depth = 0, isOpen, onToggle, onPress }) {
66
69
  const opener = isOpen !== undefined && onToggle !== undefined ? Button({ plain: true, key: `${key}:toggle`, onPress: onToggle, children: Text({ dimColor: true, children: isOpen ? '▾' : '▸' }) }) : Text({ children: ' ' });
67
70
  const shown = Text({ wrap: 'truncate-end', ...(isSelected === true ? { bold: true } : {}), children: [...statusOf(tone), ...(leading === undefined ? [] : [Text({ dimColor: true, children: `${leading} ` })]), label] });
68
- const row = Box({ columnGap: 1, children: [opener, onPress === undefined ? shown : Button({ plain: true, key, onPress, children: shown })] });
69
- if (trailing === undefined)
71
+ const row = Box({ columnGap: 1, minWidth: 0, children: [opener, onPress === undefined ? shown : Button({ plain: true, key, onPress, children: shown })] });
72
+ const end = [...(description === undefined ? [] : [Text({ dimColor: true, children: description })]), ...(trailing === undefined ? [] : [trailing])];
73
+ if (end.length === 0)
70
74
  return Box({ paddingLeft: depth * 2, children: row });
71
- return Box({ width: '100%', paddingLeft: depth * 2, columnGap: 1, justifyContent: 'space-between', children: [row, Box({ flexShrink: 0, children: trailing })] });
75
+ return Box({ width: '100%', paddingLeft: depth * 2, columnGap: 1, justifyContent: 'space-between', children: [row, Box({ flexShrink: 0, columnGap: 1, children: end })] });
72
76
  }
73
77
  export const ListItem = hostComponent('ListItem', ({ onOpenChange, ...props }) => ({ ...props, ...(onOpenChange === undefined || props.isOpen === undefined ? {} : { onToggle: () => onOpenChange(props.isOpen !== true) }) }), (props) => {
74
78
  const { key, label, description, leading, trailing, tone, isSelected, depth, onPress } = props;