giggles 0.7.2 → 0.7.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.
|
@@ -3,6 +3,7 @@ import {
|
|
|
3
3
|
} from "./chunk-C77VBSPK.js";
|
|
4
4
|
|
|
5
5
|
// src/ui/CodeBlock.tsx
|
|
6
|
+
import { useMemo } from "react";
|
|
6
7
|
import { Box, Text } from "ink";
|
|
7
8
|
import Prism from "prismjs";
|
|
8
9
|
import { jsx } from "react/jsx-runtime";
|
|
@@ -24,9 +25,12 @@ var defaultTokenColors = {
|
|
|
24
25
|
};
|
|
25
26
|
function CodeBlock({ children, language, tokenColors, ...boxProps }) {
|
|
26
27
|
const theme = useTheme();
|
|
27
|
-
const colors = { ...defaultTokenColors, ...tokenColors };
|
|
28
|
+
const colors = useMemo(() => ({ ...defaultTokenColors, ...tokenColors }), [tokenColors]);
|
|
28
29
|
const grammar = language ? Prism.languages[language] : void 0;
|
|
29
|
-
const content =
|
|
30
|
+
const content = useMemo(
|
|
31
|
+
() => grammar ? renderTokens(Prism.tokenize(children, grammar), colors) : /* @__PURE__ */ jsx(Text, { children }),
|
|
32
|
+
[children, grammar, colors]
|
|
33
|
+
);
|
|
30
34
|
return /* @__PURE__ */ jsx(Box, { paddingX: 1, borderStyle: theme.borderStyle, borderColor: theme.borderColor, ...boxProps, children: /* @__PURE__ */ jsx(Text, { children: content }) });
|
|
31
35
|
}
|
|
32
36
|
function renderTokens(tokens, colors) {
|
|
@@ -94,16 +94,16 @@ function useFocusNode(options) {
|
|
|
94
94
|
import { useEffect as useEffect2, useRef as useRef2 } from "react";
|
|
95
95
|
import { jsx } from "react/jsx-runtime";
|
|
96
96
|
function FocusTrap({ children }) {
|
|
97
|
-
const { id } = useFocusNode();
|
|
98
97
|
const store = useStore();
|
|
99
98
|
const previousFocusRef = useRef2(store.getFocusedId());
|
|
99
|
+
const { id } = useFocusNode();
|
|
100
100
|
useEffect2(() => {
|
|
101
101
|
const previousFocus = previousFocusRef.current;
|
|
102
102
|
store.setTrap(id);
|
|
103
103
|
store.focusFirstChild(id);
|
|
104
104
|
return () => {
|
|
105
105
|
store.clearTrap(id);
|
|
106
|
-
if (previousFocus) {
|
|
106
|
+
if (previousFocus && previousFocus !== id) {
|
|
107
107
|
store.focusNode(previousFocus);
|
|
108
108
|
}
|
|
109
109
|
};
|
|
@@ -277,6 +277,15 @@ var FocusStore = class {
|
|
|
277
277
|
}
|
|
278
278
|
return;
|
|
279
279
|
}
|
|
280
|
+
if (existing && existing.parentId !== parentId) {
|
|
281
|
+
if (existing.parentId) {
|
|
282
|
+
const oldParent = this.nodes.get(existing.parentId);
|
|
283
|
+
if (oldParent) {
|
|
284
|
+
oldParent.childrenIds = oldParent.childrenIds.filter((c) => c !== id);
|
|
285
|
+
}
|
|
286
|
+
}
|
|
287
|
+
this.updateFocusKey(id, existing.parentId, existing.focusKey, void 0);
|
|
288
|
+
}
|
|
280
289
|
const node = { id, parentId, childrenIds: [], focusKey };
|
|
281
290
|
this.nodes.set(id, node);
|
|
282
291
|
this.parentMap.set(id, parentId);
|
package/dist/index.js
CHANGED
package/dist/markdown/index.js
CHANGED
package/dist/ui/index.js
CHANGED
|
@@ -6,10 +6,10 @@ import {
|
|
|
6
6
|
useFocusScope,
|
|
7
7
|
useKeybindingRegistry,
|
|
8
8
|
useKeybindings
|
|
9
|
-
} from "../chunk-
|
|
9
|
+
} from "../chunk-BHA3UFY2.js";
|
|
10
10
|
import {
|
|
11
11
|
CodeBlock
|
|
12
|
-
} from "../chunk-
|
|
12
|
+
} from "../chunk-4MVZP2MB.js";
|
|
13
13
|
import {
|
|
14
14
|
useTheme
|
|
15
15
|
} from "../chunk-C77VBSPK.js";
|