@opentui/core 0.1.9 → 0.1.10
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/index.js +158 -82
- package/index.js.map +5 -5
- package/package.json +7 -7
- package/renderables/Box.d.ts +11 -2
- package/renderables/Input.d.ts +18 -7
- package/renderables/Select.d.ts +24 -9
package/index.js
CHANGED
|
@@ -9556,19 +9556,28 @@ class BoxRenderable extends Renderable {
|
|
|
9556
9556
|
shouldFill;
|
|
9557
9557
|
_title;
|
|
9558
9558
|
_titleAlignment;
|
|
9559
|
+
_defaultOptions = {
|
|
9560
|
+
backgroundColor: "transparent",
|
|
9561
|
+
borderStyle: "single",
|
|
9562
|
+
border: false,
|
|
9563
|
+
borderColor: "#FFFFFF",
|
|
9564
|
+
shouldFill: true,
|
|
9565
|
+
titleAlignment: "left",
|
|
9566
|
+
focusedBorderColor: "#00AAFF"
|
|
9567
|
+
};
|
|
9559
9568
|
constructor(id, options) {
|
|
9560
9569
|
super(id, options);
|
|
9561
|
-
this._backgroundColor = parseColor(options.backgroundColor ||
|
|
9562
|
-
this._border = options.border ??
|
|
9563
|
-
this._borderStyle = options.borderStyle ||
|
|
9564
|
-
this._borderColor = parseColor(options.borderColor ||
|
|
9565
|
-
this._focusedBorderColor = parseColor(options.focusedBorderColor ||
|
|
9570
|
+
this._backgroundColor = parseColor(options.backgroundColor || this._defaultOptions.backgroundColor);
|
|
9571
|
+
this._border = options.border ?? this._defaultOptions.border;
|
|
9572
|
+
this._borderStyle = options.borderStyle || this._defaultOptions.borderStyle;
|
|
9573
|
+
this._borderColor = parseColor(options.borderColor || this._defaultOptions.borderColor);
|
|
9574
|
+
this._focusedBorderColor = parseColor(options.focusedBorderColor || this._defaultOptions.focusedBorderColor);
|
|
9566
9575
|
this._customBorderCharsObj = options.customBorderChars;
|
|
9567
9576
|
this._customBorderChars = this._customBorderCharsObj ? borderCharsToArray(this._customBorderCharsObj) : undefined;
|
|
9568
9577
|
this.borderSides = getBorderSides(this._border);
|
|
9569
|
-
this.shouldFill = options.shouldFill ??
|
|
9578
|
+
this.shouldFill = options.shouldFill ?? this._defaultOptions.shouldFill;
|
|
9570
9579
|
this._title = options.title;
|
|
9571
|
-
this._titleAlignment = options.titleAlignment ||
|
|
9580
|
+
this._titleAlignment = options.titleAlignment || this._defaultOptions.titleAlignment;
|
|
9572
9581
|
this.applyYogaBorders();
|
|
9573
9582
|
}
|
|
9574
9583
|
get customBorderChars() {
|
|
@@ -9583,12 +9592,10 @@ class BoxRenderable extends Renderable {
|
|
|
9583
9592
|
return this._backgroundColor;
|
|
9584
9593
|
}
|
|
9585
9594
|
set backgroundColor(value) {
|
|
9586
|
-
|
|
9587
|
-
|
|
9588
|
-
|
|
9589
|
-
|
|
9590
|
-
this.needsUpdate();
|
|
9591
|
-
}
|
|
9595
|
+
const newColor = parseColor(value ?? this._defaultOptions.backgroundColor);
|
|
9596
|
+
if (this._backgroundColor !== newColor) {
|
|
9597
|
+
this._backgroundColor = newColor;
|
|
9598
|
+
this.needsUpdate();
|
|
9592
9599
|
}
|
|
9593
9600
|
}
|
|
9594
9601
|
get border() {
|
|
@@ -9606,8 +9613,9 @@ class BoxRenderable extends Renderable {
|
|
|
9606
9613
|
return this._borderStyle;
|
|
9607
9614
|
}
|
|
9608
9615
|
set borderStyle(value) {
|
|
9609
|
-
|
|
9610
|
-
|
|
9616
|
+
let _value = value ?? this._defaultOptions.borderStyle;
|
|
9617
|
+
if (this._borderStyle !== _value) {
|
|
9618
|
+
this._borderStyle = _value;
|
|
9611
9619
|
this._customBorderChars = undefined;
|
|
9612
9620
|
this.needsUpdate();
|
|
9613
9621
|
}
|
|
@@ -9616,7 +9624,7 @@ class BoxRenderable extends Renderable {
|
|
|
9616
9624
|
return this._borderColor;
|
|
9617
9625
|
}
|
|
9618
9626
|
set borderColor(value) {
|
|
9619
|
-
const newColor = parseColor(value);
|
|
9627
|
+
const newColor = parseColor(value ?? this._defaultOptions.borderColor);
|
|
9620
9628
|
if (this._borderColor !== newColor) {
|
|
9621
9629
|
this._borderColor = newColor;
|
|
9622
9630
|
this.needsUpdate();
|
|
@@ -9626,7 +9634,7 @@ class BoxRenderable extends Renderable {
|
|
|
9626
9634
|
return this._focusedBorderColor;
|
|
9627
9635
|
}
|
|
9628
9636
|
set focusedBorderColor(value) {
|
|
9629
|
-
const newColor = parseColor(value);
|
|
9637
|
+
const newColor = parseColor(value ?? this._defaultOptions.focusedBorderColor);
|
|
9630
9638
|
if (this._focusedBorderColor !== newColor) {
|
|
9631
9639
|
this._focusedBorderColor = newColor;
|
|
9632
9640
|
if (this._focused) {
|
|
@@ -10037,19 +10045,30 @@ class InputRenderable extends Renderable {
|
|
|
10037
10045
|
_cursorColor;
|
|
10038
10046
|
_maxLength;
|
|
10039
10047
|
_lastCommittedValue = "";
|
|
10048
|
+
_defaultOptions = {
|
|
10049
|
+
backgroundColor: "transparent",
|
|
10050
|
+
textColor: "#FFFFFF",
|
|
10051
|
+
focusedBackgroundColor: "#1a1a1a",
|
|
10052
|
+
focusedTextColor: "#FFFFFF",
|
|
10053
|
+
placeholder: "",
|
|
10054
|
+
placeholderColor: "#666666",
|
|
10055
|
+
cursorColor: "#FFFFFF",
|
|
10056
|
+
maxLength: 1000,
|
|
10057
|
+
value: ""
|
|
10058
|
+
};
|
|
10040
10059
|
constructor(id, options) {
|
|
10041
10060
|
super(id, { ...options, buffered: true });
|
|
10042
|
-
this._backgroundColor = parseColor(options.backgroundColor ||
|
|
10043
|
-
this._textColor = parseColor(options.textColor ||
|
|
10044
|
-
this._focusedBackgroundColor = parseColor(options.focusedBackgroundColor || options.backgroundColor ||
|
|
10045
|
-
this._focusedTextColor = parseColor(options.focusedTextColor || options.textColor ||
|
|
10046
|
-
this._placeholder = options.placeholder ||
|
|
10047
|
-
this._value = options.value ||
|
|
10061
|
+
this._backgroundColor = parseColor(options.backgroundColor || this._defaultOptions.backgroundColor);
|
|
10062
|
+
this._textColor = parseColor(options.textColor || this._defaultOptions.textColor);
|
|
10063
|
+
this._focusedBackgroundColor = parseColor(options.focusedBackgroundColor || options.backgroundColor || this._defaultOptions.focusedBackgroundColor);
|
|
10064
|
+
this._focusedTextColor = parseColor(options.focusedTextColor || options.textColor || this._defaultOptions.focusedTextColor);
|
|
10065
|
+
this._placeholder = options.placeholder || this._defaultOptions.placeholder;
|
|
10066
|
+
this._value = options.value || this._defaultOptions.value;
|
|
10048
10067
|
this._lastCommittedValue = this._value;
|
|
10049
10068
|
this._cursorPosition = this._value.length;
|
|
10050
|
-
this._maxLength = options.maxLength ||
|
|
10051
|
-
this._placeholderColor = parseColor(options.placeholderColor ||
|
|
10052
|
-
this._cursorColor = parseColor(options.cursorColor ||
|
|
10069
|
+
this._maxLength = options.maxLength || this._defaultOptions.maxLength;
|
|
10070
|
+
this._placeholderColor = parseColor(options.placeholderColor || this._defaultOptions.placeholderColor);
|
|
10071
|
+
this._cursorColor = parseColor(options.cursorColor || this._defaultOptions.cursorColor);
|
|
10053
10072
|
}
|
|
10054
10073
|
updateCursorPosition() {
|
|
10055
10074
|
if (!this._focused)
|
|
@@ -10219,29 +10238,47 @@ class InputRenderable extends Renderable {
|
|
|
10219
10238
|
this.needsUpdate();
|
|
10220
10239
|
}
|
|
10221
10240
|
}
|
|
10222
|
-
set backgroundColor(
|
|
10223
|
-
|
|
10224
|
-
this.
|
|
10241
|
+
set backgroundColor(value) {
|
|
10242
|
+
const newColor = parseColor(value ?? this._defaultOptions.backgroundColor);
|
|
10243
|
+
if (this._backgroundColor !== newColor) {
|
|
10244
|
+
this._backgroundColor = newColor;
|
|
10245
|
+
this.needsUpdate();
|
|
10246
|
+
}
|
|
10225
10247
|
}
|
|
10226
|
-
set textColor(
|
|
10227
|
-
|
|
10228
|
-
this.
|
|
10248
|
+
set textColor(value) {
|
|
10249
|
+
const newColor = parseColor(value ?? this._defaultOptions.textColor);
|
|
10250
|
+
if (this._textColor !== newColor) {
|
|
10251
|
+
this._textColor = newColor;
|
|
10252
|
+
this.needsUpdate();
|
|
10253
|
+
}
|
|
10229
10254
|
}
|
|
10230
|
-
set focusedBackgroundColor(
|
|
10231
|
-
|
|
10232
|
-
this.
|
|
10255
|
+
set focusedBackgroundColor(value) {
|
|
10256
|
+
const newColor = parseColor(value ?? this._defaultOptions.focusedBackgroundColor);
|
|
10257
|
+
if (this._focusedBackgroundColor !== newColor) {
|
|
10258
|
+
this._focusedBackgroundColor = newColor;
|
|
10259
|
+
this.needsUpdate();
|
|
10260
|
+
}
|
|
10233
10261
|
}
|
|
10234
|
-
set focusedTextColor(
|
|
10235
|
-
|
|
10236
|
-
this.
|
|
10262
|
+
set focusedTextColor(value) {
|
|
10263
|
+
const newColor = parseColor(value ?? this._defaultOptions.focusedTextColor);
|
|
10264
|
+
if (this._focusedTextColor !== newColor) {
|
|
10265
|
+
this._focusedTextColor = newColor;
|
|
10266
|
+
this.needsUpdate();
|
|
10267
|
+
}
|
|
10237
10268
|
}
|
|
10238
|
-
set placeholderColor(
|
|
10239
|
-
|
|
10240
|
-
this.
|
|
10269
|
+
set placeholderColor(value) {
|
|
10270
|
+
const newColor = parseColor(value ?? this._defaultOptions.placeholderColor);
|
|
10271
|
+
if (this._placeholderColor !== newColor) {
|
|
10272
|
+
this._placeholderColor = newColor;
|
|
10273
|
+
this.needsUpdate();
|
|
10274
|
+
}
|
|
10241
10275
|
}
|
|
10242
|
-
set cursorColor(
|
|
10243
|
-
|
|
10244
|
-
this.
|
|
10276
|
+
set cursorColor(value) {
|
|
10277
|
+
const newColor = parseColor(value ?? this._defaultOptions.cursorColor);
|
|
10278
|
+
if (this._cursorColor !== newColor) {
|
|
10279
|
+
this._cursorColor = newColor;
|
|
10280
|
+
this.needsUpdate();
|
|
10281
|
+
}
|
|
10245
10282
|
}
|
|
10246
10283
|
updateFromLayout() {
|
|
10247
10284
|
super.updateFromLayout();
|
|
@@ -10287,27 +10324,42 @@ class SelectRenderable extends Renderable {
|
|
|
10287
10324
|
linesPerItem;
|
|
10288
10325
|
fontHeight;
|
|
10289
10326
|
_fastScrollStep;
|
|
10327
|
+
_defaultOptions = {
|
|
10328
|
+
backgroundColor: "transparent",
|
|
10329
|
+
textColor: "#FFFFFF",
|
|
10330
|
+
focusedBackgroundColor: "#1a1a1a",
|
|
10331
|
+
focusedTextColor: "#FFFFFF",
|
|
10332
|
+
selectedBackgroundColor: "#334455",
|
|
10333
|
+
selectedTextColor: "#FFFF00",
|
|
10334
|
+
descriptionColor: "#888888",
|
|
10335
|
+
selectedDescriptionColor: "#CCCCCC",
|
|
10336
|
+
showScrollIndicator: false,
|
|
10337
|
+
wrapSelection: false,
|
|
10338
|
+
showDescription: true,
|
|
10339
|
+
itemSpacing: 0,
|
|
10340
|
+
fastScrollStep: 5
|
|
10341
|
+
};
|
|
10290
10342
|
constructor(id, options) {
|
|
10291
10343
|
super(id, { ...options, buffered: true });
|
|
10292
|
-
this._backgroundColor = parseColor(options.backgroundColor ||
|
|
10293
|
-
this._textColor = parseColor(options.textColor ||
|
|
10294
|
-
this._focusedBackgroundColor = parseColor(options.focusedBackgroundColor ||
|
|
10295
|
-
this._focusedTextColor = parseColor(options.focusedTextColor ||
|
|
10344
|
+
this._backgroundColor = parseColor(options.backgroundColor || this._defaultOptions.backgroundColor);
|
|
10345
|
+
this._textColor = parseColor(options.textColor || this._defaultOptions.textColor);
|
|
10346
|
+
this._focusedBackgroundColor = parseColor(options.focusedBackgroundColor || this._defaultOptions.focusedBackgroundColor);
|
|
10347
|
+
this._focusedTextColor = parseColor(options.focusedTextColor || this._defaultOptions.focusedTextColor);
|
|
10296
10348
|
this._options = options.options || [];
|
|
10297
|
-
this._showScrollIndicator = options.showScrollIndicator ??
|
|
10298
|
-
this._wrapSelection = options.wrapSelection ??
|
|
10299
|
-
this._showDescription = options.showDescription ??
|
|
10349
|
+
this._showScrollIndicator = options.showScrollIndicator ?? this._defaultOptions.showScrollIndicator;
|
|
10350
|
+
this._wrapSelection = options.wrapSelection ?? this._defaultOptions.wrapSelection;
|
|
10351
|
+
this._showDescription = options.showDescription ?? this._defaultOptions.showDescription;
|
|
10300
10352
|
this._font = options.font;
|
|
10301
|
-
this._itemSpacing = options.itemSpacing ||
|
|
10353
|
+
this._itemSpacing = options.itemSpacing || this._defaultOptions.itemSpacing;
|
|
10302
10354
|
this.fontHeight = this._font ? measureText({ text: "A", font: this._font }).height : 1;
|
|
10303
10355
|
this.linesPerItem = this._showDescription ? this._font ? this.fontHeight + 1 : 2 : this._font ? this.fontHeight : 1;
|
|
10304
10356
|
this.linesPerItem += this._itemSpacing;
|
|
10305
10357
|
this.maxVisibleItems = Math.max(1, Math.floor(this.height / this.linesPerItem));
|
|
10306
|
-
this._selectedBackgroundColor = parseColor(options.selectedBackgroundColor ||
|
|
10307
|
-
this._selectedTextColor = parseColor(options.selectedTextColor ||
|
|
10308
|
-
this._descriptionColor = parseColor(options.descriptionColor ||
|
|
10309
|
-
this._selectedDescriptionColor = parseColor(options.selectedDescriptionColor ||
|
|
10310
|
-
this._fastScrollStep = options.fastScrollStep ||
|
|
10358
|
+
this._selectedBackgroundColor = parseColor(options.selectedBackgroundColor || this._defaultOptions.selectedBackgroundColor);
|
|
10359
|
+
this._selectedTextColor = parseColor(options.selectedTextColor || this._defaultOptions.selectedTextColor);
|
|
10360
|
+
this._descriptionColor = parseColor(options.descriptionColor || this._defaultOptions.descriptionColor);
|
|
10361
|
+
this._selectedDescriptionColor = parseColor(options.selectedDescriptionColor || this._defaultOptions.selectedDescriptionColor);
|
|
10362
|
+
this._fastScrollStep = options.fastScrollStep || this._defaultOptions.fastScrollStep;
|
|
10311
10363
|
this.needsUpdate();
|
|
10312
10364
|
}
|
|
10313
10365
|
renderSelf(buffer, deltaTime) {
|
|
@@ -10492,37 +10544,61 @@ class SelectRenderable extends Renderable {
|
|
|
10492
10544
|
set wrapSelection(wrap) {
|
|
10493
10545
|
this._wrapSelection = wrap;
|
|
10494
10546
|
}
|
|
10495
|
-
set backgroundColor(
|
|
10496
|
-
|
|
10497
|
-
this.
|
|
10547
|
+
set backgroundColor(value) {
|
|
10548
|
+
const newColor = parseColor(value ?? this._defaultOptions.backgroundColor);
|
|
10549
|
+
if (this._backgroundColor !== newColor) {
|
|
10550
|
+
this._backgroundColor = newColor;
|
|
10551
|
+
this.needsUpdate();
|
|
10552
|
+
}
|
|
10498
10553
|
}
|
|
10499
|
-
set textColor(
|
|
10500
|
-
|
|
10501
|
-
this.
|
|
10554
|
+
set textColor(value) {
|
|
10555
|
+
const newColor = parseColor(value ?? this._defaultOptions.textColor);
|
|
10556
|
+
if (this._textColor !== newColor) {
|
|
10557
|
+
this._textColor = newColor;
|
|
10558
|
+
this.needsUpdate();
|
|
10559
|
+
}
|
|
10502
10560
|
}
|
|
10503
|
-
set focusedBackgroundColor(
|
|
10504
|
-
|
|
10505
|
-
this.
|
|
10561
|
+
set focusedBackgroundColor(value) {
|
|
10562
|
+
const newColor = parseColor(value ?? this._defaultOptions.focusedBackgroundColor);
|
|
10563
|
+
if (this._focusedBackgroundColor !== newColor) {
|
|
10564
|
+
this._focusedBackgroundColor = newColor;
|
|
10565
|
+
this.needsUpdate();
|
|
10566
|
+
}
|
|
10506
10567
|
}
|
|
10507
|
-
set focusedTextColor(
|
|
10508
|
-
|
|
10509
|
-
this.
|
|
10568
|
+
set focusedTextColor(value) {
|
|
10569
|
+
const newColor = parseColor(value ?? this._defaultOptions.focusedTextColor);
|
|
10570
|
+
if (this._focusedTextColor !== newColor) {
|
|
10571
|
+
this._focusedTextColor = newColor;
|
|
10572
|
+
this.needsUpdate();
|
|
10573
|
+
}
|
|
10510
10574
|
}
|
|
10511
|
-
set selectedBackgroundColor(
|
|
10512
|
-
|
|
10513
|
-
this.
|
|
10575
|
+
set selectedBackgroundColor(value) {
|
|
10576
|
+
const newColor = parseColor(value ?? this._defaultOptions.selectedBackgroundColor);
|
|
10577
|
+
if (this._selectedBackgroundColor !== newColor) {
|
|
10578
|
+
this._selectedBackgroundColor = newColor;
|
|
10579
|
+
this.needsUpdate();
|
|
10580
|
+
}
|
|
10514
10581
|
}
|
|
10515
|
-
set selectedTextColor(
|
|
10516
|
-
|
|
10517
|
-
this.
|
|
10582
|
+
set selectedTextColor(value) {
|
|
10583
|
+
const newColor = parseColor(value ?? this._defaultOptions.selectedTextColor);
|
|
10584
|
+
if (this._selectedTextColor !== newColor) {
|
|
10585
|
+
this._selectedTextColor = newColor;
|
|
10586
|
+
this.needsUpdate();
|
|
10587
|
+
}
|
|
10518
10588
|
}
|
|
10519
|
-
set descriptionColor(
|
|
10520
|
-
|
|
10521
|
-
this.
|
|
10589
|
+
set descriptionColor(value) {
|
|
10590
|
+
const newColor = parseColor(value ?? this._defaultOptions.descriptionColor);
|
|
10591
|
+
if (this._descriptionColor !== newColor) {
|
|
10592
|
+
this._descriptionColor = newColor;
|
|
10593
|
+
this.needsUpdate();
|
|
10594
|
+
}
|
|
10522
10595
|
}
|
|
10523
|
-
set selectedDescriptionColor(
|
|
10524
|
-
|
|
10525
|
-
this.
|
|
10596
|
+
set selectedDescriptionColor(value) {
|
|
10597
|
+
const newColor = parseColor(value ?? this._defaultOptions.selectedDescriptionColor);
|
|
10598
|
+
if (this._selectedDescriptionColor !== newColor) {
|
|
10599
|
+
this._selectedDescriptionColor = newColor;
|
|
10600
|
+
this.needsUpdate();
|
|
10601
|
+
}
|
|
10526
10602
|
}
|
|
10527
10603
|
set font(font) {
|
|
10528
10604
|
this._font = font;
|
|
@@ -10981,5 +11057,5 @@ export {
|
|
|
10981
11057
|
ASCIIFontRenderable
|
|
10982
11058
|
};
|
|
10983
11059
|
export { __toESM, __commonJS, __export, __require };
|
|
10984
|
-
//# debugId=
|
|
11060
|
+
//# debugId=63F280D9D38C7F3F64756E2164756E21
|
|
10985
11061
|
//# sourceMappingURL=index.js.map
|