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,337 @@
1
+ import { IS, IS_NOT, MAKE_ID, NO, UIObject, YES } from "./UIObject"
2
+
3
+
4
+ export interface UIKeyValueStringSorterSortingInstruction {
5
+
6
+ keyPath: string;
7
+
8
+ dataType: string;
9
+
10
+ direction: string;
11
+
12
+
13
+ }
14
+
15
+
16
+
17
+
18
+
19
+ export class UIKeyValueStringSorter extends UIObject {
20
+
21
+
22
+ static _sharedWebWorkerHolder = { webWorker: new Worker("compiledScripts//UIKeyValueStringSorterWebWorker.js") }
23
+
24
+ static _instanceNumber = -1
25
+
26
+
27
+ _instanceNumber: number
28
+
29
+ _isThreadClosed = NO
30
+
31
+ private _webWorkerHolder = UIKeyValueStringSorter._sharedWebWorkerHolder
32
+
33
+
34
+ constructor(useSeparateWebWorkerHolder = NO) {
35
+
36
+
37
+ super()
38
+
39
+ this._class = UIKeyValueStringSorter
40
+ this.superclass = UIObject
41
+
42
+
43
+ if (useSeparateWebWorkerHolder) {
44
+
45
+ this._webWorkerHolder = { webWorker: new Worker("compiledScripts//UIKeyValueStringSorterWebWorker.js") }
46
+
47
+ }
48
+
49
+ UIKeyValueStringSorter._instanceNumber = UIKeyValueStringSorter._instanceNumber + 1
50
+ this._instanceNumber = UIKeyValueStringSorter._instanceNumber
51
+
52
+ if (IS_NOT(this._webWorkerHolder.webWorker.onmessage)) {
53
+
54
+ this._webWorkerHolder.webWorker.onmessage = message => {
55
+
56
+ this.isWorkerBusy = NO;
57
+ this.postNextMessageIfNeeded();
58
+
59
+ const key = "" + message.data.identifier + message.data.instanceIdentifier
60
+
61
+ const completionFunction = this.completionFunctions[key]
62
+
63
+ if (IS(completionFunction)) {
64
+
65
+ //console.log("Filtering took " + (Date.now() - startTime) + " ms");
66
+
67
+ completionFunction(message.data.sortedData, message.data.sortedIndexes, message.data.identifier)
68
+
69
+ }
70
+
71
+ delete this.completionFunctions[key];
72
+
73
+ var asd = 1;
74
+
75
+ }
76
+
77
+ }
78
+
79
+
80
+
81
+
82
+
83
+
84
+
85
+
86
+
87
+ }
88
+
89
+
90
+
91
+
92
+
93
+ get instanceIdentifier() {
94
+
95
+ return this._instanceNumber
96
+
97
+ }
98
+
99
+
100
+
101
+
102
+ get completionFunctions() {
103
+
104
+ const key = "UICore_completionFunctions";
105
+ var result: {
106
+
107
+ [x: string]: (sortedData: any[], sortedIndexes: number[], identifier: any) => void
108
+
109
+ } = this._webWorkerHolder[key];
110
+
111
+ if (IS_NOT(result)) {
112
+
113
+ result = {};
114
+ this._webWorkerHolder[key] = result;
115
+
116
+ }
117
+
118
+ return result;
119
+
120
+ }
121
+
122
+ get messagesToPost() {
123
+
124
+ const key = "UICore_messagesToPost";
125
+ var result: any[] = this._webWorkerHolder[key];
126
+
127
+ if (IS_NOT(result)) {
128
+
129
+ result = [];
130
+ this._webWorkerHolder[key] = result;
131
+
132
+ }
133
+
134
+ return result;
135
+
136
+ }
137
+
138
+
139
+ set isWorkerBusy(isWorkerBusy: boolean) {
140
+
141
+ this._webWorkerHolder["UICore_isWorking"] = isWorkerBusy;
142
+
143
+ }
144
+
145
+ get isWorkerBusy() {
146
+
147
+ return IS(this._webWorkerHolder["UICore_isWorking"]);
148
+
149
+ }
150
+
151
+
152
+ postNextMessageIfNeeded() {
153
+
154
+ if (this.messagesToPost.length && IS_NOT(this.isWorkerBusy)) {
155
+
156
+ this._webWorkerHolder.webWorker.postMessage(this.messagesToPost.firstElement);
157
+ this.messagesToPost.removeElementAtIndex(0);
158
+
159
+ this.isWorkerBusy = YES;
160
+
161
+ }
162
+
163
+ }
164
+
165
+
166
+
167
+
168
+
169
+ static dataType = {
170
+
171
+ "string": "string"
172
+
173
+ }
174
+
175
+
176
+ static direction = {
177
+
178
+ "descending": "descending",
179
+ "ascending": "ascending"
180
+
181
+ }
182
+
183
+
184
+
185
+
186
+
187
+ sortData<T>(
188
+ data: T[],
189
+ sortingInstructions: UIKeyValueStringSorterSortingInstruction[],
190
+ identifier: any,
191
+ completion: (sortedData: T[], sortedIndexes: number[], identifier: any) => void
192
+ ) {
193
+
194
+
195
+ if (this._isThreadClosed) {
196
+
197
+ return
198
+
199
+ }
200
+
201
+
202
+ const instanceIdentifier = this.instanceIdentifier
203
+
204
+ const key = "" + identifier + instanceIdentifier
205
+
206
+ this.completionFunctions[key] = completion;
207
+
208
+
209
+ try {
210
+
211
+ this.messagesToPost.push({
212
+
213
+ "data": data,
214
+ "sortingInstructions": sortingInstructions,
215
+ "identifier": identifier,
216
+ "instanceIdentifier": instanceIdentifier
217
+
218
+ });
219
+
220
+ this.postNextMessageIfNeeded();
221
+
222
+ } catch (exception) {
223
+
224
+ completion([], [], identifier)
225
+
226
+ }
227
+
228
+
229
+
230
+
231
+
232
+ }
233
+
234
+
235
+
236
+
237
+
238
+ sortedData<T>(
239
+ data: T[],
240
+ sortingInstructions: UIKeyValueStringSorterSortingInstruction[],
241
+ identifier: any = MAKE_ID()
242
+ ) {
243
+
244
+ const result: Promise<{
245
+
246
+ sortedData: T[],
247
+ sortedIndexes: number[],
248
+ identifier: any
249
+
250
+ }> = new Promise((resolve, reject) => {
251
+
252
+ this.sortData(data, sortingInstructions, identifier, (sortedData, sortedIndexes, sortedIdentifier) => {
253
+
254
+ if (sortedIdentifier == identifier) {
255
+
256
+ resolve({
257
+
258
+ sortedData: sortedData,
259
+ sortedIndexes: sortedIndexes,
260
+ identifier: sortedIdentifier
261
+
262
+ })
263
+
264
+ }
265
+
266
+
267
+
268
+ })
269
+
270
+
271
+
272
+ })
273
+
274
+ return result
275
+
276
+ }
277
+
278
+
279
+
280
+
281
+
282
+ closeThread() {
283
+
284
+ this._isThreadClosed = YES
285
+
286
+ if (this._webWorkerHolder != UIKeyValueStringSorter._sharedWebWorkerHolder) {
287
+
288
+ this._webWorkerHolder.webWorker.terminate();
289
+
290
+ }
291
+
292
+
293
+
294
+ }
295
+
296
+
297
+
298
+
299
+
300
+ }
301
+
302
+
303
+
304
+
305
+
306
+
307
+
308
+
309
+
310
+
311
+
312
+
313
+
314
+
315
+
316
+
317
+
318
+
319
+
320
+
321
+
322
+
323
+
324
+
325
+
326
+
327
+
328
+
329
+
330
+
331
+
332
+
333
+
334
+
335
+
336
+
337
+
@@ -0,0 +1,83 @@
1
+ import { UIObject } from "./UIObject"
2
+ import { UIRectangle } from "./UIRectangle"
3
+
4
+
5
+ export class UILayoutGrid extends UIObject {
6
+
7
+
8
+
9
+ _frame: UIRectangle
10
+
11
+ _subframes: UILayoutGrid[] = []
12
+
13
+
14
+ constructor(frame: UIRectangle) {
15
+
16
+ super()
17
+
18
+ this._class = UILayoutGrid
19
+ this.superclass = UIObject
20
+
21
+ this._frame = frame
22
+
23
+ }
24
+
25
+
26
+
27
+
28
+
29
+ splitXInto(numberOfFrames: number) {
30
+
31
+
32
+
33
+ if (this._subframes.length == 0) {
34
+
35
+
36
+
37
+ for (var i = 0; i < numberOfFrames; i++) {
38
+
39
+ const asd = 1
40
+
41
+
42
+
43
+ }
44
+
45
+ }
46
+
47
+
48
+
49
+
50
+ }
51
+
52
+
53
+
54
+
55
+
56
+ }
57
+
58
+
59
+
60
+
61
+
62
+
63
+
64
+
65
+
66
+
67
+
68
+
69
+
70
+
71
+
72
+
73
+
74
+
75
+
76
+
77
+
78
+
79
+
80
+
81
+
82
+
83
+
@@ -0,0 +1,292 @@
1
+ import { UIBaseButton } from "./UIBaseButton"
2
+ import { UIButtonColorSpecifier } from "./UIButton"
3
+ import { UICore } from "./UICore"
4
+ import { nil, NO } from "./UIObject"
5
+ import { UIRoute } from "./UIRoute"
6
+ import { UIViewBroadcastEvent } from "./UIView"
7
+
8
+
9
+
10
+
11
+
12
+ export class UILink extends UIBaseButton {
13
+
14
+
15
+
16
+ private _colors: UIButtonColorSpecifier
17
+
18
+
19
+ constructor(elementID: string, initViewData = nil) {
20
+
21
+ super(elementID, "a", initViewData)
22
+
23
+ this._class = UILink
24
+ this.superclass = UIBaseButton
25
+
26
+ this.stopsPointerEventPropagation = NO
27
+
28
+ this.pausesPointerEvents = NO
29
+
30
+
31
+
32
+ }
33
+
34
+
35
+
36
+
37
+
38
+ initView(elementID, viewHTMLElement, initViewData: { titleType: string }) {
39
+
40
+ super.initView(elementID, viewHTMLElement, initViewData)
41
+
42
+ this.class.superclass = UIBaseButton
43
+
44
+ // Instance variables
45
+
46
+
47
+ //this.style.position = "relative"
48
+
49
+
50
+ viewHTMLElement.onclick = this.blur.bind(this)
51
+
52
+
53
+
54
+
55
+ }
56
+
57
+
58
+
59
+
60
+
61
+ get colors(): UIButtonColorSpecifier {
62
+ return this._colors
63
+ }
64
+
65
+ set colors(value: UIButtonColorSpecifier) {
66
+ this._colors = value
67
+ }
68
+
69
+
70
+
71
+
72
+
73
+ get viewHTMLElement() {
74
+
75
+ // @ts-ignore
76
+ return super.viewHTMLElement as HTMLLinkElement
77
+
78
+ }
79
+
80
+ set text(text: string) {
81
+
82
+ this.viewHTMLElement.textContent = text
83
+
84
+ }
85
+
86
+ get text() {
87
+
88
+ return this.viewHTMLElement.textContent
89
+
90
+ }
91
+
92
+
93
+ set target(target: string) {
94
+
95
+ this.viewHTMLElement.setAttribute("href", target)
96
+
97
+ }
98
+
99
+ get target() {
100
+
101
+ const result = this.viewHTMLElement.getAttribute("href")
102
+
103
+ return result
104
+
105
+ }
106
+
107
+
108
+
109
+
110
+
111
+ set targetRouteForCurrentState(targetRouteForCurrentState: () => (UIRoute | string)) {
112
+
113
+ this._targetRouteForCurrentState = targetRouteForCurrentState
114
+
115
+ this.updateTarget()
116
+
117
+ }
118
+
119
+ get targetRouteForCurrentState() {
120
+
121
+ return this._targetRouteForCurrentState
122
+
123
+ }
124
+
125
+
126
+ _targetRouteForCurrentState() {
127
+
128
+ const result = UIRoute.currentRoute.routeByRemovingComponentsOtherThanOnesNamed(["settings"]) as (UIRoute | string)
129
+
130
+ return result
131
+
132
+ }
133
+
134
+
135
+
136
+
137
+
138
+ didReceiveBroadcastEvent(event: UIViewBroadcastEvent) {
139
+
140
+ super.didReceiveBroadcastEvent(event)
141
+
142
+ if (event.name == UICore.broadcastEventName.RouteDidChange) {
143
+
144
+ this.updateTarget()
145
+
146
+ }
147
+
148
+ }
149
+
150
+
151
+
152
+
153
+
154
+ wasAddedToViewTree() {
155
+
156
+ super.wasAddedToViewTree()
157
+
158
+ this.updateTarget()
159
+
160
+
161
+ }
162
+
163
+
164
+
165
+
166
+
167
+ updateTarget() {
168
+
169
+ const route = this.targetRouteForCurrentState()
170
+
171
+ if (route instanceof UIRoute) {
172
+
173
+ this.target = route.linkRepresentation
174
+
175
+ return
176
+
177
+ }
178
+
179
+ this.target = route
180
+
181
+ }
182
+
183
+
184
+
185
+
186
+
187
+ layoutSubviews() {
188
+
189
+ super.layoutSubviews()
190
+
191
+ const bounds = this.bounds
192
+
193
+ }
194
+
195
+
196
+
197
+
198
+
199
+ }
200
+
201
+
202
+
203
+
204
+
205
+
206
+
207
+
208
+
209
+
210
+
211
+
212
+
213
+
214
+
215
+
216
+
217
+
218
+
219
+
220
+
221
+
222
+
223
+
224
+
225
+
226
+
227
+
228
+
229
+
230
+
231
+
232
+
233
+
234
+
235
+
236
+
237
+
238
+
239
+
240
+
241
+
242
+
243
+
244
+
245
+
246
+
247
+
248
+
249
+
250
+
251
+
252
+
253
+
254
+
255
+
256
+
257
+
258
+
259
+
260
+
261
+
262
+
263
+
264
+
265
+
266
+
267
+
268
+
269
+
270
+
271
+
272
+
273
+
274
+
275
+
276
+
277
+
278
+
279
+
280
+
281
+
282
+
283
+
284
+
285
+
286
+
287
+
288
+
289
+
290
+
291
+
292
+