@trendr/core 0.2.3 → 0.2.4

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/package.json +1 -1
  2. package/src/text-area.js +7 -1
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@trendr/core",
3
- "version": "0.2.3",
3
+ "version": "0.2.4",
4
4
  "description": "direct-mode TUI renderer with JSX, signals, and per-cell diffing",
5
5
  "license": "MIT",
6
6
  "type": "module",
package/src/text-area.js CHANGED
@@ -87,9 +87,15 @@ function ensureVisible(cursorRow, scroll, height, totalLines) {
87
87
  return scroll
88
88
  }
89
89
 
90
- export function TextArea({ onSubmit, onCancel, onChange, placeholder, focused = true, maxHeight = 10, clearOnSubmit = true, cursor: cursorProp }) {
90
+ export function TextArea({ onSubmit, onCancel, onChange, placeholder, focused = true, maxHeight = 10, clearOnSubmit = true, cursor: cursorProp, value: valueProp }) {
91
91
  const [value, setValue] = createSignal('')
92
92
  const [cursor, setCursor] = createSignal(0)
93
+ const _prev = registerHook(() => ({ value: undefined }))
94
+ if (valueProp !== undefined && valueProp !== _prev.value) {
95
+ _prev.value = valueProp
96
+ setValue(valueProp)
97
+ setCursor(valueProp.length)
98
+ }
93
99
  const ref = registerHook(() => ({ scroll: 0, goalCol: null }))
94
100
  const layout = useLayout()
95
101
  const { cursorStyle, reset: resetBlink } = useCursor(cursorProp, focused)