clairo 1.0.1 → 1.0.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/dist/cli.js +74 -25
  2. package/package.json +2 -1
package/dist/cli.js CHANGED
@@ -4,7 +4,7 @@
4
4
  import meow from "meow";
5
5
 
6
6
  // src/app.tsx
7
- import { useCallback as useCallback4, useState as useState9 } from "react";
7
+ import { useCallback as useCallback4, useState as useState10 } from "react";
8
8
  import { Box as Box16, useApp, useInput as useInput13 } from "ink";
9
9
 
10
10
  // src/components/github/GitHubView.tsx
@@ -1827,7 +1827,7 @@ function JiraView({ isFocused, onModalChange, onKeybindingsChange, onLogUpdated
1827
1827
  }
1828
1828
 
1829
1829
  // src/components/logs/LogsView.tsx
1830
- import { useCallback as useCallback3, useEffect as useEffect6, useState as useState8 } from "react";
1830
+ import { useCallback as useCallback3, useEffect as useEffect6, useState as useState9 } from "react";
1831
1831
  import { Box as Box14, useInput as useInput12 } from "ink";
1832
1832
 
1833
1833
  // src/components/logs/LogsHistoryBox.tsx
@@ -1890,19 +1890,30 @@ function LogsHistoryBox({
1890
1890
  }
1891
1891
 
1892
1892
  // src/components/logs/LogViewerBox.tsx
1893
- import { useRef as useRef3 } from "react";
1893
+ import { useRef as useRef3, useState as useState8 } from "react";
1894
1894
  import { TitledBox as TitledBox6 } from "@mishieck/ink-titled-box";
1895
1895
  import { Box as Box13, Text as Text13, useInput as useInput11 } from "ink";
1896
1896
  import { ScrollView as ScrollView2 } from "ink-scroll-view";
1897
+ import TextInput2 from "ink-text-input";
1897
1898
  import { jsx as jsx13, jsxs as jsxs13 } from "react/jsx-runtime";
1898
1899
  function LogViewerBox({ date, content, isFocused, onRefresh, onLogCreated }) {
1899
1900
  const scrollRef = useRef3(null);
1901
+ const [isInputMode, setIsInputMode] = useState8(false);
1902
+ const [inputValue, setInputValue] = useState8("");
1900
1903
  const title = "[6] Log Content";
1901
1904
  const borderColor = isFocused ? "yellow" : void 0;
1902
1905
  const displayTitle = date ? `${title} - ${date}.md` : title;
1903
1906
  useInput11(
1904
1907
  (input, key) => {
1905
1908
  var _a, _b;
1909
+ if (key.escape && isInputMode) {
1910
+ setIsInputMode(false);
1911
+ setInputValue("");
1912
+ return;
1913
+ }
1914
+ if (isInputMode) {
1915
+ return;
1916
+ }
1906
1917
  if (key.upArrow || input === "k") {
1907
1918
  (_a = scrollRef.current) == null ? void 0 : _a.scrollBy(-1);
1908
1919
  }
@@ -1913,6 +1924,9 @@ function LogViewerBox({ date, content, isFocused, onRefresh, onLogCreated }) {
1913
1924
  openLogInEditor(date);
1914
1925
  onRefresh();
1915
1926
  }
1927
+ if (input === "i" && date) {
1928
+ setIsInputMode(true);
1929
+ }
1916
1930
  if (input === "n") {
1917
1931
  const today = getTodayDate();
1918
1932
  if (!logExists(today)) {
@@ -1926,22 +1940,48 @@ function LogViewerBox({ date, content, isFocused, onRefresh, onLogCreated }) {
1926
1940
  },
1927
1941
  { isActive: isFocused }
1928
1942
  );
1929
- return /* @__PURE__ */ jsx13(TitledBox6, { borderStyle: "round", titles: [displayTitle], borderColor, flexGrow: 1, children: /* @__PURE__ */ jsx13(Box13, { flexDirection: "column", flexGrow: 1, children: /* @__PURE__ */ jsx13(ScrollView2, { ref: scrollRef, children: /* @__PURE__ */ jsxs13(Box13, { flexDirection: "column", paddingX: 1, children: [
1930
- !date && /* @__PURE__ */ jsx13(Text13, { dimColor: true, children: "Select a log file to view" }),
1931
- date && content === null && /* @__PURE__ */ jsx13(Text13, { dimColor: true, children: "Log file not found" }),
1932
- date && content !== null && content.trim() === "" && /* @__PURE__ */ jsx13(Text13, { dimColor: true, children: "Empty log file" }),
1933
- date && content && content.trim() !== "" && /* @__PURE__ */ jsx13(Markdown, { children: content })
1934
- ] }) }) }) });
1943
+ const handleInputSubmit = (value) => {
1944
+ if (!date || !value.trim()) {
1945
+ setIsInputMode(false);
1946
+ setInputValue("");
1947
+ return;
1948
+ }
1949
+ const timestamp = formatTimestamp();
1950
+ const entry = `
1951
+ ## ${timestamp}
1952
+
1953
+ ${value.trim()}
1954
+ `;
1955
+ appendToLog(date, entry);
1956
+ setInputValue("");
1957
+ setIsInputMode(false);
1958
+ onRefresh();
1959
+ };
1960
+ return /* @__PURE__ */ jsxs13(Box13, { flexDirection: "column", flexGrow: 1, children: [
1961
+ /* @__PURE__ */ jsx13(TitledBox6, { borderStyle: "round", titles: [displayTitle], borderColor, flexGrow: 1, children: /* @__PURE__ */ jsx13(Box13, { flexDirection: "column", flexGrow: 1, children: /* @__PURE__ */ jsx13(ScrollView2, { ref: scrollRef, children: /* @__PURE__ */ jsxs13(Box13, { flexDirection: "column", paddingX: 1, children: [
1962
+ !date && /* @__PURE__ */ jsx13(Text13, { dimColor: true, children: "Select a log file to view" }),
1963
+ date && content === null && /* @__PURE__ */ jsx13(Text13, { dimColor: true, children: "Log file not found" }),
1964
+ date && content !== null && content.trim() === "" && /* @__PURE__ */ jsx13(Text13, { dimColor: true, children: "Empty log file" }),
1965
+ date && content && content.trim() !== "" && /* @__PURE__ */ jsx13(Markdown, { children: content })
1966
+ ] }) }) }) }),
1967
+ isInputMode && /* @__PURE__ */ jsx13(TitledBox6, { borderStyle: "round", titles: ["Add Entry"], borderColor: "yellow", children: /* @__PURE__ */ jsx13(Box13, { paddingX: 1, children: /* @__PURE__ */ jsx13(
1968
+ TextInput2,
1969
+ {
1970
+ value: inputValue,
1971
+ onChange: (val) => setInputValue(val.replace(/[\r\n]/g, "")),
1972
+ onSubmit: handleInputSubmit
1973
+ }
1974
+ ) }) })
1975
+ ] });
1935
1976
  }
1936
1977
 
1937
1978
  // src/components/logs/LogsView.tsx
1938
1979
  import { jsx as jsx14, jsxs as jsxs14 } from "react/jsx-runtime";
1939
- function LogsView({ isFocused, onKeybindingsChange, refreshKey }) {
1940
- const [logFiles, setLogFiles] = useState8([]);
1941
- const [selectedDate, setSelectedDate] = useState8(null);
1942
- const [logContent, setLogContent] = useState8(null);
1943
- const [highlightedIndex, setHighlightedIndex] = useState8(0);
1944
- const [focusedBox, setFocusedBox] = useState8("history");
1980
+ function LogsView({ isFocused, onKeybindingsChange, refreshKey, focusedBox, onFocusedBoxChange }) {
1981
+ const [logFiles, setLogFiles] = useState9([]);
1982
+ const [selectedDate, setSelectedDate] = useState9(null);
1983
+ const [logContent, setLogContent] = useState9(null);
1984
+ const [highlightedIndex, setHighlightedIndex] = useState9(0);
1945
1985
  useEffect6(() => {
1946
1986
  if (!isFocused) {
1947
1987
  onKeybindingsChange == null ? void 0 : onKeybindingsChange([]);
@@ -1951,6 +1991,7 @@ function LogsView({ isFocused, onKeybindingsChange, refreshKey }) {
1951
1991
  if (focusedBox === "history") {
1952
1992
  bindings.push({ key: "Enter", label: "Select" });
1953
1993
  } else if (focusedBox === "viewer") {
1994
+ bindings.push({ key: "i", label: "Add Entry" });
1954
1995
  bindings.push({ key: "e", label: "Edit" });
1955
1996
  bindings.push({ key: "n", label: "New Log", color: "green" });
1956
1997
  bindings.push({ key: "r", label: "Refresh" });
@@ -2024,8 +2065,8 @@ function LogsView({ isFocused, onKeybindingsChange, refreshKey }) {
2024
2065
  }, []);
2025
2066
  useInput12(
2026
2067
  (input) => {
2027
- if (input === "5") setFocusedBox("history");
2028
- if (input === "6") setFocusedBox("viewer");
2068
+ if (input === "5") onFocusedBoxChange("history");
2069
+ if (input === "6") onFocusedBoxChange("viewer");
2029
2070
  },
2030
2071
  { isActive: isFocused }
2031
2072
  );
@@ -2077,10 +2118,11 @@ function KeybindingsBar({ contextBindings = [], modalOpen = false }) {
2077
2118
  import { jsx as jsx16, jsxs as jsxs16 } from "react/jsx-runtime";
2078
2119
  function App() {
2079
2120
  const { exit } = useApp();
2080
- const [focusedView, setFocusedView] = useState9("github");
2081
- const [modalOpen, setModalOpen] = useState9(false);
2082
- const [contextBindings, setContextBindings] = useState9([]);
2083
- const [logRefreshKey, setLogRefreshKey] = useState9(0);
2121
+ const [focusedView, setFocusedView] = useState10("github");
2122
+ const [modalOpen, setModalOpen] = useState10(false);
2123
+ const [contextBindings, setContextBindings] = useState10([]);
2124
+ const [logRefreshKey, setLogRefreshKey] = useState10(0);
2125
+ const [logsFocusedBox, setLogsFocusedBox] = useState10("history");
2084
2126
  const handleLogUpdated = useCallback4(() => {
2085
2127
  setLogRefreshKey((prev) => prev + 1);
2086
2128
  }, []);
@@ -2095,8 +2137,13 @@ function App() {
2095
2137
  if (input === "4") {
2096
2138
  setFocusedView("jira");
2097
2139
  }
2098
- if (input === "5" || input === "6") {
2140
+ if (input === "5") {
2141
+ setFocusedView("logs");
2142
+ setLogsFocusedBox("history");
2143
+ }
2144
+ if (input === "6") {
2099
2145
  setFocusedView("logs");
2146
+ setLogsFocusedBox("viewer");
2100
2147
  }
2101
2148
  },
2102
2149
  { isActive: !modalOpen }
@@ -2127,7 +2174,9 @@ function App() {
2127
2174
  {
2128
2175
  isFocused: focusedView === "logs",
2129
2176
  onKeybindingsChange: focusedView === "logs" ? setContextBindings : void 0,
2130
- refreshKey: logRefreshKey
2177
+ refreshKey: logRefreshKey,
2178
+ focusedBox: logsFocusedBox,
2179
+ onFocusedBoxChange: setLogsFocusedBox
2131
2180
  }
2132
2181
  ) })
2133
2182
  ] }),
@@ -2140,7 +2189,7 @@ import { render as inkRender } from "ink";
2140
2189
 
2141
2190
  // src/lib/Screen.tsx
2142
2191
  import { Box as Box17, useStdout as useStdout2 } from "ink";
2143
- import { useCallback as useCallback5, useEffect as useEffect7, useState as useState10 } from "react";
2192
+ import { useCallback as useCallback5, useEffect as useEffect7, useState as useState11 } from "react";
2144
2193
  import { jsx as jsx17 } from "react/jsx-runtime";
2145
2194
  function Screen({ children }) {
2146
2195
  const { stdout } = useStdout2();
@@ -2148,7 +2197,7 @@ function Screen({ children }) {
2148
2197
  () => ({ height: stdout.rows, width: stdout.columns }),
2149
2198
  [stdout]
2150
2199
  );
2151
- const [size, setSize] = useState10(getSize);
2200
+ const [size, setSize] = useState11(getSize);
2152
2201
  useEffect7(() => {
2153
2202
  const onResize = () => setSize(getSize());
2154
2203
  stdout.on("resize", onResize);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "clairo",
3
- "version": "1.0.1",
3
+ "version": "1.0.2",
4
4
  "license": "MIT",
5
5
  "repository": {
6
6
  "type": "git",
@@ -27,6 +27,7 @@
27
27
  "ink-link": "^5.0.0",
28
28
  "ink-scroll-view": "^0.3.5",
29
29
  "ink-select-input": "^6.2.0",
30
+ "ink-text-input": "^6.0.0",
30
31
  "marked": "^17.0.1",
31
32
  "meow": "^11.0.0",
32
33
  "open": "^11.0.0",