uicore-ts 1.1.66 → 1.1.81

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "uicore-ts",
3
- "version": "1.1.66",
3
+ "version": "1.1.81",
4
4
  "description": "UICore is a library to build native-like user interfaces using pure Typescript. No HTML is needed at all. Components are described as TS classes and all user interactions are handled explicitly. This library is strongly inspired by the UIKit framework that is used in IOS. In addition, UICore has tools to handle URL based routing, array sorting and filtering and adds a number of other utilities for convenience.",
5
5
  "main": "compiledScripts/index.js",
6
6
  "types": "compiledScripts/index.d.ts",
@@ -65,6 +65,10 @@ export class UIColor extends UIObject {
65
65
  return new UIColor("transparent")
66
66
  }
67
67
 
68
+ static get clearColor() {
69
+ return new UIColor("transparent")
70
+ }
71
+
68
72
  static get undefinedColor() {
69
73
  return new UIColor("")
70
74
  }
package/scripts/UIView.ts CHANGED
@@ -225,6 +225,13 @@ export class UIView extends UIObject {
225
225
  private _resizeObserverEntry?: ResizeObserverEntry
226
226
  protected _intrinsicSizesCache: Record<string, UIRectangle> = {}
227
227
 
228
+ static isVirtualLayouting = NO
229
+ _frameForVirtualLayouting?: UIRectangle
230
+
231
+ // Change this to no if the view contains pure HTML content that does not
232
+ // use frame logic that can influence the intrinsic size
233
+ usesVirtualLayoutingForIntrinsicSizing = YES
234
+
228
235
 
229
236
  constructor(
230
237
  elementID: string = ("UIView" + UIView.nextIndex),
@@ -949,7 +956,13 @@ export class UIView extends UIObject {
949
956
 
950
957
 
951
958
  public get frame() {
952
- let result: UIRectangle & { zIndex?: number } = this._frame?.copy() as any
959
+ let result: UIRectangle & { zIndex?: number }
960
+ if (!UIView.isVirtualLayouting) {
961
+ result = this._frame?.copy() as any
962
+ }
963
+ else {
964
+ result = this._frameForVirtualLayouting?.copy() as any
965
+ }
953
966
  if (!result) {
954
967
  result = new UIRectangle(
955
968
  this._resizeObserverEntry?.contentRect.left ?? this.viewHTMLElement.offsetLeft,
@@ -977,7 +990,12 @@ export class UIView extends UIObject {
977
990
  if (zIndex != undefined) {
978
991
  rectangle.zIndex = zIndex
979
992
  }
980
- this._frame = rectangle
993
+ if (!UIView.isVirtualLayouting) {
994
+ this._frame = rectangle
995
+ }
996
+ else {
997
+ this._frameForVirtualLayouting = rectangle
998
+ }
981
999
 
982
1000
  if (frame && frame != nil && frame.isEqualTo(rectangle) && frame.zIndex == rectangle.zIndex && !performUncheckedLayout) {
983
1001
  return
@@ -987,15 +1005,17 @@ export class UIView extends UIObject {
987
1005
  rectangle.scale(1 / this.scale)
988
1006
  }
989
1007
 
990
- UIView._setAbsoluteSizeAndPosition(
991
- this.viewHTMLElement,
992
- rectangle.topLeft.x,
993
- rectangle.topLeft.y,
994
- rectangle.width,
995
- rectangle.height,
996
- rectangle.zIndex,
997
- this.frameTransform
998
- )
1008
+ if (!UIView.isVirtualLayouting) {
1009
+ UIView._setAbsoluteSizeAndPosition(
1010
+ this.viewHTMLElement,
1011
+ rectangle.topLeft.x,
1012
+ rectangle.topLeft.y,
1013
+ rectangle.width,
1014
+ rectangle.height,
1015
+ rectangle.zIndex,
1016
+ this.frameTransform
1017
+ )
1018
+ }
999
1019
 
1000
1020
  if (frame.height != rectangle.height || frame.width != rectangle.width || performUncheckedLayout) {
1001
1021
  this.setNeedsLayout()
@@ -1005,8 +1025,17 @@ export class UIView extends UIObject {
1005
1025
  }
1006
1026
 
1007
1027
  get bounds() {
1028
+
1029
+ let _frame: (UIRectangle & { zIndex?: number }) | undefined
1030
+ if (!UIView.isVirtualLayouting) {
1031
+ _frame = this._frame
1032
+ }
1033
+ else {
1034
+ _frame = this._frameForVirtualLayouting
1035
+ }
1036
+
1008
1037
  let result: UIRectangle
1009
- if (IS_NOT(this._frame)) {
1038
+ if (IS_NOT(_frame)) {
1010
1039
  result = new UIRectangle(
1011
1040
  0,
1012
1041
  0,
@@ -1015,7 +1044,14 @@ export class UIView extends UIObject {
1015
1044
  )
1016
1045
  }
1017
1046
  else {
1018
- result = this.frame.copy()
1047
+ let frame: (UIRectangle & { zIndex?: number })
1048
+ if (!UIView.isVirtualLayouting) {
1049
+ frame = this.frame
1050
+ }
1051
+ else {
1052
+ frame = this._frameForVirtualLayouting ?? this.frame
1053
+ }
1054
+ result = frame.copy()
1019
1055
  result.x = 0
1020
1056
  result.y = 0
1021
1057
  }
@@ -3458,12 +3494,30 @@ export class UIView extends UIObject {
3458
3494
 
3459
3495
  intrinsicContentWidth(constrainingHeight: number = 0): number {
3460
3496
 
3497
+ if (this.usesVirtualLayoutingForIntrinsicSizing) {
3498
+ UIView.isVirtualLayouting = YES
3499
+ this.frame = this.frame.rectangleWithHeight(constrainingHeight)
3500
+ this.layoutIfNeeded()
3501
+ const result = this.frame
3502
+ UIView.isVirtualLayouting = NO
3503
+ return result.width
3504
+ }
3505
+
3461
3506
  return this.intrinsicContentSizeWithConstraints(constrainingHeight).width
3462
3507
 
3463
3508
  }
3464
3509
 
3465
3510
  intrinsicContentHeight(constrainingWidth: number = 0): number {
3466
3511
 
3512
+ if (this.usesVirtualLayoutingForIntrinsicSizing) {
3513
+ UIView.isVirtualLayouting = YES
3514
+ this.frame = this.frame.rectangleWithWidth(constrainingWidth)
3515
+ this.layoutIfNeeded()
3516
+ const result = this.frame
3517
+ UIView.isVirtualLayouting = NO
3518
+ return result.height
3519
+ }
3520
+
3467
3521
  return this.intrinsicContentSizeWithConstraints(undefined, constrainingWidth).height
3468
3522
 
3469
3523
 
@@ -3472,6 +3526,14 @@ export class UIView extends UIObject {
3472
3526
 
3473
3527
  intrinsicContentSize(): UIRectangle {
3474
3528
 
3529
+ if (this.usesVirtualLayoutingForIntrinsicSizing) {
3530
+ UIView.isVirtualLayouting = YES
3531
+ this.layoutIfNeeded()
3532
+ const result = this.frame
3533
+ UIView.isVirtualLayouting = NO
3534
+ return result
3535
+ }
3536
+
3475
3537
  return nil
3476
3538
 
3477
3539
  }