uicore-ts 1.1.18 → 1.1.21
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/UIImageView.d.ts +2 -2
- package/compiledScripts/UIImageView.js +9 -9
- package/compiledScripts/UIImageView.js.map +2 -2
- package/compiledScripts/UIKeyValueSorter.d.ts +4 -4
- package/compiledScripts/UIKeyValueSorter.js.map +1 -1
- package/compiledScripts/UITableView.d.ts +1 -1
- package/compiledScripts/UITableView.js +8 -8
- package/compiledScripts/UITableView.js.map +2 -2
- package/compiledScripts/UITextView.d.ts +3 -3
- package/compiledScripts/UITextView.js +36 -36
- package/compiledScripts/UITextView.js.map +2 -2
- package/compiledScripts/UIView.d.ts +4 -4
- package/compiledScripts/UIView.js +64 -64
- package/compiledScripts/UIView.js.map +2 -2
- package/package.json +1 -1
- package/scripts/UIImageView.ts +2 -2
- package/scripts/UIKeyValueSorter.ts +2 -2
- package/scripts/UITableView.ts +1 -1
- package/scripts/UITextView.ts +3 -3
- package/scripts/UIView.ts +4 -4
|
@@ -31,6 +31,6 @@ export declare class UIImageView extends UIView {
|
|
|
31
31
|
set hiddenWhenEmpty(hiddenWhenEmpty: boolean);
|
|
32
32
|
didMoveToSuperview(superview: UIView): void;
|
|
33
33
|
layoutSubviews(): void;
|
|
34
|
-
intrinsicContentSize()
|
|
35
|
-
intrinsicContentSizeWithConstraints(constrainingHeight?: number, constrainingWidth?: number)
|
|
34
|
+
intrinsicContentSize: () => UIRectangle;
|
|
35
|
+
intrinsicContentSizeWithConstraints: (constrainingHeight?: number, constrainingWidth?: number) => UIRectangle;
|
|
36
36
|
}
|
|
@@ -29,6 +29,15 @@ const _UIImageView = class extends import_UIView.UIView {
|
|
|
29
29
|
constructor(elementID, viewHTMLElement = null) {
|
|
30
30
|
super(elementID, viewHTMLElement, "img");
|
|
31
31
|
this._hiddenWhenEmpty = import_UIObject.NO;
|
|
32
|
+
this.intrinsicContentSize = () => {
|
|
33
|
+
return new import_UIRectangle.UIRectangle(0, 0, this.viewHTMLElement.naturalHeight, this.viewHTMLElement.naturalWidth);
|
|
34
|
+
};
|
|
35
|
+
this.intrinsicContentSizeWithConstraints = (constrainingHeight = 0, constrainingWidth = 0) => {
|
|
36
|
+
const heightRatio = constrainingHeight / this.viewHTMLElement.naturalHeight;
|
|
37
|
+
const widthRatio = constrainingWidth / this.viewHTMLElement.naturalWidth;
|
|
38
|
+
const multiplier = Math.max(heightRatio, widthRatio);
|
|
39
|
+
return new import_UIRectangle.UIRectangle(0, 0, this.viewHTMLElement.naturalHeight * multiplier, this.viewHTMLElement.naturalWidth * multiplier);
|
|
40
|
+
};
|
|
32
41
|
}
|
|
33
42
|
get viewHTMLElement() {
|
|
34
43
|
return super.viewHTMLElement;
|
|
@@ -141,15 +150,6 @@ const _UIImageView = class extends import_UIView.UIView {
|
|
|
141
150
|
layoutSubviews() {
|
|
142
151
|
super.layoutSubviews();
|
|
143
152
|
}
|
|
144
|
-
intrinsicContentSize() {
|
|
145
|
-
return new import_UIRectangle.UIRectangle(0, 0, this.viewHTMLElement.naturalHeight, this.viewHTMLElement.naturalWidth);
|
|
146
|
-
}
|
|
147
|
-
intrinsicContentSizeWithConstraints(constrainingHeight = 0, constrainingWidth = 0) {
|
|
148
|
-
const heightRatio = constrainingHeight / this.viewHTMLElement.naturalHeight;
|
|
149
|
-
const widthRatio = constrainingWidth / this.viewHTMLElement.naturalWidth;
|
|
150
|
-
const multiplier = Math.max(heightRatio, widthRatio);
|
|
151
|
-
return new import_UIRectangle.UIRectangle(0, 0, this.viewHTMLElement.naturalHeight * multiplier, this.viewHTMLElement.naturalWidth * multiplier);
|
|
152
|
-
}
|
|
153
153
|
};
|
|
154
154
|
let UIImageView = _UIImageView;
|
|
155
155
|
UIImageView.fillMode = {
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../scripts/UIImageView.ts"],
|
|
4
|
-
"sourcesContent": ["import { UICore } from \"./UICore\"\nimport { IS_NOT, NO, YES } from \"./UIObject\"\nimport { UIRectangle } from \"./UIRectangle\"\nimport { UIView, UIViewBroadcastEvent } from \"./UIView\"\n\n\nexport class UIImageView extends UIView {\n \n \n //actionIndicator: UIActionIndicator;\n _sourceKey?: string\n _defaultSource?: string\n \n _fillMode: any\n \n _hiddenWhenEmpty = NO\n \n \n constructor(elementID?: string, viewHTMLElement = null) {\n \n super(elementID, viewHTMLElement, \"img\")\n \n \n //this.actionIndicator = new UIActionIndicator(elementID + \"ActionIndicator\");\n \n \n }\n \n \n static fillMode = {\n \n \"stretchToFill\": \"fill\",\n \"aspectFit\": \"contain\",\n \"aspectFill\": \"cover\",\n \"center\": \"none\",\n \"aspectFitIfLarger\": \"scale-down\"\n \n }\n \n \n override get viewHTMLElement() {\n \n return super.viewHTMLElement as HTMLImageElement\n \n }\n \n \n static objectURLFromDataURL(dataURL: string) {\n // @ts-ignore\n const blob = dataURLtoBlob(dataURL)\n return URL.createObjectURL(blob)\n }\n \n \n static dataURL(url: string | URL, callback: (arg0: string | ArrayBuffer | null) => void) {\n const xhr = new XMLHttpRequest()\n xhr.open(\"get\", url)\n xhr.responseType = \"blob\"\n xhr.onload = function () {\n const fr = new FileReader()\n \n fr.onload = function () {\n callback(this.result)\n }\n \n fr.readAsDataURL(xhr.response) // async call\n }\n \n xhr.send()\n }\n \n \n static dataURLWithMaxSize(URLString: string, maxSize: number, completion: (resultURLString: string) => void) {\n \n const imageView = new UIImageView()\n imageView.imageSource = URLString\n \n imageView.viewHTMLElement.onload = () => {\n \n const originalSize = imageView.intrinsicContentSize()\n \n let multiplier = maxSize / Math.max(originalSize.height, originalSize.width)\n multiplier = Math.min(1, multiplier)\n \n const result = imageView.getDataURL((originalSize.height * multiplier).integerValue, (originalSize.width *\n multiplier).integerValue)\n \n completion(result)\n \n }\n \n }\n \n \n static dataURLWithSizes(\n URLString: string,\n height: number,\n width: number,\n completion: (resultURLString: string) => void\n ) {\n \n const imageView = new UIImageView()\n imageView.imageSource = URLString\n \n imageView.viewHTMLElement.onload = () => {\n \n const result = imageView.getDataURL(height, width)\n completion(result)\n \n }\n \n }\n \n \n getDataURL(height?: number, width?: number) {\n \n const img = this.viewHTMLElement\n \n // Create an empty canvas element\n const canvas: HTMLCanvasElement = document.createElement(\"canvas\")\n canvas.width = width ?? img.naturalWidth\n canvas.height = height ?? img.naturalHeight\n \n // Copy the image contents to the canvas\n const ctx = canvas.getContext(\"2d\") as CanvasRenderingContext2D\n ctx.drawImage(img, 0, 0, width ?? img.naturalWidth, height ?? img.naturalHeight)\n \n // Get the data-URL formatted image\n // Firefox supports PNG and JPEG. You could check img.src to\n // guess the original format, but be aware the using \"image/jpg\"\n // will re-encode the image.\n return canvas.toDataURL(\"image/png\")\n \n }\n \n \n get imageSource() {\n \n return this.viewHTMLElement.src\n \n }\n \n set imageSource(sourceString: string) {\n \n if (IS_NOT(sourceString)) {\n sourceString = \"\"\n }\n \n this.viewHTMLElement.src = sourceString\n \n if (this.hiddenWhenEmpty) {\n this.hidden = IS_NOT(this.imageSource)\n }\n \n if (!sourceString || !sourceString.length) {\n \n //this.actionIndicator.stop();\n this.hidden = YES\n \n return\n \n }\n else {\n \n this.hidden = NO\n \n }\n \n // this.superview.addSubview(this.actionIndicator);\n // this.actionIndicator.frame = this.frame;\n // this.actionIndicator.start();\n // this.actionIndicator.backgroundColor = UIColor.redColor\n \n // @ts-ignore\n this.viewHTMLElement.onload = () => this.superview?.setNeedsLayout()\n \n }\n \n \n setImageSource(key: string, defaultString: string) {\n \n const languageName = UICore.languageService.currentLanguageKey\n this.imageSource = UICore.languageService.stringForKey(key, languageName, defaultString, undefined)\n \n }\n \n \n override didReceiveBroadcastEvent(event: UIViewBroadcastEvent) {\n \n super.didReceiveBroadcastEvent(event)\n \n if (event.name == UIView.broadcastEventName.LanguageChanged || event.name ==\n UIView.broadcastEventName.AddedToViewTree) {\n \n this._setImageSourceFromKeyIfPossible()\n \n }\n \n }\n \n \n override willMoveToSuperview(superview: UIView) {\n \n super.willMoveToSuperview(superview)\n \n this._setImageSourceFromKeyIfPossible()\n \n }\n \n _setImageSourceFromKeyIfPossible() {\n \n if (this._sourceKey && this._defaultSource) {\n \n this.setImageSource(this._sourceKey, this._defaultSource)\n \n }\n \n }\n \n \n get fillMode() {\n return this._fillMode\n }\n \n set fillMode(fillMode) {\n \n this._fillMode = fillMode;\n (this.style as any).objectFit = fillMode\n \n }\n \n \n get hiddenWhenEmpty() {\n return this._hiddenWhenEmpty\n }\n \n set hiddenWhenEmpty(hiddenWhenEmpty: boolean) {\n this._hiddenWhenEmpty = hiddenWhenEmpty\n if (hiddenWhenEmpty) {\n this.hidden = IS_NOT(this.imageSource)\n }\n }\n \n \n override didMoveToSuperview(superview: UIView) {\n \n super.didMoveToSuperview(superview)\n \n \n }\n \n \n override layoutSubviews() {\n \n super.layoutSubviews()\n \n \n }\n \n \n override intrinsicContentSize() {\n \n \n return new UIRectangle(0, 0, this.viewHTMLElement.naturalHeight, this.viewHTMLElement.naturalWidth)\n \n \n }\n \n override intrinsicContentSizeWithConstraints(constrainingHeight = 0, constrainingWidth = 0) {\n \n const heightRatio = constrainingHeight / this.viewHTMLElement.naturalHeight\n \n const widthRatio = constrainingWidth / this.viewHTMLElement.naturalWidth\n \n const multiplier = Math.max(heightRatio, widthRatio)\n \n return new UIRectangle(0, 0, this.viewHTMLElement.naturalHeight *\n multiplier, this.viewHTMLElement.naturalWidth * multiplier)\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,oBAAuB;AACvB,sBAAgC;AAChC,yBAA4B;AAC5B,oBAA6C;AAGtC,MAAM,eAAN,cAA0B,qBAAO;AAAA,EAYpC,YAAY,WAAoB,kBAAkB,MAAM;AAEpD,UAAM,WAAW,iBAAiB,KAAK;AAL3C,4BAAmB;AAAA,
|
|
4
|
+
"sourcesContent": ["import { UICore } from \"./UICore\"\nimport { IS_NOT, NO, YES } from \"./UIObject\"\nimport { UIRectangle } from \"./UIRectangle\"\nimport { UIView, UIViewBroadcastEvent } from \"./UIView\"\n\n\nexport class UIImageView extends UIView {\n \n \n //actionIndicator: UIActionIndicator;\n _sourceKey?: string\n _defaultSource?: string\n \n _fillMode: any\n \n _hiddenWhenEmpty = NO\n \n \n constructor(elementID?: string, viewHTMLElement = null) {\n \n super(elementID, viewHTMLElement, \"img\")\n \n \n //this.actionIndicator = new UIActionIndicator(elementID + \"ActionIndicator\");\n \n \n }\n \n \n static fillMode = {\n \n \"stretchToFill\": \"fill\",\n \"aspectFit\": \"contain\",\n \"aspectFill\": \"cover\",\n \"center\": \"none\",\n \"aspectFitIfLarger\": \"scale-down\"\n \n }\n \n \n override get viewHTMLElement() {\n \n return super.viewHTMLElement as HTMLImageElement\n \n }\n \n \n static objectURLFromDataURL(dataURL: string) {\n // @ts-ignore\n const blob = dataURLtoBlob(dataURL)\n return URL.createObjectURL(blob)\n }\n \n \n static dataURL(url: string | URL, callback: (arg0: string | ArrayBuffer | null) => void) {\n const xhr = new XMLHttpRequest()\n xhr.open(\"get\", url)\n xhr.responseType = \"blob\"\n xhr.onload = function () {\n const fr = new FileReader()\n \n fr.onload = function () {\n callback(this.result)\n }\n \n fr.readAsDataURL(xhr.response) // async call\n }\n \n xhr.send()\n }\n \n \n static dataURLWithMaxSize(URLString: string, maxSize: number, completion: (resultURLString: string) => void) {\n \n const imageView = new UIImageView()\n imageView.imageSource = URLString\n \n imageView.viewHTMLElement.onload = () => {\n \n const originalSize = imageView.intrinsicContentSize()\n \n let multiplier = maxSize / Math.max(originalSize.height, originalSize.width)\n multiplier = Math.min(1, multiplier)\n \n const result = imageView.getDataURL((originalSize.height * multiplier).integerValue, (originalSize.width *\n multiplier).integerValue)\n \n completion(result)\n \n }\n \n }\n \n \n static dataURLWithSizes(\n URLString: string,\n height: number,\n width: number,\n completion: (resultURLString: string) => void\n ) {\n \n const imageView = new UIImageView()\n imageView.imageSource = URLString\n \n imageView.viewHTMLElement.onload = () => {\n \n const result = imageView.getDataURL(height, width)\n completion(result)\n \n }\n \n }\n \n \n getDataURL(height?: number, width?: number) {\n \n const img = this.viewHTMLElement\n \n // Create an empty canvas element\n const canvas: HTMLCanvasElement = document.createElement(\"canvas\")\n canvas.width = width ?? img.naturalWidth\n canvas.height = height ?? img.naturalHeight\n \n // Copy the image contents to the canvas\n const ctx = canvas.getContext(\"2d\") as CanvasRenderingContext2D\n ctx.drawImage(img, 0, 0, width ?? img.naturalWidth, height ?? img.naturalHeight)\n \n // Get the data-URL formatted image\n // Firefox supports PNG and JPEG. You could check img.src to\n // guess the original format, but be aware the using \"image/jpg\"\n // will re-encode the image.\n return canvas.toDataURL(\"image/png\")\n \n }\n \n \n get imageSource() {\n \n return this.viewHTMLElement.src\n \n }\n \n set imageSource(sourceString: string) {\n \n if (IS_NOT(sourceString)) {\n sourceString = \"\"\n }\n \n this.viewHTMLElement.src = sourceString\n \n if (this.hiddenWhenEmpty) {\n this.hidden = IS_NOT(this.imageSource)\n }\n \n if (!sourceString || !sourceString.length) {\n \n //this.actionIndicator.stop();\n this.hidden = YES\n \n return\n \n }\n else {\n \n this.hidden = NO\n \n }\n \n // this.superview.addSubview(this.actionIndicator);\n // this.actionIndicator.frame = this.frame;\n // this.actionIndicator.start();\n // this.actionIndicator.backgroundColor = UIColor.redColor\n \n // @ts-ignore\n this.viewHTMLElement.onload = () => this.superview?.setNeedsLayout()\n \n }\n \n \n setImageSource(key: string, defaultString: string) {\n \n const languageName = UICore.languageService.currentLanguageKey\n this.imageSource = UICore.languageService.stringForKey(key, languageName, defaultString, undefined)\n \n }\n \n \n override didReceiveBroadcastEvent(event: UIViewBroadcastEvent) {\n \n super.didReceiveBroadcastEvent(event)\n \n if (event.name == UIView.broadcastEventName.LanguageChanged || event.name ==\n UIView.broadcastEventName.AddedToViewTree) {\n \n this._setImageSourceFromKeyIfPossible()\n \n }\n \n }\n \n \n override willMoveToSuperview(superview: UIView) {\n \n super.willMoveToSuperview(superview)\n \n this._setImageSourceFromKeyIfPossible()\n \n }\n \n _setImageSourceFromKeyIfPossible() {\n \n if (this._sourceKey && this._defaultSource) {\n \n this.setImageSource(this._sourceKey, this._defaultSource)\n \n }\n \n }\n \n \n get fillMode() {\n return this._fillMode\n }\n \n set fillMode(fillMode) {\n \n this._fillMode = fillMode;\n (this.style as any).objectFit = fillMode\n \n }\n \n \n get hiddenWhenEmpty() {\n return this._hiddenWhenEmpty\n }\n \n set hiddenWhenEmpty(hiddenWhenEmpty: boolean) {\n this._hiddenWhenEmpty = hiddenWhenEmpty\n if (hiddenWhenEmpty) {\n this.hidden = IS_NOT(this.imageSource)\n }\n }\n \n \n override didMoveToSuperview(superview: UIView) {\n \n super.didMoveToSuperview(superview)\n \n \n }\n \n \n override layoutSubviews() {\n \n super.layoutSubviews()\n \n \n }\n \n \n override intrinsicContentSize = () => {\n \n \n return new UIRectangle(0, 0, this.viewHTMLElement.naturalHeight, this.viewHTMLElement.naturalWidth)\n \n \n }\n \n override intrinsicContentSizeWithConstraints = (constrainingHeight = 0, constrainingWidth = 0) => {\n \n const heightRatio = constrainingHeight / this.viewHTMLElement.naturalHeight\n \n const widthRatio = constrainingWidth / this.viewHTMLElement.naturalWidth\n \n const multiplier = Math.max(heightRatio, widthRatio)\n \n return new UIRectangle(0, 0, this.viewHTMLElement.naturalHeight *\n multiplier, this.viewHTMLElement.naturalWidth * multiplier)\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,oBAAuB;AACvB,sBAAgC;AAChC,yBAA4B;AAC5B,oBAA6C;AAGtC,MAAM,eAAN,cAA0B,qBAAO;AAAA,EAYpC,YAAY,WAAoB,kBAAkB,MAAM;AAEpD,UAAM,WAAW,iBAAiB,KAAK;AAL3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;AAE3D,UAAM,yBAAyB,KAAK;AAEpC,QAAI,MAAM,QAAQ,qBAAO,mBAAmB,mBAAmB,MAAM,QACjE,qBAAO,mBAAmB,iBAAiB;AAE3C,WAAK,iCAAiC;AAAA,IAE1C;AAAA,EAEJ;AAAA,EAGS,oBAAoB,WAAmB;AAE5C,UAAM,oBAAoB,SAAS;AAEnC,SAAK,iCAAiC;AAAA,EAE1C;AAAA,EAEA,mCAAmC;AAE/B,QAAI,KAAK,cAAc,KAAK,gBAAgB;AAExC,WAAK,eAAe,KAAK,YAAY,KAAK,cAAc;AAAA,IAE5D;AAAA,EAEJ;AAAA,EAGA,IAAI,WAAW;AACX,WAAO,KAAK;AAAA,EAChB;AAAA,EAEA,IAAI,SAAS,UAAU;AAEnB,SAAK,YAAY;AACjB,IAAC,KAAK,MAAc,YAAY;AAAA,EAEpC;AAAA,EAGA,IAAI,kBAAkB;AAClB,WAAO,KAAK;AAAA,EAChB;AAAA,EAEA,IAAI,gBAAgB,iBAA0B;AAC1C,SAAK,mBAAmB;AACxB,QAAI,iBAAiB;AACjB,WAAK,aAAS,wBAAO,KAAK,WAAW;AAAA,IACzC;AAAA,EACJ;AAAA,EAGS,mBAAmB,WAAmB;AAE3C,UAAM,mBAAmB,SAAS;AAAA,EAGtC;AAAA,EAGS,iBAAiB;AAEtB,UAAM,eAAe;AAAA,EAGzB;AA0BJ;AArRO,IAAM,cAAN;AAAM,YAuBF,WAAW;AAAA,EAEd,iBAAiB;AAAA,EACjB,aAAa;AAAA,EACb,cAAc;AAAA,EACd,UAAU;AAAA,EACV,qBAAqB;AAEzB;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -25,12 +25,12 @@ export declare class UIKeyValueSorter extends UIObject {
|
|
|
25
25
|
get isWorkerBusy(): boolean;
|
|
26
26
|
postNextMessageIfNeeded(): void;
|
|
27
27
|
static dataType: {
|
|
28
|
-
string: string;
|
|
29
|
-
number:
|
|
28
|
+
readonly string: "string";
|
|
29
|
+
readonly number: "number";
|
|
30
30
|
};
|
|
31
31
|
static direction: {
|
|
32
|
-
descending:
|
|
33
|
-
ascending:
|
|
32
|
+
readonly descending: "descending";
|
|
33
|
+
readonly ascending: "ascending";
|
|
34
34
|
};
|
|
35
35
|
sortData<T>(data: T[], sortingInstructions: UIKeyValueSorterSortingInstruction[], identifier: any, completion: (sortedData: T[], sortedIndexes: number[], identifier: any) => void): void;
|
|
36
36
|
sortedData<T>(data: T[], sortingInstructions: UIKeyValueSorterSortingInstruction[], identifier?: any): Promise<{
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../scripts/UIKeyValueSorter.ts"],
|
|
4
|
-
"sourcesContent": ["// @ts-ignore\nimport UIKeyValueSorterWebWorker from \"./UIKeyValueSorterWebWorker.worker\"\nimport { IS, IS_NOT, MAKE_ID, NO, UIObject, YES } from \"./UIObject\"\n\n\nexport interface UIKeyValueSorterSortingInstruction {\n \n keyPath: string;\n \n dataType: string;\n \n direction: string;\n \n \n}\n\n\nexport class UIKeyValueSorter extends UIObject {\n \n static _sharedWebWorkerHolder = {\n UICore_completionFunctions: {},\n UICore_isWorking: false,\n UICore_messagesToPost: undefined,\n webWorker: new UIKeyValueSorterWebWorker()\n }\n \n static _instanceNumber = -1\n \n _instanceNumber: number\n _isThreadClosed = NO\n \n private readonly _webWorkerHolder: {\n webWorker: any;\n UICore_isWorking: boolean\n UICore_messagesToPost: any\n UICore_completionFunctions: Record<string, (\n filteredData: string[],\n filteredIndexes: number[],\n identifier: any\n ) => void>\n } = UIKeyValueSorter._sharedWebWorkerHolder\n \n \n constructor(useSeparateWebWorkerHolder = NO) {\n \n super()\n \n if (useSeparateWebWorkerHolder) {\n \n this._webWorkerHolder = {\n webWorker: new UIKeyValueSorterWebWorker(),\n UICore_isWorking: false,\n UICore_messagesToPost: undefined,\n UICore_completionFunctions: {}\n }\n \n }\n \n UIKeyValueSorter._instanceNumber = UIKeyValueSorter._instanceNumber + 1\n this._instanceNumber = UIKeyValueSorter._instanceNumber\n \n if (IS_NOT(this._webWorkerHolder.webWorker.onmessage)) {\n \n this._webWorkerHolder.webWorker.onmessage = (message: { data: { identifier: string; instanceIdentifier: string; sortedData: any[]; sortedIndexes: number[]; }; }) => {\n \n this.isWorkerBusy = NO\n this.postNextMessageIfNeeded()\n \n const key = \"\" + message.data.identifier + message.data.instanceIdentifier\n \n const completionFunction = this.completionFunctions[key]\n \n if (IS(completionFunction)) {\n \n //console.log(\"Filtering took \" + (Date.now() - startTime) + \" ms\");\n \n completionFunction(message.data.sortedData, message.data.sortedIndexes, message.data.identifier)\n \n }\n \n delete this.completionFunctions[key]\n \n var asd = 1\n \n }\n \n }\n \n \n }\n \n \n get instanceIdentifier() {\n \n return this._instanceNumber\n \n }\n \n \n get completionFunctions() {\n \n const key = \"UICore_completionFunctions\"\n var result: {\n \n [x: string]: (sortedData: any[], sortedIndexes: number[], identifier: any) => void\n \n } = this._webWorkerHolder[key]\n \n if (IS_NOT(result)) {\n \n result = {}\n this._webWorkerHolder[key] = result\n \n }\n \n return result\n \n }\n \n get messagesToPost() {\n \n const key = \"UICore_messagesToPost\"\n var result: any[] = this._webWorkerHolder[key]\n \n if (IS_NOT(result)) {\n \n result = []\n this._webWorkerHolder[key] = result\n \n }\n \n return result\n \n }\n \n \n set isWorkerBusy(isWorkerBusy: boolean) {\n \n this._webWorkerHolder[\"UICore_isWorking\"] = isWorkerBusy\n \n }\n \n get isWorkerBusy() {\n \n return IS(this._webWorkerHolder[\"UICore_isWorking\"])\n \n }\n \n \n postNextMessageIfNeeded() {\n \n if (this.messagesToPost.length && IS_NOT(this.isWorkerBusy)) {\n \n this._webWorkerHolder.webWorker.postMessage(this.messagesToPost.firstElement)\n this.messagesToPost.removeElementAtIndex(0)\n \n this.isWorkerBusy = YES\n \n }\n \n }\n \n \n static dataType = {\n \n \"string\": \"string\",\n \"number\": \"number\"\n \n }\n \n \n static direction = {\n \n \"descending\": \"descending\",\n \"ascending\": \"ascending\"\n \n }\n \n \n sortData<T>(\n data: T[],\n sortingInstructions: UIKeyValueSorterSortingInstruction[],\n identifier: any,\n completion: (sortedData: T[], sortedIndexes: number[], identifier: any) => void\n ) {\n \n \n if (this._isThreadClosed) {\n \n return\n \n }\n \n if (!data?.length) {\n completion([], [], identifier)\n return\n }\n \n const instanceIdentifier = this.instanceIdentifier\n \n const key = \"\" + identifier + instanceIdentifier\n \n this.completionFunctions[key] = completion\n \n \n try {\n \n this.messagesToPost.push({\n \n \"data\": data,\n \"sortingInstructions\": sortingInstructions,\n \"identifier\": identifier,\n \"instanceIdentifier\": instanceIdentifier\n \n })\n \n this.postNextMessageIfNeeded()\n \n } catch (exception) {\n \n completion([], [], identifier)\n \n }\n \n \n }\n \n \n sortedData<T>(\n data: T[],\n sortingInstructions: UIKeyValueSorterSortingInstruction[],\n identifier: any = MAKE_ID()\n ) {\n \n const result: Promise<{\n \n sortedData: T[],\n sortedIndexes: number[],\n identifier: any\n \n }> = new Promise((resolve, reject) => {\n \n this.sortData(data, sortingInstructions, identifier, (sortedData, sortedIndexes, sortedIdentifier) => {\n \n if (sortedIdentifier == identifier) {\n \n resolve({\n \n sortedData: sortedData,\n sortedIndexes: sortedIndexes,\n identifier: sortedIdentifier\n \n })\n \n }\n \n \n })\n \n \n })\n \n return result\n \n }\n \n \n closeThread() {\n \n this._isThreadClosed = YES\n \n if (this._webWorkerHolder != UIKeyValueSorter._sharedWebWorkerHolder) {\n \n this._webWorkerHolder.webWorker.terminate()\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\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n"],
|
|
4
|
+
"sourcesContent": ["// @ts-ignore\nimport UIKeyValueSorterWebWorker from \"./UIKeyValueSorterWebWorker.worker\"\nimport { IS, IS_NOT, MAKE_ID, NO, UIObject, YES } from \"./UIObject\"\n\n\nexport interface UIKeyValueSorterSortingInstruction {\n \n keyPath: string;\n \n dataType: string;\n \n direction: string;\n \n \n}\n\n\nexport class UIKeyValueSorter extends UIObject {\n \n static _sharedWebWorkerHolder = {\n UICore_completionFunctions: {},\n UICore_isWorking: false,\n UICore_messagesToPost: undefined,\n webWorker: new UIKeyValueSorterWebWorker()\n }\n \n static _instanceNumber = -1\n \n _instanceNumber: number\n _isThreadClosed = NO\n \n private readonly _webWorkerHolder: {\n webWorker: any;\n UICore_isWorking: boolean\n UICore_messagesToPost: any\n UICore_completionFunctions: Record<string, (\n filteredData: string[],\n filteredIndexes: number[],\n identifier: any\n ) => void>\n } = UIKeyValueSorter._sharedWebWorkerHolder\n \n \n constructor(useSeparateWebWorkerHolder = NO) {\n \n super()\n \n if (useSeparateWebWorkerHolder) {\n \n this._webWorkerHolder = {\n webWorker: new UIKeyValueSorterWebWorker(),\n UICore_isWorking: false,\n UICore_messagesToPost: undefined,\n UICore_completionFunctions: {}\n }\n \n }\n \n UIKeyValueSorter._instanceNumber = UIKeyValueSorter._instanceNumber + 1\n this._instanceNumber = UIKeyValueSorter._instanceNumber\n \n if (IS_NOT(this._webWorkerHolder.webWorker.onmessage)) {\n \n this._webWorkerHolder.webWorker.onmessage = (message: { data: { identifier: string; instanceIdentifier: string; sortedData: any[]; sortedIndexes: number[]; }; }) => {\n \n this.isWorkerBusy = NO\n this.postNextMessageIfNeeded()\n \n const key = \"\" + message.data.identifier + message.data.instanceIdentifier\n \n const completionFunction = this.completionFunctions[key]\n \n if (IS(completionFunction)) {\n \n //console.log(\"Filtering took \" + (Date.now() - startTime) + \" ms\");\n \n completionFunction(message.data.sortedData, message.data.sortedIndexes, message.data.identifier)\n \n }\n \n delete this.completionFunctions[key]\n \n var asd = 1\n \n }\n \n }\n \n \n }\n \n \n get instanceIdentifier() {\n \n return this._instanceNumber\n \n }\n \n \n get completionFunctions() {\n \n const key = \"UICore_completionFunctions\"\n var result: {\n \n [x: string]: (sortedData: any[], sortedIndexes: number[], identifier: any) => void\n \n } = this._webWorkerHolder[key]\n \n if (IS_NOT(result)) {\n \n result = {}\n this._webWorkerHolder[key] = result\n \n }\n \n return result\n \n }\n \n get messagesToPost() {\n \n const key = \"UICore_messagesToPost\"\n var result: any[] = this._webWorkerHolder[key]\n \n if (IS_NOT(result)) {\n \n result = []\n this._webWorkerHolder[key] = result\n \n }\n \n return result\n \n }\n \n \n set isWorkerBusy(isWorkerBusy: boolean) {\n \n this._webWorkerHolder[\"UICore_isWorking\"] = isWorkerBusy\n \n }\n \n get isWorkerBusy() {\n \n return IS(this._webWorkerHolder[\"UICore_isWorking\"])\n \n }\n \n \n postNextMessageIfNeeded() {\n \n if (this.messagesToPost.length && IS_NOT(this.isWorkerBusy)) {\n \n this._webWorkerHolder.webWorker.postMessage(this.messagesToPost.firstElement)\n this.messagesToPost.removeElementAtIndex(0)\n \n this.isWorkerBusy = YES\n \n }\n \n }\n \n \n static dataType = {\n \n \"string\": \"string\",\n \"number\": \"number\"\n \n } as const\n \n \n static direction = {\n \n \"descending\": \"descending\",\n \"ascending\": \"ascending\"\n \n } as const\n \n \n sortData<T>(\n data: T[],\n sortingInstructions: UIKeyValueSorterSortingInstruction[],\n identifier: any,\n completion: (sortedData: T[], sortedIndexes: number[], identifier: any) => void\n ) {\n \n \n if (this._isThreadClosed) {\n \n return\n \n }\n \n if (!data?.length) {\n completion([], [], identifier)\n return\n }\n \n const instanceIdentifier = this.instanceIdentifier\n \n const key = \"\" + identifier + instanceIdentifier\n \n this.completionFunctions[key] = completion\n \n \n try {\n \n this.messagesToPost.push({\n \n \"data\": data,\n \"sortingInstructions\": sortingInstructions,\n \"identifier\": identifier,\n \"instanceIdentifier\": instanceIdentifier\n \n })\n \n this.postNextMessageIfNeeded()\n \n } catch (exception) {\n \n completion([], [], identifier)\n \n }\n \n \n }\n \n \n sortedData<T>(\n data: T[],\n sortingInstructions: UIKeyValueSorterSortingInstruction[],\n identifier: any = MAKE_ID()\n ) {\n \n const result: Promise<{\n \n sortedData: T[],\n sortedIndexes: number[],\n identifier: any\n \n }> = new Promise((resolve, reject) => {\n \n this.sortData(data, sortingInstructions, identifier, (sortedData, sortedIndexes, sortedIdentifier) => {\n \n if (sortedIdentifier == identifier) {\n \n resolve({\n \n sortedData: sortedData,\n sortedIndexes: sortedIndexes,\n identifier: sortedIdentifier\n \n })\n \n }\n \n \n })\n \n \n })\n \n return result\n \n }\n \n \n closeThread() {\n \n this._isThreadClosed = YES\n \n if (this._webWorkerHolder != UIKeyValueSorter._sharedWebWorkerHolder) {\n \n this._webWorkerHolder.webWorker.terminate()\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\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n"],
|
|
5
5
|
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AACA,uCAAsC;AACtC,sBAAuD;AAehD,MAAM,oBAAN,cAA+B,yBAAS;AAAA,EA0B3C,YAAY,6BAA6B,oBAAI;AAEzC,UAAM;AAhBV,2BAAkB;AAElB,SAAiB,mBASb,kBAAiB;AAOjB,QAAI,4BAA4B;AAE5B,WAAK,mBAAmB;AAAA,QACpB,WAAW,IAAI,iCAAAA,QAA0B;AAAA,QACzC,kBAAkB;AAAA,QAClB,uBAAuB;AAAA,QACvB,4BAA4B,CAAC;AAAA,MACjC;AAAA,IAEJ;AAEA,sBAAiB,kBAAkB,kBAAiB,kBAAkB;AACtE,SAAK,kBAAkB,kBAAiB;AAExC,YAAI,wBAAO,KAAK,iBAAiB,UAAU,SAAS,GAAG;AAEnD,WAAK,iBAAiB,UAAU,YAAY,CAAC,YAAwH;AAEjK,aAAK,eAAe;AACpB,aAAK,wBAAwB;AAE7B,cAAM,MAAM,KAAK,QAAQ,KAAK,aAAa,QAAQ,KAAK;AAExD,cAAM,qBAAqB,KAAK,oBAAoB;AAEpD,gBAAI,oBAAG,kBAAkB,GAAG;AAIxB,6BAAmB,QAAQ,KAAK,YAAY,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AAe,KAAK;AAAA,QAErB,QAAQ;AAAA,QACR,uBAAuB;AAAA,QACvB,cAAc;AAAA,QACd,sBAAsB;AAAA,MAE1B,CAAC;AAED,WAAK,wBAAwB;AAAA,IAEjC,SAAS,WAAP;AAEE,iBAAW,CAAC,GAAG,CAAC,GAAG,UAAU;AAAA,IAEjC;AAAA,EAGJ;AAAA,EAGA,WACI,MACA,qBACA,iBAAkB,yBAAQ,GAC5B;AAEE,UAAM,SAMD,IAAI,QAAQ,CAAC,SAAS,WAAW;AAElC,WAAK,SAAS,MAAM,qBAAqB,YAAY,CAAC,YAAY,eAAe,qBAAqB;AAElG,YAAI,oBAAoB,YAAY;AAEhC,kBAAQ;AAAA,YAEJ;AAAA,YACA;AAAA,YACA,YAAY;AAAA,UAEhB,CAAC;AAAA,QAEL;AAAA,MAGJ,CAAC;AAAA,IAGL,CAAC;AAED,WAAO;AAAA,EAEX;AAAA,EAGA,cAAc;AAEV,SAAK,kBAAkB;AAEvB,QAAI,KAAK,oBAAoB,kBAAiB,wBAAwB;AAElE,WAAK,iBAAiB,UAAU,UAAU;AAAA,IAE9C;AAAA,EAGJ;AAGJ;AAxQO,IAAM,mBAAN;AAAM,iBAEF,yBAAyB;AAAA,EAC5B,4BAA4B,CAAC;AAAA,EAC7B,kBAAkB;AAAA,EAClB,uBAAuB;AAAA,EACvB,WAAW,IAAI,iCAAAA,QAA0B;AAC7C;AAPS,iBASF,kBAAkB;AAThB,iBAkJF,WAAW;AAAA,EAEd,UAAU;AAAA,EACV,UAAU;AAEd;AAvJS,iBA0JF,YAAY;AAAA,EAEf,cAAc;AAAA,EACd,aAAa;AAEjB;",
|
|
6
6
|
"names": ["UIKeyValueSorterWebWorker"]
|
|
7
7
|
}
|
|
@@ -60,6 +60,6 @@ export declare class UITableView extends UINativeScrollView {
|
|
|
60
60
|
private _layoutAllRows;
|
|
61
61
|
private _animateLayoutAllRows;
|
|
62
62
|
layoutSubviews(): void;
|
|
63
|
-
intrinsicContentHeight(constrainingWidth?: number)
|
|
63
|
+
intrinsicContentHeight: (constrainingWidth?: number) => number;
|
|
64
64
|
}
|
|
65
65
|
export {};
|
|
@@ -42,6 +42,14 @@ class UITableView extends import_UINativeScrollView.UINativeScrollView {
|
|
|
42
42
|
this._needsDrawingOfVisibleRowsBeforeLayout = import_UIObject.NO;
|
|
43
43
|
this._isDrawVisibleRowsScheduled = import_UIObject.NO;
|
|
44
44
|
this.animationDuration = 0.25;
|
|
45
|
+
this.intrinsicContentHeight = (constrainingWidth = 0) => {
|
|
46
|
+
var result = 0;
|
|
47
|
+
this._calculateAllPositions();
|
|
48
|
+
if (this._rowPositions.length) {
|
|
49
|
+
result = this._rowPositions[this._rowPositions.length - 1].bottomY;
|
|
50
|
+
}
|
|
51
|
+
return result;
|
|
52
|
+
};
|
|
45
53
|
this._fullHeightView = new import_UIView.UIView();
|
|
46
54
|
this._fullHeightView.hidden = import_UIObject.YES;
|
|
47
55
|
this._fullHeightView.userInteractionEnabled = import_UIObject.NO;
|
|
@@ -367,14 +375,6 @@ class UITableView extends import_UINativeScrollView.UINativeScrollView {
|
|
|
367
375
|
this._layoutAllRows();
|
|
368
376
|
}
|
|
369
377
|
}
|
|
370
|
-
intrinsicContentHeight(constrainingWidth = 0) {
|
|
371
|
-
var result = 0;
|
|
372
|
-
this._calculateAllPositions();
|
|
373
|
-
if (this._rowPositions.length) {
|
|
374
|
-
result = this._rowPositions[this._rowPositions.length - 1].bottomY;
|
|
375
|
-
}
|
|
376
|
-
return result;
|
|
377
|
-
}
|
|
378
378
|
}
|
|
379
379
|
// Annotate the CommonJS export names for ESM import in node:
|
|
380
380
|
0 && (module.exports = {
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../scripts/UITableView.ts"],
|
|
4
|
-
"sourcesContent": ["import { UIButton } from \"./UIButton\"\nimport { UINativeScrollView } from \"./UINativeScrollView\"\nimport { FIRST_OR_NIL, IS, IS_DEFINED, nil, NO, YES } from \"./UIObject\"\nimport { UIPoint } from \"./UIPoint\"\nimport { UIRectangle } from \"./UIRectangle\"\nimport { UIView, UIViewBroadcastEvent } from \"./UIView\"\n\n\ninterface UITableViewRowView extends UIView {\n \n _UITableViewRowIndex?: number;\n \n}\n\n\nexport interface UITableViewReusableViewsContainerObject {\n \n [key: string]: UIView[];\n \n}\n\n\nexport interface UITableViewReusableViewPositionObject {\n \n bottomY: number;\n topY: number;\n \n isValid: boolean;\n \n}\n\n\nexport class UITableView extends UINativeScrollView {\n \n \n allRowsHaveEqualHeight: boolean = NO\n _visibleRows: UITableViewRowView[] = []\n _firstLayoutVisibleRows: UITableViewRowView[] = []\n \n _rowPositions: UITableViewReusableViewPositionObject[] = []\n \n _highestValidRowPositionIndex: number = 0\n \n _reusableViews: UITableViewReusableViewsContainerObject = {}\n _removedReusableViews: UITableViewReusableViewsContainerObject = {}\n \n _fullHeightView: UIView\n _rowIDIndex: number = 0\n reloadsOnLanguageChange = YES\n sidePadding = 0\n \n cellWeights?: number[]\n \n _persistedData: any[] = []\n _needsDrawingOfVisibleRowsBeforeLayout = NO\n _isDrawVisibleRowsScheduled = NO\n _shouldAnimateNextLayout?: boolean\n \n override animationDuration = 0.25\n \n \n constructor(elementID?: string) {\n \n super(elementID)\n \n this._fullHeightView = new UIView()\n this._fullHeightView.hidden = YES\n this._fullHeightView.userInteractionEnabled = NO\n this.addSubview(this._fullHeightView)\n \n this.scrollsX = NO\n \n }\n \n \n loadData() {\n \n this._persistedData = []\n \n this._calculatePositionsUntilIndex(this.numberOfRows() - 1)\n this._needsDrawingOfVisibleRowsBeforeLayout = YES\n \n this.setNeedsLayout()\n \n }\n \n reloadData() {\n \n this._removeVisibleRows()\n this._removeAllReusableRows()\n \n this._rowPositions = []\n this._highestValidRowPositionIndex = 0\n \n this.loadData()\n \n }\n \n \n highlightChanges(previousData: any[], newData: any[]) {\n \n previousData = previousData.map(dataPoint => JSON.stringify(dataPoint))\n newData = newData.map(dataPoint => JSON.stringify(dataPoint))\n \n const newIndexes: number[] = []\n \n newData.forEach((value, index) => {\n \n if (!previousData.contains(value)) {\n \n newIndexes.push(index)\n \n }\n \n })\n \n newIndexes.forEach(index => {\n \n if (this.isRowWithIndexVisible(index)) {\n this.highlightRowAsNew(this.visibleRowWithIndex(index) as UIView)\n }\n \n })\n \n }\n \n \n highlightRowAsNew(row: UIView) {\n \n \n }\n \n \n invalidateSizeOfRowWithIndex(index: number, animateChange = NO) {\n \n if (this._rowPositions[index]) {\n this._rowPositions[index].isValid = NO\n }\n \n this._highestValidRowPositionIndex = Math.min(this._highestValidRowPositionIndex, index - 1)\n \n // if (index == 0) {\n \n // this._highestValidRowPositionIndex = 0;\n \n // this._rowPositions = [];\n \n // }\n \n this._needsDrawingOfVisibleRowsBeforeLayout = YES\n \n this._shouldAnimateNextLayout = animateChange\n \n }\n \n \n _calculateAllPositions() {\n this._calculatePositionsUntilIndex(this.numberOfRows() - 1)\n }\n \n _calculatePositionsUntilIndex(maxIndex: number) {\n \n var validPositionObject = this._rowPositions[this._highestValidRowPositionIndex]\n if (!IS(validPositionObject)) {\n validPositionObject = {\n bottomY: 0,\n topY: 0,\n isValid: YES\n }\n }\n \n var previousBottomY = validPositionObject.bottomY\n \n if (!this._rowPositions.length) {\n \n this._highestValidRowPositionIndex = -1\n \n }\n \n for (var i = this._highestValidRowPositionIndex + 1; i <= maxIndex; i++) {\n \n var height: number\n \n const rowPositionObject = this._rowPositions[i]\n \n if (IS((rowPositionObject || nil).isValid)) {\n \n height = rowPositionObject.bottomY - rowPositionObject.topY\n \n }\n else {\n \n height = this.heightForRowWithIndex(i)\n \n }\n \n \n const positionObject: UITableViewReusableViewPositionObject = {\n bottomY: previousBottomY + height,\n topY: previousBottomY,\n isValid: YES\n }\n \n if (i < this._rowPositions.length) {\n this._rowPositions[i] = positionObject\n }\n else {\n this._rowPositions.push(positionObject)\n }\n this._highestValidRowPositionIndex = i\n previousBottomY = previousBottomY + height\n \n }\n \n }\n \n \n indexesForVisibleRows(paddingRatio = 0.5): number[] {\n \n const firstVisibleY = this.contentOffset.y - this.bounds.height * paddingRatio\n const lastVisibleY = firstVisibleY + this.bounds.height * (1 + paddingRatio)\n \n const numberOfRows = this.numberOfRows()\n \n if (this.allRowsHaveEqualHeight) {\n \n const rowHeight = this.heightForRowWithIndex(0)\n \n var firstIndex = firstVisibleY / rowHeight\n var lastIndex = lastVisibleY / rowHeight\n \n firstIndex = Math.trunc(firstIndex)\n lastIndex = Math.trunc(lastIndex) + 1\n \n firstIndex = Math.max(firstIndex, 0)\n lastIndex = Math.min(lastIndex, numberOfRows - 1)\n \n var result = []\n for (var i = firstIndex; i < lastIndex + 1; i++) {\n result.push(i)\n }\n return result\n }\n \n var accumulatedHeight = 0\n var result = []\n \n this._calculateAllPositions()\n \n const rowPositions = this._rowPositions\n \n for (var i = 0; i < numberOfRows; i++) {\n \n const height = rowPositions[i].bottomY - rowPositions[i].topY // this.heightForRowWithIndex(i)\n \n accumulatedHeight = accumulatedHeight + height\n if (accumulatedHeight >= firstVisibleY) {\n result.push(i)\n }\n if (accumulatedHeight >= lastVisibleY) {\n break\n }\n \n }\n \n return result\n \n }\n \n \n _removeVisibleRows() {\n \n const visibleRows: UITableViewRowView[] = []\n this._visibleRows.forEach((row: UIView) => {\n \n this._persistedData[row._UITableViewRowIndex as number] = this.persistenceDataItemForRowWithIndex(\n row._UITableViewRowIndex as number,\n row\n )\n row.removeFromSuperview()\n this._removedReusableViews[row?._UITableViewReusabilityIdentifier]?.push(row)\n \n \n })\n this._visibleRows = visibleRows\n \n }\n \n \n _removeAllReusableRows() {\n this._reusableViews.forEach((rows: UIView[]) =>\n rows.forEach((row: UIView) => {\n \n this._persistedData[row._UITableViewRowIndex as number] = this.persistenceDataItemForRowWithIndex(\n row._UITableViewRowIndex as number,\n row\n )\n row.removeFromSuperview()\n \n this._markReusableViewAsUnused(row)\n \n })\n )\n }\n \n \n _markReusableViewAsUnused(row: UIView) {\n if (!this._removedReusableViews[row._UITableViewReusabilityIdentifier].contains(row)) {\n this._removedReusableViews[row._UITableViewReusabilityIdentifier].push(row)\n }\n }\n \n _drawVisibleRows() {\n \n if (!this.isMemberOfViewTree) {\n return\n }\n \n const visibleIndexes = this.indexesForVisibleRows()\n \n const minIndex = visibleIndexes[0]\n const maxIndex = visibleIndexes[visibleIndexes.length - 1]\n \n const removedViews: UITableViewRowView[] = []\n \n const visibleRows: UITableViewRowView[] = []\n this._visibleRows.forEach((row) => {\n if (IS_DEFINED(row._UITableViewRowIndex) && (row._UITableViewRowIndex < minIndex || row._UITableViewRowIndex > maxIndex)) {\n \n //row.removeFromSuperview();\n \n this._persistedData[row._UITableViewRowIndex] = this.persistenceDataItemForRowWithIndex(\n row._UITableViewRowIndex,\n row\n )\n \n this._removedReusableViews[row._UITableViewReusabilityIdentifier].push(row)\n \n removedViews.push(row)\n \n }\n else {\n visibleRows.push(row)\n }\n })\n this._visibleRows = visibleRows\n \n visibleIndexes.forEach((rowIndex: number) => {\n \n if (this.isRowWithIndexVisible(rowIndex)) {\n return\n }\n const view: UITableViewRowView = this.viewForRowWithIndex(rowIndex)\n //view._UITableViewRowIndex = rowIndex;\n this._firstLayoutVisibleRows.push(view)\n this._visibleRows.push(view)\n this.addSubview(view)\n \n })\n \n for (let i = 0; i < removedViews.length; i++) {\n \n const view = removedViews[i]\n if (this._visibleRows.indexOf(view) == -1) {\n \n //this._persistedData[view._UITableViewRowIndex] = this.persistenceDataItemForRowWithIndex(view._UITableViewRowIndex, view);\n view.removeFromSuperview()\n \n //this._removedReusableViews[view._UITableViewReusabilityIdentifier].push(view);\n \n }\n \n }\n \n //this.setNeedsLayout();\n \n }\n \n \n visibleRowWithIndex(rowIndex: number | undefined): UIView {\n for (var i = 0; i < this._visibleRows.length; i++) {\n const row = this._visibleRows[i]\n if (row._UITableViewRowIndex == rowIndex) {\n return row\n }\n }\n return nil\n }\n \n \n isRowWithIndexVisible(rowIndex: number) {\n return IS(this.visibleRowWithIndex(rowIndex))\n }\n \n \n reusableViewForIdentifier(identifier: string, rowIndex: number): UITableViewRowView {\n \n if (!this._removedReusableViews[identifier]) {\n this._removedReusableViews[identifier] = []\n }\n \n if (this._removedReusableViews[identifier] && this._removedReusableViews[identifier].length) {\n \n const view = this._removedReusableViews[identifier].pop() as UITableViewRowView\n view._UITableViewRowIndex = rowIndex\n Object.assign(view, this._persistedData[rowIndex] || this.defaultRowPersistenceDataItem())\n return view\n \n }\n \n if (!this._reusableViews[identifier]) {\n this._reusableViews[identifier] = []\n }\n \n const newView = this.newReusableViewForIdentifier(identifier, this._rowIDIndex) as UITableViewRowView\n this._rowIDIndex = this._rowIDIndex + 1\n \n newView._UITableViewReusabilityIdentifier = identifier\n newView._UITableViewRowIndex = rowIndex\n \n Object.assign(newView, this._persistedData[rowIndex] || this.defaultRowPersistenceDataItem())\n this._reusableViews[identifier].push(newView)\n \n return newView\n \n }\n \n \n // Functions that should be overridden to draw the correct content START\n newReusableViewForIdentifier(identifier: string, rowIDIndex: number): UIView {\n \n const view = new UIButton(this.elementID + \"Row\" + rowIDIndex)\n \n view.stopsPointerEventPropagation = NO\n view.pausesPointerEvents = NO\n \n return view\n \n }\n \n heightForRowWithIndex(index: number): number {\n return 50\n }\n \n numberOfRows() {\n return 10000\n }\n \n defaultRowPersistenceDataItem(): any {\n \n \n }\n \n persistenceDataItemForRowWithIndex(rowIndex: number, row: UIView): any {\n \n \n }\n \n viewForRowWithIndex(rowIndex: number): UITableViewRowView {\n const row = this.reusableViewForIdentifier(\"Row\", rowIndex)\n row._UITableViewRowIndex = rowIndex\n FIRST_OR_NIL((row as unknown as UIButton).titleLabel).text = \"Row \" + rowIndex\n return row\n }\n \n // Functions that should be overridden to draw the correct content END\n \n \n // Functions that trigger redrawing of the content\n override didScrollToPosition(offsetPosition: UIPoint) {\n \n super.didScrollToPosition(offsetPosition)\n \n this.forEachViewInSubtree(function (view: UIView) {\n \n view._isPointerValid = NO\n \n })\n \n if (!this._isDrawVisibleRowsScheduled) {\n \n this._isDrawVisibleRowsScheduled = YES\n \n UIView.runFunctionBeforeNextFrame(function (this: UITableView) {\n \n this._calculateAllPositions()\n \n this._drawVisibleRows()\n \n this.setNeedsLayout()\n \n this._isDrawVisibleRowsScheduled = NO\n \n }.bind(this))\n \n }\n \n }\n \n override wasAddedToViewTree() {\n this.loadData()\n }\n \n override setFrame(rectangle: UIRectangle, zIndex?: number, performUncheckedLayout?: boolean) {\n \n const frame = this.frame\n super.setFrame(rectangle, zIndex, performUncheckedLayout)\n if (frame.isEqualTo(rectangle) && !performUncheckedLayout) {\n return\n }\n \n this._needsDrawingOfVisibleRowsBeforeLayout = YES\n \n }\n \n \n override didReceiveBroadcastEvent(event: UIViewBroadcastEvent) {\n \n super.didReceiveBroadcastEvent(event)\n \n if (event.name == UIView.broadcastEventName.LanguageChanged && this.reloadsOnLanguageChange) {\n \n this.reloadData()\n \n }\n \n \n }\n \n \n private _layoutAllRows(positions = this._rowPositions) {\n \n const bounds = this.bounds\n \n this._visibleRows.sort((rowA, rowB) => rowA._UITableViewRowIndex! - rowB._UITableViewRowIndex!)\n .forEach(row => {\n \n const frame = bounds.copy()\n \n const positionObject = positions[row._UITableViewRowIndex!]\n frame.min.y = positionObject.topY\n frame.max.y = positionObject.bottomY\n row.frame = frame\n \n row.style.width = \"\" + (bounds.width - this.sidePadding * 2).integerValue + \"px\"\n row.style.left = \"\" + this.sidePadding.integerValue + \"px\"\n \n // This is to reorder the elements in the DOM\n this.viewHTMLElement.appendChild(row.viewHTMLElement)\n \n })\n \n this._fullHeightView.frame = bounds.rectangleWithHeight((positions.lastElement ||\n nil).bottomY).rectangleWithWidth(bounds.width * 0.5)\n \n this._firstLayoutVisibleRows = []\n \n }\n \n private _animateLayoutAllRows() {\n \n UIView.animateViewOrViewsWithDurationDelayAndFunction(\n this._visibleRows,\n this.animationDuration,\n 0,\n undefined,\n function (this: UITableView) {\n \n this._layoutAllRows()\n \n }.bind(this),\n function (this: UITableView) {\n \n // this._calculateAllPositions()\n // this._layoutAllRows()\n \n }.bind(this)\n )\n \n }\n \n \n override layoutSubviews() {\n \n const previousPositions: UITableViewReusableViewPositionObject[] = JSON.parse(JSON.stringify(this._rowPositions))\n \n const previousVisibleRowsLength = this._visibleRows.length\n \n if (this._needsDrawingOfVisibleRowsBeforeLayout) {\n \n //this._calculateAllPositions()\n \n this._drawVisibleRows()\n \n this._needsDrawingOfVisibleRowsBeforeLayout = NO\n \n }\n \n \n super.layoutSubviews()\n \n \n if (!this.numberOfRows() || !this.isMemberOfViewTree) {\n \n return\n \n }\n \n \n if (this._shouldAnimateNextLayout) {\n \n \n // Need to do layout with the previous positions\n \n this._layoutAllRows(previousPositions)\n \n \n if (previousVisibleRowsLength < this._visibleRows.length) {\n \n \n UIView.runFunctionBeforeNextFrame(function (this: UITableView) {\n \n this._animateLayoutAllRows()\n \n }.bind(this))\n \n }\n else {\n \n this._animateLayoutAllRows()\n \n }\n \n \n this._shouldAnimateNextLayout = NO\n \n }\n else {\n \n // if (this._needsDrawingOfVisibleRowsBeforeLayout) {\n \n // this._drawVisibleRows();\n \n // this._needsDrawingOfVisibleRowsBeforeLayout = NO;\n \n // }\n \n this._calculateAllPositions()\n \n this._layoutAllRows()\n \n \n }\n \n \n }\n \n \n override intrinsicContentHeight(constrainingWidth = 0) {\n \n \n var result = 0\n \n this._calculateAllPositions()\n \n if (this._rowPositions.length) {\n \n result = this._rowPositions[this._rowPositions.length - 1].bottomY\n \n }\n \n return result\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\n\n\n\n\n\n\n\n\n"],
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,sBAAyB;AACzB,gCAAmC;AACnC,sBAA2D;AAG3D,oBAA6C;AA2BtC,MAAM,oBAAoB,6CAAmB;AAAA,EA6BhD,YAAY,WAAoB;AAE5B,UAAM,SAAS;AA5BnB,kCAAkC;AAClC,wBAAqC,CAAC;AACtC,mCAAgD,CAAC;AAEjD,yBAAyD,CAAC;AAE1D,yCAAwC;AAExC,0BAA0D,CAAC;AAC3D,iCAAiE,CAAC;AAGlE,uBAAsB;AACtB,mCAA0B;AAC1B,uBAAc;AAId,0BAAwB,CAAC;AACzB,kDAAyC;AACzC,uCAA8B;AAG9B,SAAS,oBAAoB;
|
|
4
|
+
"sourcesContent": ["import { UIButton } from \"./UIButton\"\nimport { UINativeScrollView } from \"./UINativeScrollView\"\nimport { FIRST_OR_NIL, IS, IS_DEFINED, nil, NO, YES } from \"./UIObject\"\nimport { UIPoint } from \"./UIPoint\"\nimport { UIRectangle } from \"./UIRectangle\"\nimport { UIView, UIViewBroadcastEvent } from \"./UIView\"\n\n\ninterface UITableViewRowView extends UIView {\n \n _UITableViewRowIndex?: number;\n \n}\n\n\nexport interface UITableViewReusableViewsContainerObject {\n \n [key: string]: UIView[];\n \n}\n\n\nexport interface UITableViewReusableViewPositionObject {\n \n bottomY: number;\n topY: number;\n \n isValid: boolean;\n \n}\n\n\nexport class UITableView extends UINativeScrollView {\n \n \n allRowsHaveEqualHeight: boolean = NO\n _visibleRows: UITableViewRowView[] = []\n _firstLayoutVisibleRows: UITableViewRowView[] = []\n \n _rowPositions: UITableViewReusableViewPositionObject[] = []\n \n _highestValidRowPositionIndex: number = 0\n \n _reusableViews: UITableViewReusableViewsContainerObject = {}\n _removedReusableViews: UITableViewReusableViewsContainerObject = {}\n \n _fullHeightView: UIView\n _rowIDIndex: number = 0\n reloadsOnLanguageChange = YES\n sidePadding = 0\n \n cellWeights?: number[]\n \n _persistedData: any[] = []\n _needsDrawingOfVisibleRowsBeforeLayout = NO\n _isDrawVisibleRowsScheduled = NO\n _shouldAnimateNextLayout?: boolean\n \n override animationDuration = 0.25\n \n \n constructor(elementID?: string) {\n \n super(elementID)\n \n this._fullHeightView = new UIView()\n this._fullHeightView.hidden = YES\n this._fullHeightView.userInteractionEnabled = NO\n this.addSubview(this._fullHeightView)\n \n this.scrollsX = NO\n \n }\n \n \n loadData() {\n \n this._persistedData = []\n \n this._calculatePositionsUntilIndex(this.numberOfRows() - 1)\n this._needsDrawingOfVisibleRowsBeforeLayout = YES\n \n this.setNeedsLayout()\n \n }\n \n reloadData() {\n \n this._removeVisibleRows()\n this._removeAllReusableRows()\n \n this._rowPositions = []\n this._highestValidRowPositionIndex = 0\n \n this.loadData()\n \n }\n \n \n highlightChanges(previousData: any[], newData: any[]) {\n \n previousData = previousData.map(dataPoint => JSON.stringify(dataPoint))\n newData = newData.map(dataPoint => JSON.stringify(dataPoint))\n \n const newIndexes: number[] = []\n \n newData.forEach((value, index) => {\n \n if (!previousData.contains(value)) {\n \n newIndexes.push(index)\n \n }\n \n })\n \n newIndexes.forEach(index => {\n \n if (this.isRowWithIndexVisible(index)) {\n this.highlightRowAsNew(this.visibleRowWithIndex(index) as UIView)\n }\n \n })\n \n }\n \n \n highlightRowAsNew(row: UIView) {\n \n \n }\n \n \n invalidateSizeOfRowWithIndex(index: number, animateChange = NO) {\n \n if (this._rowPositions[index]) {\n this._rowPositions[index].isValid = NO\n }\n \n this._highestValidRowPositionIndex = Math.min(this._highestValidRowPositionIndex, index - 1)\n \n // if (index == 0) {\n \n // this._highestValidRowPositionIndex = 0;\n \n // this._rowPositions = [];\n \n // }\n \n this._needsDrawingOfVisibleRowsBeforeLayout = YES\n \n this._shouldAnimateNextLayout = animateChange\n \n }\n \n \n _calculateAllPositions() {\n this._calculatePositionsUntilIndex(this.numberOfRows() - 1)\n }\n \n _calculatePositionsUntilIndex(maxIndex: number) {\n \n var validPositionObject = this._rowPositions[this._highestValidRowPositionIndex]\n if (!IS(validPositionObject)) {\n validPositionObject = {\n bottomY: 0,\n topY: 0,\n isValid: YES\n }\n }\n \n var previousBottomY = validPositionObject.bottomY\n \n if (!this._rowPositions.length) {\n \n this._highestValidRowPositionIndex = -1\n \n }\n \n for (var i = this._highestValidRowPositionIndex + 1; i <= maxIndex; i++) {\n \n var height: number\n \n const rowPositionObject = this._rowPositions[i]\n \n if (IS((rowPositionObject || nil).isValid)) {\n \n height = rowPositionObject.bottomY - rowPositionObject.topY\n \n }\n else {\n \n height = this.heightForRowWithIndex(i)\n \n }\n \n \n const positionObject: UITableViewReusableViewPositionObject = {\n bottomY: previousBottomY + height,\n topY: previousBottomY,\n isValid: YES\n }\n \n if (i < this._rowPositions.length) {\n this._rowPositions[i] = positionObject\n }\n else {\n this._rowPositions.push(positionObject)\n }\n this._highestValidRowPositionIndex = i\n previousBottomY = previousBottomY + height\n \n }\n \n }\n \n \n indexesForVisibleRows(paddingRatio = 0.5): number[] {\n \n const firstVisibleY = this.contentOffset.y - this.bounds.height * paddingRatio\n const lastVisibleY = firstVisibleY + this.bounds.height * (1 + paddingRatio)\n \n const numberOfRows = this.numberOfRows()\n \n if (this.allRowsHaveEqualHeight) {\n \n const rowHeight = this.heightForRowWithIndex(0)\n \n var firstIndex = firstVisibleY / rowHeight\n var lastIndex = lastVisibleY / rowHeight\n \n firstIndex = Math.trunc(firstIndex)\n lastIndex = Math.trunc(lastIndex) + 1\n \n firstIndex = Math.max(firstIndex, 0)\n lastIndex = Math.min(lastIndex, numberOfRows - 1)\n \n var result = []\n for (var i = firstIndex; i < lastIndex + 1; i++) {\n result.push(i)\n }\n return result\n }\n \n var accumulatedHeight = 0\n var result = []\n \n this._calculateAllPositions()\n \n const rowPositions = this._rowPositions\n \n for (var i = 0; i < numberOfRows; i++) {\n \n const height = rowPositions[i].bottomY - rowPositions[i].topY // this.heightForRowWithIndex(i)\n \n accumulatedHeight = accumulatedHeight + height\n if (accumulatedHeight >= firstVisibleY) {\n result.push(i)\n }\n if (accumulatedHeight >= lastVisibleY) {\n break\n }\n \n }\n \n return result\n \n }\n \n \n _removeVisibleRows() {\n \n const visibleRows: UITableViewRowView[] = []\n this._visibleRows.forEach((row: UIView) => {\n \n this._persistedData[row._UITableViewRowIndex as number] = this.persistenceDataItemForRowWithIndex(\n row._UITableViewRowIndex as number,\n row\n )\n row.removeFromSuperview()\n this._removedReusableViews[row?._UITableViewReusabilityIdentifier]?.push(row)\n \n \n })\n this._visibleRows = visibleRows\n \n }\n \n \n _removeAllReusableRows() {\n this._reusableViews.forEach((rows: UIView[]) =>\n rows.forEach((row: UIView) => {\n \n this._persistedData[row._UITableViewRowIndex as number] = this.persistenceDataItemForRowWithIndex(\n row._UITableViewRowIndex as number,\n row\n )\n row.removeFromSuperview()\n \n this._markReusableViewAsUnused(row)\n \n })\n )\n }\n \n \n _markReusableViewAsUnused(row: UIView) {\n if (!this._removedReusableViews[row._UITableViewReusabilityIdentifier].contains(row)) {\n this._removedReusableViews[row._UITableViewReusabilityIdentifier].push(row)\n }\n }\n \n _drawVisibleRows() {\n \n if (!this.isMemberOfViewTree) {\n return\n }\n \n const visibleIndexes = this.indexesForVisibleRows()\n \n const minIndex = visibleIndexes[0]\n const maxIndex = visibleIndexes[visibleIndexes.length - 1]\n \n const removedViews: UITableViewRowView[] = []\n \n const visibleRows: UITableViewRowView[] = []\n this._visibleRows.forEach((row) => {\n if (IS_DEFINED(row._UITableViewRowIndex) && (row._UITableViewRowIndex < minIndex || row._UITableViewRowIndex > maxIndex)) {\n \n //row.removeFromSuperview();\n \n this._persistedData[row._UITableViewRowIndex] = this.persistenceDataItemForRowWithIndex(\n row._UITableViewRowIndex,\n row\n )\n \n this._removedReusableViews[row._UITableViewReusabilityIdentifier].push(row)\n \n removedViews.push(row)\n \n }\n else {\n visibleRows.push(row)\n }\n })\n this._visibleRows = visibleRows\n \n visibleIndexes.forEach((rowIndex: number) => {\n \n if (this.isRowWithIndexVisible(rowIndex)) {\n return\n }\n const view: UITableViewRowView = this.viewForRowWithIndex(rowIndex)\n //view._UITableViewRowIndex = rowIndex;\n this._firstLayoutVisibleRows.push(view)\n this._visibleRows.push(view)\n this.addSubview(view)\n \n })\n \n for (let i = 0; i < removedViews.length; i++) {\n \n const view = removedViews[i]\n if (this._visibleRows.indexOf(view) == -1) {\n \n //this._persistedData[view._UITableViewRowIndex] = this.persistenceDataItemForRowWithIndex(view._UITableViewRowIndex, view);\n view.removeFromSuperview()\n \n //this._removedReusableViews[view._UITableViewReusabilityIdentifier].push(view);\n \n }\n \n }\n \n //this.setNeedsLayout();\n \n }\n \n \n visibleRowWithIndex(rowIndex: number | undefined): UIView {\n for (var i = 0; i < this._visibleRows.length; i++) {\n const row = this._visibleRows[i]\n if (row._UITableViewRowIndex == rowIndex) {\n return row\n }\n }\n return nil\n }\n \n \n isRowWithIndexVisible(rowIndex: number) {\n return IS(this.visibleRowWithIndex(rowIndex))\n }\n \n \n reusableViewForIdentifier(identifier: string, rowIndex: number): UITableViewRowView {\n \n if (!this._removedReusableViews[identifier]) {\n this._removedReusableViews[identifier] = []\n }\n \n if (this._removedReusableViews[identifier] && this._removedReusableViews[identifier].length) {\n \n const view = this._removedReusableViews[identifier].pop() as UITableViewRowView\n view._UITableViewRowIndex = rowIndex\n Object.assign(view, this._persistedData[rowIndex] || this.defaultRowPersistenceDataItem())\n return view\n \n }\n \n if (!this._reusableViews[identifier]) {\n this._reusableViews[identifier] = []\n }\n \n const newView = this.newReusableViewForIdentifier(identifier, this._rowIDIndex) as UITableViewRowView\n this._rowIDIndex = this._rowIDIndex + 1\n \n newView._UITableViewReusabilityIdentifier = identifier\n newView._UITableViewRowIndex = rowIndex\n \n Object.assign(newView, this._persistedData[rowIndex] || this.defaultRowPersistenceDataItem())\n this._reusableViews[identifier].push(newView)\n \n return newView\n \n }\n \n \n // Functions that should be overridden to draw the correct content START\n newReusableViewForIdentifier(identifier: string, rowIDIndex: number): UIView {\n \n const view = new UIButton(this.elementID + \"Row\" + rowIDIndex)\n \n view.stopsPointerEventPropagation = NO\n view.pausesPointerEvents = NO\n \n return view\n \n }\n \n heightForRowWithIndex(index: number): number {\n return 50\n }\n \n numberOfRows() {\n return 10000\n }\n \n defaultRowPersistenceDataItem(): any {\n \n \n }\n \n persistenceDataItemForRowWithIndex(rowIndex: number, row: UIView): any {\n \n \n }\n \n viewForRowWithIndex(rowIndex: number): UITableViewRowView {\n const row = this.reusableViewForIdentifier(\"Row\", rowIndex)\n row._UITableViewRowIndex = rowIndex\n FIRST_OR_NIL((row as unknown as UIButton).titleLabel).text = \"Row \" + rowIndex\n return row\n }\n \n // Functions that should be overridden to draw the correct content END\n \n \n // Functions that trigger redrawing of the content\n override didScrollToPosition(offsetPosition: UIPoint) {\n \n super.didScrollToPosition(offsetPosition)\n \n this.forEachViewInSubtree(function (view: UIView) {\n \n view._isPointerValid = NO\n \n })\n \n if (!this._isDrawVisibleRowsScheduled) {\n \n this._isDrawVisibleRowsScheduled = YES\n \n UIView.runFunctionBeforeNextFrame(function (this: UITableView) {\n \n this._calculateAllPositions()\n \n this._drawVisibleRows()\n \n this.setNeedsLayout()\n \n this._isDrawVisibleRowsScheduled = NO\n \n }.bind(this))\n \n }\n \n }\n \n override wasAddedToViewTree() {\n this.loadData()\n }\n \n override setFrame(rectangle: UIRectangle, zIndex?: number, performUncheckedLayout?: boolean) {\n \n const frame = this.frame\n super.setFrame(rectangle, zIndex, performUncheckedLayout)\n if (frame.isEqualTo(rectangle) && !performUncheckedLayout) {\n return\n }\n \n this._needsDrawingOfVisibleRowsBeforeLayout = YES\n \n }\n \n \n override didReceiveBroadcastEvent(event: UIViewBroadcastEvent) {\n \n super.didReceiveBroadcastEvent(event)\n \n if (event.name == UIView.broadcastEventName.LanguageChanged && this.reloadsOnLanguageChange) {\n \n this.reloadData()\n \n }\n \n \n }\n \n \n private _layoutAllRows(positions = this._rowPositions) {\n \n const bounds = this.bounds\n \n this._visibleRows.sort((rowA, rowB) => rowA._UITableViewRowIndex! - rowB._UITableViewRowIndex!)\n .forEach(row => {\n \n const frame = bounds.copy()\n \n const positionObject = positions[row._UITableViewRowIndex!]\n frame.min.y = positionObject.topY\n frame.max.y = positionObject.bottomY\n row.frame = frame\n \n row.style.width = \"\" + (bounds.width - this.sidePadding * 2).integerValue + \"px\"\n row.style.left = \"\" + this.sidePadding.integerValue + \"px\"\n \n // This is to reorder the elements in the DOM\n this.viewHTMLElement.appendChild(row.viewHTMLElement)\n \n })\n \n this._fullHeightView.frame = bounds.rectangleWithHeight((positions.lastElement ||\n nil).bottomY).rectangleWithWidth(bounds.width * 0.5)\n \n this._firstLayoutVisibleRows = []\n \n }\n \n private _animateLayoutAllRows() {\n \n UIView.animateViewOrViewsWithDurationDelayAndFunction(\n this._visibleRows,\n this.animationDuration,\n 0,\n undefined,\n function (this: UITableView) {\n \n this._layoutAllRows()\n \n }.bind(this),\n function (this: UITableView) {\n \n // this._calculateAllPositions()\n // this._layoutAllRows()\n \n }.bind(this)\n )\n \n }\n \n \n override layoutSubviews() {\n \n const previousPositions: UITableViewReusableViewPositionObject[] = JSON.parse(JSON.stringify(this._rowPositions))\n \n const previousVisibleRowsLength = this._visibleRows.length\n \n if (this._needsDrawingOfVisibleRowsBeforeLayout) {\n \n //this._calculateAllPositions()\n \n this._drawVisibleRows()\n \n this._needsDrawingOfVisibleRowsBeforeLayout = NO\n \n }\n \n \n super.layoutSubviews()\n \n \n if (!this.numberOfRows() || !this.isMemberOfViewTree) {\n \n return\n \n }\n \n \n if (this._shouldAnimateNextLayout) {\n \n \n // Need to do layout with the previous positions\n \n this._layoutAllRows(previousPositions)\n \n \n if (previousVisibleRowsLength < this._visibleRows.length) {\n \n \n UIView.runFunctionBeforeNextFrame(function (this: UITableView) {\n \n this._animateLayoutAllRows()\n \n }.bind(this))\n \n }\n else {\n \n this._animateLayoutAllRows()\n \n }\n \n \n this._shouldAnimateNextLayout = NO\n \n }\n else {\n \n // if (this._needsDrawingOfVisibleRowsBeforeLayout) {\n \n // this._drawVisibleRows();\n \n // this._needsDrawingOfVisibleRowsBeforeLayout = NO;\n \n // }\n \n this._calculateAllPositions()\n \n this._layoutAllRows()\n \n \n }\n \n \n }\n \n \n override intrinsicContentHeight = (constrainingWidth = 0) => {\n \n \n var result = 0\n \n this._calculateAllPositions()\n \n if (this._rowPositions.length) {\n \n result = this._rowPositions[this._rowPositions.length - 1].bottomY\n \n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;AAEtB,UAAM,oBAA6D,KAAK,MAAM,KAAK,UAAU,KAAK,aAAa,CAAC;AAEhH,UAAM,4BAA4B,KAAK,aAAa;AAEpD,QAAI,KAAK,wCAAwC;AAI7C,WAAK,iBAAiB;AAEtB,WAAK,yCAAyC;AAAA,IAElD;AAGA,UAAM,eAAe;AAGrB,QAAI,CAAC,KAAK,aAAa,KAAK,CAAC,KAAK,oBAAoB;AAElD;AAAA,IAEJ;AAGA,QAAI,KAAK,0BAA0B;AAK/B,WAAK,eAAe,iBAAiB;AAGrC,UAAI,4BAA4B,KAAK,aAAa,QAAQ;AAGtD,6BAAO,2BAA2B,WAA6B;AAE3D,eAAK,sBAAsB;AAAA,QAE/B,EAAE,KAAK,IAAI,CAAC;AAAA,MAEhB,OACK;AAED,aAAK,sBAAsB;AAAA,MAE/B;AAGA,WAAK,2BAA2B;AAAA,IAEpC,OACK;AAUD,WAAK,uBAAuB;AAE5B,WAAK,eAAe;AAAA,IAGxB;AAAA,EAGJ;AAqBJ;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -84,7 +84,7 @@ export declare class UITextView extends UIView {
|
|
|
84
84
|
didReceiveBroadcastEvent(event: UIViewBroadcastEvent): void;
|
|
85
85
|
willMoveToSuperview(superview: UIView): void;
|
|
86
86
|
layoutSubviews(): void;
|
|
87
|
-
intrinsicContentHeight(constrainingWidth?: number)
|
|
88
|
-
intrinsicContentWidth(constrainingHeight?: number)
|
|
89
|
-
intrinsicContentSize()
|
|
87
|
+
intrinsicContentHeight: (constrainingWidth?: number) => any;
|
|
88
|
+
intrinsicContentWidth: (constrainingHeight?: number) => any;
|
|
89
|
+
intrinsicContentSize: () => UIRectangle;
|
|
90
90
|
}
|
|
@@ -37,6 +37,42 @@ const _UITextView = class extends import_UIView.UIView {
|
|
|
37
37
|
this.changesOften = import_UIObject.NO;
|
|
38
38
|
this._intrinsicHeightCache = new import_UIObject.UIObject();
|
|
39
39
|
this._intrinsicWidthCache = new import_UIObject.UIObject();
|
|
40
|
+
this.intrinsicContentHeight = (constrainingWidth = 0) => {
|
|
41
|
+
const keyPath = (this.viewHTMLElement.innerHTML + "_csf_" + this.computedStyle.font).replace(new RegExp(
|
|
42
|
+
"\\.",
|
|
43
|
+
"g"
|
|
44
|
+
), "_") + "." + ("" + constrainingWidth).replace(new RegExp("\\.", "g"), "_");
|
|
45
|
+
let cacheObject = _UITextView._intrinsicHeightCache;
|
|
46
|
+
if (this.changesOften) {
|
|
47
|
+
cacheObject = this._intrinsicHeightCache;
|
|
48
|
+
}
|
|
49
|
+
var result = cacheObject.valueForKeyPath(keyPath);
|
|
50
|
+
if ((0, import_UIObject.IS_LIKE_NULL)(result)) {
|
|
51
|
+
result = super.intrinsicContentHeight(constrainingWidth);
|
|
52
|
+
cacheObject.setValueForKeyPath(keyPath, result);
|
|
53
|
+
}
|
|
54
|
+
return result;
|
|
55
|
+
};
|
|
56
|
+
this.intrinsicContentWidth = (constrainingHeight = 0) => {
|
|
57
|
+
const keyPath = (this.viewHTMLElement.innerHTML + "_csf_" + this.computedStyle.font).replace(new RegExp(
|
|
58
|
+
"\\.",
|
|
59
|
+
"g"
|
|
60
|
+
), "_") + "." + ("" + constrainingHeight).replace(new RegExp("\\.", "g"), "_");
|
|
61
|
+
let cacheObject = _UITextView._intrinsicWidthCache;
|
|
62
|
+
if (this.changesOften) {
|
|
63
|
+
cacheObject = this._intrinsicWidthCache;
|
|
64
|
+
}
|
|
65
|
+
var result = cacheObject.valueForKeyPath(keyPath);
|
|
66
|
+
if ((0, import_UIObject.IS_LIKE_NULL)(result)) {
|
|
67
|
+
result = super.intrinsicContentWidth(constrainingHeight);
|
|
68
|
+
cacheObject.setValueForKeyPath(keyPath, result);
|
|
69
|
+
}
|
|
70
|
+
return result;
|
|
71
|
+
};
|
|
72
|
+
this.intrinsicContentSize = () => {
|
|
73
|
+
const result = this.intrinsicContentSizeWithConstraints(import_UIObject.nil, import_UIObject.nil);
|
|
74
|
+
return result;
|
|
75
|
+
};
|
|
40
76
|
this.text = "";
|
|
41
77
|
this.style.overflow = "hidden";
|
|
42
78
|
this.style.textOverflow = "ellipsis";
|
|
@@ -182,42 +218,6 @@ const _UITextView = class extends import_UIView.UIView {
|
|
|
182
218
|
);
|
|
183
219
|
}
|
|
184
220
|
}
|
|
185
|
-
intrinsicContentHeight(constrainingWidth = 0) {
|
|
186
|
-
const keyPath = (this.viewHTMLElement.innerHTML + "_csf_" + this.computedStyle.font).replace(new RegExp(
|
|
187
|
-
"\\.",
|
|
188
|
-
"g"
|
|
189
|
-
), "_") + "." + ("" + constrainingWidth).replace(new RegExp("\\.", "g"), "_");
|
|
190
|
-
let cacheObject = _UITextView._intrinsicHeightCache;
|
|
191
|
-
if (this.changesOften) {
|
|
192
|
-
cacheObject = this._intrinsicHeightCache;
|
|
193
|
-
}
|
|
194
|
-
var result = cacheObject.valueForKeyPath(keyPath);
|
|
195
|
-
if ((0, import_UIObject.IS_LIKE_NULL)(result)) {
|
|
196
|
-
result = super.intrinsicContentHeight(constrainingWidth);
|
|
197
|
-
cacheObject.setValueForKeyPath(keyPath, result);
|
|
198
|
-
}
|
|
199
|
-
return result;
|
|
200
|
-
}
|
|
201
|
-
intrinsicContentWidth(constrainingHeight = 0) {
|
|
202
|
-
const keyPath = (this.viewHTMLElement.innerHTML + "_csf_" + this.computedStyle.font).replace(new RegExp(
|
|
203
|
-
"\\.",
|
|
204
|
-
"g"
|
|
205
|
-
), "_") + "." + ("" + constrainingHeight).replace(new RegExp("\\.", "g"), "_");
|
|
206
|
-
let cacheObject = _UITextView._intrinsicWidthCache;
|
|
207
|
-
if (this.changesOften) {
|
|
208
|
-
cacheObject = this._intrinsicWidthCache;
|
|
209
|
-
}
|
|
210
|
-
var result = cacheObject.valueForKeyPath(keyPath);
|
|
211
|
-
if ((0, import_UIObject.IS_LIKE_NULL)(result)) {
|
|
212
|
-
result = super.intrinsicContentWidth(constrainingHeight);
|
|
213
|
-
cacheObject.setValueForKeyPath(keyPath, result);
|
|
214
|
-
}
|
|
215
|
-
return result;
|
|
216
|
-
}
|
|
217
|
-
intrinsicContentSize() {
|
|
218
|
-
const result = this.intrinsicContentSizeWithConstraints(import_UIObject.nil, import_UIObject.nil);
|
|
219
|
-
return result;
|
|
220
|
-
}
|
|
221
221
|
};
|
|
222
222
|
let UITextView = _UITextView;
|
|
223
223
|
UITextView.defaultTextColor = import_UIColor.UIColor.blackColor;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../scripts/UITextView.ts"],
|
|
4
|
-
"sourcesContent": ["import { UIColor } from \"./UIColor\"\nimport { UILocalizedTextObject } from \"./UIInterfaces\"\nimport { FIRST, IS_LIKE_NULL, nil, NO, UIObject, YES } from \"./UIObject\"\nimport { UIRectangle } from \"./UIRectangle\"\nimport type { ValueOf } from \"./UIObject\"\nimport { UIView, UIViewBroadcastEvent } from \"./UIView\"\n\n\nexport class UITextView extends UIView {\n \n \n _textColor: UIColor = UITextView.defaultTextColor\n _textAlignment?: ValueOf<typeof UITextView.textAlignment>\n \n _isSingleLine = YES\n \n textPrefix = \"\"\n textSuffix = \"\"\n \n _notificationAmount = 0\n \n _minFontSize?: number\n _maxFontSize?: number\n \n _automaticFontSizeSelection = NO\n \n changesOften = NO\n \n static defaultTextColor = UIColor.blackColor\n static notificationTextColor = UIColor.redColor\n \n static _intrinsicHeightCache: { [x: string]: { [x: string]: number; }; } & UIObject = new UIObject() as any\n static _intrinsicWidthCache: { [x: string]: { [x: string]: number; }; } & UIObject = new UIObject() as any\n \n _intrinsicHeightCache: { [x: string]: { [x: string]: number; }; } & UIObject = new UIObject() as any\n _intrinsicWidthCache: { [x: string]: { [x: string]: number; }; } & UIObject = new UIObject() as any\n \n \n static _ptToPx: number\n static _pxToPt: number\n _text?: string\n \n \n constructor(\n elementID?: string,\n textViewType: string | ValueOf<typeof UITextView.type> = UITextView.type.paragraph,\n viewHTMLElement = null\n ) {\n \n super(elementID, viewHTMLElement, textViewType)\n \n this.text = \"\"\n \n this.style.overflow = \"hidden\"\n this.style.textOverflow = \"ellipsis\"\n this.isSingleLine = YES\n \n this.textColor = this.textColor\n \n this.userInteractionEnabled = YES\n \n \n if (textViewType == UITextView.type.textArea) {\n \n this.pausesPointerEvents = YES\n \n this.addTargetForControlEvent(\n UIView.controlEvent.PointerUpInside,\n (sender, event) => sender.focus()\n )\n \n \n }\n \n \n }\n \n \n static _determinePXAndPTRatios() {\n \n if (UITextView._ptToPx) {\n return\n }\n \n const o = document.createElement(\"div\")\n o.style.width = \"1000pt\"\n document.body.appendChild(o)\n UITextView._ptToPx = o.clientWidth / 1000\n document.body.removeChild(o)\n UITextView._pxToPt = 1 / UITextView._ptToPx\n \n }\n \n \n static type = {\n \n \"paragraph\": \"p\",\n \"header1\": \"h1\",\n \"header2\": \"h2\",\n \"header3\": \"h3\",\n \"header4\": \"h4\",\n \"header5\": \"h5\",\n \"header6\": \"h6\",\n \"textArea\": \"textarea\",\n \"textField\": \"input\",\n \"span\": \"span\",\n \"label\": \"label\"\n \n } as const\n \n \n static textAlignment = {\n \n \"left\": \"left\",\n \"center\": \"center\",\n \"right\": \"right\",\n \"justify\": \"justify\"\n \n } as const\n \n get textAlignment() {\n // @ts-ignore\n return this.style.textAlign\n }\n \n set textAlignment(textAlignment: ValueOf<typeof UITextView.textAlignment>) {\n this._textAlignment = textAlignment\n this.style.textAlign = textAlignment\n }\n \n \n get textColor() {\n return this._textColor\n }\n \n set textColor(color: UIColor) {\n \n this._textColor = color || UITextView.defaultTextColor\n this.style.color = this._textColor.stringValue\n \n }\n \n \n get isSingleLine() {\n \n return this._isSingleLine\n \n }\n \n set isSingleLine(isSingleLine: boolean) {\n \n this._isSingleLine = isSingleLine\n \n this._intrinsicHeightCache = new UIObject() as any\n this._intrinsicWidthCache = new UIObject() as any\n \n if (isSingleLine) {\n \n this.style.whiteSpace = \"pre\"\n \n return\n \n }\n \n this.style.whiteSpace = \"pre-wrap\"\n \n }\n \n \n get notificationAmount() {\n \n return this._notificationAmount\n \n }\n \n set notificationAmount(notificationAmount: number) {\n \n if (this._notificationAmount == notificationAmount) {\n \n return\n \n }\n \n this._notificationAmount = notificationAmount\n \n this.text = this.text\n \n this.setNeedsLayoutUpToRootView()\n \n this.notificationAmountDidChange(notificationAmount)\n \n }\n \n notificationAmountDidChange(notificationAmount: number) {\n \n \n }\n \n \n get text() {\n \n return (this._text || this.viewHTMLElement.innerHTML)\n \n }\n \n set text(text) {\n \n this._text = text\n \n var notificationText = \"\"\n \n if (this.notificationAmount) {\n \n notificationText = \"<span style=\\\"color: \" + UITextView.notificationTextColor.stringValue + \";\\\">\" +\n (\" (\" + this.notificationAmount + \")\").bold() + \"</span>\"\n \n }\n \n if (this.viewHTMLElement.innerHTML != this.textPrefix + text + this.textSuffix + notificationText) {\n \n this.viewHTMLElement.innerHTML = this.textPrefix + FIRST(text, \"\") + this.textSuffix + notificationText\n \n }\n \n if (this.changesOften) {\n \n this._intrinsicHeightCache = new UIObject() as any\n this._intrinsicWidthCache = new UIObject() as any\n \n }\n \n this.setNeedsLayout()\n \n }\n \n override set innerHTML(innerHTML: string) {\n \n this.text = innerHTML\n \n }\n \n override get innerHTML() {\n \n return this.viewHTMLElement.innerHTML\n \n }\n \n \n setText(key: string, defaultString: string, parameters?: { [x: string]: string | UILocalizedTextObject }) {\n \n this.setInnerHTML(key, defaultString, parameters)\n \n }\n \n \n get fontSize() {\n \n const style = window.getComputedStyle(this.viewHTMLElement, null).fontSize\n \n const result = (parseFloat(style) * UITextView._pxToPt)\n \n return result\n \n }\n \n set fontSize(fontSize: number) {\n \n \n this.style.fontSize = \"\" + fontSize + \"pt\"\n \n this._intrinsicHeightCache = new UIObject() as any\n this._intrinsicWidthCache = new UIObject() as any // MEETOD LUUA!!!!\n \n \n }\n \n \n useAutomaticFontSize(minFontSize: number = nil, maxFontSize: number = nil) {\n \n \n this._automaticFontSizeSelection = YES\n \n \n this._minFontSize = minFontSize\n \n this._maxFontSize = maxFontSize\n \n this.setNeedsLayout()\n \n \n }\n \n \n static automaticallyCalculatedFontSize(\n bounds: UIRectangle,\n currentSize: UIRectangle,\n currentFontSize: number,\n minFontSize?: number,\n maxFontSize?: number\n ) {\n \n minFontSize = FIRST(minFontSize, 1)\n \n maxFontSize = FIRST(maxFontSize, 100000000000)\n \n \n const heightMultiplier = bounds.height / (currentSize.height + 1)\n \n const widthMultiplier = bounds.width / (currentSize.width + 1)\n \n \n var multiplier = heightMultiplier\n \n if (heightMultiplier > widthMultiplier) {\n \n multiplier = widthMultiplier\n \n \n }\n \n \n const maxFittingFontSize = currentFontSize * multiplier\n \n \n if (maxFittingFontSize > maxFontSize) {\n \n return maxFontSize\n \n }\n \n if (minFontSize > maxFittingFontSize) {\n \n return minFontSize\n \n }\n \n \n return maxFittingFontSize\n \n \n }\n \n \n override didReceiveBroadcastEvent(event: UIViewBroadcastEvent) {\n \n super.didReceiveBroadcastEvent(event)\n \n }\n \n \n override willMoveToSuperview(superview: UIView) {\n \n super.willMoveToSuperview(superview)\n \n }\n \n \n override layoutSubviews() {\n \n super.layoutSubviews()\n \n \n if (this._automaticFontSizeSelection) {\n \n this.fontSize = UITextView.automaticallyCalculatedFontSize(\n new UIRectangle(0, 0, 1 *\n this.viewHTMLElement.offsetHeight, 1 *\n this.viewHTMLElement.offsetWidth),\n this.intrinsicContentSize(),\n this.fontSize,\n this._minFontSize,\n this._maxFontSize\n )\n \n \n }\n \n \n }\n \n \n override intrinsicContentHeight(constrainingWidth = 0) {\n \n const keyPath = (this.viewHTMLElement.innerHTML + \"_csf_\" + this.computedStyle.font).replace(new RegExp(\n \"\\\\.\",\n \"g\"\n ), \"_\") + \".\" +\n (\"\" + constrainingWidth).replace(new RegExp(\"\\\\.\", \"g\"), \"_\")\n \n let cacheObject = UITextView._intrinsicHeightCache\n \n if (this.changesOften) {\n \n // @ts-ignore\n cacheObject = this._intrinsicHeightCache\n \n \n }\n \n \n var result = cacheObject.valueForKeyPath(keyPath)\n \n \n if (IS_LIKE_NULL(result)) {\n \n result = super.intrinsicContentHeight(constrainingWidth)\n \n cacheObject.setValueForKeyPath(keyPath, result)\n \n \n }\n \n \n return result\n \n }\n \n override intrinsicContentWidth(constrainingHeight = 0) {\n \n const keyPath = (this.viewHTMLElement.innerHTML + \"_csf_\" + this.computedStyle.font).replace(new RegExp(\n \"\\\\.\",\n \"g\"\n ), \"_\") + \".\" +\n (\"\" + constrainingHeight).replace(new RegExp(\"\\\\.\", \"g\"), \"_\")\n \n let cacheObject = UITextView._intrinsicWidthCache\n \n if (this.changesOften) {\n \n // @ts-ignore\n cacheObject = this._intrinsicWidthCache\n \n \n }\n \n \n var result = cacheObject.valueForKeyPath(keyPath)\n \n \n if (IS_LIKE_NULL(result)) {\n \n result = super.intrinsicContentWidth(constrainingHeight)\n \n cacheObject.setValueForKeyPath(keyPath, result)\n \n \n }\n \n \n return result\n \n }\n \n \n override intrinsicContentSize() {\n \n // This works but is slow\n const result = this.intrinsicContentSizeWithConstraints(nil, nil)\n \n return result\n \n }\n \n \n}\n\n\nUITextView._determinePXAndPTRatios()\n\n\n// /**\n// * Uses canvas.measureText to compute and return the width of the given text of given font in pixels.\n// * \n// * @param {String} text The text to be rendered.\n// * @param {String} font The css font descriptor that text is to be rendered with (e.g. \"bold 14px verdana\").\n// * \n// * @see https://stackoverflow.com/questions/118241/calculate-text-width-with-javascript/21015393#21015393\n// */\n// function getTextMetrics(text, font) {\n// // re-use canvas object for better performance\n// var canvas = getTextMetrics.canvas || (getTextMetrics.canvas = document.createElement(\"canvas\"));\n// var context = canvas.getContext(\"2d\");\n// context.font = font;\n// var metrics = context.measureText(text);\n// return metrics;\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\n\n\n\n\n"],
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,qBAAwB;AAExB,sBAA4D;AAC5D,yBAA4B;AAE5B,oBAA6C;AAGtC,MAAM,cAAN,cAAyB,qBAAO;AAAA,EAmCnC,YACI,WACA,eAAyD,YAAW,KAAK,WACzE,kBAAkB,MACpB;AAEE,UAAM,WAAW,iBAAiB,YAAY;AAtClD,sBAAsB,YAAW;AAGjC,yBAAgB;AAEhB,sBAAa;AACb,sBAAa;AAEb,+BAAsB;AAKtB,uCAA8B;AAE9B,wBAAe;AAQf,iCAA+E,IAAI,yBAAS;AAC5F,gCAA8E,IAAI,yBAAS;
|
|
4
|
+
"sourcesContent": ["import { UIColor } from \"./UIColor\"\nimport { UILocalizedTextObject } from \"./UIInterfaces\"\nimport { FIRST, IS_LIKE_NULL, nil, NO, UIObject, YES } from \"./UIObject\"\nimport { UIRectangle } from \"./UIRectangle\"\nimport type { ValueOf } from \"./UIObject\"\nimport { UIView, UIViewBroadcastEvent } from \"./UIView\"\n\n\nexport class UITextView extends UIView {\n \n \n _textColor: UIColor = UITextView.defaultTextColor\n _textAlignment?: ValueOf<typeof UITextView.textAlignment>\n \n _isSingleLine = YES\n \n textPrefix = \"\"\n textSuffix = \"\"\n \n _notificationAmount = 0\n \n _minFontSize?: number\n _maxFontSize?: number\n \n _automaticFontSizeSelection = NO\n \n changesOften = NO\n \n static defaultTextColor = UIColor.blackColor\n static notificationTextColor = UIColor.redColor\n \n static _intrinsicHeightCache: { [x: string]: { [x: string]: number; }; } & UIObject = new UIObject() as any\n static _intrinsicWidthCache: { [x: string]: { [x: string]: number; }; } & UIObject = new UIObject() as any\n \n _intrinsicHeightCache: { [x: string]: { [x: string]: number; }; } & UIObject = new UIObject() as any\n _intrinsicWidthCache: { [x: string]: { [x: string]: number; }; } & UIObject = new UIObject() as any\n \n \n static _ptToPx: number\n static _pxToPt: number\n _text?: string\n \n \n constructor(\n elementID?: string,\n textViewType: string | ValueOf<typeof UITextView.type> = UITextView.type.paragraph,\n viewHTMLElement = null\n ) {\n \n super(elementID, viewHTMLElement, textViewType)\n \n this.text = \"\"\n \n this.style.overflow = \"hidden\"\n this.style.textOverflow = \"ellipsis\"\n this.isSingleLine = YES\n \n this.textColor = this.textColor\n \n this.userInteractionEnabled = YES\n \n \n if (textViewType == UITextView.type.textArea) {\n \n this.pausesPointerEvents = YES\n \n this.addTargetForControlEvent(\n UIView.controlEvent.PointerUpInside,\n (sender, event) => sender.focus()\n )\n \n \n }\n \n \n }\n \n \n static _determinePXAndPTRatios() {\n \n if (UITextView._ptToPx) {\n return\n }\n \n const o = document.createElement(\"div\")\n o.style.width = \"1000pt\"\n document.body.appendChild(o)\n UITextView._ptToPx = o.clientWidth / 1000\n document.body.removeChild(o)\n UITextView._pxToPt = 1 / UITextView._ptToPx\n \n }\n \n \n static type = {\n \n \"paragraph\": \"p\",\n \"header1\": \"h1\",\n \"header2\": \"h2\",\n \"header3\": \"h3\",\n \"header4\": \"h4\",\n \"header5\": \"h5\",\n \"header6\": \"h6\",\n \"textArea\": \"textarea\",\n \"textField\": \"input\",\n \"span\": \"span\",\n \"label\": \"label\"\n \n } as const\n \n \n static textAlignment = {\n \n \"left\": \"left\",\n \"center\": \"center\",\n \"right\": \"right\",\n \"justify\": \"justify\"\n \n } as const\n \n get textAlignment() {\n // @ts-ignore\n return this.style.textAlign\n }\n \n set textAlignment(textAlignment: ValueOf<typeof UITextView.textAlignment>) {\n this._textAlignment = textAlignment\n this.style.textAlign = textAlignment\n }\n \n \n get textColor() {\n return this._textColor\n }\n \n set textColor(color: UIColor) {\n \n this._textColor = color || UITextView.defaultTextColor\n this.style.color = this._textColor.stringValue\n \n }\n \n \n get isSingleLine() {\n \n return this._isSingleLine\n \n }\n \n set isSingleLine(isSingleLine: boolean) {\n \n this._isSingleLine = isSingleLine\n \n this._intrinsicHeightCache = new UIObject() as any\n this._intrinsicWidthCache = new UIObject() as any\n \n if (isSingleLine) {\n \n this.style.whiteSpace = \"pre\"\n \n return\n \n }\n \n this.style.whiteSpace = \"pre-wrap\"\n \n }\n \n \n get notificationAmount() {\n \n return this._notificationAmount\n \n }\n \n set notificationAmount(notificationAmount: number) {\n \n if (this._notificationAmount == notificationAmount) {\n \n return\n \n }\n \n this._notificationAmount = notificationAmount\n \n this.text = this.text\n \n this.setNeedsLayoutUpToRootView()\n \n this.notificationAmountDidChange(notificationAmount)\n \n }\n \n notificationAmountDidChange(notificationAmount: number) {\n \n \n }\n \n \n get text() {\n \n return (this._text || this.viewHTMLElement.innerHTML)\n \n }\n \n set text(text) {\n \n this._text = text\n \n var notificationText = \"\"\n \n if (this.notificationAmount) {\n \n notificationText = \"<span style=\\\"color: \" + UITextView.notificationTextColor.stringValue + \";\\\">\" +\n (\" (\" + this.notificationAmount + \")\").bold() + \"</span>\"\n \n }\n \n if (this.viewHTMLElement.innerHTML != this.textPrefix + text + this.textSuffix + notificationText) {\n \n this.viewHTMLElement.innerHTML = this.textPrefix + FIRST(text, \"\") + this.textSuffix + notificationText\n \n }\n \n if (this.changesOften) {\n \n this._intrinsicHeightCache = new UIObject() as any\n this._intrinsicWidthCache = new UIObject() as any\n \n }\n \n this.setNeedsLayout()\n \n }\n \n override set innerHTML(innerHTML: string) {\n \n this.text = innerHTML\n \n }\n \n override get innerHTML() {\n \n return this.viewHTMLElement.innerHTML\n \n }\n \n \n setText(key: string, defaultString: string, parameters?: { [x: string]: string | UILocalizedTextObject }) {\n \n this.setInnerHTML(key, defaultString, parameters)\n \n }\n \n \n get fontSize() {\n \n const style = window.getComputedStyle(this.viewHTMLElement, null).fontSize\n \n const result = (parseFloat(style) * UITextView._pxToPt)\n \n return result\n \n }\n \n set fontSize(fontSize: number) {\n \n \n this.style.fontSize = \"\" + fontSize + \"pt\"\n \n this._intrinsicHeightCache = new UIObject() as any\n this._intrinsicWidthCache = new UIObject() as any // MEETOD LUUA!!!!\n \n \n }\n \n \n useAutomaticFontSize(minFontSize: number = nil, maxFontSize: number = nil) {\n \n \n this._automaticFontSizeSelection = YES\n \n \n this._minFontSize = minFontSize\n \n this._maxFontSize = maxFontSize\n \n this.setNeedsLayout()\n \n \n }\n \n \n static automaticallyCalculatedFontSize(\n bounds: UIRectangle,\n currentSize: UIRectangle,\n currentFontSize: number,\n minFontSize?: number,\n maxFontSize?: number\n ) {\n \n minFontSize = FIRST(minFontSize, 1)\n \n maxFontSize = FIRST(maxFontSize, 100000000000)\n \n \n const heightMultiplier = bounds.height / (currentSize.height + 1)\n \n const widthMultiplier = bounds.width / (currentSize.width + 1)\n \n \n var multiplier = heightMultiplier\n \n if (heightMultiplier > widthMultiplier) {\n \n multiplier = widthMultiplier\n \n \n }\n \n \n const maxFittingFontSize = currentFontSize * multiplier\n \n \n if (maxFittingFontSize > maxFontSize) {\n \n return maxFontSize\n \n }\n \n if (minFontSize > maxFittingFontSize) {\n \n return minFontSize\n \n }\n \n \n return maxFittingFontSize\n \n \n }\n \n \n override didReceiveBroadcastEvent(event: UIViewBroadcastEvent) {\n \n super.didReceiveBroadcastEvent(event)\n \n }\n \n \n override willMoveToSuperview(superview: UIView) {\n \n super.willMoveToSuperview(superview)\n \n }\n \n \n override layoutSubviews() {\n \n super.layoutSubviews()\n \n \n if (this._automaticFontSizeSelection) {\n \n this.fontSize = UITextView.automaticallyCalculatedFontSize(\n new UIRectangle(0, 0, 1 *\n this.viewHTMLElement.offsetHeight, 1 *\n this.viewHTMLElement.offsetWidth),\n this.intrinsicContentSize(),\n this.fontSize,\n this._minFontSize,\n this._maxFontSize\n )\n \n \n }\n \n \n }\n \n \n override intrinsicContentHeight = (constrainingWidth = 0) => {\n \n const keyPath = (this.viewHTMLElement.innerHTML + \"_csf_\" + this.computedStyle.font).replace(new RegExp(\n \"\\\\.\",\n \"g\"\n ), \"_\") + \".\" +\n (\"\" + constrainingWidth).replace(new RegExp(\"\\\\.\", \"g\"), \"_\")\n \n let cacheObject = UITextView._intrinsicHeightCache\n \n if (this.changesOften) {\n \n // @ts-ignore\n cacheObject = this._intrinsicHeightCache\n \n \n }\n \n \n var result = cacheObject.valueForKeyPath(keyPath)\n \n \n if (IS_LIKE_NULL(result)) {\n \n result = super.intrinsicContentHeight(constrainingWidth)\n \n cacheObject.setValueForKeyPath(keyPath, result)\n \n \n }\n \n \n return result\n \n }\n \n override intrinsicContentWidth = (constrainingHeight = 0) => {\n \n const keyPath = (this.viewHTMLElement.innerHTML + \"_csf_\" + this.computedStyle.font).replace(new RegExp(\n \"\\\\.\",\n \"g\"\n ), \"_\") + \".\" +\n (\"\" + constrainingHeight).replace(new RegExp(\"\\\\.\", \"g\"), \"_\")\n \n let cacheObject = UITextView._intrinsicWidthCache\n \n if (this.changesOften) {\n \n // @ts-ignore\n cacheObject = this._intrinsicWidthCache\n \n \n }\n \n \n var result = cacheObject.valueForKeyPath(keyPath)\n \n \n if (IS_LIKE_NULL(result)) {\n \n result = super.intrinsicContentWidth(constrainingHeight)\n \n cacheObject.setValueForKeyPath(keyPath, result)\n \n \n }\n \n \n return result\n \n }\n \n \n override intrinsicContentSize = () => {\n \n // This works but is slow\n const result = this.intrinsicContentSizeWithConstraints(nil, nil)\n \n return result\n \n }\n \n \n}\n\n\nUITextView._determinePXAndPTRatios()\n\n\n// /**\n// * Uses canvas.measureText to compute and return the width of the given text of given font in pixels.\n// * \n// * @param {String} text The text to be rendered.\n// * @param {String} font The css font descriptor that text is to be rendered with (e.g. \"bold 14px verdana\").\n// * \n// * @see https://stackoverflow.com/questions/118241/calculate-text-width-with-javascript/21015393#21015393\n// */\n// function getTextMetrics(text, font) {\n// // re-use canvas object for better performance\n// var canvas = getTextMetrics.canvas || (getTextMetrics.canvas = document.createElement(\"canvas\"));\n// var context = canvas.getContext(\"2d\");\n// context.font = font;\n// var metrics = context.measureText(text);\n// return metrics;\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\n\n\n\n\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,qBAAwB;AAExB,sBAA4D;AAC5D,yBAA4B;AAE5B,oBAA6C;AAGtC,MAAM,cAAN,cAAyB,qBA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MACT;AAAA,IAGJ;AAAA,EAGJ;AAsFJ;AAxcO,IAAM,aAAN;AAAM,WAoBF,mBAAmB,uBAAQ;AApBzB,WAqBF,wBAAwB,uBAAQ;AArB9B,WAuBF,wBAA+E,IAAI,yBAAS;AAvB1F,WAwBF,uBAA8E,IAAI,yBAAS;AAxBzF,WAsFF,OAAO;AAAA,EAEV,aAAa;AAAA,EACb,WAAW;AAAA,EACX,WAAW;AAAA,EACX,WAAW;AAAA,EACX,WAAW;AAAA,EACX,WAAW;AAAA,EACX,WAAW;AAAA,EACX,YAAY;AAAA,EACZ,aAAa;AAAA,EACb,QAAQ;AAAA,EACR,SAAS;AAEb;AApGS,WAuGF,gBAAgB;AAAA,EAEnB,QAAQ;AAAA,EACR,UAAU;AAAA,EACV,SAAS;AAAA,EACT,WAAW;AAEf;AA6VJ,WAAW,wBAAwB;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -387,9 +387,9 @@ export declare class UIView extends UIObject {
|
|
|
387
387
|
forEachViewInSubtree(functionToCall: (view: UIView) => void): void;
|
|
388
388
|
rectangleInView(rectangle: UIRectangle, view: UIView): any;
|
|
389
389
|
rectangleFromView(rectangle: UIRectangle, view: UIView): any;
|
|
390
|
-
intrinsicContentSizeWithConstraints(constrainingHeight?: number, constrainingWidth?: number)
|
|
391
|
-
intrinsicContentWidth(constrainingHeight?: number)
|
|
392
|
-
intrinsicContentHeight(constrainingWidth?: number)
|
|
393
|
-
intrinsicContentSize()
|
|
390
|
+
intrinsicContentSizeWithConstraints: (constrainingHeight?: number, constrainingWidth?: number) => UIRectangle;
|
|
391
|
+
intrinsicContentWidth: (constrainingHeight?: number) => number;
|
|
392
|
+
intrinsicContentHeight: (constrainingWidth?: number) => number;
|
|
393
|
+
intrinsicContentSize: () => UIRectangle;
|
|
394
394
|
}
|
|
395
395
|
export {};
|