uicore-ts 1.1.51 → 1.1.55

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.
@@ -1,6 +1,7 @@
1
1
  import { UIObject } from "./UIObject";
2
2
  import { UIPoint } from "./UIPoint";
3
3
  import { UIView } from "./UIView";
4
+ type SizeNumberOrFunctionOrView = number | ((constrainingOrthogonalSize: number) => number) | UIView;
4
5
  export declare class UIRectangle extends UIObject {
5
6
  _isBeingUpdated: boolean;
6
7
  rectanglePointDidChange?: (b: any) => void;
@@ -66,18 +67,20 @@ export declare class UIRectangle extends UIObject {
66
67
  */
67
68
  rectangleWithMinHeight(minHeight: number, centeredOnPosition?: number): UIRectangle;
68
69
  rectangleByCenteringInRectangle(referenceRectangle: UIRectangle, xPosition?: number, yPosition?: number): UIRectangle;
69
- rectanglesBySplittingWidth(weights: number[], paddings?: number | number[], absoluteWidths?: number | number[]): UIRectangle[];
70
- rectanglesBySplittingHeight(weights: number[], paddings?: number | number[], absoluteHeights?: number | number[]): UIRectangle[];
70
+ rectanglesBySplittingWidth(weights: SizeNumberOrFunctionOrView[], paddings?: SizeNumberOrFunctionOrView | SizeNumberOrFunctionOrView[], absoluteWidths?: SizeNumberOrFunctionOrView | SizeNumberOrFunctionOrView[]): UIRectangle[];
71
+ rectanglesBySplittingHeight(weights: SizeNumberOrFunctionOrView[], paddings?: SizeNumberOrFunctionOrView | SizeNumberOrFunctionOrView[], absoluteHeights?: SizeNumberOrFunctionOrView | SizeNumberOrFunctionOrView[]): UIRectangle[];
71
72
  rectanglesByEquallySplittingWidth(numberOfFrames: number, padding?: number): UIRectangle[];
72
73
  rectanglesByEquallySplittingHeight(numberOfFrames: number, padding?: number): UIRectangle[];
73
- distributeViewsAlongWidth(views: UIView[], weights?: number | number[], paddings?: number | number[], absoluteWidths?: number | number[]): this;
74
- distributeViewsAlongHeight(views: UIView[], weights?: number | number[], paddings?: number | number[], absoluteHeights?: number | number[]): this;
74
+ distributeViewsAlongWidth(views: UIView[], weights?: SizeNumberOrFunctionOrView | SizeNumberOrFunctionOrView[], paddings?: SizeNumberOrFunctionOrView | SizeNumberOrFunctionOrView[], absoluteWidths?: SizeNumberOrFunctionOrView | SizeNumberOrFunctionOrView[]): this;
75
+ distributeViewsAlongHeight(views: UIView[], weights?: SizeNumberOrFunctionOrView | SizeNumberOrFunctionOrView[], paddings?: SizeNumberOrFunctionOrView | SizeNumberOrFunctionOrView[], absoluteHeights?: SizeNumberOrFunctionOrView | SizeNumberOrFunctionOrView[]): this;
75
76
  distributeViewsEquallyAlongWidth(views: UIView[], padding: number): this;
76
77
  distributeViewsEquallyAlongHeight(views: UIView[], padding: number): this;
77
- rectangleForNextRow(padding?: number, height?: number | ((constrainingWidth: number) => number) | UIView): UIRectangle;
78
- rectangleForNextColumn(padding?: number, width?: number | ((constrainingHeight: number) => number) | UIView): UIRectangle;
79
- rectangleForPreviousRow(padding?: number, height?: number | ((constrainingWidth: number) => number) | UIView): UIRectangle;
80
- rectangleForPreviousColumn(padding?: number, width?: number | ((constrainingHeight: number) => number) | UIView): UIRectangle;
78
+ _heightNumberFromSizeNumberOrFunctionOrView(height: SizeNumberOrFunctionOrView): number;
79
+ _widthNumberFromSizeNumberOrFunctionOrView(width: SizeNumberOrFunctionOrView): number;
80
+ rectangleForNextRow(padding?: number, height?: SizeNumberOrFunctionOrView): UIRectangle;
81
+ rectangleForNextColumn(padding?: number, width?: SizeNumberOrFunctionOrView): UIRectangle;
82
+ rectangleForPreviousRow(padding?: number, height?: SizeNumberOrFunctionOrView): UIRectangle;
83
+ rectangleForPreviousColumn(padding?: number, width?: SizeNumberOrFunctionOrView): UIRectangle;
81
84
  rectangleWithIntrinsicContentSizeForView(view: UIView, centeredOnXPosition?: number, centeredOnYPosition?: number): UIRectangle;
82
85
  rectangleWithIntrinsicContentHeightForView(view: UIView, centeredOnPosition?: number): UIRectangle;
83
86
  rectangleWithIntrinsicContentWidthForView(view: UIView, centeredOnPosition?: number): UIRectangle;
@@ -93,3 +96,4 @@ export declare class UIRectangle extends UIObject {
93
96
  didChange(): void;
94
97
  _rectanglePointDidChange(): void;
95
98
  }
99
+ export {};
@@ -50,7 +50,12 @@ class UIRectangle extends import_UIObject.UIObject {
50
50
  }
51
51
  }
52
52
  copy() {
53
- return new UIRectangle(this.x, this.y, this.height, this.width);
53
+ const result = new UIRectangle(this.x, this.y, this.height, this.width);
54
+ result.minHeight = this.minHeight;
55
+ result.minWidth = this.minWidth;
56
+ result.maxHeight = this.maxHeight;
57
+ result.maxWidth = this.maxWidth;
58
+ return result;
54
59
  }
55
60
  isEqualTo(rectangle) {
56
61
  return (0, import_UIObject.IS)(rectangle) && this.min.isEqualTo(rectangle.min) && this.max.isEqualTo(rectangle.max);
@@ -314,9 +319,14 @@ class UIRectangle extends import_UIObject.UIObject {
314
319
  paddings = [paddings].arrayByRepeating(weights.length - 1);
315
320
  }
316
321
  paddings = paddings.arrayByTrimmingToLengthIfLonger(weights.length - 1);
322
+ paddings = paddings.map((padding) => this._widthNumberFromSizeNumberOrFunctionOrView(padding));
317
323
  if (!(absoluteWidths instanceof Array) && (0, import_UIObject.IS_NOT_NIL)(absoluteWidths)) {
318
324
  absoluteWidths = [absoluteWidths].arrayByRepeating(weights.length);
319
325
  }
326
+ absoluteWidths = absoluteWidths.map(
327
+ (width) => this._widthNumberFromSizeNumberOrFunctionOrView(width)
328
+ );
329
+ weights = weights.map((weight) => this._widthNumberFromSizeNumberOrFunctionOrView(weight));
320
330
  const result = [];
321
331
  const sumOfWeights = weights.reduce(
322
332
  (a, b, index) => {
@@ -357,9 +367,14 @@ class UIRectangle extends import_UIObject.UIObject {
357
367
  paddings = [paddings].arrayByRepeating(weights.length - 1);
358
368
  }
359
369
  paddings = paddings.arrayByTrimmingToLengthIfLonger(weights.length - 1);
370
+ paddings = paddings.map((padding) => this._heightNumberFromSizeNumberOrFunctionOrView(padding));
360
371
  if (!(absoluteHeights instanceof Array) && (0, import_UIObject.IS_NOT_NIL)(absoluteHeights)) {
361
372
  absoluteHeights = [absoluteHeights].arrayByRepeating(weights.length);
362
373
  }
374
+ absoluteHeights = absoluteHeights.map(
375
+ (height) => this._heightNumberFromSizeNumberOrFunctionOrView(height)
376
+ );
377
+ weights = weights.map((weight) => this._heightNumberFromSizeNumberOrFunctionOrView(weight));
363
378
  const result = [];
364
379
  const sumOfWeights = weights.reduce(
365
380
  (a, b, index) => {
@@ -373,16 +388,16 @@ class UIRectangle extends import_UIObject.UIObject {
373
388
  const sumOfPaddings = paddings.summedValue;
374
389
  const sumOfAbsoluteHeights = absoluteHeights.summedValue;
375
390
  const totalRelativeHeight = this.height - sumOfPaddings - sumOfAbsoluteHeights;
376
- var previousCellMaxY = this.y;
377
- for (var i = 0; i < weights.length; i++) {
378
- var resultHeight;
391
+ let previousCellMaxY = this.y;
392
+ for (let i = 0; i < weights.length; i++) {
393
+ let resultHeight;
379
394
  if ((0, import_UIObject.IS_NOT_NIL)(absoluteHeights[i])) {
380
395
  resultHeight = absoluteHeights[i] || 0;
381
396
  } else {
382
397
  resultHeight = totalRelativeHeight * (weights[i] / sumOfWeights);
383
398
  }
384
399
  const rectangle = this.rectangleWithHeight(resultHeight);
385
- var padding = 0;
400
+ let padding = 0;
386
401
  if (paddings.length > i && paddings[i]) {
387
402
  padding = paddings[i];
388
403
  }
@@ -438,55 +453,53 @@ class UIRectangle extends import_UIObject.UIObject {
438
453
  frames.forEach((frame, index) => views[index].frame = frame);
439
454
  return this;
440
455
  }
441
- rectangleForNextRow(padding = 0, height = this.height) {
456
+ _heightNumberFromSizeNumberOrFunctionOrView(height) {
442
457
  if (height instanceof Function) {
443
- height = height(this.width);
458
+ return height(this.width);
444
459
  }
445
460
  if (height instanceof import_UIView.UIView) {
446
- height = height.intrinsicContentHeight(this.width);
461
+ return height.intrinsicContentHeight(this.width);
447
462
  }
448
- const result = this.rectangleWithY(this.max.y + padding);
449
- if (height != this.height) {
450
- result.height = height;
451
- }
452
- return result;
463
+ return height;
453
464
  }
454
- rectangleForNextColumn(padding = 0, width = this.width) {
465
+ _widthNumberFromSizeNumberOrFunctionOrView(width) {
455
466
  if (width instanceof Function) {
456
- width = width(this.height);
467
+ return width(this.height);
457
468
  }
458
469
  if (width instanceof import_UIView.UIView) {
459
- width = width.intrinsicContentWidth(this.height);
470
+ return width.intrinsicContentWidth(this.height);
460
471
  }
472
+ return width;
473
+ }
474
+ rectangleForNextRow(padding = 0, height = this.height) {
475
+ const heightNumber = this._heightNumberFromSizeNumberOrFunctionOrView(height);
476
+ const result = this.rectangleWithY(this.max.y + padding);
477
+ if (heightNumber != this.height) {
478
+ result.height = heightNumber;
479
+ }
480
+ return result;
481
+ }
482
+ rectangleForNextColumn(padding = 0, width = this.width) {
483
+ const widthNumber = this._widthNumberFromSizeNumberOrFunctionOrView(width);
461
484
  const result = this.rectangleWithX(this.max.x + padding);
462
- if (width != this.width) {
463
- result.width = width;
485
+ if (widthNumber != this.width) {
486
+ result.width = widthNumber;
464
487
  }
465
488
  return result;
466
489
  }
467
490
  rectangleForPreviousRow(padding = 0, height = this.height) {
468
- if (height instanceof Function) {
469
- height = height(this.width);
470
- }
471
- if (height instanceof import_UIView.UIView) {
472
- height = height.intrinsicContentHeight(this.width);
473
- }
474
- const result = this.rectangleWithY(this.min.y - height - padding);
475
- if (height != this.height) {
476
- result.height = height;
491
+ const heightNumber = this._heightNumberFromSizeNumberOrFunctionOrView(height);
492
+ const result = this.rectangleWithY(this.min.y - heightNumber - padding);
493
+ if (heightNumber != this.height) {
494
+ result.height = heightNumber;
477
495
  }
478
496
  return result;
479
497
  }
480
498
  rectangleForPreviousColumn(padding = 0, width = this.width) {
481
- if (width instanceof Function) {
482
- width = width(this.height);
483
- }
484
- if (width instanceof import_UIView.UIView) {
485
- width = width.intrinsicContentWidth(this.height);
486
- }
487
- const result = this.rectangleWithX(this.min.x - width - padding);
488
- if (width != this.width) {
489
- result.width = width;
499
+ const widthNumber = this._widthNumberFromSizeNumberOrFunctionOrView(width);
500
+ const result = this.rectangleWithX(this.min.x - widthNumber - padding);
501
+ if (widthNumber != this.width) {
502
+ result.width = widthNumber;
490
503
  }
491
504
  return result;
492
505
  }
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../scripts/UIRectangle.ts"],
4
- "sourcesContent": ["import { FIRST_OR_NIL, IS, IS_DEFINED, IS_NIL, IS_NOT_NIL, nil, NO, UIObject, YES } from \"./UIObject\"\nimport { UIPoint } from \"./UIPoint\"\nimport { UIView } from \"./UIView\"\n\n\nexport class UIRectangle extends UIObject {\n \n _isBeingUpdated: boolean\n rectanglePointDidChange?: (b: any) => void\n max: UIPoint\n min: UIPoint\n \n minHeight?: number\n maxHeight?: number\n \n minWidth?: number\n maxWidth?: number\n \n \n constructor(x: number = 0, y: number = 0, height: number = 0, width: number = 0) {\n \n super()\n \n this.min = new UIPoint(Number.POSITIVE_INFINITY, Number.POSITIVE_INFINITY)\n this.max = new UIPoint(Number.NEGATIVE_INFINITY, Number.NEGATIVE_INFINITY)\n \n this.min.didChange = (point) => {\n this.rectanglePointDidChange?.(point)\n this._rectanglePointDidChange()\n }\n this.max.didChange = (point) => {\n this.rectanglePointDidChange?.(point)\n this._rectanglePointDidChange()\n }\n \n this._isBeingUpdated = NO\n \n this.min = new UIPoint(x, y)\n this.max = new UIPoint(x + width, y + height)\n \n if (IS_NIL(height)) {\n this.max.y = height\n }\n \n if (IS_NIL(width)) {\n this.max.x = width\n }\n \n }\n \n \n copy() {\n return new UIRectangle(this.x, this.y, this.height, this.width)\n }\n \n isEqualTo(rectangle: UIRectangle | null | undefined) {\n return (IS(rectangle) && this.min.isEqualTo(rectangle.min) && this.max.isEqualTo(rectangle.max))\n }\n \n static zero() {\n return new UIRectangle(0, 0, 0, 0)\n }\n \n containsPoint(point: UIPoint) {\n return this.min.x <= point.x && this.min.y <= point.y &&\n point.x <= this.max.x && point.y <= this.max.y\n }\n \n updateByAddingPoint(point: UIPoint) {\n \n if (!point) {\n point = new UIPoint(0, 0)\n }\n \n this.beginUpdates()\n \n const min = this.min.copy()\n if (min.x === nil) {\n min.x = this.max.x\n }\n if (min.y === nil) {\n min.y = this.max.y\n }\n \n const max = this.max.copy()\n if (max.x === nil) {\n max.x = this.min.x\n }\n if (max.y === nil) {\n max.y = this.min.y\n }\n \n this.min.x = Math.min(min.x, point.x)\n this.min.y = Math.min(min.y, point.y)\n this.max.x = Math.max(max.x, point.x)\n this.max.y = Math.max(max.y, point.y)\n \n this.finishUpdates()\n \n }\n \n scale(scale: number) {\n if (IS_NOT_NIL(this.max.y)) {\n this.height = this.height * scale\n }\n if (IS_NOT_NIL(this.max.x)) {\n this.width = this.width * scale\n }\n }\n \n get height() {\n if (this.max.y === nil) {\n return nil\n }\n return this.max.y - this.min.y\n }\n \n set height(height: number) {\n this.max.y = this.min.y + height\n }\n \n \n get width() {\n if (this.max.x === nil) {\n return nil\n }\n return this.max.x - this.min.x\n }\n \n set width(width: number) {\n this.max.x = this.min.x + width\n }\n \n \n get x() {\n return this.min.x\n }\n \n set x(x: number) {\n \n this.beginUpdates()\n \n const width = this.width\n this.min.x = x\n this.max.x = this.min.x + width\n \n this.finishUpdates()\n \n }\n \n \n get y() {\n return this.min.y\n }\n \n \n set y(y: number) {\n \n this.beginUpdates()\n \n const height = this.height\n this.min.y = y\n this.max.y = this.min.y + height\n \n this.finishUpdates()\n \n }\n \n \n get topLeft() {\n return this.min.copy()\n }\n \n get topRight() {\n return new UIPoint(this.max.x, this.y)\n }\n \n get bottomLeft() {\n return new UIPoint(this.x, this.max.y)\n }\n \n get bottomRight() {\n return this.max.copy()\n }\n \n \n get center() {\n return this.min.copy().add(this.min.to(this.max).scale(0.5))\n }\n \n set center(center: UIPoint) {\n const offset = this.center.to(center)\n this.offsetByPoint(offset)\n }\n \n offsetByPoint(offset: UIPoint) {\n this.min.add(offset)\n this.max.add(offset)\n \n return this\n }\n \n \n concatenateWithRectangle(rectangle: UIRectangle) {\n this.updateByAddingPoint(rectangle.bottomRight)\n this.updateByAddingPoint(rectangle.topLeft)\n return this\n }\n \n rectangleByConcatenatingWithRectangle(rectangle: UIRectangle) {\n return this.copy().concatenateWithRectangle(rectangle)\n }\n \n \n intersectionRectangleWithRectangle(rectangle: UIRectangle): UIRectangle {\n \n const result = this.copy()\n \n result.beginUpdates()\n \n const min = result.min\n if (min.x === nil) {\n min.x = rectangle.max.x - Math.min(result.width, rectangle.width)\n }\n if (min.y === nil) {\n min.y = rectangle.max.y - Math.min(result.height, rectangle.height)\n }\n \n const max = result.max\n if (max.x === nil) {\n max.x = rectangle.min.x + Math.min(result.width, rectangle.width)\n }\n if (max.y === nil) {\n max.y = rectangle.min.y + Math.min(result.height, rectangle.height)\n }\n \n result.min.x = Math.max(result.min.x, rectangle.min.x)\n result.min.y = Math.max(result.min.y, rectangle.min.y)\n result.max.x = Math.min(result.max.x, rectangle.max.x)\n result.max.y = Math.min(result.max.y, rectangle.max.y)\n \n \n if (result.height < 0) {\n \n const averageY = (this.center.y + rectangle.center.y) * 0.5\n result.min.y = averageY\n result.max.y = averageY\n \n }\n \n if (result.width < 0) {\n \n const averageX = (this.center.x + rectangle.center.x) * 0.5\n result.min.x = averageX\n result.max.x = averageX\n \n }\n \n result.finishUpdates()\n \n return result\n \n }\n \n \n get area() {\n return this.height * this.width\n }\n \n \n intersectsWithRectangle(rectangle: UIRectangle) {\n return (this.intersectionRectangleWithRectangle(rectangle).area != 0)\n }\n \n \n // add some space around the rectangle\n rectangleWithInsets(left: number, right: number, bottom: number, top: number) {\n const result = this.copy()\n result.min.x = this.min.x + left\n result.max.x = this.max.x - right\n result.min.y = this.min.y + top\n result.max.y = this.max.y - bottom\n return result\n }\n \n rectangleWithInset(inset: number) {\n return this.rectangleWithInsets(inset, inset, inset, inset)\n }\n \n rectangleWithHeight(height: number, centeredOnPosition: number = nil) {\n \n if (isNaN(centeredOnPosition)) {\n centeredOnPosition = nil\n }\n \n const result = this.copy()\n result.height = height\n \n if (centeredOnPosition != nil) {\n const change = height - this.height\n result.offsetByPoint(new UIPoint(0, change * centeredOnPosition).scale(-1))\n }\n \n return result\n \n }\n \n rectangleWithWidth(width: number, centeredOnPosition: number = nil) {\n \n if (isNaN(centeredOnPosition)) {\n centeredOnPosition = nil\n }\n \n const result = this.copy()\n result.width = width\n \n if (centeredOnPosition != nil) {\n const change = width - this.width\n result.offsetByPoint(new UIPoint(change * centeredOnPosition, 0).scale(-1))\n }\n \n return result\n \n }\n \n rectangleWithHeightRelativeToWidth(heightRatio: number = 1, centeredOnPosition: number = nil) {\n return this.rectangleWithHeight(this.width * heightRatio, centeredOnPosition)\n }\n \n rectangleWithWidthRelativeToHeight(widthRatio: number = 1, centeredOnPosition: number = nil) {\n return this.rectangleWithWidth(this.height * widthRatio, centeredOnPosition)\n }\n \n rectangleWithX(x: number, centeredOnPosition: number = 0) {\n \n const result = this.copy()\n result.x = x - result.width * centeredOnPosition\n \n return result\n \n }\n \n rectangleWithY(y: number, centeredOnPosition: number = 0) {\n \n const result = this.copy()\n result.y = y - result.height * centeredOnPosition\n \n return result\n \n }\n \n \n rectangleByAddingX(x: number) {\n \n const result = this.copy()\n result.x = this.x + x\n \n return result\n \n }\n \n rectangleByAddingY(y: number) {\n \n const result = this.copy()\n result.y = this.y + y\n \n return result\n \n }\n \n \n rectangleWithRelativeValues(\n relativeXPosition: number,\n widthMultiplier: number,\n relativeYPosition: number,\n heightMultiplier: number\n ) {\n \n const result = this.copy()\n \n const width = result.width\n const height = result.height\n \n result.width = widthMultiplier * width\n result.height = heightMultiplier * height\n \n result.center = new UIPoint(\n relativeXPosition * width,\n relativeYPosition * height\n )\n \n return result\n \n }\n \n \n /**\n * Returns a rectangle with a maximum width constraint\n * If current width exceeds max, centers the constrained width\n */\n rectangleWithMaxWidth(maxWidth: number, centeredOnPosition: number = 0): UIRectangle {\n if (this.width <= maxWidth) {\n return this.copy()\n }\n return this.rectangleWithWidth(maxWidth, centeredOnPosition)\n }\n \n /**\n * Returns a rectangle with a maximum height constraint\n */\n rectangleWithMaxHeight(maxHeight: number, centeredOnPosition: number = 0): UIRectangle {\n if (this.height <= maxHeight) {\n return this.copy()\n }\n return this.rectangleWithHeight(maxHeight, centeredOnPosition)\n }\n \n /**\n * Returns a rectangle with minimum width constraint\n */\n rectangleWithMinWidth(minWidth: number, centeredOnPosition: number = 0): UIRectangle {\n if (this.width >= minWidth) {\n return this.copy()\n }\n return this.rectangleWithWidth(minWidth, centeredOnPosition)\n }\n \n /**\n * Returns a rectangle with minimum height constraint\n */\n rectangleWithMinHeight(minHeight: number, centeredOnPosition: number = 0): UIRectangle {\n if (this.height >= minHeight) {\n return this.copy()\n }\n return this.rectangleWithHeight(minHeight, centeredOnPosition)\n }\n \n // Returns a new rectangle that is positioned relative to the reference rectangle\n // By default, it makes a copy of this rectangle taht is centered in the target rectangle\n rectangleByCenteringInRectangle(referenceRectangle: UIRectangle, xPosition = 0.5, yPosition = 0.5) {\n const result = this.copy()\n result.center = referenceRectangle.topLeft\n .pointByAddingX(xPosition * referenceRectangle.width)\n .pointByAddingY(yPosition * referenceRectangle.height)\n return result\n }\n \n \n rectanglesBySplittingWidth(\n weights: number[],\n paddings: number | number[] = 0,\n absoluteWidths: number | number[] = nil\n ) {\n \n if (IS_NIL(paddings)) {\n paddings = 1\n }\n if (!((paddings as any) instanceof Array)) {\n paddings = [paddings].arrayByRepeating(weights.length - 1)\n }\n paddings = (paddings as number[]).arrayByTrimmingToLengthIfLonger(weights.length - 1)\n if (!(absoluteWidths instanceof Array) && IS_NOT_NIL(absoluteWidths)) {\n absoluteWidths = [absoluteWidths].arrayByRepeating(weights.length)\n }\n \n const result: UIRectangle[] = []\n const sumOfWeights = weights.reduce(\n (a, b, index) => {\n if (IS_NOT_NIL((absoluteWidths as number[])[index])) {\n b = 0\n }\n return a + b\n },\n 0\n )\n const sumOfPaddings = paddings.summedValue\n const sumOfAbsoluteWidths = (absoluteWidths as number[]).summedValue\n const totalRelativeWidth = this.width - sumOfPaddings - sumOfAbsoluteWidths\n let previousCellMaxX = this.x\n \n for (let i = 0; i < weights.length; i++) {\n \n let resultWidth: number\n if (IS_NOT_NIL(absoluteWidths[i])) {\n resultWidth = absoluteWidths[i] || 0\n }\n else {\n resultWidth = totalRelativeWidth * (weights[i] / sumOfWeights)\n }\n \n const rectangle = this.rectangleWithWidth(resultWidth)\n \n let padding = 0\n if (paddings.length > i && paddings[i]) {\n padding = paddings[i]\n }\n \n rectangle.x = previousCellMaxX\n previousCellMaxX = rectangle.max.x + padding\n result.push(rectangle)\n \n }\n \n return result\n \n }\n \n rectanglesBySplittingHeight(\n weights: number[],\n paddings: number | number[] = 0,\n absoluteHeights: number | number[] = nil\n ) {\n \n if (IS_NIL(paddings)) {\n paddings = 1\n }\n if (!((paddings as any) instanceof Array)) {\n paddings = [paddings].arrayByRepeating(weights.length - 1)\n }\n paddings = (paddings as number[]).arrayByTrimmingToLengthIfLonger(weights.length - 1)\n if (!(absoluteHeights instanceof Array) && IS_NOT_NIL(absoluteHeights)) {\n absoluteHeights = [absoluteHeights].arrayByRepeating(weights.length)\n }\n \n const result: UIRectangle[] = []\n const sumOfWeights = weights.reduce(\n (a, b, index) => {\n if (IS_NOT_NIL((absoluteHeights as number[])[index])) {\n b = 0\n }\n return a + b\n },\n 0\n )\n const sumOfPaddings = paddings.summedValue\n const sumOfAbsoluteHeights = (absoluteHeights as number[]).summedValue\n const totalRelativeHeight = this.height - sumOfPaddings - sumOfAbsoluteHeights\n var previousCellMaxY = this.y\n \n for (var i = 0; i < weights.length; i++) {\n var resultHeight: number\n if (IS_NOT_NIL(absoluteHeights[i])) {\n \n resultHeight = absoluteHeights[i] || 0\n \n }\n else {\n \n resultHeight = totalRelativeHeight * (weights[i] / sumOfWeights)\n \n }\n \n const rectangle = this.rectangleWithHeight(resultHeight)\n \n var padding = 0\n if (paddings.length > i && paddings[i]) {\n padding = paddings[i]\n }\n \n rectangle.y = previousCellMaxY\n previousCellMaxY = rectangle.max.y + padding\n //rectangle = rectangle.rectangleWithInsets(0, 0, padding, 0);\n result.push(rectangle)\n }\n \n return result\n \n }\n \n \n rectanglesByEquallySplittingWidth(numberOfFrames: number, padding: number = 0) {\n const result: UIRectangle[] = []\n const totalPadding = padding * (numberOfFrames - 1)\n const resultWidth = (this.width - totalPadding) / numberOfFrames\n for (var i = 0; i < numberOfFrames; i++) {\n const rectangle = this.rectangleWithWidth(resultWidth, i / (numberOfFrames - 1))\n result.push(rectangle)\n }\n return result\n }\n \n rectanglesByEquallySplittingHeight(numberOfFrames: number, padding: number = 0) {\n const result: UIRectangle[] = []\n const totalPadding = padding * (numberOfFrames - 1)\n const resultHeight = (this.height - totalPadding) / numberOfFrames\n for (var i = 0; i < numberOfFrames; i++) {\n const rectangle = this.rectangleWithHeight(resultHeight, i / (numberOfFrames - 1))\n result.push(rectangle)\n }\n return result\n }\n \n \n distributeViewsAlongWidth(\n views: UIView[],\n weights: number | number[] = 1,\n paddings?: number | number[],\n absoluteWidths?: number | number[]\n ) {\n if (!(weights instanceof Array)) {\n weights = [weights].arrayByRepeating(views.length)\n }\n const frames = this.rectanglesBySplittingWidth(weights, paddings, absoluteWidths)\n frames.forEach((frame, index) => FIRST_OR_NIL(views[index]).frame = frame)\n return this\n }\n \n distributeViewsAlongHeight(\n views: UIView[],\n weights: number | number[] = 1,\n paddings?: number | number[],\n absoluteHeights?: number | number[]\n ) {\n if (!(weights instanceof Array)) {\n weights = [weights].arrayByRepeating(views.length)\n }\n const frames = this.rectanglesBySplittingHeight(weights, paddings, absoluteHeights)\n frames.forEach((frame, index) => FIRST_OR_NIL(views[index]).frame = frame)\n return this\n }\n \n \n distributeViewsEquallyAlongWidth(views: UIView[], padding: number) {\n const frames = this.rectanglesByEquallySplittingWidth(views.length, padding)\n frames.forEach((frame, index) => views[index].frame = frame)\n return this\n }\n \n distributeViewsEquallyAlongHeight(views: UIView[], padding: number) {\n const frames = this.rectanglesByEquallySplittingHeight(views.length, padding)\n frames.forEach((frame, index) => views[index].frame = frame)\n return this\n }\n \n \n rectangleForNextRow(padding: number = 0, height: number | ((constrainingWidth: number) => number) | UIView = this.height) {\n if (height instanceof Function) {\n height = height(this.width)\n }\n if (height instanceof UIView) {\n height = height.intrinsicContentHeight(this.width)\n }\n const result = this.rectangleWithY(this.max.y + padding)\n if (height != this.height) {\n result.height = height\n }\n return result\n }\n \n rectangleForNextColumn(padding: number = 0, width: number | ((constrainingHeight: number) => number) | UIView = this.width) {\n if (width instanceof Function) {\n width = width(this.height)\n }\n if (width instanceof UIView) {\n width = width.intrinsicContentWidth(this.height)\n }\n const result = this.rectangleWithX(this.max.x + padding)\n if (width != this.width) {\n result.width = width\n }\n return result\n }\n \n rectangleForPreviousRow(padding: number = 0, height: number | ((constrainingWidth: number) => number) | UIView = this.height) {\n if (height instanceof Function) {\n height = height(this.width)\n }\n if (height instanceof UIView) {\n height = height.intrinsicContentHeight(this.width)\n }\n const result = this.rectangleWithY(this.min.y - height - padding)\n if (height != this.height) {\n result.height = height\n }\n return result\n }\n \n rectangleForPreviousColumn(padding: number = 0, width: number | ((constrainingHeight: number) => number) | UIView = this.width) {\n if (width instanceof Function) {\n width = width(this.height)\n }\n if (width instanceof UIView) {\n width = width.intrinsicContentWidth(this.height)\n }\n const result = this.rectangleWithX(this.min.x - width - padding)\n if (width != this.width) {\n result.width = width\n }\n return result\n \n }\n \n rectangleWithIntrinsicContentSizeForView(view: UIView, centeredOnXPosition = 0, centeredOnYPosition = 0) {\n const intrinsicContentSize = view.intrinsicContentSize()\n return this.rectangleWithHeight(intrinsicContentSize.height, centeredOnYPosition)\n .rectangleWithWidth(intrinsicContentSize.width, centeredOnXPosition)\n }\n \n rectangleWithIntrinsicContentHeightForView(view: UIView, centeredOnPosition = 0) {\n return this.rectangleWithHeight(view.intrinsicContentHeight(this.width), centeredOnPosition)\n }\n \n rectangleWithIntrinsicContentWidthForView(view: UIView, centeredOnPosition = 0) {\n return this.rectangleWithWidth(view.intrinsicContentWidth(this.height), centeredOnPosition)\n }\n \n settingMinHeight(minHeight?: number) {\n this.minHeight = minHeight\n return this\n }\n \n settingMinWidth(minWidth?: number) {\n this.minWidth = minWidth\n return this\n }\n \n settingMaxHeight(maxHeight?: number) {\n this.maxHeight = maxHeight\n return this\n }\n \n settingMaxWidth(maxWidth?: number) {\n this.maxWidth = maxWidth\n return this\n }\n \n rectangleByEnforcingMinAndMaxSizes(centeredOnXPosition = 0, centeredOnYPosition = 0) {\n return this.rectangleWithHeight(\n [\n [this.height, this.maxHeight].min(),\n this.minHeight\n ].max(),\n centeredOnYPosition\n ).rectangleWithWidth(\n [\n [this.width, this.maxWidth].min(),\n this.minWidth\n ].max(),\n centeredOnXPosition\n )\n }\n \n \n assignedAsFrameOfView(view: UIView) {\n view.frame = this\n return this\n }\n \n \n // Bounding box\n static boundingBoxForPoints(points: string | any[]) {\n const result = new UIRectangle()\n for (let i = 0; i < points.length; i++) {\n result.updateByAddingPoint(points[i])\n }\n return result\n }\n \n \n beginUpdates() {\n this._isBeingUpdated = YES\n }\n \n finishUpdates() {\n this._isBeingUpdated = NO\n this.didChange()\n }\n \n \n didChange() {\n \n // Callback to be set by delegate\n \n }\n \n _rectanglePointDidChange() {\n if (!this._isBeingUpdated) {\n this.didChange()\n }\n }\n \n \n}\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n"],
5
- "mappings": ";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,sBAAyF;AACzF,qBAAwB;AACxB,oBAAuB;AAGhB,MAAM,oBAAoB,yBAAS;AAAA,EActC,YAAY,IAAY,GAAG,IAAY,GAAG,SAAiB,GAAG,QAAgB,GAAG;AAE7E,UAAM;AAEN,SAAK,MAAM,IAAI,uBAAQ,OAAO,mBAAmB,OAAO,iBAAiB;AACzE,SAAK,MAAM,IAAI,uBAAQ,OAAO,mBAAmB,OAAO,iBAAiB;AAEzE,SAAK,IAAI,YAAY,CAAC,UAAU;AA1BxC;AA2BY,iBAAK,4BAAL,8BAA+B;AAC/B,WAAK,yBA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AO;AAAA,EACX;AAAA,EAEA,gBAAgB,UAAmB;AAC/B,SAAK,WAAW;AAChB,WAAO;AAAA,EACX;AAAA,EAEA,iBAAiB,WAAoB;AACjC,SAAK,YAAY;AACjB,WAAO;AAAA,EACX;AAAA,EAEA,gBAAgB,UAAmB;AAC/B,SAAK,WAAW;AAChB,WAAO;AAAA,EACX;AAAA,EAEA,mCAAmC,sBAAsB,GAAG,sBAAsB,GAAG;AACjF,WAAO,KAAK;AAAA,MACR;AAAA,QACI,CAAC,KAAK,QAAQ,KAAK,SAAS,EAAE,IAAI;AAAA,QAClC,KAAK;AAAA,MACT,EAAE,IAAI;AAAA,MACN;AAAA,IACJ,EAAE;AAAA,MACE;AAAA,QACI,CAAC,KAAK,OAAO,KAAK,QAAQ,EAAE,IAAI;AAAA,QAChC,KAAK;AAAA,MACT,EAAE,IAAI;AAAA,MACN;AAAA,IACJ;AAAA,EACJ;AAAA,EAGA,sBAAsB,MAAc;AAChC,SAAK,QAAQ;AACb,WAAO;AAAA,EACX;AAAA,EAIA,OAAO,qBAAqB,QAAwB;AAChD,UAAM,SAAS,IAAI,YAAY;AAC/B,aAAS,IAAI,GAAG,IAAI,OAAO,QAAQ,KAAK;AACpC,aAAO,oBAAoB,OAAO,EAAE;AAAA,IACxC;AACA,WAAO;AAAA,EACX;AAAA,EAGA,eAAe;AACX,SAAK,kBAAkB;AAAA,EAC3B;AAAA,EAEA,gBAAgB;AACZ,SAAK,kBAAkB;AACvB,SAAK,UAAU;AAAA,EACnB;AAAA,EAGA,YAAY;AAAA,EAIZ;AAAA,EAEA,2BAA2B;AACvB,QAAI,CAAC,KAAK,iBAAiB;AACvB,WAAK,UAAU;AAAA,IACnB;AAAA,EACJ;AAGJ;",
4
+ "sourcesContent": ["import { FIRST_OR_NIL, IS, IS_DEFINED, IS_NIL, IS_NOT_NIL, nil, NO, UIObject, YES } from \"./UIObject\"\nimport { UIPoint } from \"./UIPoint\"\nimport { UIView } from \"./UIView\"\n\n\ntype SizeNumberOrFunctionOrView = number | ((constrainingOrthogonalSize: number) => number) | UIView\n\nexport class UIRectangle extends UIObject {\n \n _isBeingUpdated: boolean\n rectanglePointDidChange?: (b: any) => void\n max: UIPoint\n min: UIPoint\n \n // The min and max values are just for storage.\n // You need to call rectangleByEnforcingMinAndMaxSizes to make use of them.\n minHeight?: number\n maxHeight?: number\n minWidth?: number\n maxWidth?: number\n \n \n constructor(x: number = 0, y: number = 0, height: number = 0, width: number = 0) {\n \n super()\n \n this.min = new UIPoint(Number.POSITIVE_INFINITY, Number.POSITIVE_INFINITY)\n this.max = new UIPoint(Number.NEGATIVE_INFINITY, Number.NEGATIVE_INFINITY)\n \n this.min.didChange = (point) => {\n this.rectanglePointDidChange?.(point)\n this._rectanglePointDidChange()\n }\n this.max.didChange = (point) => {\n this.rectanglePointDidChange?.(point)\n this._rectanglePointDidChange()\n }\n \n this._isBeingUpdated = NO\n \n this.min = new UIPoint(x, y)\n this.max = new UIPoint(x + width, y + height)\n \n if (IS_NIL(height)) {\n this.max.y = height\n }\n \n if (IS_NIL(width)) {\n this.max.x = width\n }\n \n }\n \n \n copy() {\n \n const result = new UIRectangle(this.x, this.y, this.height, this.width)\n \n result.minHeight = this.minHeight\n result.minWidth = this.minWidth\n result.maxHeight = this.maxHeight\n result.maxWidth = this.maxWidth\n \n return result\n \n }\n \n isEqualTo(rectangle: UIRectangle | null | undefined) {\n return (IS(rectangle) && this.min.isEqualTo(rectangle.min) && this.max.isEqualTo(rectangle.max))\n }\n \n static zero() {\n return new UIRectangle(0, 0, 0, 0)\n }\n \n containsPoint(point: UIPoint) {\n return this.min.x <= point.x && this.min.y <= point.y &&\n point.x <= this.max.x && point.y <= this.max.y\n }\n \n updateByAddingPoint(point: UIPoint) {\n \n if (!point) {\n point = new UIPoint(0, 0)\n }\n \n this.beginUpdates()\n \n const min = this.min.copy()\n if (min.x === nil) {\n min.x = this.max.x\n }\n if (min.y === nil) {\n min.y = this.max.y\n }\n \n const max = this.max.copy()\n if (max.x === nil) {\n max.x = this.min.x\n }\n if (max.y === nil) {\n max.y = this.min.y\n }\n \n this.min.x = Math.min(min.x, point.x)\n this.min.y = Math.min(min.y, point.y)\n this.max.x = Math.max(max.x, point.x)\n this.max.y = Math.max(max.y, point.y)\n \n this.finishUpdates()\n \n }\n \n scale(scale: number) {\n if (IS_NOT_NIL(this.max.y)) {\n this.height = this.height * scale\n }\n if (IS_NOT_NIL(this.max.x)) {\n this.width = this.width * scale\n }\n }\n \n get height() {\n if (this.max.y === nil) {\n return nil\n }\n return this.max.y - this.min.y\n }\n \n set height(height: number) {\n this.max.y = this.min.y + height\n }\n \n \n get width() {\n if (this.max.x === nil) {\n return nil\n }\n return this.max.x - this.min.x\n }\n \n set width(width: number) {\n this.max.x = this.min.x + width\n }\n \n \n get x() {\n return this.min.x\n }\n \n set x(x: number) {\n \n this.beginUpdates()\n \n const width = this.width\n this.min.x = x\n this.max.x = this.min.x + width\n \n this.finishUpdates()\n \n }\n \n \n get y() {\n return this.min.y\n }\n \n \n set y(y: number) {\n \n this.beginUpdates()\n \n const height = this.height\n this.min.y = y\n this.max.y = this.min.y + height\n \n this.finishUpdates()\n \n }\n \n \n get topLeft() {\n return this.min.copy()\n }\n \n get topRight() {\n return new UIPoint(this.max.x, this.y)\n }\n \n get bottomLeft() {\n return new UIPoint(this.x, this.max.y)\n }\n \n get bottomRight() {\n return this.max.copy()\n }\n \n \n get center() {\n return this.min.copy().add(this.min.to(this.max).scale(0.5))\n }\n \n set center(center: UIPoint) {\n const offset = this.center.to(center)\n this.offsetByPoint(offset)\n }\n \n offsetByPoint(offset: UIPoint) {\n this.min.add(offset)\n this.max.add(offset)\n \n return this\n }\n \n \n concatenateWithRectangle(rectangle: UIRectangle) {\n this.updateByAddingPoint(rectangle.bottomRight)\n this.updateByAddingPoint(rectangle.topLeft)\n return this\n }\n \n rectangleByConcatenatingWithRectangle(rectangle: UIRectangle) {\n return this.copy().concatenateWithRectangle(rectangle)\n }\n \n \n intersectionRectangleWithRectangle(rectangle: UIRectangle): UIRectangle {\n \n const result = this.copy()\n \n result.beginUpdates()\n \n const min = result.min\n if (min.x === nil) {\n min.x = rectangle.max.x - Math.min(result.width, rectangle.width)\n }\n if (min.y === nil) {\n min.y = rectangle.max.y - Math.min(result.height, rectangle.height)\n }\n \n const max = result.max\n if (max.x === nil) {\n max.x = rectangle.min.x + Math.min(result.width, rectangle.width)\n }\n if (max.y === nil) {\n max.y = rectangle.min.y + Math.min(result.height, rectangle.height)\n }\n \n result.min.x = Math.max(result.min.x, rectangle.min.x)\n result.min.y = Math.max(result.min.y, rectangle.min.y)\n result.max.x = Math.min(result.max.x, rectangle.max.x)\n result.max.y = Math.min(result.max.y, rectangle.max.y)\n \n \n if (result.height < 0) {\n \n const averageY = (this.center.y + rectangle.center.y) * 0.5\n result.min.y = averageY\n result.max.y = averageY\n \n }\n \n if (result.width < 0) {\n \n const averageX = (this.center.x + rectangle.center.x) * 0.5\n result.min.x = averageX\n result.max.x = averageX\n \n }\n \n result.finishUpdates()\n \n return result\n \n }\n \n \n get area() {\n return this.height * this.width\n }\n \n \n intersectsWithRectangle(rectangle: UIRectangle) {\n return (this.intersectionRectangleWithRectangle(rectangle).area != 0)\n }\n \n \n // add some space around the rectangle\n rectangleWithInsets(left: number, right: number, bottom: number, top: number) {\n const result = this.copy()\n result.min.x = this.min.x + left\n result.max.x = this.max.x - right\n result.min.y = this.min.y + top\n result.max.y = this.max.y - bottom\n return result\n }\n \n rectangleWithInset(inset: number) {\n return this.rectangleWithInsets(inset, inset, inset, inset)\n }\n \n rectangleWithHeight(height: number, centeredOnPosition: number = nil) {\n \n if (isNaN(centeredOnPosition)) {\n centeredOnPosition = nil\n }\n \n const result = this.copy()\n result.height = height\n \n if (centeredOnPosition != nil) {\n const change = height - this.height\n result.offsetByPoint(new UIPoint(0, change * centeredOnPosition).scale(-1))\n }\n \n return result\n \n }\n \n rectangleWithWidth(width: number, centeredOnPosition: number = nil) {\n \n if (isNaN(centeredOnPosition)) {\n centeredOnPosition = nil\n }\n \n const result = this.copy()\n result.width = width\n \n if (centeredOnPosition != nil) {\n const change = width - this.width\n result.offsetByPoint(new UIPoint(change * centeredOnPosition, 0).scale(-1))\n }\n \n return result\n \n }\n \n rectangleWithHeightRelativeToWidth(heightRatio: number = 1, centeredOnPosition: number = nil) {\n return this.rectangleWithHeight(this.width * heightRatio, centeredOnPosition)\n }\n \n rectangleWithWidthRelativeToHeight(widthRatio: number = 1, centeredOnPosition: number = nil) {\n return this.rectangleWithWidth(this.height * widthRatio, centeredOnPosition)\n }\n \n rectangleWithX(x: number, centeredOnPosition: number = 0) {\n \n const result = this.copy()\n result.x = x - result.width * centeredOnPosition\n \n return result\n \n }\n \n rectangleWithY(y: number, centeredOnPosition: number = 0) {\n \n const result = this.copy()\n result.y = y - result.height * centeredOnPosition\n \n return result\n \n }\n \n \n rectangleByAddingX(x: number) {\n \n const result = this.copy()\n result.x = this.x + x\n \n return result\n \n }\n \n rectangleByAddingY(y: number) {\n \n const result = this.copy()\n result.y = this.y + y\n \n return result\n \n }\n \n \n rectangleWithRelativeValues(\n relativeXPosition: number,\n widthMultiplier: number,\n relativeYPosition: number,\n heightMultiplier: number\n ) {\n \n const result = this.copy()\n \n const width = result.width\n const height = result.height\n \n result.width = widthMultiplier * width\n result.height = heightMultiplier * height\n \n result.center = new UIPoint(\n relativeXPosition * width,\n relativeYPosition * height\n )\n \n return result\n \n }\n \n \n /**\n * Returns a rectangle with a maximum width constraint\n * If current width exceeds max, centers the constrained width\n */\n rectangleWithMaxWidth(maxWidth: number, centeredOnPosition: number = 0): UIRectangle {\n if (this.width <= maxWidth) {\n return this.copy()\n }\n return this.rectangleWithWidth(maxWidth, centeredOnPosition)\n }\n \n /**\n * Returns a rectangle with a maximum height constraint\n */\n rectangleWithMaxHeight(maxHeight: number, centeredOnPosition: number = 0): UIRectangle {\n if (this.height <= maxHeight) {\n return this.copy()\n }\n return this.rectangleWithHeight(maxHeight, centeredOnPosition)\n }\n \n /**\n * Returns a rectangle with minimum width constraint\n */\n rectangleWithMinWidth(minWidth: number, centeredOnPosition: number = 0): UIRectangle {\n if (this.width >= minWidth) {\n return this.copy()\n }\n return this.rectangleWithWidth(minWidth, centeredOnPosition)\n }\n \n /**\n * Returns a rectangle with minimum height constraint\n */\n rectangleWithMinHeight(minHeight: number, centeredOnPosition: number = 0): UIRectangle {\n if (this.height >= minHeight) {\n return this.copy()\n }\n return this.rectangleWithHeight(minHeight, centeredOnPosition)\n }\n \n // Returns a new rectangle that is positioned relative to the reference rectangle\n // By default, it makes a copy of this rectangle taht is centered in the target rectangle\n rectangleByCenteringInRectangle(referenceRectangle: UIRectangle, xPosition = 0.5, yPosition = 0.5) {\n const result = this.copy()\n result.center = referenceRectangle.topLeft\n .pointByAddingX(xPosition * referenceRectangle.width)\n .pointByAddingY(yPosition * referenceRectangle.height)\n return result\n }\n \n \n rectanglesBySplittingWidth(\n weights: SizeNumberOrFunctionOrView[],\n paddings: SizeNumberOrFunctionOrView | SizeNumberOrFunctionOrView[] = 0,\n absoluteWidths: SizeNumberOrFunctionOrView | SizeNumberOrFunctionOrView[] = nil\n ) {\n \n if (IS_NIL(paddings)) {\n paddings = 1\n }\n if (!((paddings as any) instanceof Array)) {\n paddings = [paddings].arrayByRepeating(weights.length - 1)\n }\n paddings = (paddings as any[]).arrayByTrimmingToLengthIfLonger(weights.length - 1)\n paddings = paddings.map(padding => this._widthNumberFromSizeNumberOrFunctionOrView(padding))\n if (!(absoluteWidths instanceof Array) && IS_NOT_NIL(absoluteWidths)) {\n absoluteWidths = [absoluteWidths].arrayByRepeating(weights.length)\n }\n absoluteWidths = absoluteWidths.map(\n width => this._widthNumberFromSizeNumberOrFunctionOrView(width)\n )\n \n weights = weights.map(weight => this._widthNumberFromSizeNumberOrFunctionOrView(weight))\n const result: UIRectangle[] = []\n const sumOfWeights = (weights as number[]).reduce(\n (a, b, index) => {\n if (IS_NOT_NIL((absoluteWidths as number[])[index])) {\n b = 0\n }\n return a + b\n },\n 0\n )\n const sumOfPaddings = paddings.summedValue as number\n const sumOfAbsoluteWidths = (absoluteWidths as number[]).summedValue\n const totalRelativeWidth = this.width - sumOfPaddings - sumOfAbsoluteWidths\n let previousCellMaxX = this.x\n \n for (let i = 0; i < weights.length; i++) {\n \n let resultWidth: number\n if (IS_NOT_NIL(absoluteWidths[i])) {\n resultWidth = (absoluteWidths[i] || 0) as number\n }\n else {\n resultWidth = totalRelativeWidth * (weights[i] as number / sumOfWeights)\n }\n \n const rectangle = this.rectangleWithWidth(resultWidth)\n \n let padding = 0\n if (paddings.length > i && paddings[i]) {\n padding = paddings[i] as number\n }\n \n rectangle.x = previousCellMaxX\n previousCellMaxX = rectangle.max.x + padding\n result.push(rectangle)\n \n }\n \n return result\n \n }\n \n rectanglesBySplittingHeight(\n weights: SizeNumberOrFunctionOrView[],\n paddings: SizeNumberOrFunctionOrView | SizeNumberOrFunctionOrView[] = 0,\n absoluteHeights: SizeNumberOrFunctionOrView | SizeNumberOrFunctionOrView[] = nil\n ) {\n \n if (IS_NIL(paddings)) {\n paddings = 1\n }\n if (!((paddings as any) instanceof Array)) {\n paddings = [paddings].arrayByRepeating(weights.length - 1)\n }\n paddings = (paddings as number[]).arrayByTrimmingToLengthIfLonger(weights.length - 1)\n paddings = paddings.map(padding => this._heightNumberFromSizeNumberOrFunctionOrView(padding))\n if (!(absoluteHeights instanceof Array) && IS_NOT_NIL(absoluteHeights)) {\n absoluteHeights = [absoluteHeights].arrayByRepeating(weights.length)\n }\n absoluteHeights = absoluteHeights.map(\n height => this._heightNumberFromSizeNumberOrFunctionOrView(height)\n )\n \n weights = weights.map(weight => this._heightNumberFromSizeNumberOrFunctionOrView(weight))\n const result: UIRectangle[] = []\n const sumOfWeights = (weights as number[]).reduce(\n (a, b, index) => {\n if (IS_NOT_NIL((absoluteHeights as number[])[index])) {\n b = 0\n }\n return a + b\n },\n 0\n )\n const sumOfPaddings = paddings.summedValue as number\n const sumOfAbsoluteHeights = (absoluteHeights as number[]).summedValue\n const totalRelativeHeight = this.height - sumOfPaddings - sumOfAbsoluteHeights\n let previousCellMaxY = this.y\n \n for (let i = 0; i < weights.length; i++) {\n let resultHeight: number\n if (IS_NOT_NIL(absoluteHeights[i])) {\n \n resultHeight = (absoluteHeights[i] || 0) as number\n \n }\n else {\n \n resultHeight = totalRelativeHeight * (weights[i] as number / sumOfWeights)\n \n }\n \n const rectangle = this.rectangleWithHeight(resultHeight)\n \n let padding = 0\n if (paddings.length > i && paddings[i]) {\n padding = paddings[i] as number\n }\n \n rectangle.y = previousCellMaxY\n previousCellMaxY = rectangle.max.y + padding\n //rectangle = rectangle.rectangleWithInsets(0, 0, padding, 0);\n result.push(rectangle)\n }\n \n return result\n \n }\n \n \n rectanglesByEquallySplittingWidth(numberOfFrames: number, padding: number = 0) {\n const result: UIRectangle[] = []\n const totalPadding = padding * (numberOfFrames - 1)\n const resultWidth = (this.width - totalPadding) / numberOfFrames\n for (var i = 0; i < numberOfFrames; i++) {\n const rectangle = this.rectangleWithWidth(resultWidth, i / (numberOfFrames - 1))\n result.push(rectangle)\n }\n return result\n }\n \n rectanglesByEquallySplittingHeight(numberOfFrames: number, padding: number = 0) {\n const result: UIRectangle[] = []\n const totalPadding = padding * (numberOfFrames - 1)\n const resultHeight = (this.height - totalPadding) / numberOfFrames\n for (var i = 0; i < numberOfFrames; i++) {\n const rectangle = this.rectangleWithHeight(resultHeight, i / (numberOfFrames - 1))\n result.push(rectangle)\n }\n return result\n }\n \n \n distributeViewsAlongWidth(\n views: UIView[],\n weights: SizeNumberOrFunctionOrView | SizeNumberOrFunctionOrView[] = 1,\n paddings?: SizeNumberOrFunctionOrView | SizeNumberOrFunctionOrView[],\n absoluteWidths?: SizeNumberOrFunctionOrView | SizeNumberOrFunctionOrView[]\n ) {\n if (!(weights instanceof Array)) {\n weights = [weights].arrayByRepeating(views.length)\n }\n const frames = this.rectanglesBySplittingWidth(weights, paddings, absoluteWidths)\n frames.forEach((frame, index) => FIRST_OR_NIL(views[index]).frame = frame)\n return this\n }\n \n distributeViewsAlongHeight(\n views: UIView[],\n weights: SizeNumberOrFunctionOrView | SizeNumberOrFunctionOrView[] = 1,\n paddings?: SizeNumberOrFunctionOrView | SizeNumberOrFunctionOrView[],\n absoluteHeights?: SizeNumberOrFunctionOrView | SizeNumberOrFunctionOrView[]\n ) {\n if (!(weights instanceof Array)) {\n weights = [weights].arrayByRepeating(views.length)\n }\n const frames = this.rectanglesBySplittingHeight(weights, paddings, absoluteHeights)\n frames.forEach((frame, index) => FIRST_OR_NIL(views[index]).frame = frame)\n return this\n }\n \n \n distributeViewsEquallyAlongWidth(views: UIView[], padding: number) {\n const frames = this.rectanglesByEquallySplittingWidth(views.length, padding)\n frames.forEach((frame, index) => views[index].frame = frame)\n return this\n }\n \n distributeViewsEquallyAlongHeight(views: UIView[], padding: number) {\n const frames = this.rectanglesByEquallySplittingHeight(views.length, padding)\n frames.forEach((frame, index) => views[index].frame = frame)\n return this\n }\n \n \n _heightNumberFromSizeNumberOrFunctionOrView(height: SizeNumberOrFunctionOrView) {\n if (height instanceof Function) {\n return height(this.width)\n }\n if (height instanceof UIView) {\n return height.intrinsicContentHeight(this.width)\n }\n return height\n }\n \n _widthNumberFromSizeNumberOrFunctionOrView(width: SizeNumberOrFunctionOrView) {\n if (width instanceof Function) {\n return width(this.height)\n }\n if (width instanceof UIView) {\n return width.intrinsicContentWidth(this.height)\n }\n return width\n }\n \n rectangleForNextRow(padding: number = 0, height: SizeNumberOrFunctionOrView = this.height) {\n const heightNumber = this._heightNumberFromSizeNumberOrFunctionOrView(height)\n const result = this.rectangleWithY(this.max.y + padding)\n if (heightNumber != this.height) {\n result.height = heightNumber\n }\n return result\n }\n \n rectangleForNextColumn(padding: number = 0, width: SizeNumberOrFunctionOrView = this.width) {\n const widthNumber = this._widthNumberFromSizeNumberOrFunctionOrView(width)\n const result = this.rectangleWithX(this.max.x + padding)\n if (widthNumber != this.width) {\n result.width = widthNumber\n }\n return result\n }\n \n rectangleForPreviousRow(padding: number = 0, height: SizeNumberOrFunctionOrView = this.height) {\n const heightNumber = this._heightNumberFromSizeNumberOrFunctionOrView(height)\n const result = this.rectangleWithY(this.min.y - heightNumber - padding)\n if (heightNumber != this.height) {\n result.height = heightNumber\n }\n return result\n }\n \n rectangleForPreviousColumn(padding: number = 0, width: SizeNumberOrFunctionOrView = this.width) {\n const widthNumber = this._widthNumberFromSizeNumberOrFunctionOrView(width)\n const result = this.rectangleWithX(this.min.x - widthNumber - padding)\n if (widthNumber != this.width) {\n result.width = widthNumber\n }\n return result\n \n }\n \n rectangleWithIntrinsicContentSizeForView(view: UIView, centeredOnXPosition = 0, centeredOnYPosition = 0) {\n const intrinsicContentSize = view.intrinsicContentSize()\n return this.rectangleWithHeight(intrinsicContentSize.height, centeredOnYPosition)\n .rectangleWithWidth(intrinsicContentSize.width, centeredOnXPosition)\n }\n \n rectangleWithIntrinsicContentHeightForView(view: UIView, centeredOnPosition = 0) {\n return this.rectangleWithHeight(view.intrinsicContentHeight(this.width), centeredOnPosition)\n }\n \n rectangleWithIntrinsicContentWidthForView(view: UIView, centeredOnPosition = 0) {\n return this.rectangleWithWidth(view.intrinsicContentWidth(this.height), centeredOnPosition)\n }\n \n settingMinHeight(minHeight?: number) {\n this.minHeight = minHeight\n return this\n }\n \n settingMinWidth(minWidth?: number) {\n this.minWidth = minWidth\n return this\n }\n \n settingMaxHeight(maxHeight?: number) {\n this.maxHeight = maxHeight\n return this\n }\n \n settingMaxWidth(maxWidth?: number) {\n this.maxWidth = maxWidth\n return this\n }\n \n rectangleByEnforcingMinAndMaxSizes(centeredOnXPosition = 0, centeredOnYPosition = 0) {\n return this.rectangleWithHeight(\n [\n [this.height, this.maxHeight].min(),\n this.minHeight\n ].max(),\n centeredOnYPosition\n ).rectangleWithWidth(\n [\n [this.width, this.maxWidth].min(),\n this.minWidth\n ].max(),\n centeredOnXPosition\n )\n }\n \n \n assignedAsFrameOfView(view: UIView) {\n view.frame = this\n return this\n }\n \n \n // Bounding box\n static boundingBoxForPoints(points: string | any[]) {\n const result = new UIRectangle()\n for (let i = 0; i < points.length; i++) {\n result.updateByAddingPoint(points[i])\n }\n return result\n }\n \n \n beginUpdates() {\n this._isBeingUpdated = YES\n }\n \n finishUpdates() {\n this._isBeingUpdated = NO\n this.didChange()\n }\n \n \n didChange() {\n \n // Callback to be set by delegate\n \n }\n \n _rectanglePointDidChange() {\n if (!this._isBeingUpdated) {\n this.didChange()\n }\n }\n \n \n}\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n"],
5
+ "mappings": ";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,sBAAyF;AACzF,qBAAwB;AACxB,oBAAuB;AAKhB,MAAM,oBAAoB,yBAAS;AAAA,EAetC,YAAY,IAAY,GAAG,IAAY,GAAG,SAAiB,GAAG,QAAgB,GAAG;AAE7E,UAAM;AAEN,SAAK,MAAM,IAAI,uBAAQ,OAAO,mBAAmB,OAAO,iBAAiB;AACzE,SAAK,MAAM,IAAI,uBAAQ,OAAO,mBAAmB,OAAO,iBAAiB;AAEzE,SAAK,IAAI,YAAY,CAAC,UAAU;AA7BxC;AA8BY,iBAAK,4BAAL,8BAA+B;AAC/B,WAAK,yBAAyB;AAAA,IAClC;AACA,SAAK,IAAI,YAAY,CAAC,UAAU;AAjCxC;AAkCY,iBAAK,4BAAL,8BAA+B;AAC/B,WAAK,yBAAyB;AAAA,IAClC;AAEA,SAAK,kBAAkB;AAEvB,SAAK,MAAM,IAAI,uBAAQ,GAAG,CAAC;AAC3B,SAAK,MAAM,IAAI,uBAAQ,IAAI,OAAO,IAAI,MAAM;AAE5C,YAAI,wBAAO,MAAM,GAAG;AAChB,WAAK,IAAI,IAAI;AAAA,IACjB;AAEA,YAAI,wBAAO,KAAK,GAAG;AACf,WAAK,IAAI,IAAI;AAAA,IACjB;AAAA,EAEJ;AAAA,EAGA,OAAO;AAEH,UAAM,SAAS,IAAI,YAAY,KAAK,GAAG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jB,WAAO;AAAA,EACX;AAAA,EAEA,gBAAgB,UAAmB;AAC/B,SAAK,WAAW;AAChB,WAAO;AAAA,EACX;AAAA,EAEA,iBAAiB,WAAoB;AACjC,SAAK,YAAY;AACjB,WAAO;AAAA,EACX;AAAA,EAEA,gBAAgB,UAAmB;AAC/B,SAAK,WAAW;AAChB,WAAO;AAAA,EACX;AAAA,EAEA,mCAAmC,sBAAsB,GAAG,sBAAsB,GAAG;AACjF,WAAO,KAAK;AAAA,MACR;AAAA,QACI,CAAC,KAAK,QAAQ,KAAK,SAAS,EAAE,IAAI;AAAA,QAClC,KAAK;AAAA,MACT,EAAE,IAAI;AAAA,MACN;AAAA,IACJ,EAAE;AAAA,MACE;AAAA,QACI,CAAC,KAAK,OAAO,KAAK,QAAQ,EAAE,IAAI;AAAA,QAChC,KAAK;AAAA,MACT,EAAE,IAAI;AAAA,MACN;AAAA,IACJ;AAAA,EACJ;AAAA,EAGA,sBAAsB,MAAc;AAChC,SAAK,QAAQ;AACb,WAAO;AAAA,EACX;AAAA,EAIA,OAAO,qBAAqB,QAAwB;AAChD,UAAM,SAAS,IAAI,YAAY;AAC/B,aAAS,IAAI,GAAG,IAAI,OAAO,QAAQ,KAAK;AACpC,aAAO,oBAAoB,OAAO,EAAE;AAAA,IACxC;AACA,WAAO;AAAA,EACX;AAAA,EAGA,eAAe;AACX,SAAK,kBAAkB;AAAA,EAC3B;AAAA,EAEA,gBAAgB;AACZ,SAAK,kBAAkB;AACvB,SAAK,UAAU;AAAA,EACnB;AAAA,EAGA,YAAY;AAAA,EAIZ;AAAA,EAEA,2BAA2B;AACvB,QAAI,CAAC,KAAK,iBAAiB;AACvB,WAAK,UAAU;AAAA,IACnB;AAAA,EACJ;AAGJ;",
6
6
  "names": []
7
7
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "uicore-ts",
3
- "version": "1.1.51",
3
+ "version": "1.1.55",
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",
@@ -3,6 +3,8 @@ import { UIPoint } from "./UIPoint"
3
3
  import { UIView } from "./UIView"
4
4
 
5
5
 
6
+ type SizeNumberOrFunctionOrView = number | ((constrainingOrthogonalSize: number) => number) | UIView
7
+
6
8
  export class UIRectangle extends UIObject {
7
9
 
8
10
  _isBeingUpdated: boolean
@@ -10,9 +12,10 @@ export class UIRectangle extends UIObject {
10
12
  max: UIPoint
11
13
  min: UIPoint
12
14
 
15
+ // The min and max values are just for storage.
16
+ // You need to call rectangleByEnforcingMinAndMaxSizes to make use of them.
13
17
  minHeight?: number
14
18
  maxHeight?: number
15
-
16
19
  minWidth?: number
17
20
  maxWidth?: number
18
21
 
@@ -50,7 +53,16 @@ export class UIRectangle extends UIObject {
50
53
 
51
54
 
52
55
  copy() {
53
- return new UIRectangle(this.x, this.y, this.height, this.width)
56
+
57
+ const result = new UIRectangle(this.x, this.y, this.height, this.width)
58
+
59
+ result.minHeight = this.minHeight
60
+ result.minWidth = this.minWidth
61
+ result.maxHeight = this.maxHeight
62
+ result.maxWidth = this.maxWidth
63
+
64
+ return result
65
+
54
66
  }
55
67
 
56
68
  isEqualTo(rectangle: UIRectangle | null | undefined) {
@@ -447,9 +459,9 @@ export class UIRectangle extends UIObject {
447
459
 
448
460
 
449
461
  rectanglesBySplittingWidth(
450
- weights: number[],
451
- paddings: number | number[] = 0,
452
- absoluteWidths: number | number[] = nil
462
+ weights: SizeNumberOrFunctionOrView[],
463
+ paddings: SizeNumberOrFunctionOrView | SizeNumberOrFunctionOrView[] = 0,
464
+ absoluteWidths: SizeNumberOrFunctionOrView | SizeNumberOrFunctionOrView[] = nil
453
465
  ) {
454
466
 
455
467
  if (IS_NIL(paddings)) {
@@ -458,13 +470,18 @@ export class UIRectangle extends UIObject {
458
470
  if (!((paddings as any) instanceof Array)) {
459
471
  paddings = [paddings].arrayByRepeating(weights.length - 1)
460
472
  }
461
- paddings = (paddings as number[]).arrayByTrimmingToLengthIfLonger(weights.length - 1)
473
+ paddings = (paddings as any[]).arrayByTrimmingToLengthIfLonger(weights.length - 1)
474
+ paddings = paddings.map(padding => this._widthNumberFromSizeNumberOrFunctionOrView(padding))
462
475
  if (!(absoluteWidths instanceof Array) && IS_NOT_NIL(absoluteWidths)) {
463
476
  absoluteWidths = [absoluteWidths].arrayByRepeating(weights.length)
464
477
  }
478
+ absoluteWidths = absoluteWidths.map(
479
+ width => this._widthNumberFromSizeNumberOrFunctionOrView(width)
480
+ )
465
481
 
482
+ weights = weights.map(weight => this._widthNumberFromSizeNumberOrFunctionOrView(weight))
466
483
  const result: UIRectangle[] = []
467
- const sumOfWeights = weights.reduce(
484
+ const sumOfWeights = (weights as number[]).reduce(
468
485
  (a, b, index) => {
469
486
  if (IS_NOT_NIL((absoluteWidths as number[])[index])) {
470
487
  b = 0
@@ -473,7 +490,7 @@ export class UIRectangle extends UIObject {
473
490
  },
474
491
  0
475
492
  )
476
- const sumOfPaddings = paddings.summedValue
493
+ const sumOfPaddings = paddings.summedValue as number
477
494
  const sumOfAbsoluteWidths = (absoluteWidths as number[]).summedValue
478
495
  const totalRelativeWidth = this.width - sumOfPaddings - sumOfAbsoluteWidths
479
496
  let previousCellMaxX = this.x
@@ -482,17 +499,17 @@ export class UIRectangle extends UIObject {
482
499
 
483
500
  let resultWidth: number
484
501
  if (IS_NOT_NIL(absoluteWidths[i])) {
485
- resultWidth = absoluteWidths[i] || 0
502
+ resultWidth = (absoluteWidths[i] || 0) as number
486
503
  }
487
504
  else {
488
- resultWidth = totalRelativeWidth * (weights[i] / sumOfWeights)
505
+ resultWidth = totalRelativeWidth * (weights[i] as number / sumOfWeights)
489
506
  }
490
507
 
491
508
  const rectangle = this.rectangleWithWidth(resultWidth)
492
509
 
493
510
  let padding = 0
494
511
  if (paddings.length > i && paddings[i]) {
495
- padding = paddings[i]
512
+ padding = paddings[i] as number
496
513
  }
497
514
 
498
515
  rectangle.x = previousCellMaxX
@@ -506,9 +523,9 @@ export class UIRectangle extends UIObject {
506
523
  }
507
524
 
508
525
  rectanglesBySplittingHeight(
509
- weights: number[],
510
- paddings: number | number[] = 0,
511
- absoluteHeights: number | number[] = nil
526
+ weights: SizeNumberOrFunctionOrView[],
527
+ paddings: SizeNumberOrFunctionOrView | SizeNumberOrFunctionOrView[] = 0,
528
+ absoluteHeights: SizeNumberOrFunctionOrView | SizeNumberOrFunctionOrView[] = nil
512
529
  ) {
513
530
 
514
531
  if (IS_NIL(paddings)) {
@@ -518,12 +535,17 @@ export class UIRectangle extends UIObject {
518
535
  paddings = [paddings].arrayByRepeating(weights.length - 1)
519
536
  }
520
537
  paddings = (paddings as number[]).arrayByTrimmingToLengthIfLonger(weights.length - 1)
538
+ paddings = paddings.map(padding => this._heightNumberFromSizeNumberOrFunctionOrView(padding))
521
539
  if (!(absoluteHeights instanceof Array) && IS_NOT_NIL(absoluteHeights)) {
522
540
  absoluteHeights = [absoluteHeights].arrayByRepeating(weights.length)
523
541
  }
542
+ absoluteHeights = absoluteHeights.map(
543
+ height => this._heightNumberFromSizeNumberOrFunctionOrView(height)
544
+ )
524
545
 
546
+ weights = weights.map(weight => this._heightNumberFromSizeNumberOrFunctionOrView(weight))
525
547
  const result: UIRectangle[] = []
526
- const sumOfWeights = weights.reduce(
548
+ const sumOfWeights = (weights as number[]).reduce(
527
549
  (a, b, index) => {
528
550
  if (IS_NOT_NIL((absoluteHeights as number[])[index])) {
529
551
  b = 0
@@ -532,29 +554,29 @@ export class UIRectangle extends UIObject {
532
554
  },
533
555
  0
534
556
  )
535
- const sumOfPaddings = paddings.summedValue
557
+ const sumOfPaddings = paddings.summedValue as number
536
558
  const sumOfAbsoluteHeights = (absoluteHeights as number[]).summedValue
537
559
  const totalRelativeHeight = this.height - sumOfPaddings - sumOfAbsoluteHeights
538
- var previousCellMaxY = this.y
560
+ let previousCellMaxY = this.y
539
561
 
540
- for (var i = 0; i < weights.length; i++) {
541
- var resultHeight: number
562
+ for (let i = 0; i < weights.length; i++) {
563
+ let resultHeight: number
542
564
  if (IS_NOT_NIL(absoluteHeights[i])) {
543
565
 
544
- resultHeight = absoluteHeights[i] || 0
566
+ resultHeight = (absoluteHeights[i] || 0) as number
545
567
 
546
568
  }
547
569
  else {
548
570
 
549
- resultHeight = totalRelativeHeight * (weights[i] / sumOfWeights)
571
+ resultHeight = totalRelativeHeight * (weights[i] as number / sumOfWeights)
550
572
 
551
573
  }
552
574
 
553
575
  const rectangle = this.rectangleWithHeight(resultHeight)
554
576
 
555
- var padding = 0
577
+ let padding = 0
556
578
  if (paddings.length > i && paddings[i]) {
557
- padding = paddings[i]
579
+ padding = paddings[i] as number
558
580
  }
559
581
 
560
582
  rectangle.y = previousCellMaxY
@@ -593,9 +615,9 @@ export class UIRectangle extends UIObject {
593
615
 
594
616
  distributeViewsAlongWidth(
595
617
  views: UIView[],
596
- weights: number | number[] = 1,
597
- paddings?: number | number[],
598
- absoluteWidths?: number | number[]
618
+ weights: SizeNumberOrFunctionOrView | SizeNumberOrFunctionOrView[] = 1,
619
+ paddings?: SizeNumberOrFunctionOrView | SizeNumberOrFunctionOrView[],
620
+ absoluteWidths?: SizeNumberOrFunctionOrView | SizeNumberOrFunctionOrView[]
599
621
  ) {
600
622
  if (!(weights instanceof Array)) {
601
623
  weights = [weights].arrayByRepeating(views.length)
@@ -607,9 +629,9 @@ export class UIRectangle extends UIObject {
607
629
 
608
630
  distributeViewsAlongHeight(
609
631
  views: UIView[],
610
- weights: number | number[] = 1,
611
- paddings?: number | number[],
612
- absoluteHeights?: number | number[]
632
+ weights: SizeNumberOrFunctionOrView | SizeNumberOrFunctionOrView[] = 1,
633
+ paddings?: SizeNumberOrFunctionOrView | SizeNumberOrFunctionOrView[],
634
+ absoluteHeights?: SizeNumberOrFunctionOrView | SizeNumberOrFunctionOrView[]
613
635
  ) {
614
636
  if (!(weights instanceof Array)) {
615
637
  weights = [weights].arrayByRepeating(views.length)
@@ -633,58 +655,58 @@ export class UIRectangle extends UIObject {
633
655
  }
634
656
 
635
657
 
636
- rectangleForNextRow(padding: number = 0, height: number | ((constrainingWidth: number) => number) | UIView = this.height) {
658
+ _heightNumberFromSizeNumberOrFunctionOrView(height: SizeNumberOrFunctionOrView) {
637
659
  if (height instanceof Function) {
638
- height = height(this.width)
660
+ return height(this.width)
639
661
  }
640
662
  if (height instanceof UIView) {
641
- height = height.intrinsicContentHeight(this.width)
663
+ return height.intrinsicContentHeight(this.width)
642
664
  }
643
- const result = this.rectangleWithY(this.max.y + padding)
644
- if (height != this.height) {
645
- result.height = height
646
- }
647
- return result
665
+ return height
648
666
  }
649
667
 
650
- rectangleForNextColumn(padding: number = 0, width: number | ((constrainingHeight: number) => number) | UIView = this.width) {
668
+ _widthNumberFromSizeNumberOrFunctionOrView(width: SizeNumberOrFunctionOrView) {
651
669
  if (width instanceof Function) {
652
- width = width(this.height)
670
+ return width(this.height)
653
671
  }
654
672
  if (width instanceof UIView) {
655
- width = width.intrinsicContentWidth(this.height)
673
+ return width.intrinsicContentWidth(this.height)
656
674
  }
657
- const result = this.rectangleWithX(this.max.x + padding)
658
- if (width != this.width) {
659
- result.width = width
675
+ return width
676
+ }
677
+
678
+ rectangleForNextRow(padding: number = 0, height: SizeNumberOrFunctionOrView = this.height) {
679
+ const heightNumber = this._heightNumberFromSizeNumberOrFunctionOrView(height)
680
+ const result = this.rectangleWithY(this.max.y + padding)
681
+ if (heightNumber != this.height) {
682
+ result.height = heightNumber
660
683
  }
661
684
  return result
662
685
  }
663
686
 
664
- rectangleForPreviousRow(padding: number = 0, height: number | ((constrainingWidth: number) => number) | UIView = this.height) {
665
- if (height instanceof Function) {
666
- height = height(this.width)
667
- }
668
- if (height instanceof UIView) {
669
- height = height.intrinsicContentHeight(this.width)
670
- }
671
- const result = this.rectangleWithY(this.min.y - height - padding)
672
- if (height != this.height) {
673
- result.height = height
687
+ rectangleForNextColumn(padding: number = 0, width: SizeNumberOrFunctionOrView = this.width) {
688
+ const widthNumber = this._widthNumberFromSizeNumberOrFunctionOrView(width)
689
+ const result = this.rectangleWithX(this.max.x + padding)
690
+ if (widthNumber != this.width) {
691
+ result.width = widthNumber
674
692
  }
675
693
  return result
676
694
  }
677
695
 
678
- rectangleForPreviousColumn(padding: number = 0, width: number | ((constrainingHeight: number) => number) | UIView = this.width) {
679
- if (width instanceof Function) {
680
- width = width(this.height)
681
- }
682
- if (width instanceof UIView) {
683
- width = width.intrinsicContentWidth(this.height)
696
+ rectangleForPreviousRow(padding: number = 0, height: SizeNumberOrFunctionOrView = this.height) {
697
+ const heightNumber = this._heightNumberFromSizeNumberOrFunctionOrView(height)
698
+ const result = this.rectangleWithY(this.min.y - heightNumber - padding)
699
+ if (heightNumber != this.height) {
700
+ result.height = heightNumber
684
701
  }
685
- const result = this.rectangleWithX(this.min.x - width - padding)
686
- if (width != this.width) {
687
- result.width = width
702
+ return result
703
+ }
704
+
705
+ rectangleForPreviousColumn(padding: number = 0, width: SizeNumberOrFunctionOrView = this.width) {
706
+ const widthNumber = this._widthNumberFromSizeNumberOrFunctionOrView(width)
707
+ const result = this.rectangleWithX(this.min.x - widthNumber - padding)
708
+ if (widthNumber != this.width) {
709
+ result.width = widthNumber
688
710
  }
689
711
  return result
690
712