uicore-ts 1.1.102 → 1.1.108

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/scripts/UIView.ts CHANGED
@@ -133,6 +133,12 @@ interface Constraint {
133
133
  }
134
134
 
135
135
 
136
+ export interface IUILoadingView extends UIView {
137
+ theme: "light" | "dark";
138
+ // Add any other specific methods you need to call from UIView
139
+ }
140
+
141
+
136
142
  export function UIComponentView(target: Function, context: ClassDecoratorContext) {
137
143
  console.log("Recording annotation UIComponentView on " + target.name)
138
144
  UIObject.recordAnnotation(UIComponentView, target)
@@ -149,7 +155,7 @@ export class UIView extends UIObject {
149
155
  _UIViewIntrinsicTemporaryWidth?: string
150
156
  _UIViewIntrinsicTemporaryHeight?: string
151
157
  _enabled: boolean = YES
152
- _frame?: UIRectangle & { zIndex?: number };
158
+ _frame?: UIRectangle & { zIndex?: number }
153
159
  _frameCache?: UIRectangle
154
160
  _backgroundColor: UIColor = UIColor.transparentColor
155
161
 
@@ -220,6 +226,43 @@ export class UIView extends UIObject {
220
226
  makeNotResizable?: () => void
221
227
  resizingHandles: UIView[] = []
222
228
 
229
+ public static LoadingViewClass: new () => IUILoadingView
230
+ private _loadingView?: IUILoadingView
231
+
232
+ public set loading(isLoading: boolean) {
233
+ this.userInteractionEnabled = !isLoading
234
+ if (isLoading) {
235
+ if (!IS(this._loadingView)) {
236
+ if (UIView.LoadingViewClass) {
237
+ this._loadingView = new UIView.LoadingViewClass()
238
+ }
239
+ else {
240
+ console.warn("UILoadingView class not registered yet.")
241
+ return
242
+ }
243
+ }
244
+
245
+ // Add to superview if not already added
246
+ if (this._loadingView.superview != this) {
247
+ this.addSubview(this._loadingView)
248
+ // Ensure it sits above other content
249
+ this._loadingView.style.zIndex = "1000"
250
+ }
251
+
252
+ // Force an immediate layout update to position the overlay
253
+ // this._loadingView.setFrame(this.bounds)
254
+
255
+ }
256
+ else {
257
+ this._loadingView?.removeFromSuperview()
258
+ }
259
+ }
260
+
261
+ public get loading(): boolean {
262
+ return IS(this._loadingView) && IS(this._loadingView.superview)
263
+ }
264
+
265
+
223
266
  private _isMoving: boolean = NO
224
267
  _isCBEditorTemporaryResizable = NO
225
268
  _isCBEditorTemporaryMovable = NO
@@ -334,7 +377,7 @@ export class UIView extends UIObject {
334
377
  this._resizeObserverInitialized = true
335
378
 
336
379
  // Invalidate cache on window resize
337
- window.addEventListener('resize', () => {
380
+ window.addEventListener("resize", () => {
338
381
  this._pageDimensionsCacheValid = false
339
382
  }, { passive: true })
340
383
 
@@ -346,9 +389,10 @@ export class UIView extends UIObject {
346
389
  // Start observing once body is available
347
390
  if (document.body) {
348
391
  bodyObserver.observe(document.body)
349
- } else {
392
+ }
393
+ else {
350
394
  // Wait for DOMContentLoaded if body isn't ready yet
351
- document.addEventListener('DOMContentLoaded', () => {
395
+ document.addEventListener("DOMContentLoaded", () => {
352
396
  bodyObserver.observe(document.body)
353
397
  }, { once: true })
354
398
  }
@@ -363,14 +407,15 @@ export class UIView extends UIObject {
363
407
  childList: true,
364
408
  subtree: true,
365
409
  attributes: true,
366
- attributeFilter: ['style', 'class']
410
+ attributeFilter: ["style", "class"]
367
411
  })
368
412
  }
369
413
 
370
414
  if (document.body) {
371
415
  observeMutations()
372
- } else {
373
- document.addEventListener('DOMContentLoaded', observeMutations, { once: true })
416
+ }
417
+ else {
418
+ document.addEventListener("DOMContentLoaded", observeMutations, { once: true })
374
419
  }
375
420
  }
376
421
 
@@ -431,7 +476,6 @@ export class UIView extends UIObject {
431
476
  //#endregion
432
477
 
433
478
 
434
-
435
479
  centerInContainer() {
436
480
  this.style.left = "50%"
437
481
  this.style.top = "50%"
@@ -1745,7 +1789,7 @@ export class UIView extends UIObject {
1745
1789
 
1746
1790
  // Skip if this view has been laid out too many times (cycle detection)
1747
1791
  if (layoutCount >= 5) {
1748
- console.warn('View layout cycle detected:', view)
1792
+ console.warn("View layout cycle detected:", view)
1749
1793
  continue
1750
1794
  }
1751
1795
 
@@ -1847,6 +1891,10 @@ export class UIView extends UIObject {
1847
1891
 
1848
1892
  }
1849
1893
 
1894
+ // if (this._loadingView && this._loadingView.superview == this) {
1895
+ // this._loadingView.setFrame(this.bounds)
1896
+ // }
1897
+
1850
1898
  this.didLayoutSubviews()
1851
1899
 
1852
1900
  }
@@ -3687,6 +3735,9 @@ export class UIView extends UIObject {
3687
3735
 
3688
3736
  const framePoints: UIPoint[] = []
3689
3737
  this.subviews.forEach(subview => {
3738
+ if (subview == this._loadingView) {
3739
+ return
3740
+ }
3690
3741
  subview.layoutIfNeeded()
3691
3742
  framePoints.push(subview.frame.min)
3692
3743
  framePoints.push(subview.frame.max)
@@ -3695,11 +3746,11 @@ export class UIView extends UIObject {
3695
3746
  // we will add padding based on the _contentInsets
3696
3747
  const resultFrame = UIRectangle.boundingBoxForPoints(framePoints)
3697
3748
  .rectangleWithInsets(
3698
- -this._contentInsets?.left ?? 0,
3699
- -this._contentInsets?.right ?? 0,
3700
- -this._contentInsets?.bottom ?? 0,
3701
- -this._contentInsets?.top ?? 0
3702
- )
3749
+ -this._contentInsets?.left ?? 0,
3750
+ -this._contentInsets?.right ?? 0,
3751
+ -this._contentInsets?.bottom ?? 0,
3752
+ -this._contentInsets?.top ?? 0
3753
+ )
3703
3754
  return resultFrame
3704
3755
  }
3705
3756
 
package/scripts/index.ts CHANGED
@@ -32,6 +32,8 @@ export * from "./UIInterfaces"
32
32
  export * from "./ClientCheckers"
33
33
  export * from "./UICore"
34
34
  export * from "./UIRootViewController"
35
+ export * from "./UILoadingView"
36
+
35
37
 
36
38
 
37
39