OpenTUI 0.6.6
Previously, most layout setters ignored null, undefined, or both, so the node kept its old style. As a result, a React or Solid component that removed a style prop kept the old layout. A plugin that read Unit.Undefined from a getter also could not write that value back. In 0.6.6, a nullish write restores the default that the constructor uses when the option is omitted:
const box = new BoxRenderable(renderer, { paddingX: 2 })
box.paddingLeft = 5 // pads the left side by 5
box.paddingLeft = undefined // pads it by 2 again, from paddingX
Margin, padding, gap, min and max sizes, and flexBasis become unset, so an edge falls back to its shorthand again. top, right, bottom, and left also unset the native edge. Before, the getter reported undefined while layout kept the old offset. width and height become "auto", position becomes "relative", overflow becomes "visible", and visible becomes true. Invalid values are still ignored. Not every default comes back. Class defaults such as the row direction of ScrollBoxRenderable stay as they are, and flexShrink becomes 1.
If a custom renderable passes its own width or height to super(), it should override the new protected defaultDimension(kind) method. A nullish write then restores that size instead of "auto". Built-in classes that size themselves, such as InputRenderable, TabSelectRenderable, and ASCIIFontRenderable, already override it.
Added
- core: A custom renderable can override
protected defaultDimension(kind)to set thewidthorheightthat a nullish write restores. See Custom renderables. (#1678)
Changed
- core: Assigning
nullorundefinedto a layout property restores the default for an omitted option, and removing a React or Solid style prop does the same. See Layout. (#1678) - core: Assigning
nullorundefinedtovisibleshows the node. Before,nullhid the node, so assignfalseto hide it. (#1678)
Fixed
- core:
fillRect,drawBox,setCell,drawChar, and other calls with u32 fields now say “must be a non-negative integer” for NaN, Infinity, fractional, and negative values. Before, the error said that the value exceeded the u32 limit. See Buffer API. (#1674) - core: A box
titleorbottomTitleover 64 KiB throws the sameRangeErrorasdrawTextinstead of aNativeErrorwith theInvalidArgumentstatus. See Box. (#1674) - core: Nesting deeper than 256 levels, counting the root, throws a
NativeErrorwith the message “Scene nesting depth exceeds the native limit”. Before, the message gave only theObjectLimitstatus. See Layout. (#1674)
API changes#
@opentui/core#
Added
protected method ASCIIFontRenderable.defaultDimension(kind: "width" | "height"): numberprotected method ArrowRenderable.defaultDimension(kind: "width" | "height"): number | "auto" | `${number}%`protected method EmbeddedTerminalRenderable.defaultDimension(kind: "width" | "height"): numberprotected method InputRenderable.defaultDimension(kind: "width" | "height"): number | "auto" | `${number}%`protected method Renderable.defaultDimension(_kind: "width" | "height"): number | "auto" | `${number}%`protected method TabSelectRenderable.defaultDimension(kind: "width" | "height"): number | "auto" | `${number}%`protected method TimeToFirstDrawRenderable.defaultDimension(kind: "width" | "height"): number | `${number}%`
Changed
constructor NativeError(operation: string, status: NativeStatus)constructor NativeError(operation: string, status: NativeStatus, reason?: string)property BoxRenderable.columnGap: number | `${number}%` | undefinedproperty BoxRenderable.columnGap: number | `${number}%` | null | undefinedproperty BoxRenderable.gap: number | `${number}%` | undefinedproperty BoxRenderable.gap: number | `${number}%` | null | undefinedproperty BoxRenderable.rowGap: number | `${number}%` | undefinedproperty BoxRenderable.rowGap: number | `${number}%` | null | undefined