uicore-ts 1.0.521 → 1.0.527

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 (60) hide show
  1. package/compiledScripts/UIButton.d.ts +2 -2
  2. package/compiledScripts/UIButton.js +1 -0
  3. package/compiledScripts/UIButton.js.map +2 -2
  4. package/compiledScripts/UICore.js +3 -1
  5. package/compiledScripts/UICore.js.map +2 -2
  6. package/compiledScripts/UICoreExtensions.d.ts +4 -1
  7. package/compiledScripts/UICoreExtensions.js +29 -3
  8. package/compiledScripts/UICoreExtensions.js.map +2 -2
  9. package/compiledScripts/UIDialogView.d.ts +2 -2
  10. package/compiledScripts/UIDialogView.js +1 -0
  11. package/compiledScripts/UIDialogView.js.map +2 -2
  12. package/compiledScripts/UIImageView.js +4 -1
  13. package/compiledScripts/UIImageView.js.map +2 -2
  14. package/compiledScripts/UIKeyValueSorter.d.ts +42 -0
  15. package/compiledScripts/UIKeyValueSorter.js +155 -0
  16. package/compiledScripts/UIKeyValueSorter.js.map +7 -0
  17. package/compiledScripts/UIKeyValueSorterWebWorker.worker.d.ts +10 -0
  18. package/compiledScripts/UIKeyValueSorterWebWorker.worker.js +78 -0
  19. package/compiledScripts/UIKeyValueSorterWebWorker.worker.js.map +7 -0
  20. package/compiledScripts/UILinkButton.d.ts +1 -1
  21. package/compiledScripts/UINativeScrollView.d.ts +1 -0
  22. package/compiledScripts/UINativeScrollView.js +7 -3
  23. package/compiledScripts/UINativeScrollView.js.map +2 -2
  24. package/compiledScripts/UIObject.d.ts +14 -4
  25. package/compiledScripts/UIObject.js +4 -0
  26. package/compiledScripts/UIObject.js.map +2 -2
  27. package/compiledScripts/UIRootViewController.js +8 -9
  28. package/compiledScripts/UIRootViewController.js.map +2 -2
  29. package/compiledScripts/UITableView.d.ts +1 -0
  30. package/compiledScripts/UITableView.js +3 -1
  31. package/compiledScripts/UITableView.js.map +2 -2
  32. package/compiledScripts/UITextField.d.ts +1 -1
  33. package/compiledScripts/UITextField.js.map +2 -2
  34. package/compiledScripts/UITextView.js +4 -2
  35. package/compiledScripts/UITextView.js.map +2 -2
  36. package/compiledScripts/UIView.d.ts +12 -3
  37. package/compiledScripts/UIView.js +101 -40
  38. package/compiledScripts/UIView.js.map +2 -2
  39. package/compiledScripts/UIViewController.js +4 -2
  40. package/compiledScripts/UIViewController.js.map +2 -2
  41. package/compiledScripts/index.d.ts +1 -1
  42. package/compiledScripts/index.js +1 -1
  43. package/compiledScripts/index.js.map +2 -2
  44. package/package.json +1 -1
  45. package/scripts/UIButton.ts +2 -2
  46. package/scripts/UICore.ts +37 -36
  47. package/scripts/UICoreExtensions.ts +41 -4
  48. package/scripts/UIDialogView.ts +2 -2
  49. package/scripts/UIImageView.ts +1 -1
  50. package/scripts/{UIKeyValueStringSorter.ts → UIKeyValueSorter.ts} +10 -9
  51. package/scripts/{UIKeyValueStringSorterWebWorker.worker.ts → UIKeyValueSorterWebWorker.worker.ts} +15 -4
  52. package/scripts/UINativeScrollView.ts +10 -4
  53. package/scripts/UIObject.ts +24 -6
  54. package/scripts/UIRootViewController.ts +16 -5
  55. package/scripts/UITableView.ts +4 -5
  56. package/scripts/UITextField.ts +1 -1
  57. package/scripts/UITextView.ts +20 -12
  58. package/scripts/UIView.ts +165 -65
  59. package/scripts/UIViewController.ts +7 -3
  60. package/scripts/index.ts +1 -1
@@ -61,6 +61,7 @@ if (!window.AutoLayout) {
61
61
  window.AutoLayout = import_UIObject.nil;
62
62
  }
63
63
  function UIComponentView(target, context) {
64
+ console.log("Recording annotation UIComponentView on " + target.name);
64
65
  import_UIObject.UIObject.recordAnnotation(UIComponentView, target);
65
66
  }
66
67
  const _UIView = class extends import_UIObject.UIObject {
@@ -90,6 +91,7 @@ const _UIView = class extends import_UIObject.UIObject {
90
91
  this._isMoving = import_UIObject.NO;
91
92
  this._isCBEditorTemporaryResizable = import_UIObject.NO;
92
93
  this._isCBEditorTemporaryMovable = import_UIObject.NO;
94
+ this._intrinsicSizesCache = {};
93
95
  this.controlEvent = _UIView.controlEvent;
94
96
  _UIView._UIViewIndex = _UIView.nextIndex;
95
97
  this._UIViewIndex = _UIView._UIViewIndex;
@@ -150,8 +152,6 @@ const _UIView = class extends import_UIObject.UIObject {
150
152
  this.viewHTMLElement.obeyAutolayout = import_UIObject.YES;
151
153
  this.viewHTMLElement.UIView = this;
152
154
  this.addStyleClass(this.styleClassName);
153
- this._resizeObserver = new ResizeObserver(() => this.setNeedsLayout());
154
- this._resizeObserver.observe(this.viewHTMLElement);
155
155
  }
156
156
  set nativeSelectionEnabled(selectable) {
157
157
  this._nativeSelectionEnabled = selectable;
@@ -456,14 +456,14 @@ const _UIView = class extends import_UIObject.UIObject {
456
456
  calculateAndSetViewFrame() {
457
457
  }
458
458
  get frame() {
459
- var _a;
459
+ var _a, _b, _c, _d, _e, _f, _g, _h, _i;
460
460
  let result = (_a = this._frame) == null ? void 0 : _a.copy();
461
461
  if (!result) {
462
462
  result = new import_UIRectangle.UIRectangle(
463
- this.viewHTMLElement.offsetLeft,
464
- this.viewHTMLElement.offsetTop,
465
- this.viewHTMLElement.offsetHeight,
466
- this.viewHTMLElement.offsetWidth
463
+ (_c = (_b = this._resizeObserverEntry) == null ? void 0 : _b.contentRect.left) != null ? _c : this.viewHTMLElement.offsetLeft,
464
+ (_e = (_d = this._resizeObserverEntry) == null ? void 0 : _d.contentRect.top) != null ? _e : this.viewHTMLElement.offsetTop,
465
+ (_g = (_f = this._resizeObserverEntry) == null ? void 0 : _f.contentRect.height) != null ? _g : this.viewHTMLElement.offsetHeight,
466
+ (_i = (_h = this._resizeObserverEntry) == null ? void 0 : _h.contentRect.width) != null ? _i : this.viewHTMLElement.offsetWidth
467
467
  );
468
468
  result.zIndex = 0;
469
469
  }
@@ -480,7 +480,7 @@ const _UIView = class extends import_UIObject.UIObject {
480
480
  rectangle.zIndex = zIndex;
481
481
  }
482
482
  this._frame = rectangle;
483
- if (frame && frame.isEqualTo(rectangle) && frame.zIndex == rectangle.zIndex && !performUncheckedLayout) {
483
+ if (frame && frame != import_UIObject.nil && frame.isEqualTo(rectangle) && frame.zIndex == rectangle.zIndex && !performUncheckedLayout) {
484
484
  return;
485
485
  }
486
486
  if (this.isInternalScaling) {
@@ -497,13 +497,19 @@ const _UIView = class extends import_UIObject.UIObject {
497
497
  );
498
498
  if (frame.height != rectangle.height || frame.width != rectangle.width || performUncheckedLayout) {
499
499
  this.setNeedsLayout();
500
- this.boundsDidChange();
500
+ this.boundsDidChange(this.bounds);
501
501
  }
502
502
  }
503
503
  get bounds() {
504
+ var _a, _b, _c, _d;
504
505
  let result;
505
506
  if ((0, import_UIObject.IS_NOT)(this._frame)) {
506
- result = new import_UIRectangle.UIRectangle(0, 0, this.viewHTMLElement.offsetHeight, this.viewHTMLElement.offsetWidth);
507
+ result = new import_UIRectangle.UIRectangle(
508
+ 0,
509
+ 0,
510
+ (_b = (_a = this._resizeObserverEntry) == null ? void 0 : _a.contentRect.height) != null ? _b : this.viewHTMLElement.offsetHeight,
511
+ (_d = (_c = this._resizeObserverEntry) == null ? void 0 : _c.contentRect.width) != null ? _d : this.viewHTMLElement.offsetWidth
512
+ );
507
513
  } else {
508
514
  result = this.frame.copy();
509
515
  result.x = 0;
@@ -517,7 +523,12 @@ const _UIView = class extends import_UIObject.UIObject {
517
523
  newFrame.zIndex = frame.zIndex;
518
524
  this.frame = newFrame;
519
525
  }
520
- boundsDidChange() {
526
+ boundsDidChange(bounds) {
527
+ }
528
+ didResize(entry) {
529
+ this._resizeObserverEntry = entry;
530
+ this.setNeedsLayout();
531
+ this.boundsDidChange(new import_UIRectangle.UIRectangle(0, 0, entry.contentRect.height, entry.contentRect.width));
521
532
  }
522
533
  get frameTransform() {
523
534
  return this._frameTransform;
@@ -537,7 +548,7 @@ const _UIView = class extends import_UIObject.UIObject {
537
548
  const bounds = this.bounds;
538
549
  if (bounds.height != previousBounds.height || bounds.width != previousBounds.width) {
539
550
  this.setNeedsLayout();
540
- this.boundsDidChange();
551
+ this.boundsDidChange(bounds);
541
552
  }
542
553
  }
543
554
  setSizes(height, width) {
@@ -547,7 +558,7 @@ const _UIView = class extends import_UIObject.UIObject {
547
558
  const bounds = this.bounds;
548
559
  if (bounds.height != previousBounds.height || bounds.width != previousBounds.width) {
549
560
  this.setNeedsLayout();
550
- this.boundsDidChange();
561
+ this.boundsDidChange(bounds);
551
562
  }
552
563
  }
553
564
  setMinSizes(height, width) {
@@ -557,7 +568,7 @@ const _UIView = class extends import_UIObject.UIObject {
557
568
  const bounds = this.bounds;
558
569
  if (bounds.height != previousBounds.height || bounds.width != previousBounds.width) {
559
570
  this.setNeedsLayout();
560
- this.boundsDidChange();
571
+ this.boundsDidChange(bounds);
561
572
  }
562
573
  }
563
574
  setMaxSizes(height, width) {
@@ -567,7 +578,7 @@ const _UIView = class extends import_UIObject.UIObject {
567
578
  const bounds = this.bounds;
568
579
  if (bounds.height != previousBounds.height || bounds.width != previousBounds.width) {
569
580
  this.setNeedsLayout();
570
- this.boundsDidChange();
581
+ this.boundsDidChange(bounds);
571
582
  }
572
583
  }
573
584
  setMargin(margin) {
@@ -576,7 +587,7 @@ const _UIView = class extends import_UIObject.UIObject {
576
587
  const bounds = this.bounds;
577
588
  if (bounds.height != previousBounds.height || bounds.width != previousBounds.width) {
578
589
  this.setNeedsLayout();
579
- this.boundsDidChange();
590
+ this.boundsDidChange(bounds);
580
591
  }
581
592
  }
582
593
  setMargins(left, right, bottom, top) {
@@ -588,7 +599,7 @@ const _UIView = class extends import_UIObject.UIObject {
588
599
  const bounds = this.bounds;
589
600
  if (bounds.height != previousBounds.height || bounds.width != previousBounds.width) {
590
601
  this.setNeedsLayout();
591
- this.boundsDidChange();
602
+ this.boundsDidChange(bounds);
592
603
  }
593
604
  }
594
605
  setPadding(padding) {
@@ -597,7 +608,7 @@ const _UIView = class extends import_UIObject.UIObject {
597
608
  const bounds = this.bounds;
598
609
  if (bounds.height != previousBounds.height || bounds.width != previousBounds.width) {
599
610
  this.setNeedsLayout();
600
- this.boundsDidChange();
611
+ this.boundsDidChange(bounds);
601
612
  }
602
613
  }
603
614
  setPaddings(left, right, bottom, top) {
@@ -609,7 +620,7 @@ const _UIView = class extends import_UIObject.UIObject {
609
620
  const bounds = this.bounds;
610
621
  if (bounds.height != previousBounds.height || bounds.width != previousBounds.width) {
611
622
  this.setNeedsLayout();
612
- this.boundsDidChange();
623
+ this.boundsDidChange(bounds);
613
624
  }
614
625
  }
615
626
  setBorder(radius = import_UIObject.nil, width = 1, color = import_UIColor.UIColor.blackColor, style = "solid") {
@@ -756,29 +767,27 @@ const _UIView = class extends import_UIObject.UIObject {
756
767
  if ((0, import_UIObject.IS)(width)) {
757
768
  width = width.integerValue + "px";
758
769
  }
759
- let str = element.style.cssText;
760
- frameTransform = _UIView._transformAttribute + ": translate3d(" + left.integerValue + "px, " + top.integerValue + "px, 0px)" + frameTransform;
770
+ frameTransform = "translate3d(" + left.integerValue + "px, " + top.integerValue + "px, 0px)" + frameTransform;
771
+ const style = element.style;
761
772
  if (element.UIView) {
762
- str = str + frameTransform + ((_b = (_a = element.style.transform.match(
773
+ frameTransform = frameTransform + ((_b = (_a = style.transform.match(
763
774
  new RegExp("scale\\(.*\\)", "g")
764
- )) == null ? void 0 : _a.firstElement) != null ? _b : "") + ";";
775
+ )) == null ? void 0 : _a.firstElement) != null ? _b : "");
765
776
  }
766
777
  if ((0, import_UIObject.IS_NIL)(height)) {
767
- str = str + " height: unset;";
768
- } else {
769
- str = str + " height:" + height + ";";
778
+ height = "unset";
770
779
  }
771
780
  if ((0, import_UIObject.IS_NIL)(width)) {
772
- str = str + " width: unset;";
773
- } else {
774
- str = str + " width:" + width + ";";
781
+ width = "unset";
775
782
  }
783
+ let zIndexString = "" + zIndex;
776
784
  if ((0, import_UIObject.IS_NIL)(zIndex)) {
777
- str = str + " z-index: unset;";
778
- } else {
779
- str = str + " z-index:" + zIndex + ";";
785
+ zIndexString = "unset";
780
786
  }
781
- element.style.cssText = element.style.cssText + str;
787
+ style.transform = frameTransform;
788
+ style.height = height;
789
+ style.width = width;
790
+ style.zIndex = zIndexString;
782
791
  }
783
792
  static performAutoLayout(parentElement, visualFormatArray, constraintsArray) {
784
793
  const view = new AutoLayout.View();
@@ -857,6 +866,7 @@ const _UIView = class extends import_UIObject.UIObject {
857
866
  }
858
867
  this._shouldLayout = import_UIObject.YES;
859
868
  _UIView._viewsToLayout.push(this);
869
+ this._intrinsicSizesCache = {};
860
870
  if (_UIView._viewsToLayout.length == 1) {
861
871
  _UIView.scheduleLayoutViewsIfNeeded();
862
872
  }
@@ -894,7 +904,7 @@ const _UIView = class extends import_UIObject.UIObject {
894
904
  applyClassesAndStyles() {
895
905
  for (let i = 0; i < this.styleClasses.length; i++) {
896
906
  const styleClass = this.styleClasses[i];
897
- if (styleClass) {
907
+ if (styleClass && !this.viewHTMLElement.classList.contains(styleClass)) {
898
908
  this.viewHTMLElement.classList.add(styleClass);
899
909
  }
900
910
  }
@@ -1022,7 +1032,7 @@ const _UIView = class extends import_UIObject.UIObject {
1022
1032
  views.forEach((view) => this.addSubview(view));
1023
1033
  }
1024
1034
  addedAsSubviewToView(view, aboveView) {
1025
- view.addSubview(this, aboveView);
1035
+ view == null ? void 0 : view.addSubview(this, aboveView);
1026
1036
  return this;
1027
1037
  }
1028
1038
  moveToBottomOfSuperview() {
@@ -1072,8 +1082,10 @@ const _UIView = class extends import_UIObject.UIObject {
1072
1082
  this.superview = superview;
1073
1083
  }
1074
1084
  wasAddedToViewTree() {
1085
+ _UIView.resizeObserver.observe(this.viewHTMLElement);
1075
1086
  }
1076
1087
  wasRemovedFromViewTree() {
1088
+ _UIView.resizeObserver.unobserve(this.viewHTMLElement);
1077
1089
  }
1078
1090
  get isMemberOfViewTree() {
1079
1091
  let element = this.viewHTMLElement;
@@ -1094,6 +1106,18 @@ const _UIView = class extends import_UIObject.UIObject {
1094
1106
  }
1095
1107
  return result;
1096
1108
  }
1109
+ get elementWithAllSuperviewElements() {
1110
+ const result = [];
1111
+ let view = this.viewHTMLElement;
1112
+ for (let i = 0; (0, import_UIObject.IS)(view); i = i) {
1113
+ if (!view) {
1114
+ return result;
1115
+ }
1116
+ result.push(view);
1117
+ view = view.parentElement;
1118
+ }
1119
+ return result;
1120
+ }
1097
1121
  setNeedsLayoutOnAllSuperviews() {
1098
1122
  this.withAllSuperviews.reverse().everyElement.setNeedsLayout();
1099
1123
  }
@@ -2034,20 +2058,48 @@ const _UIView = class extends import_UIObject.UIObject {
2034
2058
  this.subviews.everyElement.forEachViewInSubtree(functionToCall);
2035
2059
  }
2036
2060
  rectangleInView(rectangle, view) {
2061
+ var _a, _b, _c, _d;
2037
2062
  if (!view.isMemberOfViewTree || !this.isMemberOfViewTree) {
2038
2063
  return import_UIObject.nil;
2039
2064
  }
2040
- const viewClientRectangle = view.viewHTMLElement.getBoundingClientRect();
2041
- const viewLocation = new import_UIPoint.UIPoint(viewClientRectangle.left, viewClientRectangle.top);
2042
- const selfClientRectangle = this.viewHTMLElement.getBoundingClientRect();
2043
- const selfLocation = new import_UIPoint.UIPoint(selfClientRectangle.left, selfClientRectangle.top);
2044
- const offsetPoint = selfLocation.subtract(viewLocation);
2065
+ const allViewSuperviewElements = view.elementWithAllSuperviewElements;
2066
+ const superviewElementsUntilCommonElement = this.elementWithAllSuperviewElements.slice(
2067
+ 0,
2068
+ this.elementWithAllSuperviewElements.findIndex(
2069
+ (viewElement) => allViewSuperviewElements.contains(viewElement)
2070
+ ) + 1
2071
+ );
2072
+ const commonElement = superviewElementsUntilCommonElement.lastElement;
2073
+ const viewSuperviewElementsUntilCommonElement = allViewSuperviewElements.slice(
2074
+ 0,
2075
+ allViewSuperviewElements.findIndex((viewElement) => viewElement == commonElement) + 1
2076
+ );
2077
+ let selfOffsetPoint = new import_UIPoint.UIPoint(0, 0);
2078
+ for (let i = 0; i < superviewElementsUntilCommonElement.length - 1; i++) {
2079
+ const element = superviewElementsUntilCommonElement[i];
2080
+ selfOffsetPoint = selfOffsetPoint.add(
2081
+ (_b = (_a = element.UIView) == null ? void 0 : _a.frame.min) != null ? _b : new import_UIPoint.UIPoint(element.offsetLeft, element.offsetTop)
2082
+ );
2083
+ }
2084
+ let viewOffsetPoint = new import_UIPoint.UIPoint(0, 0);
2085
+ for (let i = 0; i < viewSuperviewElementsUntilCommonElement.length - 1; i++) {
2086
+ const element = viewSuperviewElementsUntilCommonElement[i];
2087
+ viewOffsetPoint = viewOffsetPoint.add(
2088
+ (_d = (_c = element.UIView) == null ? void 0 : _c.frame.min) != null ? _d : new import_UIPoint.UIPoint(element.offsetLeft, element.offsetTop)
2089
+ );
2090
+ }
2091
+ const offsetPoint = selfOffsetPoint.subtract(viewOffsetPoint);
2045
2092
  return rectangle.copy().offsetByPoint(offsetPoint);
2046
2093
  }
2047
2094
  rectangleFromView(rectangle, view) {
2048
2095
  return view.rectangleInView(rectangle, this);
2049
2096
  }
2050
2097
  intrinsicContentSizeWithConstraints(constrainingHeight = 0, constrainingWidth = 0) {
2098
+ const cacheKey = "h_" + constrainingHeight + "__w_" + constrainingWidth;
2099
+ const cachedResult = this._intrinsicSizesCache[cacheKey];
2100
+ if (cachedResult) {
2101
+ return cachedResult;
2102
+ }
2051
2103
  const result = new import_UIRectangle.UIRectangle(0, 0, 0, 0);
2052
2104
  if (this.rootView.forceIntrinsicSizeZero) {
2053
2105
  return result;
@@ -2094,6 +2146,7 @@ const _UIView = class extends import_UIObject.UIObject {
2094
2146
  }
2095
2147
  result.height = resultHeight;
2096
2148
  result.width = resultWidth;
2149
+ this._intrinsicSizesCache[cacheKey] = result.copy();
2097
2150
  return result;
2098
2151
  }
2099
2152
  intrinsicContentWidth(constrainingHeight = 0) {
@@ -2110,6 +2163,14 @@ let UIView = _UIView;
2110
2163
  UIView._UIViewIndex = -1;
2111
2164
  UIView._viewsToLayout = [];
2112
2165
  UIView._pageScale = 1;
2166
+ UIView.resizeObserver = new ResizeObserver((entries, observer) => {
2167
+ var _a;
2168
+ for (let i = 0; i < entries.length; i++) {
2169
+ const entry = entries[i];
2170
+ const view = entry.target.UIView;
2171
+ (_a = view == null ? void 0 : view.didResize) == null ? void 0 : _a.call(view, entry);
2172
+ }
2173
+ });
2113
2174
  UIView._onWindowTouchMove = import_UIObject.nil;
2114
2175
  UIView._onWindowMouseMove = import_UIObject.nil;
2115
2176
  UIView._onWindowMouseup = import_UIObject.nil;