uicore-ts 1.1.59 → 1.1.62
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/compiledScripts/UIRectangle.d.ts +29 -0
- package/compiledScripts/UIRectangle.js +77 -0
- package/compiledScripts/UIRectangle.js.map +2 -2
- package/compiledScripts/UIView.js +4 -1
- package/compiledScripts/UIView.js.map +2 -2
- package/package.json +1 -1
- package/scripts/UIRectangle.ts +139 -0
- package/scripts/UIView.ts +4 -1
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "uicore-ts",
|
|
3
|
-
"version": "1.1.
|
|
3
|
+
"version": "1.1.62",
|
|
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",
|
package/scripts/UIRectangle.ts
CHANGED
|
@@ -712,6 +712,145 @@ export class UIRectangle extends UIObject {
|
|
|
712
712
|
|
|
713
713
|
}
|
|
714
714
|
|
|
715
|
+
/**
|
|
716
|
+
* Distributes views vertically as a column, returning their calculated frames.
|
|
717
|
+
* Each view is positioned below the previous one with optional padding between them.
|
|
718
|
+
* @param views - Array of views to distribute
|
|
719
|
+
* @param paddings - Padding between views (single value or array of values)
|
|
720
|
+
* @param absoluteHeights - Optional fixed heights for views (overrides intrinsic height)
|
|
721
|
+
* @returns Array of rectangles representing the frame for each view
|
|
722
|
+
*/
|
|
723
|
+
framesByDistributingViewsAsColumn(
|
|
724
|
+
views: UIView[],
|
|
725
|
+
paddings: SizeNumberOrFunctionOrView | SizeNumberOrFunctionOrView[] = 0,
|
|
726
|
+
absoluteHeights: SizeNumberOrFunctionOrView | SizeNumberOrFunctionOrView[] = nil
|
|
727
|
+
) {
|
|
728
|
+
const frames: UIRectangle[] = []
|
|
729
|
+
let currentRectangle = this.copy()
|
|
730
|
+
|
|
731
|
+
if (!(paddings instanceof Array)) {
|
|
732
|
+
paddings = [paddings].arrayByRepeating(views.length - 1)
|
|
733
|
+
}
|
|
734
|
+
paddings = paddings.map(padding => this._heightNumberFromSizeNumberOrFunctionOrView(padding))
|
|
735
|
+
|
|
736
|
+
if (!(absoluteHeights instanceof Array) && IS_NOT_NIL(absoluteHeights)) {
|
|
737
|
+
absoluteHeights = [absoluteHeights].arrayByRepeating(views.length)
|
|
738
|
+
}
|
|
739
|
+
absoluteHeights = absoluteHeights.map(
|
|
740
|
+
height => this._heightNumberFromSizeNumberOrFunctionOrView(height)
|
|
741
|
+
)
|
|
742
|
+
|
|
743
|
+
for (let i = 0; i < views.length; i++) {
|
|
744
|
+
const frame = currentRectangle.rectangleWithIntrinsicContentHeightForView(views[i])
|
|
745
|
+
|
|
746
|
+
if (IS_NOT_NIL(absoluteHeights[i])) {
|
|
747
|
+
frame.height = absoluteHeights[i] as number
|
|
748
|
+
}
|
|
749
|
+
|
|
750
|
+
frames.push(frame)
|
|
751
|
+
|
|
752
|
+
const padding = (paddings[i] || 0) as number
|
|
753
|
+
currentRectangle = frame.rectangleForNextRow(padding)
|
|
754
|
+
}
|
|
755
|
+
|
|
756
|
+
return frames
|
|
757
|
+
}
|
|
758
|
+
|
|
759
|
+
/**
|
|
760
|
+
* Distributes views horizontally as a row, returning their calculated frames.
|
|
761
|
+
* Each view is positioned to the right of the previous one with optional padding between them.
|
|
762
|
+
* @param views - Array of views to distribute
|
|
763
|
+
* @param paddings - Padding between views (single value or array of values)
|
|
764
|
+
* @param absoluteWidths - Optional fixed widths for views (overrides intrinsic width)
|
|
765
|
+
* @returns Array of rectangles representing the frame for each view
|
|
766
|
+
*/
|
|
767
|
+
framesByDistributingViewsAsRow(
|
|
768
|
+
views: UIView[],
|
|
769
|
+
paddings: SizeNumberOrFunctionOrView | SizeNumberOrFunctionOrView[] = 0,
|
|
770
|
+
absoluteWidths: SizeNumberOrFunctionOrView | SizeNumberOrFunctionOrView[] = nil
|
|
771
|
+
) {
|
|
772
|
+
const frames: UIRectangle[] = []
|
|
773
|
+
let currentRectangle = this.copy()
|
|
774
|
+
|
|
775
|
+
if (!(paddings instanceof Array)) {
|
|
776
|
+
paddings = [paddings].arrayByRepeating(views.length - 1)
|
|
777
|
+
}
|
|
778
|
+
paddings = paddings.map(padding => this._widthNumberFromSizeNumberOrFunctionOrView(padding))
|
|
779
|
+
|
|
780
|
+
if (!(absoluteWidths instanceof Array) && IS_NOT_NIL(absoluteWidths)) {
|
|
781
|
+
absoluteWidths = [absoluteWidths].arrayByRepeating(views.length)
|
|
782
|
+
}
|
|
783
|
+
absoluteWidths = absoluteWidths.map(
|
|
784
|
+
width => this._widthNumberFromSizeNumberOrFunctionOrView(width)
|
|
785
|
+
)
|
|
786
|
+
|
|
787
|
+
for (let i = 0; i < views.length; i++) {
|
|
788
|
+
const frame = currentRectangle.rectangleWithIntrinsicContentWidthForView(views[i])
|
|
789
|
+
|
|
790
|
+
if (IS_NOT_NIL(absoluteWidths[i])) {
|
|
791
|
+
frame.width = absoluteWidths[i] as number
|
|
792
|
+
}
|
|
793
|
+
|
|
794
|
+
frames.push(frame)
|
|
795
|
+
|
|
796
|
+
const padding = (paddings[i] || 0) as number
|
|
797
|
+
currentRectangle = frame.rectangleForNextColumn(padding)
|
|
798
|
+
}
|
|
799
|
+
|
|
800
|
+
return frames
|
|
801
|
+
}
|
|
802
|
+
|
|
803
|
+
/**
|
|
804
|
+
* Distributes views as a grid (2D array), returning their calculated frames.
|
|
805
|
+
* The first index represents rows (vertical), the second index represents columns (horizontal).
|
|
806
|
+
* Example: views[0] is the first row, views[0][0] is the first column in the first row.
|
|
807
|
+
* Each row is laid out horizontally, and rows are stacked vertically.
|
|
808
|
+
* @param views - 2D array where views[row][column] represents the grid structure
|
|
809
|
+
* @param paddings - Vertical padding between rows (single value or array of values)
|
|
810
|
+
* @param absoluteHeights - Optional fixed heights for each row (overrides intrinsic height)
|
|
811
|
+
* @returns 2D array of rectangles where frames[row][column] matches views[row][column]
|
|
812
|
+
*/
|
|
813
|
+
framesByDistributingViewsAsGrid(
|
|
814
|
+
views: UIView[][],
|
|
815
|
+
paddings: SizeNumberOrFunctionOrView | SizeNumberOrFunctionOrView[] = 0,
|
|
816
|
+
absoluteHeights: SizeNumberOrFunctionOrView | SizeNumberOrFunctionOrView[] = nil
|
|
817
|
+
) {
|
|
818
|
+
const frames: UIRectangle[][] = []
|
|
819
|
+
let currentRowRectangle = this.copy()
|
|
820
|
+
|
|
821
|
+
if (!(paddings instanceof Array)) {
|
|
822
|
+
paddings = [paddings].arrayByRepeating(views.length - 1)
|
|
823
|
+
}
|
|
824
|
+
paddings = paddings.map(padding => this._heightNumberFromSizeNumberOrFunctionOrView(padding))
|
|
825
|
+
|
|
826
|
+
if (!(absoluteHeights instanceof Array) && IS_NOT_NIL(absoluteHeights)) {
|
|
827
|
+
absoluteHeights = [absoluteHeights].arrayByRepeating(views.length)
|
|
828
|
+
}
|
|
829
|
+
absoluteHeights = absoluteHeights.map(
|
|
830
|
+
height => this._heightNumberFromSizeNumberOrFunctionOrView(height)
|
|
831
|
+
)
|
|
832
|
+
|
|
833
|
+
for (let i = 0; i < views.length; i++) {
|
|
834
|
+
const rowViews = views[i]
|
|
835
|
+
const rowFrames = currentRowRectangle.framesByDistributingViewsAsRow(rowViews)
|
|
836
|
+
|
|
837
|
+
if (IS_NOT_NIL(absoluteHeights[i])) {
|
|
838
|
+
const heightNumber = absoluteHeights[i] as number
|
|
839
|
+
rowFrames.forEach(frame => {
|
|
840
|
+
frame.height = heightNumber
|
|
841
|
+
})
|
|
842
|
+
}
|
|
843
|
+
|
|
844
|
+
frames.push(rowFrames)
|
|
845
|
+
|
|
846
|
+
const padding = (paddings[i] || 0) as number
|
|
847
|
+
const maxHeight = Math.max(...rowFrames.map(f => f.height))
|
|
848
|
+
currentRowRectangle = currentRowRectangle.rectangleForNextRow(padding, maxHeight)
|
|
849
|
+
}
|
|
850
|
+
|
|
851
|
+
return frames
|
|
852
|
+
}
|
|
853
|
+
|
|
715
854
|
rectangleWithIntrinsicContentSizeForView(view: UIView, centeredOnXPosition = 0, centeredOnYPosition = 0) {
|
|
716
855
|
const intrinsicContentSize = view.intrinsicContentSize()
|
|
717
856
|
return this.rectangleWithHeight(intrinsicContentSize.height, centeredOnYPosition)
|
package/scripts/UIView.ts
CHANGED
|
@@ -1950,7 +1950,10 @@ export class UIView extends UIObject {
|
|
|
1950
1950
|
|
|
1951
1951
|
removeFromSuperview() {
|
|
1952
1952
|
if (IS(this.superview)) {
|
|
1953
|
-
this.forEachViewInSubtree(view =>
|
|
1953
|
+
this.forEachViewInSubtree(view => {
|
|
1954
|
+
view.blur()
|
|
1955
|
+
view.cancelNeedsLayout()
|
|
1956
|
+
})
|
|
1954
1957
|
this.cancelNeedsLayout()
|
|
1955
1958
|
const index = this.superview.subviews.indexOf(this)
|
|
1956
1959
|
if (index > -1) {
|