@effect-tui/react 0.15.0 → 0.15.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/dist/src/hosts/box.d.ts.map +1 -1
- package/dist/src/hosts/box.js +29 -15
- package/dist/src/hosts/box.js.map +1 -1
- package/dist/src/reconciler/host-config.d.ts.map +1 -1
- package/dist/src/reconciler/host-config.js +0 -7
- package/dist/src/reconciler/host-config.js.map +1 -1
- package/dist/src/renderer.d.ts.map +1 -1
- package/dist/src/renderer.js +3 -0
- package/dist/src/renderer.js.map +1 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +2 -2
- package/src/hosts/box.ts +30 -16
- package/src/reconciler/host-config.ts +0 -7
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@effect-tui/react",
|
|
3
|
-
"version": "0.15.
|
|
3
|
+
"version": "0.15.1",
|
|
4
4
|
"description": "React bindings for @effect-tui/core",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"files": [
|
|
@@ -83,7 +83,7 @@
|
|
|
83
83
|
"prepublishOnly": "bun run typecheck && bun run build"
|
|
84
84
|
},
|
|
85
85
|
"dependencies": {
|
|
86
|
-
"@effect-tui/core": "^0.15.
|
|
86
|
+
"@effect-tui/core": "^0.15.1",
|
|
87
87
|
"@effect/platform": "^0.94.1",
|
|
88
88
|
"@effect/platform-bun": "^0.87.0",
|
|
89
89
|
"@effect/rpc": "^0.73.0",
|
package/src/hosts/box.ts
CHANGED
|
@@ -59,8 +59,10 @@ export class BoxHost extends SingleChildHost {
|
|
|
59
59
|
}
|
|
60
60
|
|
|
61
61
|
private get insetY(): number {
|
|
62
|
-
|
|
63
|
-
|
|
62
|
+
// When titleDivider is enabled: top border + title row + divider line = 3
|
|
63
|
+
// When title but no divider: title embedded in top border = 1
|
|
64
|
+
const titleHeight = this.titleDivider && this.title && this.border !== "none" ? 2 : 0 // title row + divider
|
|
65
|
+
return this.borderThickness + titleHeight + this.padding.top + this.padding.bottom + this.borderThickness
|
|
64
66
|
}
|
|
65
67
|
|
|
66
68
|
measure(maxW: number, maxH: number): Size {
|
|
@@ -93,10 +95,11 @@ export class BoxHost extends SingleChildHost {
|
|
|
93
95
|
const layoutRect = this.layoutWithConstraints(rect)
|
|
94
96
|
|
|
95
97
|
const t = this.borderThickness
|
|
96
|
-
|
|
98
|
+
// When titleDivider: title row (1) + divider line (1) = 2
|
|
99
|
+
const titleHeight = this.titleDivider && this.title && this.border !== "none" ? 2 : 0
|
|
97
100
|
const innerRect: Rect = {
|
|
98
101
|
x: layoutRect.x + t + this.padding.left,
|
|
99
|
-
y: layoutRect.y + t +
|
|
102
|
+
y: layoutRect.y + t + titleHeight + this.padding.top,
|
|
100
103
|
w: Math.max(0, layoutRect.w - this.insetX),
|
|
101
104
|
h: Math.max(0, layoutRect.h - this.insetY),
|
|
102
105
|
}
|
|
@@ -123,29 +126,40 @@ export class BoxHost extends SingleChildHost {
|
|
|
123
126
|
const borderStyle = palette.id({ fg: borderFg })
|
|
124
127
|
drawBorder(buffer, x, y, w, h, chars, borderStyle)
|
|
125
128
|
|
|
126
|
-
// Draw title
|
|
129
|
+
// Draw title if present
|
|
127
130
|
if (this.title && w >= 7) {
|
|
128
131
|
const titleFg = toColorValue(this.titleColor) ?? borderFg
|
|
129
132
|
const titleStyle = palette.id({ fg: titleFg, bold: this.titleBold })
|
|
130
|
-
// Reserve
|
|
131
|
-
const maxTitleLen = w -
|
|
133
|
+
// Reserve space for borders and padding: 4 chars (│ + space + space + │)
|
|
134
|
+
const maxTitleLen = w - 4
|
|
132
135
|
const displayTitle =
|
|
133
136
|
this.title.length > maxTitleLen ? this.title.slice(0, maxTitleLen - 1) + "…" : this.title
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
137
|
+
|
|
138
|
+
if (this.titleDivider && h >= 4) {
|
|
139
|
+
// Title in its own row: │ Title │
|
|
140
|
+
const titleRowY = y + 1
|
|
141
|
+
const titleText = ` ${displayTitle}`
|
|
142
|
+
buffer.drawText(x, titleRowY, chars.v, borderStyle, 1)
|
|
143
|
+
buffer.drawText(x + 1, titleRowY, titleText, titleStyle, titleText.length)
|
|
144
|
+
// Fill remaining space and draw right border
|
|
145
|
+
for (let dx = 1 + titleText.length; dx < w - 1; dx++) {
|
|
146
|
+
buffer.drawText(x + dx, titleRowY, " ", borderStyle, 1)
|
|
147
|
+
}
|
|
148
|
+
buffer.drawText(x + w - 1, titleRowY, chars.v, borderStyle, 1)
|
|
149
|
+
|
|
150
|
+
// Divider line: ├───┤
|
|
151
|
+
const dividerY = y + 2
|
|
142
152
|
const tableChars = tableBorderChars(this.border)
|
|
143
|
-
// Draw ├ at left, ─ across, ┤ at right
|
|
144
153
|
buffer.drawText(x, dividerY, tableChars.lt, borderStyle, 1)
|
|
145
154
|
for (let dx = 1; dx < w - 1; dx++) {
|
|
146
155
|
buffer.drawText(x + dx, dividerY, tableChars.h, borderStyle, 1)
|
|
147
156
|
}
|
|
148
157
|
buffer.drawText(x + w - 1, dividerY, tableChars.rt, borderStyle, 1)
|
|
158
|
+
} else {
|
|
159
|
+
// Title embedded in top border: ┌─ Title ─┐
|
|
160
|
+
const titleX = x + 2
|
|
161
|
+
const titleText = ` ${displayTitle} `
|
|
162
|
+
buffer.drawText(titleX, y, titleText, titleStyle, titleText.length)
|
|
149
163
|
}
|
|
150
164
|
}
|
|
151
165
|
}
|
|
@@ -57,9 +57,6 @@ const hostConfig = {
|
|
|
57
57
|
supportsHydration: false,
|
|
58
58
|
|
|
59
59
|
createInstance(type: Type, props: Props, rootContainer: Container) {
|
|
60
|
-
if (type === "vstack") {
|
|
61
|
-
console.log("createInstance vstack props", props)
|
|
62
|
-
}
|
|
63
60
|
const instance = createHostInstance(type, props, rootContainer.ctx)
|
|
64
61
|
|
|
65
62
|
// Track static content (from <Static> component)
|
|
@@ -67,7 +64,6 @@ const hostConfig = {
|
|
|
67
64
|
instance.__static = true
|
|
68
65
|
rootContainer.staticRoot = instance
|
|
69
66
|
rootContainer.staticDirty = true
|
|
70
|
-
console.log("set staticRoot", Boolean(rootContainer.staticRoot))
|
|
71
67
|
}
|
|
72
68
|
|
|
73
69
|
return instance
|
|
@@ -98,9 +94,6 @@ const hostConfig = {
|
|
|
98
94
|
},
|
|
99
95
|
|
|
100
96
|
removeChildFromContainer(container: Container, child: Instance) {
|
|
101
|
-
if (child.__static) {
|
|
102
|
-
console.log("removeChildFromContainer static")
|
|
103
|
-
}
|
|
104
97
|
if (container.root) {
|
|
105
98
|
container.root.removeChild(child)
|
|
106
99
|
child.destroy()
|