ink 2.7.0 → 2.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.
|
@@ -38,12 +38,16 @@ const isAllTextNodes = node => {
|
|
|
38
38
|
|
|
39
39
|
|
|
40
40
|
const squashTextNodes = node => {
|
|
41
|
-
|
|
41
|
+
if (node.childNodes.length === 0) {
|
|
42
|
+
return '';
|
|
43
|
+
} // If parent container is `<Box>`, text nodes will be treated as separate nodes in
|
|
42
44
|
// the tree and will have their own coordinates in the layout.
|
|
43
45
|
// To ensure text nodes are aligned correctly, take X and Y of the first text node
|
|
44
46
|
// and use them as offset for the rest of the nodes
|
|
45
47
|
// Only first node is taken into account, because other text nodes can't have margin or padding,
|
|
46
48
|
// so their coordinates will be relative to the first node anyway
|
|
49
|
+
|
|
50
|
+
|
|
47
51
|
const offsetX = node.childNodes[0].yogaNode.getComputedLeft();
|
|
48
52
|
const offsetY = node.childNodes[0].yogaNode.getComputedTop();
|
|
49
53
|
let text = '\n'.repeat(offsetY) + ' '.repeat(offsetX);
|
package/package.json
CHANGED
package/build/hooks/useInput.js
DELETED
|
@@ -1,38 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.default = void 0;
|
|
7
|
-
|
|
8
|
-
var _react = require("react");
|
|
9
|
-
|
|
10
|
-
var _ = require("..");
|
|
11
|
-
|
|
12
|
-
var _default = inputHandler => {
|
|
13
|
-
const {
|
|
14
|
-
stdin,
|
|
15
|
-
setRawMode
|
|
16
|
-
} = (0, _react.useContext)(_.StdinContext);
|
|
17
|
-
(0, _react.useLayoutEffect)(() => {
|
|
18
|
-
setRawMode(true);
|
|
19
|
-
return () => setRawMode(false);
|
|
20
|
-
}, [setRawMode]);
|
|
21
|
-
(0, _react.useLayoutEffect)(() => {
|
|
22
|
-
const handleData = data => {
|
|
23
|
-
const input = String(data);
|
|
24
|
-
const meta = {
|
|
25
|
-
up: input === '\u001B[A',
|
|
26
|
-
down: input === '\u001B[B',
|
|
27
|
-
left: input === '\u001B[D',
|
|
28
|
-
right: input === '\u001B[C'
|
|
29
|
-
};
|
|
30
|
-
inputHandler(input, meta);
|
|
31
|
-
};
|
|
32
|
-
|
|
33
|
-
stdin.on('data', handleData);
|
|
34
|
-
return () => stdin.off('data', handleData);
|
|
35
|
-
}, [stdin, inputHandler]);
|
|
36
|
-
};
|
|
37
|
-
|
|
38
|
-
exports.default = _default;
|