@sushant-kum/ccstatus 0.3.2 → 0.3.3

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.
@@ -332,19 +332,64 @@ function Chip({ item, selected }) {
332
332
  }
333
333
  function Items({ config, setConfig, goHome }) {
334
334
  const [surface, setSurface] = useState3("band");
335
+ const [line, setLine] = useState3(0);
335
336
  const [sel, setSel] = useState3(0);
336
337
  const [mode, setMode] = useState3("strip");
337
338
  const [linkPick, setLinkPick] = useState3(0);
338
339
  const [confirm, setConfirm] = useState3(null);
339
340
  const [field, setField] = useState3(0);
340
341
  const [pick, setPick] = useState3(0);
341
- const items = config.surfaces[surface].lines[0] ?? [];
342
+ const allLines = config.surfaces[surface].lines;
343
+ const displayLines = allLines.length ? allLines : [[]];
344
+ const lineCount = displayLines.length;
345
+ const curLine = Math.min(line, lineCount - 1);
346
+ const items = displayLines[curLine] ?? [];
342
347
  const cur = items[Math.min(sel, items.length - 1)];
343
348
  const idx = cur ? items.indexOf(cur) : -1;
344
- const commit = (next) => {
345
- const lines = [next, ...config.surfaces[surface].lines.slice(1)];
349
+ const commitLines = (lines) => {
346
350
  setConfig({ ...config, surfaces: writeLinkedLines(config.surfaces, surface, lines) });
347
351
  };
352
+ const commit = (next) => {
353
+ const lines = [...displayLines];
354
+ lines[curLine] = next;
355
+ commitLines(lines);
356
+ };
357
+ const addLine = () => {
358
+ const lines = [...displayLines];
359
+ lines.splice(curLine + 1, 0, []);
360
+ commitLines(lines);
361
+ setLine(curLine + 1);
362
+ setSel(0);
363
+ };
364
+ const removeLine = () => {
365
+ if (lineCount <= 1 && items.length === 0) {
366
+ return;
367
+ }
368
+ const lines = lineCount <= 1 ? [[]] : displayLines.filter((_, i) => i !== curLine);
369
+ commitLines(lines);
370
+ setLine(Math.min(curLine, lines.length - 1));
371
+ setSel(0);
372
+ };
373
+ const moveItemToLine = (dir) => {
374
+ const target = curLine + dir;
375
+ if (idx < 0 || target < 0 || target >= lineCount) {
376
+ return;
377
+ }
378
+ const lines = displayLines.map((l) => [...l]);
379
+ const src = lines[curLine];
380
+ const tgt = lines[target];
381
+ if (!src || !tgt) {
382
+ return;
383
+ }
384
+ const [moved] = src.splice(idx, 1);
385
+ if (!moved) {
386
+ return;
387
+ }
388
+ tgt.push(moved);
389
+ commitLines(lines);
390
+ setLine(target);
391
+ setSel(tgt.length - 1);
392
+ };
348
393
  const patch = (p) => {
349
394
  const base = items[idx];
350
395
  if (idx < 0 || !base || !isStylable(base)) {
@@ -413,7 +458,7 @@ function Items({ config, setConfig, goHome }) {
413
458
  ...layout,
414
459
  linked: false,
415
460
  lines: layout.lines.map(
416
- (line) => line.map((it) => ({ ...it, id: makeId(it.type) }))
461
+ (line2) => line2.map((it) => ({ ...it, id: makeId(it.type) }))
417
462
  )
418
463
  }
419
464
  };
@@ -491,7 +536,16 @@ function Items({ config, setConfig, goHome }) {
491
536
  goHome();
492
537
  } else if (key.tab) {
493
538
  setSurface((s) => SURFACES[wrap(SURFACES.indexOf(s) + 1, SURFACES.length)] ?? s);
539
+ setLine(0);
494
540
  setSel(0);
541
+ } else if (key.upArrow) {
542
+ const t = Math.max(0, curLine - 1);
543
+ setLine(t);
544
+ setSel((s) => Math.min(s, Math.max(0, (displayLines[t]?.length ?? 0) - 1)));
545
+ } else if (key.downArrow) {
546
+ const t = Math.min(lineCount - 1, curLine + 1);
547
+ setLine(t);
548
+ setSel((s) => Math.min(s, Math.max(0, (displayLines[t]?.length ?? 0) - 1)));
495
549
  } else if (key.leftArrow) {
496
550
  setSel(Math.max(0, idx - 1));
497
551
  } else if (key.rightArrow) {
@@ -500,6 +554,14 @@ function Items({ config, setConfig, goHome }) {
500
554
  move(-1);
501
555
  } else if (input === "]") {
502
556
  move(1);
557
+ } else if (input === "{") {
558
+ moveItemToLine(-1);
559
+ } else if (input === "}") {
560
+ moveItemToLine(1);
561
+ } else if (input === "A") {
562
+ addLine();
563
+ } else if (input === "X") {
564
+ removeLine();
503
565
  } else if (input === "a") {
504
566
  setPick(0);
505
567
  setMode("picker");
@@ -538,13 +600,15 @@ function Items({ config, setConfig, goHome }) {
538
600
  SURFACES.filter((s) => config.surfaces[s].linked).join(", "),
539
601
  " \u2014 edits apply to all"
540
602
  ] }),
541
- /* @__PURE__ */ jsx4(Box5, { children: items.length === 0 ? /* @__PURE__ */ jsx4(Text5, { dimColor: true, children: "(no items \u2014 press a)" }) : (
542
- // Item ids are unique within a surface. Linked surfaces share ids across
543
- // surfaces (DEC-0018), but only one surface's items render here at a time,
544
- // so these keys never collide. (The live Preview renders a RenderModel of
545
- // positional segments — paint.tsx keys by index, not item id.)
546
- items.map((it, i) => /* @__PURE__ */ jsx4(Chip, { item: it, selected: i === idx }, it.id))
547
- ) }),
603
+ /* @__PURE__ */ jsx4(Box5, { flexDirection: "column", children: displayLines.map((lineItems, li) => /* @__PURE__ */ jsxs4(Box5, { children: [
604
+ /* @__PURE__ */ jsxs4(Text5, { color: li === curLine ? "cyan" : void 0, children: [
605
+ li === curLine ? "\u25B8" : " ",
606
+ " ",
607
+ li + 1,
608
+ " "
609
+ ] }),
610
+ lineItems.length === 0 ? /* @__PURE__ */ jsx4(Text5, { dimColor: true, children: "(empty \u2014 press a)" }) : lineItems.map((it, i) => /* @__PURE__ */ jsx4(Chip, { item: it, selected: li === curLine && i === idx }, `${li}-${it.id}`))
611
+ ] }, li)) }),
548
612
  mode === "link" ? /* @__PURE__ */ jsx4(Box5, { flexDirection: "column", marginTop: 1, children: confirm ? /* @__PURE__ */ jsxs4(Text5, { children: [
549
613
  "Replace ",
550
614
  confirm.join(", "),
@@ -584,7 +648,7 @@ function Items({ config, setConfig, goHome }) {
584
648
  ] }),
585
649
  /* @__PURE__ */ jsx4(Text5, { dimColor: true, children: "(flex separator \u2014 no style options)" })
586
650
  ] })),
587
- /* @__PURE__ */ jsx4(Text5, { dimColor: true, children: mode === "strip" ? "\u2190/\u2192 select \xB7 [/] move \xB7 a add \xB7 x remove \xB7 e edit \xB7 l link \xB7 u unlink \xB7 tab surface \xB7 esc back" : mode === "editor" ? "\u2191/\u2193 field \xB7 \u2190/\u2192 change \xB7 esc done" : mode === "link" ? confirm ? "y confirm \xB7 n cancel" : "\u2191/\u2193 choose \xB7 enter link \xB7 esc cancel" : "\u2191/\u2193 choose \xB7 enter add \xB7 esc cancel" })
651
+ /* @__PURE__ */ jsx4(Text5, { dimColor: true, children: mode === "strip" ? "\u2191/\u2193 line \xB7 \u2190/\u2192 item \xB7 [/] move \xB7 {/} to line \xB7 a add \xB7 x del \xB7 A +line \xB7 X \u2212line \xB7 e edit \xB7 l/u link \xB7 tab \xB7 esc" : mode === "editor" ? "\u2191/\u2193 field \xB7 \u2190/\u2192 change \xB7 esc done" : mode === "link" ? confirm ? "y confirm \xB7 n cancel" : "\u2191/\u2193 choose \xB7 enter link \xB7 esc cancel" : "\u2191/\u2193 choose \xB7 enter add \xB7 esc cancel" })
588
652
  ] });
589
653
  }
590
654
 
package/dist/index.js CHANGED
@@ -8,6 +8,6 @@ if (sub === "statusline") {
8
8
  await runStatusline();
9
9
  } else {
10
10
  const { render } = await import("ink");
11
- const { App } = await import("./app-JJQ6RQ3D.js");
11
+ const { App } = await import("./app-O4Q6TMY4.js");
12
12
  render(/* @__PURE__ */ jsx(App, {}));
13
13
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sushant-kum/ccstatus",
3
- "version": "0.3.2",
3
+ "version": "0.3.3",
4
4
  "description": "Interactive configurator (npx @sushant-kum/ccstatus) for the ccstatus Claude Code status bar — band, status line, pane, and threshold toasts from one config.",
5
5
  "license": "MIT",
6
6
  "author": "Sushant Kumar",