uicore-ts 1.0.1

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.
Files changed (128) hide show
  1. package/.idea/misc.xml +6 -0
  2. package/.idea/modules.xml +8 -0
  3. package/.idea/uicore.iml +9 -0
  4. package/.idea/vcs.xml +6 -0
  5. package/LICENSE +21 -0
  6. package/README.md +5 -0
  7. package/compiledScripts/UIActionIndicator.d.ts +12 -0
  8. package/compiledScripts/UIActionIndicator.js +54 -0
  9. package/compiledScripts/UIActionIndicator.js.map +1 -0
  10. package/compiledScripts/UIBaseButton.d.ts +52 -0
  11. package/compiledScripts/UIBaseButton.js +268 -0
  12. package/compiledScripts/UIBaseButton.js.map +1 -0
  13. package/compiledScripts/UIButton.d.ts +54 -0
  14. package/compiledScripts/UIButton.js +247 -0
  15. package/compiledScripts/UIButton.js.map +1 -0
  16. package/compiledScripts/UIColor.d.ts +41 -0
  17. package/compiledScripts/UIColor.js +286 -0
  18. package/compiledScripts/UIColor.js.map +1 -0
  19. package/compiledScripts/UICore.d.ts +27 -0
  20. package/compiledScripts/UICore.js +105 -0
  21. package/compiledScripts/UICore.js.map +1 -0
  22. package/compiledScripts/UICoreExtensions.d.ts +60 -0
  23. package/compiledScripts/UICoreExtensions.js +527 -0
  24. package/compiledScripts/UICoreExtensions.js.map +1 -0
  25. package/compiledScripts/UIDateTimeInput.d.ts +40 -0
  26. package/compiledScripts/UIDateTimeInput.js +38 -0
  27. package/compiledScripts/UIDateTimeInput.js.map +1 -0
  28. package/compiledScripts/UIDialogView.d.ts +23 -0
  29. package/compiledScripts/UIDialogView.js +118 -0
  30. package/compiledScripts/UIDialogView.js.map +1 -0
  31. package/compiledScripts/UIImageView.d.ts +36 -0
  32. package/compiledScripts/UIImageView.js +170 -0
  33. package/compiledScripts/UIImageView.js.map +1 -0
  34. package/compiledScripts/UIKeyValueStringFilter.d.ts +21 -0
  35. package/compiledScripts/UIKeyValueStringFilter.js +98 -0
  36. package/compiledScripts/UIKeyValueStringFilter.js.map +1 -0
  37. package/compiledScripts/UIKeyValueStringSorter.d.ts +38 -0
  38. package/compiledScripts/UIKeyValueStringSorter.js +117 -0
  39. package/compiledScripts/UIKeyValueStringSorter.js.map +1 -0
  40. package/compiledScripts/UILayoutGrid.d.ts +8 -0
  41. package/compiledScripts/UILayoutGrid.js +22 -0
  42. package/compiledScripts/UILayoutGrid.js.map +1 -0
  43. package/compiledScripts/UILink.d.ts +25 -0
  44. package/compiledScripts/UILink.js +81 -0
  45. package/compiledScripts/UILink.js.map +1 -0
  46. package/compiledScripts/UILinkButton.d.ts +18 -0
  47. package/compiledScripts/UILinkButton.js +60 -0
  48. package/compiledScripts/UILinkButton.js.map +1 -0
  49. package/compiledScripts/UINativeScrollView.d.ts +20 -0
  50. package/compiledScripts/UINativeScrollView.js +121 -0
  51. package/compiledScripts/UINativeScrollView.js.map +1 -0
  52. package/compiledScripts/UIObject.d.ts +69 -0
  53. package/compiledScripts/UIObject.js +442 -0
  54. package/compiledScripts/UIObject.js.map +1 -0
  55. package/compiledScripts/UIPoint.d.ts +18 -0
  56. package/compiledScripts/UIPoint.js +68 -0
  57. package/compiledScripts/UIPoint.js.map +1 -0
  58. package/compiledScripts/UIRectangle.d.ts +61 -0
  59. package/compiledScripts/UIRectangle.js +421 -0
  60. package/compiledScripts/UIRectangle.js.map +1 -0
  61. package/compiledScripts/UIRoute.d.ts +39 -0
  62. package/compiledScripts/UIRoute.js +202 -0
  63. package/compiledScripts/UIRoute.js.map +1 -0
  64. package/compiledScripts/UIScrollView.d.ts +19 -0
  65. package/compiledScripts/UIScrollView.js +121 -0
  66. package/compiledScripts/UIScrollView.js.map +1 -0
  67. package/compiledScripts/UISlideScrollerView.d.ts +40 -0
  68. package/compiledScripts/UISlideScrollerView.js +242 -0
  69. package/compiledScripts/UISlideScrollerView.js.map +1 -0
  70. package/compiledScripts/UIStringFilter.d.ts +26 -0
  71. package/compiledScripts/UIStringFilter.js +107 -0
  72. package/compiledScripts/UIStringFilter.js.map +1 -0
  73. package/compiledScripts/UITableView.d.ts +61 -0
  74. package/compiledScripts/UITableView.js +383 -0
  75. package/compiledScripts/UITableView.js.map +1 -0
  76. package/compiledScripts/UITextArea.d.ts +7 -0
  77. package/compiledScripts/UITextArea.js +27 -0
  78. package/compiledScripts/UITextArea.js.map +1 -0
  79. package/compiledScripts/UITextField.d.ts +44 -0
  80. package/compiledScripts/UITextField.js +83 -0
  81. package/compiledScripts/UITextField.js.map +1 -0
  82. package/compiledScripts/UITextView.d.ts +89 -0
  83. package/compiledScripts/UITextView.js +237 -0
  84. package/compiledScripts/UITextView.js.map +1 -0
  85. package/compiledScripts/UITimer.d.ts +13 -0
  86. package/compiledScripts/UITimer.js +45 -0
  87. package/compiledScripts/UITimer.js.map +1 -0
  88. package/compiledScripts/UIView.d.ts +330 -0
  89. package/compiledScripts/UIView.js +1533 -0
  90. package/compiledScripts/UIView.js.map +1 -0
  91. package/compiledScripts/UIViewController.d.ts +38 -0
  92. package/compiledScripts/UIViewController.js +153 -0
  93. package/compiledScripts/UIViewController.js.map +1 -0
  94. package/compiledScripts/index.d.ts +29 -0
  95. package/compiledScripts/index.js +46 -0
  96. package/compiledScripts/index.js.map +1 -0
  97. package/package.json +36 -0
  98. package/scripts/UIActionIndicator.ts +139 -0
  99. package/scripts/UIBaseButton.ts +563 -0
  100. package/scripts/UIButton.ts +552 -0
  101. package/scripts/UIColor.ts +427 -0
  102. package/scripts/UICore.ts +223 -0
  103. package/scripts/UICoreExtensions.ts +949 -0
  104. package/scripts/UIDateTimeInput.ts +109 -0
  105. package/scripts/UIDialogView.ts +297 -0
  106. package/scripts/UIImageView.ts +366 -0
  107. package/scripts/UIKeyValueStringFilter.ts +260 -0
  108. package/scripts/UIKeyValueStringSorter.ts +337 -0
  109. package/scripts/UILayoutGrid.ts +83 -0
  110. package/scripts/UILink.ts +292 -0
  111. package/scripts/UILinkButton.ts +238 -0
  112. package/scripts/UINativeScrollView.ts +254 -0
  113. package/scripts/UIObject.ts +827 -0
  114. package/scripts/UIPoint.ts +123 -0
  115. package/scripts/UIRectangle.ts +730 -0
  116. package/scripts/UIRoute.ts +391 -0
  117. package/scripts/UIScrollView.ts +290 -0
  118. package/scripts/UISlideScrollerView.ts +530 -0
  119. package/scripts/UIStringFilter.ts +293 -0
  120. package/scripts/UITableView.ts +790 -0
  121. package/scripts/UITextArea.ts +91 -0
  122. package/scripts/UITextField.ts +218 -0
  123. package/scripts/UITextView.ts +561 -0
  124. package/scripts/UITimer.ts +107 -0
  125. package/scripts/UIView.ts +2789 -0
  126. package/scripts/UIViewController.ts +304 -0
  127. package/scripts/index.ts +36 -0
  128. package/tsconfig.json +59 -0
@@ -0,0 +1,105 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.IS_SAFARI = exports.IS_FIREFOX = exports.UICore = void 0;
4
+ const UIObject_1 = require("./UIObject");
5
+ const UIRoute_1 = require("./UIRoute");
6
+ const UIView_1 = require("./UIView");
7
+ const UIViewController_1 = require("./UIViewController");
8
+ require("./UICoreExtensions");
9
+ class UICore extends UIObject_1.UIObject {
10
+ constructor(rootDivElementID, rootViewControllerClass) {
11
+ super();
12
+ this.rootViewController = UIObject_1.nil;
13
+ this._class = UICore;
14
+ this.superclass = UIObject_1.UIObject;
15
+ UICore.RootViewControllerClass = rootViewControllerClass;
16
+ UICore.main = this;
17
+ const rootViewElement = document.getElementById(rootDivElementID);
18
+ const rootView = new UIView_1.UIView(rootDivElementID, rootViewElement);
19
+ rootView.pausesPointerEvents = UIObject_1.NO; //YES;
20
+ if (UICore.RootViewControllerClass) {
21
+ if (!(UICore.RootViewControllerClass.prototype instanceof UIViewController_1.UIViewController) ||
22
+ UICore.RootViewControllerClass === UIViewController_1.UIViewController) {
23
+ console.log("Error, UICore.RootViewControllerClass must be a or a subclass of UIViewController, falling back to UIViewController.");
24
+ UICore.RootViewControllerClass = UIViewController_1.UIViewController;
25
+ }
26
+ this.rootViewController = new UICore.RootViewControllerClass(rootView);
27
+ }
28
+ else {
29
+ this.rootViewController = new UIViewController_1.UIViewController(rootView);
30
+ }
31
+ this.rootViewController.viewWillAppear();
32
+ this.rootViewController.viewDidAppear();
33
+ this.rootViewController.view.addTargetForControlEvent(UIView_1.UIView.controlEvent.PointerUpInside, function (sender, event) {
34
+ document.activeElement.blur();
35
+ });
36
+ const windowDidResize = function () {
37
+ // Doing layout two times to prevent page scrollbars from confusing the layout
38
+ this.rootViewController._layoutViewSubviews();
39
+ UIView_1.UIView.layoutViewsIfNeeded();
40
+ this.rootViewController._layoutViewSubviews();
41
+ //UIView.layoutViewsIfNeeded()
42
+ this.rootViewController.view.broadcastEventInSubtree({
43
+ name: UICore.broadcastEventName.WindowDidResize,
44
+ parameters: UIObject_1.nil
45
+ });
46
+ };
47
+ window.addEventListener("resize", windowDidResize.bind(this));
48
+ const didScroll = function () {
49
+ //code
50
+ this.rootViewController.view.broadcastEventInSubtree({
51
+ name: UIView_1.UIView.broadcastEventName.PageDidScroll,
52
+ parameters: UIObject_1.nil
53
+ });
54
+ }.bind(this);
55
+ window.addEventListener("scroll", didScroll, false);
56
+ const hashDidChange = function () {
57
+ //code
58
+ this.rootViewController.handleRouteRecursively(UIRoute_1.UIRoute.currentRoute);
59
+ this.rootViewController.view.broadcastEventInSubtree({
60
+ name: UICore.broadcastEventName.RouteDidChange,
61
+ parameters: UIObject_1.nil
62
+ });
63
+ }.bind(this);
64
+ window.addEventListener("hashchange", hashDidChange.bind(this), false);
65
+ hashDidChange();
66
+ }
67
+ static loadClass(className) {
68
+ if (window[className]) {
69
+ return;
70
+ }
71
+ document.writeln("<script type='text/javascript' src='dist/UICore/" + className + ".js'></script>");
72
+ }
73
+ }
74
+ exports.UICore = UICore;
75
+ UICore.languageService = UIObject_1.nil;
76
+ UICore.broadcastEventName = {
77
+ "RouteDidChange": "RouteDidChange",
78
+ "WindowDidResize": "WindowDidResize"
79
+ };
80
+ UICore.RootViewControllerClass = UIObject_1.nil;
81
+ exports.IS_FIREFOX = navigator.userAgent.toLowerCase().indexOf("firefox") > -1;
82
+ exports.IS_SAFARI = /^((?!chrome|android).)*safari/i.test(navigator.userAgent);
83
+ Array.prototype.indexOf || (Array.prototype.indexOf = function (d, e) {
84
+ var a;
85
+ if (null == this) {
86
+ throw new TypeError("\"this\" is null or not defined");
87
+ }
88
+ const c = Object(this), b = c.length >>> 0;
89
+ if (0 === b) {
90
+ return -1;
91
+ }
92
+ a = +e || 0;
93
+ Infinity === Math.abs(a) && (a = 0);
94
+ if (a >= b) {
95
+ return -1;
96
+ }
97
+ for (a = Math.max(0 <= a ? a : b - Math.abs(a), 0); a < b;) {
98
+ if (a in c && c[a] === d) {
99
+ return a;
100
+ }
101
+ a++;
102
+ }
103
+ return -1;
104
+ });
105
+ //# sourceMappingURL=UICore.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"UICore.js","sourceRoot":"","sources":["../scripts/UICore.ts"],"names":[],"mappings":";;;AAAA,yCAA8C;AAC9C,uCAAmC;AACnC,qCAAiC;AACjC,yDAAqD;AACrD,8BAA2B;AAkC3B,MAAa,MAAO,SAAQ,mBAAQ;IAQhC,YAAY,gBAAwB,EAAE,uBAAgD;QAElF,KAAK,EAAE,CAAA;QARX,uBAAkB,GAAqB,cAAG,CAAA;QAUtC,IAAI,CAAC,MAAM,GAAG,MAAM,CAAA;QACpB,IAAI,CAAC,UAAU,GAAG,mBAAQ,CAAA;QAE1B,MAAM,CAAC,uBAAuB,GAAG,uBAAuB,CAAA;QAExD,MAAM,CAAC,IAAI,GAAG,IAAI,CAAA;QAElB,MAAM,eAAe,GAAG,QAAQ,CAAC,cAAc,CAAC,gBAAgB,CAAC,CAAA;QAEjE,MAAM,QAAQ,GAAG,IAAI,eAAM,CAAC,gBAAgB,EAAE,eAAe,CAAC,CAAA;QAE9D,QAAQ,CAAC,mBAAmB,GAAG,aAAE,CAAA,CAAC,MAAM;QAExC,IAAI,MAAM,CAAC,uBAAuB,EAAE;YAEhC,IAA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CAAgC,CAAC,IAAI,CAAC,SAAS,CAAC,SAAS,CAAC,CAAA;AAGnF,KAAK,CAAC,SAAS,CAAC,OAAO,IAAI,CAAC,KAAK,CAAC,SAAS,CAAC,OAAO,GAAG,UAAU,CAAC,EAAE,CAAC;IAChE,IAAI,CAAC,CAAA;IACL,IAAI,IAAI,IAAI,IAAI,EAAE;QACd,MAAM,IAAI,SAAS,CAAC,iCAAiC,CAAC,CAAA;KACzD;IACD,MAAM,CAAC,GAAG,MAAM,CAAC,IAAI,CAAC,EAClB,CAAC,GAAG,CAAC,CAAC,MAAM,KAAK,CAAC,CAAA;IACtB,IAAI,CAAC,KAAK,CAAC,EAAE;QACT,OAAO,CAAC,CAAC,CAAA;KACZ;IACD,CAAC,GAAG,CAAC,CAAC,IAAI,CAAC,CAAA;IACX,QAAQ,KAAK,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,GAAG,CAAC,CAAC,CAAA;IACnC,IAAI,CAAC,IAAI,CAAC,EAAE;QACR,OAAO,CAAC,CAAC,CAAA;KACZ;IACD,KAAK,CAAC,GAAG,IAAI,CAAC,GAAG,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,GAAG,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,EAAE,CAAC,GAAG,CAAC,GAAG;QACxD,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,EAAE;YACtB,OAAO,CAAC,CAAA;SACX;QACD,CAAC,EAAE,CAAA;KACN;IACD,OAAO,CAAC,CAAC,CAAA;AACb,CAAC,CAAC,CAAA"}
@@ -0,0 +1,60 @@
1
+ declare global {
2
+ interface Array<T> {
3
+ removeElementAtIndex(index: number): any;
4
+ removeElement(element: T): any;
5
+ insertElementAtIndex(index: number, element: T): any;
6
+ replaceElementAtIndex(index: number, element: T): any;
7
+ contains(element: T): boolean;
8
+ groupedBy(keyFunction: (item: T) => any): {
9
+ [key: string]: Array<T>;
10
+ } & Object;
11
+ copy(): Array<T>;
12
+ arrayByRepeating(numberOfRepetitions: number): Array<T>;
13
+ arrayByTrimmingToLengthIfLonger(maxLength: number): Array<T>;
14
+ anyMatch(predicate: (value: T, index: number, obj: T[]) => boolean): boolean;
15
+ noneMatch(predicate: (value: T, index: number, obj: T[]) => boolean): boolean;
16
+ allMatch(predicate: (value: T, index: number, obj: T[]) => boolean): boolean;
17
+ readonly firstElement: T;
18
+ readonly lastElement: T;
19
+ readonly summedValue: T;
20
+ max(): number;
21
+ min(): number;
22
+ isEqualToArray(array: Array<T>, keyPath?: string): boolean;
23
+ }
24
+ interface String {
25
+ contains(string: any): boolean;
26
+ readonly numericalValue: number;
27
+ isAString: boolean;
28
+ }
29
+ interface Number {
30
+ isANumber: boolean;
31
+ readonly integerValue: number;
32
+ }
33
+ interface Date {
34
+ readonly dateString: string;
35
+ }
36
+ interface Object {
37
+ forEach(callbackFunction: (value: any, key: string) => void): void;
38
+ readonly allValues: Array<any>;
39
+ readonly allKeys: string[];
40
+ }
41
+ }
42
+ export {};
43
+ export declare type UIEveryElementItem<T> = {
44
+ [P in keyof T]: UIEveryElementItem<T[P]>;
45
+ } & {
46
+ UI_elementValues?: T[];
47
+ } & T;
48
+ export declare class UICoreExtensionValueObject {
49
+ isAUICoreExtensionValueObject: boolean;
50
+ value: any;
51
+ constructor(value: any);
52
+ }
53
+ export declare type Unpacked<T> = T extends (infer U)[] ? U : T extends (...args: any[]) => infer U ? U : T extends Promise<infer U> ? U : T;
54
+ export declare type UnpackedObject<T> = {
55
+ [P in keyof T]: Unpacked<T[P]>;
56
+ };
57
+ export declare function promisedProperties<ObjectType extends object>(object: ObjectType): UnpackedObject<ObjectType>;
58
+ export declare class PrimitiveNumber {
59
+ static [Symbol.hasInstance](x: any): void;
60
+ }
@@ -0,0 +1,527 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.PrimitiveNumber = exports.promisedProperties = exports.UICoreExtensionValueObject = void 0;
4
+ const UIObject_1 = require("./UIObject");
5
+ if ("removeElementAtIndex" in Array.prototype == UIObject_1.NO) {
6
+ Array.prototype.removeElementAtIndex = function (index) {
7
+ // @ts-ignore
8
+ if (index >= 0 && index < this.length) {
9
+ this.splice(index, 1);
10
+ }
11
+ };
12
+ }
13
+ // interface Array<T> {
14
+ //
15
+ // removeElementAtIndex(index: number);
16
+ //
17
+ // }
18
+ if ("removeElement" in Array.prototype == UIObject_1.NO) {
19
+ Array.prototype.removeElement = function (element) {
20
+ this.removeElementAtIndex(this.indexOf(element));
21
+ };
22
+ }
23
+ // interface Array<T> {
24
+ //
25
+ // removeElement(element: T);
26
+ //
27
+ // }
28
+ if ("insertElementAtIndex" in Array.prototype == UIObject_1.NO) {
29
+ Array.prototype.insertElementAtIndex = function (index, element) {
30
+ if (index >= 0 && index <= this.length) {
31
+ this.splice(index, 0, element);
32
+ }
33
+ };
34
+ }
35
+ // interface Array<T> {
36
+ //
37
+ // insertElementAtIndex(index: number, element: T);
38
+ //
39
+ // }
40
+ if ("replaceElementAtIndex" in Array.prototype == UIObject_1.NO) {
41
+ Array.prototype.replaceElementAtIndex = function (index, element) {
42
+ this.removeElementAtIndex(index);
43
+ this.insertElementAtIndex(index, element);
44
+ };
45
+ }
46
+ // interface Array<T> {
47
+ //
48
+ // replaceElementAtIndex(index: number, element: T);
49
+ //
50
+ // }
51
+ if ("contains" in Array.prototype == UIObject_1.NO) {
52
+ Array.prototype.contains = function (element) {
53
+ const result = (this.indexOf(element) != -1);
54
+ return result;
55
+ };
56
+ }
57
+ if ("containsAny" in Array.prototype == UIObject_1.NO) {
58
+ Array.prototype.containsAny = function (elements) {
59
+ const result = this.anyMatch(function (element, index, array) {
60
+ return elements.contains(element);
61
+ });
62
+ return result;
63
+ };
64
+ }
65
+ // interface Array<T> {
66
+ //
67
+ // contains(element: T): boolean;
68
+ //
69
+ // containsAny(element: T[]): boolean;
70
+ //
71
+ // }
72
+ if ("anyMatch" in Array.prototype == UIObject_1.NO) {
73
+ Array.prototype.anyMatch = function (functionToCall) {
74
+ // @ts-ignore
75
+ const result = (this.findIndex(functionToCall) > -1);
76
+ return result;
77
+ };
78
+ }
79
+ if ("noneMatch" in Array.prototype == UIObject_1.NO) {
80
+ Array.prototype.noneMatch = function (functionToCall) {
81
+ // @ts-ignore
82
+ const result = (this.findIndex(functionToCall) == -1);
83
+ return result;
84
+ };
85
+ }
86
+ if ("allMatch" in Array.prototype == UIObject_1.NO) {
87
+ Array.prototype.allMatch = function (functionToCall) {
88
+ function reversedFunction(value, index, array) {
89
+ return !functionToCall(value, index, array);
90
+ }
91
+ // @ts-ignore
92
+ const result = (this.findIndex(reversedFunction) == -1);
93
+ return result;
94
+ };
95
+ }
96
+ // interface Array<T> {
97
+ //
98
+ // anyMatch(predicate: (value: T, index: number, obj: T[]) => boolean): boolean
99
+ //
100
+ // noneMatch(predicate: (value: T, index: number, obj: T[]) => boolean): boolean
101
+ //
102
+ // allMatch(predicate: (value: T, index: number, obj: T[]) => boolean): boolean
103
+ //
104
+ // }
105
+ if ("groupedBy" in Array.prototype == UIObject_1.NO) {
106
+ Array.prototype.groupedBy = function (funcProp) {
107
+ return this.reduce(function (acc, val) {
108
+ (acc[funcProp(val)] = acc[funcProp(val)] || []).push(val);
109
+ return acc;
110
+ }, {});
111
+ };
112
+ }
113
+ // interface Array<T> {
114
+ //
115
+ // groupedBy(keyFunction: (item: T) => any): { [key: string]: Array<T> };
116
+ //
117
+ // }
118
+ if ("firstElement" in Array.prototype == UIObject_1.NO) {
119
+ Object.defineProperty(Array.prototype, "firstElement", {
120
+ get: function firstElement() {
121
+ const result = this[0];
122
+ return result;
123
+ },
124
+ set: function (element) {
125
+ if (this.length == 0) {
126
+ this.push(element);
127
+ return;
128
+ }
129
+ this[0] = element;
130
+ }
131
+ });
132
+ }
133
+ if ("lastElement" in Array.prototype == UIObject_1.NO) {
134
+ Object.defineProperty(Array.prototype, "lastElement", {
135
+ get: function lastElement() {
136
+ const result = this[this.length - 1];
137
+ return result;
138
+ },
139
+ set: function (element) {
140
+ if (this.length == 0) {
141
+ this.push(element);
142
+ return;
143
+ }
144
+ this[this.length - 1] = element;
145
+ }
146
+ });
147
+ }
148
+ if ("everyElement" in Array.prototype == UIObject_1.NO) {
149
+ Object.defineProperty(Array.prototype, "everyElement", {
150
+ get: function everyElement() {
151
+ var valueKeys = [];
152
+ const targetFunction = (objects) => {
153
+ return this.map((element, index, array) => {
154
+ var elementFunction = UIObject_1.UIObject.valueForKeyPath(valueKeys.join("."), element).bind(element, objects);
155
+ return elementFunction();
156
+ });
157
+ };
158
+ const result = new Proxy(targetFunction, {
159
+ get: (target, key, receiver) => {
160
+ if (key == "UI_elementValues") {
161
+ return this.map((element, index, array) => UIObject_1.UIObject.valueForKeyPath(valueKeys.join("."), element));
162
+ }
163
+ valueKeys.push(key);
164
+ return result;
165
+ },
166
+ set: (target, key, value, receiver) => {
167
+ valueKeys.push(key);
168
+ this.forEach((element, index, array) => {
169
+ UIObject_1.UIObject.setValueForKeyPath(valueKeys.join("."), value, element, UIObject_1.YES);
170
+ });
171
+ return true;
172
+ }
173
+ });
174
+ return result;
175
+ },
176
+ set: function (element) {
177
+ for (var i = 0; i < this.length; ++i) {
178
+ this[i] = element;
179
+ }
180
+ }
181
+ });
182
+ }
183
+ // interface Array<T> {
184
+ //
185
+ // firstElement: T;
186
+ // lastElement: T;
187
+ //
188
+ // everyElement: UIEveryElementItem<T>;
189
+ //
190
+ // }
191
+ if ("copy" in Array.prototype == UIObject_1.NO) {
192
+ Array.prototype.copy = function () {
193
+ const result = this.slice(0);
194
+ return result;
195
+ };
196
+ }
197
+ // interface Array<T> {
198
+ //
199
+ // copy(): Array<T>;
200
+ //
201
+ // }
202
+ if ("arrayByRepeating" in Array.prototype == UIObject_1.NO) {
203
+ Array.prototype.arrayByRepeating = function (numberOfRepetitions) {
204
+ const result = [];
205
+ for (var i = 0; i < numberOfRepetitions; i++) {
206
+ this.forEach(function (element, index, array) {
207
+ result.push(element);
208
+ });
209
+ }
210
+ return result;
211
+ };
212
+ }
213
+ // interface Array<T> {
214
+ //
215
+ // arrayByRepeating(numberOfRepetitions: number): Array<T>;
216
+ //
217
+ // }
218
+ if ("arrayByTrimmingToLengthIfLonger" in Array.prototype == UIObject_1.NO) {
219
+ Array.prototype.arrayByTrimmingToLengthIfLonger = function (maxLength) {
220
+ const result = [];
221
+ for (var i = 0; i < maxLength && i < this.length; i++) {
222
+ result.push(this[i]);
223
+ }
224
+ return result;
225
+ };
226
+ }
227
+ // interface Array<T> {
228
+ //
229
+ // arrayByTrimmingToLengthIfLonger(maxLength: number): Array<T>;
230
+ //
231
+ // }
232
+ if ("summedValue" in Array.prototype == UIObject_1.NO) {
233
+ Object.defineProperty(Array.prototype, "summedValue", {
234
+ get: function summedValue() {
235
+ const result = this.reduce(function (a, b) {
236
+ return a + b;
237
+ }, 0);
238
+ return result;
239
+ }
240
+ });
241
+ }
242
+ // interface Array<T> {
243
+ //
244
+ // readonly summedValue: T;
245
+ //
246
+ // max(): number;
247
+ // min(): number;
248
+ //
249
+ //
250
+ // }
251
+ Array.prototype.max = function () {
252
+ return Math.max.apply(null, this);
253
+ };
254
+ Array.prototype.min = function () {
255
+ return Math.min.apply(null, this);
256
+ };
257
+ // interface Array<T> {
258
+ //
259
+ // isEqualToArray(array: Array<T>, keyPath?: string): boolean;
260
+ //
261
+ // }
262
+ // Warn if overriding existing method
263
+ if ("isEqualToArray" in Array.prototype == UIObject_1.YES) {
264
+ console.warn("Overriding existing Array.prototype.isEqualToArray. Possible causes: New API defines the method, there's a framework conflict or you've got double inclusions in your code.");
265
+ }
266
+ // attach the .equals method to Array's prototype to call it on any array
267
+ Array.prototype.isEqualToArray = function (array, keyPath) {
268
+ // if the other array is a falsy value, return
269
+ if (!array) {
270
+ return false;
271
+ }
272
+ // compare lengths - can save a lot of time
273
+ if (this.length != array.length) {
274
+ return false;
275
+ }
276
+ var i = 0;
277
+ const l = this.length;
278
+ for (; i < l; i++) {
279
+ // Check if we have nested arrays
280
+ if (this[i] instanceof Array && array[i] instanceof Array && !keyPath) {
281
+ // recurse into the nested arrays
282
+ if (!this[i].isEqualToArray(array[i])) {
283
+ return false;
284
+ }
285
+ }
286
+ else if (keyPath && UIObject_1.UIObject.valueForKeyPath(keyPath, this[i]) != UIObject_1.UIObject.valueForKeyPath(keyPath, array[i])) {
287
+ return false;
288
+ }
289
+ else if (this[i] != array[i]) {
290
+ // Warning - two different object instances will never be equal: {x:20} != {x:20}
291
+ return false;
292
+ }
293
+ }
294
+ return true;
295
+ };
296
+ // Hide method from for-in loops
297
+ Object.defineProperty(Array.prototype, "isEqualToArray", { enumerable: false });
298
+ if ("forEach" in Object.prototype == UIObject_1.NO) {
299
+ Object.prototype.forEach = function (callbackFunction) {
300
+ const keys = Object.keys(this);
301
+ keys.forEach(function (key, index, array) {
302
+ callbackFunction(this[key], key);
303
+ }.bind(this));
304
+ };
305
+ // Hide method from for-in loops
306
+ Object.defineProperty(Object.prototype, "forEach", { enumerable: false });
307
+ }
308
+ // interface Object {
309
+ //
310
+ // forEach(callbackFunction: (value: any, key: string) => void): void;
311
+ //
312
+ // }
313
+ if ("allValues" in Object.prototype == UIObject_1.NO) {
314
+ Object.defineProperty(Object.prototype, "allValues", {
315
+ get: function () {
316
+ const values = [];
317
+ this.forEach(function (value) {
318
+ values.push(value);
319
+ });
320
+ return values;
321
+ }
322
+ });
323
+ }
324
+ // interface Object {
325
+ //
326
+ // readonly allValues: Array<any>;
327
+ //
328
+ // }
329
+ if ("allKeys" in Object.prototype == UIObject_1.NO) {
330
+ Object.defineProperty(Object.prototype, "allKeys", {
331
+ get: function () {
332
+ const values = Object.keys(this);
333
+ return values;
334
+ }
335
+ });
336
+ }
337
+ // interface Object {
338
+ //
339
+ // readonly allKeys: string[];
340
+ //
341
+ // }
342
+ if ("objectByCopyingValuesRecursivelyFromObject" in Object.prototype == UIObject_1.NO) {
343
+ Object.prototype.objectByCopyingValuesRecursivelyFromObject = function (object) {
344
+ function isAnObject(item) {
345
+ return (item && typeof item === "object" && !Array.isArray(item));
346
+ }
347
+ function mergeRecursively(target, source) {
348
+ const output = Object.assign({}, target);
349
+ if (isAnObject(target) && isAnObject(source)) {
350
+ Object.keys(source).forEach(function (key) {
351
+ if (isAnObject(source[key])) {
352
+ // if (!(key in target)) {
353
+ // Object.assign(output, { [key]: source[key] });
354
+ // }
355
+ // else {
356
+ output[key] = mergeRecursively(target[key], source[key]);
357
+ //}
358
+ }
359
+ else {
360
+ Object.assign(output, { [key]: source[key] });
361
+ }
362
+ });
363
+ }
364
+ return output;
365
+ }
366
+ const result = mergeRecursively(this, object);
367
+ return result;
368
+ };
369
+ // Hide method from for-in loops
370
+ Object.defineProperty(Object.prototype, "objectByCopyingValuesRecursivelyFromObject", { enumerable: false });
371
+ }
372
+ class UICoreExtensionValueObject {
373
+ constructor(value) {
374
+ this.isAUICoreExtensionValueObject = UIObject_1.YES;
375
+ this.value = value;
376
+ }
377
+ }
378
+ exports.UICoreExtensionValueObject = UICoreExtensionValueObject;
379
+ if ("asValueObject" in Object.prototype == UIObject_1.NO) {
380
+ Object.prototype.asValueObject = function () {
381
+ const result = new UICoreExtensionValueObject(this);
382
+ return result;
383
+ };
384
+ // Hide method from for-in loops
385
+ Object.defineProperty(Object.prototype, "asValueObject", { enumerable: false });
386
+ }
387
+ function promisedProperties(object) {
388
+ let promisedProperties = [];
389
+ const objectKeys = Object.keys(object);
390
+ objectKeys.forEach((key) => promisedProperties.push(object[key]));
391
+ // @ts-ignore
392
+ return Promise.all(promisedProperties)
393
+ .then((resolvedValues) => {
394
+ return resolvedValues.reduce((resolvedObject, property, index) => {
395
+ resolvedObject[objectKeys[index]] = property;
396
+ return resolvedObject;
397
+ }, object);
398
+ });
399
+ }
400
+ exports.promisedProperties = promisedProperties;
401
+ // if ("promisedProperties" in Object.prototype == NO) {
402
+ //
403
+ // (Object.prototype as any).promisedProperties = function () {
404
+ //
405
+ // const result = promisedProperties(this);
406
+ //
407
+ // return result
408
+ //
409
+ // }
410
+ //
411
+ // // Hide method from for-in loops
412
+ // Object.defineProperty(Object.prototype, "promisedProperties", { enumerable: false });
413
+ //
414
+ // }
415
+ //
416
+ //
417
+ // interface Object {
418
+ //
419
+ // readonly promisedProperties: UnpackedObject<this>;
420
+ //
421
+ // }
422
+ if ("contains" in String.prototype == UIObject_1.NO) {
423
+ String.prototype.contains = function (string) {
424
+ const result = (this.indexOf(string) != -1);
425
+ return result;
426
+ };
427
+ // Hide method from for-in loops
428
+ Object.defineProperty(Object.prototype, "contains", { enumerable: false });
429
+ }
430
+ // interface String {
431
+ //
432
+ // contains(string): boolean;
433
+ //
434
+ // }
435
+ if ("capitalizedString" in String.prototype == UIObject_1.NO) {
436
+ Object.defineProperty(Object.prototype, "capitalizedString", {
437
+ get: function () {
438
+ const result = this.charAt(0).toUpperCase() + this.slice(1).toLowerCase();
439
+ return result;
440
+ }
441
+ });
442
+ }
443
+ // interface String {
444
+ //
445
+ // readonly capitalizedString: string;
446
+ //
447
+ // }
448
+ if ("numericalValue" in String.prototype == UIObject_1.NO) {
449
+ Object.defineProperty(String.prototype, "numericalValue", {
450
+ get: function numericalValue() {
451
+ const result = Number(this);
452
+ return result;
453
+ }
454
+ });
455
+ }
456
+ // interface String {
457
+ //
458
+ // readonly numericalValue: number;
459
+ //
460
+ // }
461
+ if ("isAString" in String.prototype == UIObject_1.NO) {
462
+ String.prototype.isAString = UIObject_1.YES;
463
+ }
464
+ // interface String {
465
+ //
466
+ // isAString: boolean;
467
+ //
468
+ // }
469
+ if ("isANumber" in Number.prototype == UIObject_1.NO) {
470
+ Number.prototype.isANumber = UIObject_1.YES;
471
+ }
472
+ // interface Number {
473
+ //
474
+ // isANumber: boolean;
475
+ //
476
+ // }
477
+ if ("integerValue" in Number.prototype == UIObject_1.NO) {
478
+ Object.defineProperty(Number.prototype, "integerValue", {
479
+ get: function () {
480
+ const result = parseInt("" + (Math.round(this) + 0.5));
481
+ return result;
482
+ }
483
+ });
484
+ }
485
+ // interface Number {
486
+ //
487
+ // readonly integerValue: number;
488
+ //
489
+ // }
490
+ class PrimitiveNumber {
491
+ // @ts-ignore
492
+ static [Symbol.hasInstance](x) {
493
+ return;
494
+ }
495
+ }
496
+ exports.PrimitiveNumber = PrimitiveNumber;
497
+ if ("integerValue" in Boolean.prototype == UIObject_1.NO) {
498
+ Object.defineProperty(Boolean.prototype, "integerValue", {
499
+ get: function () {
500
+ if (this == true) {
501
+ return 1;
502
+ }
503
+ return 0;
504
+ }
505
+ });
506
+ }
507
+ // interface Boolean {
508
+ //
509
+ // readonly integerValue: number;
510
+ //
511
+ // }
512
+ if ("dateString" in Date.prototype == UIObject_1.NO) {
513
+ Object.defineProperty(Date.prototype, "dateString", {
514
+ get: function dateString() {
515
+ const result = ("0" + this.getDate()).slice(-2) + "-" + ("0" + (this.getMonth() + 1)).slice(-2) + "-" +
516
+ this.getFullYear() + " " + ("0" + this.getHours()).slice(-2) + ":" +
517
+ ("0" + this.getMinutes()).slice(-2);
518
+ return result;
519
+ }
520
+ });
521
+ }
522
+ // interface Date {
523
+ //
524
+ // readonly dateString: string;
525
+ //
526
+ // }
527
+ //# sourceMappingURL=UICoreExtensions.js.map