uicore-ts 1.1.81 → 1.1.83
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/UITextView.d.ts +1 -0
- package/compiledScripts/UITextView.js +1 -0
- package/compiledScripts/UITextView.js.map +2 -2
- package/compiledScripts/UIView.d.ts +1 -0
- package/compiledScripts/UIView.js +48 -8
- package/compiledScripts/UIView.js.map +2 -2
- package/package.json +1 -1
- package/scripts/UITextView.ts +2 -0
- package/scripts/UIView.ts +66 -99
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "uicore-ts",
|
|
3
|
-
"version": "1.1.
|
|
3
|
+
"version": "1.1.83",
|
|
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/UITextView.ts
CHANGED
|
@@ -44,6 +44,8 @@ export class UITextView extends UIView {
|
|
|
44
44
|
private _useFastMeasurement: boolean | undefined;
|
|
45
45
|
private _cachedMeasurementStyles: TextMeasurementStyle | undefined;
|
|
46
46
|
|
|
47
|
+
override usesVirtualLayoutingForIntrinsicSizing = NO
|
|
48
|
+
|
|
47
49
|
|
|
48
50
|
constructor(
|
|
49
51
|
elementID?: string,
|
package/scripts/UIView.ts
CHANGED
|
@@ -161,7 +161,10 @@ export class UIView extends UIObject {
|
|
|
161
161
|
|
|
162
162
|
_localizedTextObject?: UILocalizedTextObject
|
|
163
163
|
|
|
164
|
-
_controlEventTargets: ControlEventTargetsObject = {} //{ "PointerDown": Function[]; "PointerMove": Function[];
|
|
164
|
+
_controlEventTargets: ControlEventTargetsObject = {} //{ "PointerDown": Function[]; "PointerMove": Function[];
|
|
165
|
+
// "PointerLeave": Function[]; "PointerEnter": Function[];
|
|
166
|
+
// "PointerUpInside": Function[]; "PointerUp": Function[];
|
|
167
|
+
// "PointerHover": Function[]; };
|
|
165
168
|
_frameTransform: string
|
|
166
169
|
viewController?: UIViewController
|
|
167
170
|
_updateLayoutFunction?: Function
|
|
@@ -727,93 +730,23 @@ export class UIView extends UIObject {
|
|
|
727
730
|
}
|
|
728
731
|
|
|
729
732
|
|
|
730
|
-
static
|
|
733
|
+
static injectCSS(cssText: string, id?: string) {
|
|
734
|
+
// Prevent duplicate injection if an ID is supplied
|
|
735
|
+
if (id && document.getElementById(id)) {
|
|
736
|
+
return
|
|
737
|
+
}
|
|
731
738
|
|
|
732
|
-
|
|
739
|
+
const style = document.createElement("style")
|
|
740
|
+
if (id) {
|
|
741
|
+
style.id = id
|
|
742
|
+
}
|
|
733
743
|
|
|
734
|
-
|
|
735
|
-
|
|
736
|
-
|
|
737
|
-
|
|
738
|
-
|
|
739
|
-
|
|
740
|
-
// }
|
|
741
|
-
//
|
|
742
|
-
// let styleSheet
|
|
743
|
-
// let mediaType
|
|
744
|
-
//
|
|
745
|
-
// if (document.styleSheets.length > 0) {
|
|
746
|
-
// for (var i = 0, l: any = document.styleSheets.length; i < l; i++) {
|
|
747
|
-
// if (document.styleSheets[i].disabled) {
|
|
748
|
-
// continue
|
|
749
|
-
// }
|
|
750
|
-
// const media = document.styleSheets[i].media
|
|
751
|
-
// mediaType = typeof media
|
|
752
|
-
//
|
|
753
|
-
// if (mediaType === "string") {
|
|
754
|
-
// if (media as any === "" || ((media as any).indexOf("screen") !== -1)) {
|
|
755
|
-
// styleSheet = document.styleSheets[i]
|
|
756
|
-
// }
|
|
757
|
-
// }
|
|
758
|
-
// else if (mediaType == "object") {
|
|
759
|
-
// if (media.mediaText === "" || (media.mediaText.indexOf("screen") !== -1)) {
|
|
760
|
-
// styleSheet = document.styleSheets[i]
|
|
761
|
-
// }
|
|
762
|
-
// }
|
|
763
|
-
//
|
|
764
|
-
// if (typeof styleSheet !== "undefined") {
|
|
765
|
-
// break
|
|
766
|
-
// }
|
|
767
|
-
// }
|
|
768
|
-
// }
|
|
769
|
-
//
|
|
770
|
-
// if (typeof styleSheet === "undefined") {
|
|
771
|
-
// const styleSheetElement = document.createElement("style")
|
|
772
|
-
// styleSheetElement.type = "text/css"
|
|
773
|
-
// document.getElementsByTagName("head")[0].appendChild(styleSheetElement)
|
|
774
|
-
//
|
|
775
|
-
// for (i = 0; i < document.styleSheets.length; i++) {
|
|
776
|
-
// if (document.styleSheets[i].disabled) {
|
|
777
|
-
// continue
|
|
778
|
-
// }
|
|
779
|
-
// styleSheet = document.styleSheets[i]
|
|
780
|
-
// }
|
|
781
|
-
//
|
|
782
|
-
// mediaType = typeof styleSheet.media
|
|
783
|
-
// }
|
|
784
|
-
//
|
|
785
|
-
// if (mediaType === "string") {
|
|
786
|
-
// for (var i = 0, l = styleSheet.rules.length; i < l; i++) {
|
|
787
|
-
// if (styleSheet.rules[i].selectorText && styleSheet.rules[i].selectorText.toLowerCase() ==
|
|
788
|
-
// selector.toLowerCase()) {
|
|
789
|
-
// styleSheet.rules[i].style.cssText = style
|
|
790
|
-
// return
|
|
791
|
-
// }
|
|
792
|
-
// }
|
|
793
|
-
// styleSheet.addRule(selector, style)
|
|
794
|
-
// }
|
|
795
|
-
// else if (mediaType === "object") {
|
|
796
|
-
//
|
|
797
|
-
// var styleSheetLength = 0
|
|
798
|
-
//
|
|
799
|
-
// try {
|
|
800
|
-
//
|
|
801
|
-
// styleSheetLength = (styleSheet.cssRules) ? styleSheet.cssRules.length : 0
|
|
802
|
-
//
|
|
803
|
-
// } catch (error) {
|
|
804
|
-
//
|
|
805
|
-
// }
|
|
806
|
-
//
|
|
807
|
-
//
|
|
808
|
-
// for (var i = 0; i < styleSheetLength; i++) {
|
|
809
|
-
// if (styleSheet.cssRules[i].selectorText && styleSheet.cssRules[i].selectorText.toLowerCase() ==
|
|
810
|
-
// selector.toLowerCase()) {
|
|
811
|
-
// styleSheet.cssRules[i].style.cssText = style
|
|
812
|
-
// return
|
|
813
|
-
// }
|
|
814
|
-
// }
|
|
815
|
-
// styleSheet.insertRule(selector + "{" + style + "}", styleSheetLength)
|
|
816
|
-
// }
|
|
744
|
+
style.textContent = cssText
|
|
745
|
+
document.head.appendChild(style)
|
|
746
|
+
}
|
|
747
|
+
|
|
748
|
+
static createStyleSelector(selector: string, style: string) {
|
|
749
|
+
this.injectCSS(selector + " { " + style + " }")
|
|
817
750
|
}
|
|
818
751
|
|
|
819
752
|
static getStyleRules(selector: string) {
|
|
@@ -997,7 +930,8 @@ export class UIView extends UIObject {
|
|
|
997
930
|
this._frameForVirtualLayouting = rectangle
|
|
998
931
|
}
|
|
999
932
|
|
|
1000
|
-
if (frame && frame != nil && frame.isEqualTo(
|
|
933
|
+
if (frame && frame != nil && frame.isEqualTo(
|
|
934
|
+
rectangle) && frame.zIndex == rectangle.zIndex && !performUncheckedLayout) {
|
|
1001
935
|
return
|
|
1002
936
|
}
|
|
1003
937
|
|
|
@@ -1260,7 +1194,8 @@ export class UIView extends UIObject {
|
|
|
1260
1194
|
// @ts-ignore
|
|
1261
1195
|
this.style[propertyName] = value
|
|
1262
1196
|
|
|
1263
|
-
}
|
|
1197
|
+
}
|
|
1198
|
+
catch (exception) {
|
|
1264
1199
|
|
|
1265
1200
|
console.log(exception)
|
|
1266
1201
|
|
|
@@ -1560,7 +1495,8 @@ export class UIView extends UIObject {
|
|
|
1560
1495
|
|
|
1561
1496
|
element = parentElement.querySelector("#" + key)
|
|
1562
1497
|
|
|
1563
|
-
}
|
|
1498
|
+
}
|
|
1499
|
+
catch (error) {
|
|
1564
1500
|
|
|
1565
1501
|
//console.log("Error occurred " + error);
|
|
1566
1502
|
|
|
@@ -1690,7 +1626,8 @@ export class UIView extends UIObject {
|
|
|
1690
1626
|
|
|
1691
1627
|
this.layoutSubviews()
|
|
1692
1628
|
|
|
1693
|
-
}
|
|
1629
|
+
}
|
|
1630
|
+
catch (exception) {
|
|
1694
1631
|
|
|
1695
1632
|
console.log(exception)
|
|
1696
1633
|
|
|
@@ -1847,7 +1784,8 @@ export class UIView extends UIObject {
|
|
|
1847
1784
|
|
|
1848
1785
|
try {
|
|
1849
1786
|
resultHTMLElement = this.viewHTMLElement.querySelector("#" + viewID)
|
|
1850
|
-
}
|
|
1787
|
+
}
|
|
1788
|
+
catch (error) {
|
|
1851
1789
|
console.log(error)
|
|
1852
1790
|
}
|
|
1853
1791
|
|
|
@@ -3385,7 +3323,8 @@ export class UIView extends UIObject {
|
|
|
3385
3323
|
selfOffsetPoint = selfOffsetPoint.add(
|
|
3386
3324
|
element.UIViewObject?.frame.min ?? new UIPoint(element.offsetLeft, element.offsetTop)
|
|
3387
3325
|
)
|
|
3388
|
-
//selfScale = selfScale * (element.UIView?.scale ?? (element.getBoundingClientRect().width /
|
|
3326
|
+
//selfScale = selfScale * (element.UIView?.scale ?? (element.getBoundingClientRect().width /
|
|
3327
|
+
// element.offsetWidth))
|
|
3389
3328
|
}
|
|
3390
3329
|
|
|
3391
3330
|
let viewOffsetPoint = new UIPoint(0, 0)
|
|
@@ -3395,7 +3334,8 @@ export class UIView extends UIObject {
|
|
|
3395
3334
|
viewOffsetPoint = viewOffsetPoint.add(
|
|
3396
3335
|
element.UIViewObject?.frame.min ?? new UIPoint(element.offsetLeft, element.offsetTop)
|
|
3397
3336
|
)
|
|
3398
|
-
//viewScale = viewScale * (element.UIView?.scale ?? (element.getBoundingClientRect().width /
|
|
3337
|
+
//viewScale = viewScale * (element.UIView?.scale ?? (element.getBoundingClientRect().width /
|
|
3338
|
+
// element.offsetWidth))
|
|
3399
3339
|
}
|
|
3400
3340
|
|
|
3401
3341
|
const offsetPoint = selfOffsetPoint.subtract(viewOffsetPoint)
|
|
@@ -3498,9 +3438,18 @@ export class UIView extends UIObject {
|
|
|
3498
3438
|
UIView.isVirtualLayouting = YES
|
|
3499
3439
|
this.frame = this.frame.rectangleWithHeight(constrainingHeight)
|
|
3500
3440
|
this.layoutIfNeeded()
|
|
3501
|
-
const
|
|
3441
|
+
const framePoints: UIPoint[] = []
|
|
3442
|
+
this.forEachViewInSubtree(view => {
|
|
3443
|
+
const frame = view.rectangleInView(
|
|
3444
|
+
view.frame,
|
|
3445
|
+
this
|
|
3446
|
+
)
|
|
3447
|
+
framePoints.push(frame.min)
|
|
3448
|
+
framePoints.push(frame.max)
|
|
3449
|
+
})
|
|
3450
|
+
const resultFrame = UIRectangle.boundingBoxForPoints(framePoints)
|
|
3502
3451
|
UIView.isVirtualLayouting = NO
|
|
3503
|
-
return
|
|
3452
|
+
return resultFrame.width
|
|
3504
3453
|
}
|
|
3505
3454
|
|
|
3506
3455
|
return this.intrinsicContentSizeWithConstraints(constrainingHeight).width
|
|
@@ -3513,9 +3462,18 @@ export class UIView extends UIObject {
|
|
|
3513
3462
|
UIView.isVirtualLayouting = YES
|
|
3514
3463
|
this.frame = this.frame.rectangleWithWidth(constrainingWidth)
|
|
3515
3464
|
this.layoutIfNeeded()
|
|
3516
|
-
const
|
|
3465
|
+
const framePoints: UIPoint[] = []
|
|
3466
|
+
this.forEachViewInSubtree(view => {
|
|
3467
|
+
const frame = view.rectangleInView(
|
|
3468
|
+
view.frame,
|
|
3469
|
+
this
|
|
3470
|
+
)
|
|
3471
|
+
framePoints.push(frame.min)
|
|
3472
|
+
framePoints.push(frame.max)
|
|
3473
|
+
})
|
|
3474
|
+
const resultFrame = UIRectangle.boundingBoxForPoints(framePoints)
|
|
3517
3475
|
UIView.isVirtualLayouting = NO
|
|
3518
|
-
return
|
|
3476
|
+
return resultFrame.height
|
|
3519
3477
|
}
|
|
3520
3478
|
|
|
3521
3479
|
return this.intrinsicContentSizeWithConstraints(undefined, constrainingWidth).height
|
|
@@ -3529,9 +3487,18 @@ export class UIView extends UIObject {
|
|
|
3529
3487
|
if (this.usesVirtualLayoutingForIntrinsicSizing) {
|
|
3530
3488
|
UIView.isVirtualLayouting = YES
|
|
3531
3489
|
this.layoutIfNeeded()
|
|
3532
|
-
const
|
|
3490
|
+
const framePoints: UIPoint[] = []
|
|
3491
|
+
this.forEachViewInSubtree(view => {
|
|
3492
|
+
const frame = view.rectangleInView(
|
|
3493
|
+
view.frame,
|
|
3494
|
+
this
|
|
3495
|
+
)
|
|
3496
|
+
framePoints.push(frame.min)
|
|
3497
|
+
framePoints.push(frame.max)
|
|
3498
|
+
})
|
|
3499
|
+
const resultFrame = UIRectangle.boundingBoxForPoints(framePoints)
|
|
3533
3500
|
UIView.isVirtualLayouting = NO
|
|
3534
|
-
return
|
|
3501
|
+
return resultFrame
|
|
3535
3502
|
}
|
|
3536
3503
|
|
|
3537
3504
|
return nil
|