targetj 1.0.210 → 1.0.212
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/README.md +120 -117
- package/build/App.js +52 -38
- package/build/BaseModel.js +1 -1
- package/build/DomInit.js +24 -0
- package/build/TModel.js +4 -8
- package/build/TargetData.js +2 -2
- package/build/TargetUtil.js +4 -4
- package/dist/targetjs.js +1 -2
- package/dist/targetjs.js.gz +0 -0
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
[](https://github.com/livetrails/targetjs/stargazers)
|
|
6
6
|
[](https://www.npmjs.com/package/targetj)
|
|
7
7
|
|
|
8
|
-
TargetJS is a modern JavaScript UI framework that simplifies front-end development with a code-ordered reactivity model and
|
|
8
|
+
TargetJS is a modern JavaScript UI framework that simplifies front-end development with a code-ordered reactivity model and an ultra-compact syntax. It provides a unified solution for key aspects like UI rendering, animations, APIs, state management, and event handling.
|
|
9
9
|
It can be used as a full-featured framework or as a lightweight library alongside other frameworks. It is also a highly performant web framework, as shown in the [framework benchmark](https://krausest.github.io/js-framework-benchmark/current.html).
|
|
10
10
|
|
|
11
11
|
## The Philosophy Behind TargetJS
|
|
@@ -47,7 +47,7 @@ App({
|
|
|
47
47
|
lineHeight: 60,
|
|
48
48
|
textAlign: "center",
|
|
49
49
|
borderRadius: 10,
|
|
50
|
-
|
|
50
|
+
backgroundColor: "#f5f5f5",
|
|
51
51
|
html: "♡ Like"
|
|
52
52
|
});
|
|
53
53
|
```
|
|
@@ -57,7 +57,7 @@ App({
|
|
|
57
57
|
|
|
58
58
|
### 2) Animation
|
|
59
59
|
|
|
60
|
-
**What this shows:** A mount-time animation that scales and changes the
|
|
60
|
+
**What this shows:** A mount-time animation that scales and changes the `backgroundColor` over 12 steps, with 12ms pauses between steps. Targets without (`$`, `$$`, `_`) execute immediately in the order they are defined.
|
|
61
61
|
|
|
62
62
|
<img src="https://targetjs.io/img/likeButton6.gif" width="130" />
|
|
63
63
|
|
|
@@ -71,8 +71,8 @@ App({
|
|
|
71
71
|
textAlign: "center",
|
|
72
72
|
borderRadius: 10,
|
|
73
73
|
html: "♡ Like",
|
|
74
|
-
scale:
|
|
75
|
-
|
|
74
|
+
scale: { value: [1.2, 1], steps: 12, interval: 12 },
|
|
75
|
+
backgroundColor: { value: ["#ffe8ec", "#f5f5f5"], steps: 12, interval: 12 }
|
|
76
76
|
});
|
|
77
77
|
```
|
|
78
78
|
|
|
@@ -87,14 +87,13 @@ import { App } from "targetj";
|
|
|
87
87
|
|
|
88
88
|
App({
|
|
89
89
|
width: 220, height: 60, lineHeight: 60, textAlign: "center",
|
|
90
|
-
borderRadius: 10,
|
|
90
|
+
borderRadius: 10, backgroundColor: "#f5f5f5",
|
|
91
91
|
cursor: "pointer", userSelect: "none",
|
|
92
92
|
html: "♡ Like",
|
|
93
93
|
|
|
94
94
|
onClick() {
|
|
95
|
-
this.setTarget(
|
|
96
|
-
this.setTarget(
|
|
97
|
-
this.setTarget("html", "♥ Liked");
|
|
95
|
+
this.setTarget('scale', { value: [1.2, 1], steps: 8, interval: 12 });
|
|
96
|
+
this.setTarget('backgroundColor', { value: [ '#ffe8ec', '#f5f5f5' ], steps: 12, interval: 12 });
|
|
98
97
|
}
|
|
99
98
|
});
|
|
100
99
|
```
|
|
@@ -112,12 +111,11 @@ import { App } from "targetj";
|
|
|
112
111
|
|
|
113
112
|
App({
|
|
114
113
|
width: 220, height: 60, lineHeight: 60, textAlign: "center",
|
|
115
|
-
borderRadius: 10,
|
|
114
|
+
borderRadius: 10, backgroundColor: "#f5f5f5", cursor: "pointer", userSelect: "none",
|
|
116
115
|
html: "♡ Like",
|
|
117
116
|
onClick() {
|
|
118
|
-
this.setTarget(
|
|
119
|
-
this.setTarget(
|
|
120
|
-
this.setTarget("html", "♥ Liked");
|
|
117
|
+
this.setTarget('scale', { value: [1.2, 1], steps: 8, interval: 12 });
|
|
118
|
+
this.setTarget('backgroundColor', { value: [ '#ffe8ec', '#f5f5f5' ], steps: 12, interval: 12 });
|
|
121
119
|
},
|
|
122
120
|
heart$$: {
|
|
123
121
|
html: "♥", color: "crimson", fontSize: 20,
|
|
@@ -148,13 +146,12 @@ import { App } from "targetj";
|
|
|
148
146
|
|
|
149
147
|
App({
|
|
150
148
|
width: 220, height: 60, lineHeight: 60, textAlign: "center",
|
|
151
|
-
borderRadius: 10,
|
|
149
|
+
borderRadius: 10, backgroundColor: "#f5f5f5", cursor: "pointer", userSelect: "none",
|
|
152
150
|
html: "♡ Like",
|
|
153
151
|
|
|
154
152
|
onClick() {
|
|
155
|
-
this.setTarget(
|
|
156
|
-
this.setTarget(
|
|
157
|
-
this.setTarget("html", "♥ Liked");
|
|
153
|
+
this.setTarget('scale', { value: [1.2, 1], steps: 8, interval: 12 });
|
|
154
|
+
this.setTarget('backgroundColor', { value: [ '#ffe8ec', '#f5f5f5' ], steps: 12, interval: 12 });
|
|
158
155
|
},
|
|
159
156
|
|
|
160
157
|
heart$$: {
|
|
@@ -214,13 +211,12 @@ import { App } from "targetj";
|
|
|
214
211
|
App({
|
|
215
212
|
likeButton: {
|
|
216
213
|
width: 220, height: 60, lineHeight: 60, textAlign: "center",
|
|
217
|
-
borderRadius: 10,
|
|
214
|
+
borderRadius: 10, backgroundColor: "#f5f5f5", cursor: "pointer", userSelect: "none",
|
|
218
215
|
role: "button", tabIndex: 0,
|
|
219
216
|
html: "♡ Like",
|
|
220
217
|
onClick() {
|
|
221
|
-
this.setTarget(
|
|
222
|
-
this.setTarget(
|
|
223
|
-
this.setTarget("html", "♥ Liked");
|
|
218
|
+
this.setTarget('scale', { value: [1.2, 1], steps: 8, interval: 12 });
|
|
219
|
+
this.setTarget('backgroundColor', { value: [ '#ffe8ec', '#f5f5f5' ], steps: 12, interval: 12 });
|
|
224
220
|
},
|
|
225
221
|
|
|
226
222
|
heart$$: {
|
|
@@ -251,7 +247,7 @@ App({
|
|
|
251
247
|
}
|
|
252
248
|
},
|
|
253
249
|
fetch$$: { method: "POST", id: 123, url: "/api/like" },
|
|
254
|
-
removeHearts$$() { this.
|
|
250
|
+
removeHearts$$() { this.removeChildren(); },
|
|
255
251
|
onKey(e) { if (e.key === "Enter") this.activateTarget("onClick"); }
|
|
256
252
|
}
|
|
257
253
|
});
|
|
@@ -327,23 +323,25 @@ import { App } from "targetj";
|
|
|
327
323
|
|
|
328
324
|
**Via CDN**
|
|
329
325
|
|
|
330
|
-
Add the following `<script>` tag to your HTML to load TargetJS from a CDN
|
|
326
|
+
Add the following `<script>` tag to your HTML to load TargetJS from a CDN:
|
|
331
327
|
|
|
332
328
|
```html
|
|
333
329
|
<script src="https://unpkg.com/targetj@latest/dist/targetjs.js"></script>
|
|
334
330
|
```
|
|
335
331
|
|
|
336
|
-
This exposes `TargetJS` on `window`, so you can initialize your app with `TargetJS.App(...)`. Make sure your code runs after the TargetJS script
|
|
332
|
+
This exposes `TargetJS` on `window`, so you can initialize your app with `TargetJS.App(...)`. Make sure your code runs after the TargetJS script and the DOM are ready (use defer, place your script below it, or wait for `DOMContentLoaded`).
|
|
337
333
|
|
|
338
334
|
You can also use it without `App` by mounting a `TModel` object to an HTML element, for example:
|
|
339
335
|
|
|
340
336
|
```html
|
|
337
|
+
<div id='redbox'></div>
|
|
338
|
+
|
|
341
339
|
<script>
|
|
342
340
|
new TargetJS.TModel({
|
|
343
|
-
|
|
344
|
-
width: [100,
|
|
345
|
-
height: [100,
|
|
346
|
-
}).mount(
|
|
341
|
+
backgroundColor: 'red',
|
|
342
|
+
width: { value: [100, 250, 100], steps: 20 },
|
|
343
|
+
height: { value: [100, 250, 100], steps: 20 }
|
|
344
|
+
}).mount('#redbox');
|
|
347
345
|
</script>
|
|
348
346
|
```
|
|
349
347
|
Or, directly in your HTML with `tg-` attributes:
|
|
@@ -351,8 +349,8 @@ Or, directly in your HTML with `tg-` attributes:
|
|
|
351
349
|
```html
|
|
352
350
|
<div
|
|
353
351
|
tg-background="red"
|
|
354
|
-
tg-width="[100,
|
|
355
|
-
tg-height="[100,
|
|
352
|
+
tg-width="{ value: [100, 250, 100], steps: 20 }"
|
|
353
|
+
tg-height="{ value: [100, 250, 100], steps: 20 }">
|
|
356
354
|
</div>
|
|
357
355
|
```
|
|
358
356
|
|
|
@@ -368,7 +366,7 @@ TargetJS addresses several common pain points in front-end development:
|
|
|
368
366
|
4. **Rigid Static Layer of HTML:** Many frameworks use HTML as the primary medium for generating the user interface. TargetJS makes JavaScript the primary driver.
|
|
369
367
|
5. **Boilerplate and Verbosity:** TargetJS aims to reduce boilerplate code. The code is compact and follows a predictable execution flow.
|
|
370
368
|
6. **Difficult Animation Control:** TargetJS makes animations first-class citizens with fine-grained control.
|
|
371
|
-
|
|
369
|
+
7. **Performance Bottlenecks with Large Lists:** TargetJS optimizes rendering for large lists by using a tree structure that renders only the visible branches.
|
|
372
370
|
|
|
373
371
|
---
|
|
374
372
|
|
|
@@ -398,19 +396,28 @@ App({
|
|
|
398
396
|
child$() {
|
|
399
397
|
const user = this.prevTargetValue;
|
|
400
398
|
return {
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
399
|
+
width: 200,
|
|
400
|
+
height: 65,
|
|
401
|
+
borderRadius: 10,
|
|
402
|
+
boxSizing: "border-box",
|
|
403
|
+
padding: 10,
|
|
404
|
+
fontSize: 14,
|
|
405
|
+
backgroundColor: "#f0f0f0",
|
|
406
|
+
scale: { value: [0.8, 1], steps: 14, interval: 12 },
|
|
407
|
+
userName$$: {
|
|
408
|
+
padding: "10px 0 5px 10px",
|
|
404
409
|
boxSizing: "border-box",
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
},
|
|
413
|
-
|
|
410
|
+
fontWeight: 600,
|
|
411
|
+
opacity: { value: [0, 1], steps: 50 },
|
|
412
|
+
html: user.name
|
|
413
|
+
},
|
|
414
|
+
userEmail$$: {
|
|
415
|
+
paddingLeft: 10,
|
|
416
|
+
boxSizing: "border-box",
|
|
417
|
+
opacity: { value: [0, 0.7], steps: 50 },
|
|
418
|
+
html: user.email
|
|
419
|
+
}
|
|
420
|
+
};
|
|
414
421
|
}
|
|
415
422
|
});
|
|
416
423
|
```
|
|
@@ -438,92 +445,85 @@ App({
|
|
|
438
445
|
|
|
439
446
|
### Infinite Loading and Scrolling Example
|
|
440
447
|
|
|
441
|
-
In this advanced example, we implement an infinite-scrolling application.
|
|
442
|
-
1. Insert new items, and animate their width and background.
|
|
443
|
-
2. On animation completion, trigger the API request for the visible items.
|
|
444
|
-
3. Await for all API responses of all the items and then populate their names.
|
|
445
|
-
|
|
446
|
-
This example could use other flows such as calling the API as soon as items are added, or populating each item’s name as its result arrives instead of waiting for all visible items.
|
|
447
|
-
All of these are doable, but we chose the above to showcase a more complex, sequential async flow.
|
|
448
|
+
In this advanced example, we implement an infinite-scrolling application.
|
|
448
449
|
|
|
449
450
|
**Explanation:**
|
|
450
451
|
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
- _loadItems: Because the target name starts with `_`, it executes only when explicitly activated, which happens inside the `onVisibleChildrenChange` event function. TargetJS guarantees that this array preserves the order in which API calls were made, not the order in which responses were received.
|
|
454
|
-
|
|
455
|
-
- populate: Since the target name ends with `$$`, it executes only after all API calls have completed. It updates the content of each scrollable item with the name returned by the API.
|
|
452
|
+
* `addChildren` is a special target that adds multiple items to the container’s children each time it executes. The `onVisibleChildrenChange` event detects changes in the visible children and activates `addChildren` to insert new items and fill any gaps.
|
|
456
453
|
|
|
457
|
-
|
|
454
|
+
* `photo` and `userName` each add a `div` element inside every item, serving as placeholders for the photo and user name.
|
|
458
455
|
|
|
456
|
+
* `pause$$` delays the execution of all targets that follow it by 100 ms.
|
|
459
457
|
|
|
460
|
-
|
|
458
|
+
* `fetch$$` retrieves the user’s details.
|
|
461
459
|
|
|
462
|
-
|
|
463
|
-
import { App, TModel, getEvents, fetch, getScreenWidth, getScreenHeight } from "targetj";
|
|
460
|
+
* `reveal$$` executes after `fetch$$`, revealing the user name and populating the photo with a random color.
|
|
464
461
|
|
|
465
|
-
|
|
466
|
-
preventDefault: true,
|
|
467
|
-
containerOverflowMode: "always",
|
|
468
|
-
_loadItems() {
|
|
469
|
-
this.visibleChildren.filter(child => !child.loaded).forEach(child => {
|
|
470
|
-
child.loaded = true;
|
|
471
|
-
fetch(this, `https://targetjs.io/api/randomUser?id=${child.oid}`);
|
|
472
|
-
});
|
|
473
|
-
},
|
|
474
|
-
populate$$() {
|
|
475
|
-
if (this.prevTargetValue) {
|
|
476
|
-
this.prevTargetValue.forEach(data => this.getChildByOid(data.id).setTarget("html", data.name));
|
|
477
|
-
}
|
|
478
|
-
},
|
|
479
|
-
children() {
|
|
480
|
-
const childrenCount = this.getChildren().length;
|
|
481
|
-
return Array.from({length: 20}, (_, i) => ({
|
|
482
|
-
animate() {
|
|
483
|
-
const pWidth = this.parent.getWidth();
|
|
484
|
-
this.setTarget({ width: {list: [100, 250, 100]}, x: { list: [ (pWidth - 100) / 2, (pWidth - 250) / 2, (pWidth - 100) / 2 ] } }, 100);
|
|
485
|
-
},
|
|
486
|
-
backgroundColor: [{list: ["#FCE961", "#B388FF"]}, 15, 15],
|
|
487
|
-
height: 48,
|
|
488
|
-
color: "#C2FC61",
|
|
489
|
-
textAlign: "center",
|
|
490
|
-
lineHeight: 48,
|
|
491
|
-
bottomMargin: 2,
|
|
492
|
-
html: childrenCount + i,
|
|
493
|
-
validateVisibilityInParent: true,
|
|
494
|
-
}));
|
|
495
|
-
},
|
|
496
|
-
onScroll() {
|
|
497
|
-
this.setTarget("scrollTop", Math.max(0, this.getScrollTop() + getEvents().deltaY()));
|
|
498
|
-
},
|
|
499
|
-
onVisibleChildrenChange() {
|
|
500
|
-
this.activateTarget("loadItems");
|
|
462
|
+
* `wave$$` executes only after all preceding children have completed their targets, giving each user item a coordinated animation.
|
|
501
463
|
|
|
502
|
-
|
|
503
|
-
this.activateTarget("children");
|
|
504
|
-
}
|
|
505
|
-
},
|
|
506
|
-
width: getScreenWidth,
|
|
507
|
-
height: getScreenHeight,
|
|
508
|
-
onResize: "width"
|
|
509
|
-
});
|
|
464
|
+
TargetJS employs a tree-like structure to track visible branches, optimizing scroller performance.
|
|
510
465
|
|
|
511
|
-
```
|
|
512
466
|
|
|
513
|
-
|
|
467
|
+
<img src="https://targetjs.io/img/infiniteScrolling20.gif" width="130" />
|
|
514
468
|
|
|
515
469
|
```javascript
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
|
|
470
|
+
import { App, getEvents, getScreenWidth, getScreenHeight } from "targetj";
|
|
471
|
+
|
|
472
|
+
App({
|
|
473
|
+
preventDefault: true,
|
|
474
|
+
width: 250,
|
|
475
|
+
height() { return getScreenHeight(); },
|
|
476
|
+
x() { return (getScreenWidth() - this.getWidth()) / 2; },
|
|
477
|
+
containerOverflowMode: "always",
|
|
478
|
+
addChildren() {
|
|
479
|
+
return Array.from({ length: 10 }, (_, i) => ({
|
|
480
|
+
height: 56,
|
|
481
|
+
width() { return this.parent.getWidth(); },
|
|
482
|
+
bottomMargin: 8,
|
|
483
|
+
borderRadius: 12,
|
|
484
|
+
backgroundColor: "white",
|
|
485
|
+
validateVisibilityInParent: true,
|
|
486
|
+
boxShadow: "0 8px 20px rgba(0,0,0,0.08)",
|
|
487
|
+
photo: {
|
|
488
|
+
x: 10, y: 10, width: 34, height: 34,
|
|
489
|
+
borderRadius: "50%",
|
|
490
|
+
backgroundColor: "#ddd"
|
|
491
|
+
},
|
|
492
|
+
userName: {
|
|
493
|
+
x: 60, y: 10, width: 180, height: 30,
|
|
494
|
+
overflow: "hidden",
|
|
495
|
+
borderRadius: 5,
|
|
496
|
+
backgroundColor: "#ddd"
|
|
497
|
+
},
|
|
498
|
+
pause$$: { interval: 100 },
|
|
499
|
+
fetch$$: "https://targetjs.io/api/randomUser",
|
|
500
|
+
reveal$$() {
|
|
501
|
+
const userName = this.getChild("userName");
|
|
502
|
+
userName.setTarget("html", this.val("fetch$$").name);
|
|
503
|
+
userName.setTarget("backgroundColor", { value: "white", steps: 20 });
|
|
504
|
+
this.getChild("photo").setTarget("backgroundColor", { value: "#" + Math.random().toString(16).slice(-6), steps: 20 });
|
|
505
|
+
},
|
|
506
|
+
}));
|
|
507
|
+
},
|
|
508
|
+
wave$$: {
|
|
509
|
+
interval: 30,
|
|
510
|
+
cycles() { return this.visibleChildren.length - 1; },
|
|
511
|
+
value(i) {
|
|
512
|
+
const child = this.visibleChildren[i];
|
|
513
|
+
child.setTarget("scale", { value: [1, 1.06, 1], steps: 18 });
|
|
514
|
+
child.setTarget("opacity", { value: [1, 0.92, 1], steps: 18 });
|
|
526
515
|
}
|
|
516
|
+
},
|
|
517
|
+
onScroll() {
|
|
518
|
+
this.setTarget("scrollTop", Math.max(0, this.getScrollTop() + getEvents().deltaY()));
|
|
519
|
+
},
|
|
520
|
+
onVisibleChildrenChange() {
|
|
521
|
+
const visibleCount = this.visibleChildren.length;
|
|
522
|
+
if (getEvents().dir() !== "up" && visibleCount * 64 < this.getHeight()) {
|
|
523
|
+
this.activateTarget("addChildren");
|
|
524
|
+
}
|
|
525
|
+
}
|
|
526
|
+
});
|
|
527
527
|
```
|
|
528
528
|
---
|
|
529
529
|
|
|
@@ -541,12 +541,15 @@ each time an API response is received, while ensuring the order of API calls is
|
|
|
541
541
|
then the second, and so on.
|
|
542
542
|
|
|
543
543
|
1. **Postfix `$$` to the target name** (Deferred):
|
|
544
|
-
A target name ending with `$$` indicates that it will be activated only after all the preceding
|
|
544
|
+
A target name ending with `$$` indicates that it will be activated only after all the preceding targets have completed, along with all its imperative targets,
|
|
545
545
|
and after all API results have been received.
|
|
546
546
|
|
|
547
547
|
1. **Prefix `_` to the target name** (Inactive):
|
|
548
548
|
It indicates that the target is in an inactive state and must be activated by an event or other targets explicitly.
|
|
549
549
|
|
|
550
|
+
1. **onComplete**
|
|
551
|
+
It gets executed when the target and all proceeding targets fully complete their execution. It is equivalent to `$$`, but is executed from the same target.
|
|
552
|
+
|
|
550
553
|
1. **enabledOn**
|
|
551
554
|
Determines whether the target is eligible for execution. If enabledOn() returns false, the target remains active until it is enabled and gets executed.
|
|
552
555
|
|
|
@@ -563,7 +566,7 @@ It specifies the pause between each target execution or each actual value update
|
|
|
563
566
|
By default, the actual value is updated immediately after the target value. The steps option allows the actual value to be updated in iterations specified by the number of steps.
|
|
564
567
|
|
|
565
568
|
1. **easing**
|
|
566
|
-
|
|
569
|
+
A string that defines a predefined easing function that controls how the actual value is updated in relation to the steps.
|
|
567
570
|
|
|
568
571
|
1. **onValueChange**
|
|
569
572
|
This callback is triggered whenever there is a change returned by the target method/property `value`.
|
package/build/App.js
CHANGED
|
@@ -30,7 +30,7 @@ function _regeneratorRuntime() { "use strict"; /*! regenerator-runtime -- Copyri
|
|
|
30
30
|
function asyncGeneratorStep(n, t, e, r, o, a, c) { try { var i = n[a](c), u = i.value; } catch (n) { return void e(n); } i.done ? t(u) : Promise.resolve(u).then(r, o); }
|
|
31
31
|
function _asyncToGenerator(n) { return function () { var t = this, e = arguments; return new Promise(function (r, o) { var a = n.apply(t, e); function _next(n) { asyncGeneratorStep(a, r, o, _next, _throw, "next", n); } function _throw(n) { asyncGeneratorStep(a, r, o, _next, _throw, "throw", n); } _next(void 0); }); }; }
|
|
32
32
|
var tApp;
|
|
33
|
-
var
|
|
33
|
+
var queuedAppCalls = [];
|
|
34
34
|
var AppFn = function AppFn() {
|
|
35
35
|
var my = {};
|
|
36
36
|
my.throttle = 0;
|
|
@@ -67,10 +67,13 @@ var AppFn = function AppFn() {
|
|
|
67
67
|
return height;
|
|
68
68
|
},
|
|
69
69
|
initPageDom: function initPageDom() {
|
|
70
|
+
var _this = this;
|
|
70
71
|
_DomInit.DomInit.initPageDoms(this.$dom);
|
|
71
|
-
if (
|
|
72
|
-
|
|
73
|
-
|
|
72
|
+
if (queuedAppCalls.length) {
|
|
73
|
+
queuedAppCalls.forEach(function (child) {
|
|
74
|
+
return _this.addChild(child);
|
|
75
|
+
});
|
|
76
|
+
queuedAppCalls.length = 0;
|
|
74
77
|
}
|
|
75
78
|
}
|
|
76
79
|
});
|
|
@@ -190,12 +193,23 @@ var AppFn = function AppFn() {
|
|
|
190
193
|
};
|
|
191
194
|
var App = exports.App = function App(firstChild) {
|
|
192
195
|
var _tApp;
|
|
196
|
+
if (!firstChild) {
|
|
197
|
+
return;
|
|
198
|
+
}
|
|
199
|
+
var tmodel = firstChild instanceof _TModel.TModel ? firstChild : new _TModel.TModel('App', firstChild);
|
|
193
200
|
if (!((_tApp = tApp) !== null && _tApp !== void 0 && _tApp.tRoot)) {
|
|
194
|
-
|
|
195
|
-
} else
|
|
196
|
-
|
|
197
|
-
|
|
201
|
+
queuedAppCalls.push(tmodel);
|
|
202
|
+
} else {
|
|
203
|
+
tApp.tRoot.addChild(tmodel);
|
|
204
|
+
}
|
|
205
|
+
return tmodel;
|
|
206
|
+
};
|
|
207
|
+
App.mount = function (child, elemTarget) {
|
|
208
|
+
var tmodel = App(child);
|
|
209
|
+
if (tmodel) {
|
|
210
|
+
tmodel.mount(elemTarget);
|
|
198
211
|
}
|
|
212
|
+
return tmodel;
|
|
199
213
|
};
|
|
200
214
|
App.oids = {};
|
|
201
215
|
App.tmodelIdMap = {};
|
|
@@ -214,64 +228,64 @@ var isRunning = exports.isRunning = function isRunning() {
|
|
|
214
228
|
return tApp ? tApp.runningFlag : false;
|
|
215
229
|
};
|
|
216
230
|
var tRoot = exports.tRoot = function tRoot() {
|
|
217
|
-
var
|
|
218
|
-
return (
|
|
231
|
+
var _tApp2;
|
|
232
|
+
return (_tApp2 = tApp) === null || _tApp2 === void 0 ? void 0 : _tApp2.tRoot;
|
|
219
233
|
};
|
|
220
234
|
var getEvents = exports.getEvents = function getEvents() {
|
|
221
|
-
var
|
|
222
|
-
return (
|
|
235
|
+
var _tApp3;
|
|
236
|
+
return (_tApp3 = tApp) === null || _tApp3 === void 0 ? void 0 : _tApp3.events;
|
|
223
237
|
};
|
|
224
238
|
var getPager = exports.getPager = function getPager() {
|
|
225
|
-
var
|
|
226
|
-
return (
|
|
239
|
+
var _tApp4;
|
|
240
|
+
return (_tApp4 = tApp) === null || _tApp4 === void 0 ? void 0 : _tApp4.pager;
|
|
227
241
|
};
|
|
228
242
|
var getLoader = exports.getLoader = function getLoader() {
|
|
229
|
-
var
|
|
230
|
-
return (
|
|
243
|
+
var _tApp5;
|
|
244
|
+
return (_tApp5 = tApp) === null || _tApp5 === void 0 ? void 0 : _tApp5.loader;
|
|
231
245
|
};
|
|
232
246
|
var fetch = exports.fetch = function fetch(tmodel, url, query, cacheId) {
|
|
233
|
-
var
|
|
234
|
-
return (
|
|
247
|
+
var _tApp6;
|
|
248
|
+
return (_tApp6 = tApp) === null || _tApp6 === void 0 || (_tApp6 = _tApp6.loader) === null || _tApp6 === void 0 ? void 0 : _tApp6.fetch(tmodel, url, query, cacheId);
|
|
235
249
|
};
|
|
236
250
|
var fetchImage = exports.fetchImage = function fetchImage(tmodel, src, cacheId) {
|
|
237
|
-
var
|
|
238
|
-
return (
|
|
251
|
+
var _tApp7;
|
|
252
|
+
return (_tApp7 = tApp) === null || _tApp7 === void 0 || (_tApp7 = _tApp7.loader) === null || _tApp7 === void 0 ? void 0 : _tApp7.fetchImage(tmodel, src, cacheId);
|
|
239
253
|
};
|
|
240
254
|
var getManager = exports.getManager = function getManager() {
|
|
241
|
-
var
|
|
242
|
-
return (
|
|
255
|
+
var _tApp8;
|
|
256
|
+
return (_tApp8 = tApp) === null || _tApp8 === void 0 ? void 0 : _tApp8.manager;
|
|
243
257
|
};
|
|
244
258
|
var getTargetManager = exports.getTargetManager = function getTargetManager() {
|
|
245
|
-
var
|
|
246
|
-
return (
|
|
259
|
+
var _tApp9;
|
|
260
|
+
return (_tApp9 = tApp) === null || _tApp9 === void 0 ? void 0 : _tApp9.targetManager;
|
|
247
261
|
};
|
|
248
262
|
var getAnimationManager = exports.getAnimationManager = function getAnimationManager() {
|
|
249
|
-
var
|
|
250
|
-
return (
|
|
263
|
+
var _tApp10;
|
|
264
|
+
return (_tApp10 = tApp) === null || _tApp10 === void 0 ? void 0 : _tApp10.animationManager;
|
|
251
265
|
};
|
|
252
266
|
var getRunScheduler = exports.getRunScheduler = function getRunScheduler() {
|
|
253
|
-
var
|
|
254
|
-
return (
|
|
267
|
+
var _tApp11;
|
|
268
|
+
return (_tApp11 = tApp) === null || _tApp11 === void 0 ? void 0 : _tApp11.runScheduler;
|
|
255
269
|
};
|
|
256
270
|
var getLocationManager = exports.getLocationManager = function getLocationManager() {
|
|
257
|
-
var
|
|
258
|
-
return (
|
|
271
|
+
var _tApp12;
|
|
272
|
+
return (_tApp12 = tApp) === null || _tApp12 === void 0 ? void 0 : _tApp12.locationManager;
|
|
259
273
|
};
|
|
260
274
|
var getScreenWidth = exports.getScreenWidth = function getScreenWidth() {
|
|
261
|
-
var _tApp$tRoot$val,
|
|
262
|
-
return (_tApp$tRoot$val = (
|
|
275
|
+
var _tApp$tRoot$val, _tApp13;
|
|
276
|
+
return (_tApp$tRoot$val = (_tApp13 = tApp) === null || _tApp13 === void 0 || (_tApp13 = _tApp13.tRoot) === null || _tApp13 === void 0 ? void 0 : _tApp13.val('screenWidth')) !== null && _tApp$tRoot$val !== void 0 ? _tApp$tRoot$val : 0;
|
|
263
277
|
};
|
|
264
278
|
var getScreenHeight = exports.getScreenHeight = function getScreenHeight() {
|
|
265
|
-
var _tApp$tRoot$val2,
|
|
266
|
-
return (_tApp$tRoot$val2 = (
|
|
279
|
+
var _tApp$tRoot$val2, _tApp14;
|
|
280
|
+
return (_tApp$tRoot$val2 = (_tApp14 = tApp) === null || _tApp14 === void 0 || (_tApp14 = _tApp14.tRoot) === null || _tApp14 === void 0 ? void 0 : _tApp14.val('screenHeight')) !== null && _tApp$tRoot$val2 !== void 0 ? _tApp$tRoot$val2 : 0;
|
|
267
281
|
};
|
|
268
282
|
var getVisibles = exports.getVisibles = function getVisibles() {
|
|
269
|
-
var
|
|
270
|
-
return (
|
|
283
|
+
var _tApp15;
|
|
284
|
+
return (_tApp15 = tApp) === null || _tApp15 === void 0 || (_tApp15 = _tApp15.manager) === null || _tApp15 === void 0 ? void 0 : _tApp15.getVisibles();
|
|
271
285
|
};
|
|
272
286
|
var getResizeLastUpdate = exports.getResizeLastUpdate = function getResizeLastUpdate() {
|
|
273
|
-
var
|
|
274
|
-
return (
|
|
287
|
+
var _tApp16;
|
|
288
|
+
return (_tApp16 = tApp) === null || _tApp16 === void 0 ? void 0 : _tApp16.resizeLastUpdate;
|
|
275
289
|
};
|
|
276
290
|
var getTModelById = exports.getTModelById = function getTModelById(id) {
|
|
277
291
|
return App.tmodelIdMap[id];
|
package/build/BaseModel.js
CHANGED
|
@@ -1150,7 +1150,7 @@ var BaseModel = exports.BaseModel = /*#__PURE__*/function () {
|
|
|
1150
1150
|
if (this.getParent() === invokerTModel) {
|
|
1151
1151
|
_TargetUtil.TargetUtil.markChildAction(invokerTModel, invokerTarget, this);
|
|
1152
1152
|
}
|
|
1153
|
-
targetValue.
|
|
1153
|
+
targetValue.invokerTModel = invokerTModel;
|
|
1154
1154
|
targetValue.invokerTarget = invokerTarget;
|
|
1155
1155
|
if (this.targetValues[key]) {
|
|
1156
1156
|
targetValue.activationTime = _TUtil.TUtil.now();
|
package/build/DomInit.js
CHANGED
|
@@ -8,6 +8,7 @@ var _$Dom = require("./$Dom.js");
|
|
|
8
8
|
var _TUtil = require("./TUtil.js");
|
|
9
9
|
var _App = require("./App.js");
|
|
10
10
|
var _TargetData = require("./TargetData.js");
|
|
11
|
+
var _TModelUtil = require("./TModelUtil.js");
|
|
11
12
|
function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
|
|
12
13
|
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
13
14
|
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
@@ -65,6 +66,29 @@ var DomInit = exports.DomInit = /*#__PURE__*/function () {
|
|
|
65
66
|
}
|
|
66
67
|
return newVisibles;
|
|
67
68
|
}
|
|
69
|
+
}, {
|
|
70
|
+
key: "mount",
|
|
71
|
+
value: function mount(tmodel, elemTarget) {
|
|
72
|
+
if (elemTarget !== undefined) {
|
|
73
|
+
var $dom = _TModelUtil.TModelUtil.normalizeDomHolder(elemTarget);
|
|
74
|
+
if ($dom) {
|
|
75
|
+
tmodel.targets.$dom = $dom;
|
|
76
|
+
tmodel.val('$dom', $dom);
|
|
77
|
+
delete tmodel.targets.position;
|
|
78
|
+
var id = $dom.getId();
|
|
79
|
+
if (id) {
|
|
80
|
+
var uniqueId = _App.App.getOid(id);
|
|
81
|
+
tmodel.type = id;
|
|
82
|
+
tmodel.oid = uniqueId.oid;
|
|
83
|
+
tmodel.oidNum = uniqueId.num;
|
|
84
|
+
}
|
|
85
|
+
$dom.setSelector("#".concat(tmodel.oid));
|
|
86
|
+
$dom.setId(tmodel.oid);
|
|
87
|
+
$dom.attr('tgjs', 'true');
|
|
88
|
+
tmodel.initTargets();
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
}
|
|
68
92
|
}, {
|
|
69
93
|
key: "initPageDoms",
|
|
70
94
|
value: function initPageDoms($dom) {
|
package/build/TModel.js
CHANGED
|
@@ -12,6 +12,7 @@ var _TargetData = require("./TargetData.js");
|
|
|
12
12
|
var _SearchUtil = require("./SearchUtil.js");
|
|
13
13
|
var _TargetUtil = require("./TargetUtil.js");
|
|
14
14
|
var _TModelUtil = require("./TModelUtil.js");
|
|
15
|
+
var _DomInit = require("./DomInit.js");
|
|
15
16
|
function _toConsumableArray(r) { return _arrayWithoutHoles(r) || _iterableToArray(r) || _unsupportedIterableToArray(r) || _nonIterableSpread(); }
|
|
16
17
|
function _nonIterableSpread() { throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
|
|
17
18
|
function _unsupportedIterableToArray(r, a) { if (r) { if ("string" == typeof r) return _arrayLikeToArray(r, a); var t = {}.toString.call(r).slice(8, -1); return "Object" === t && r.constructor && (t = r.constructor.name), "Map" === t || "Set" === t ? Array.from(r) : "Arguments" === t || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t) ? _arrayLikeToArray(r, a) : void 0; } }
|
|
@@ -633,14 +634,9 @@ var TModel = exports.TModel = /*#__PURE__*/function (_BaseModel) {
|
|
|
633
634
|
}
|
|
634
635
|
}, {
|
|
635
636
|
key: "mount",
|
|
636
|
-
value: function mount(
|
|
637
|
-
|
|
638
|
-
|
|
639
|
-
if (domHolder) {
|
|
640
|
-
this.val('domHolder', domHolder);
|
|
641
|
-
}
|
|
642
|
-
}
|
|
643
|
-
(0, _App.tRoot)().addChild(this);
|
|
637
|
+
value: function mount(elemTarget) {
|
|
638
|
+
_DomInit.DomInit.mount(this, elemTarget);
|
|
639
|
+
return this;
|
|
644
640
|
}
|
|
645
641
|
}, {
|
|
646
642
|
key: "hasDom",
|
package/build/TargetData.js
CHANGED
|
@@ -880,8 +880,8 @@ _defineProperty(TargetData, "allEventMap", {
|
|
|
880
880
|
return (0, _App.getEvents)().getEventType() === 'submit';
|
|
881
881
|
}
|
|
882
882
|
});
|
|
883
|
-
_defineProperty(TargetData, "excludedTargetKeys", new Set(['originalTargetName', 'originalTModel', 'activateNextTarget', 'active', 'childAction', 'fetchAction']));
|
|
884
|
-
_defineProperty(TargetData, "lifecycleCallbackSet", new Set(['onValueChange', 'onImperativeEnd', 'onImperativeStep', 'onStepsEnd', 'onSuccess', 'onError']));
|
|
883
|
+
_defineProperty(TargetData, "excludedTargetKeys", new Set(['originalTargetName', 'originalTModel', 'activateNextTarget', 'invokerTarget', 'invokerTModel', 'active', 'addChildAction', 'childAction', 'fetchAction']));
|
|
884
|
+
_defineProperty(TargetData, "lifecycleCallbackSet", new Set(['onComplete', 'onValueChange', 'onImperativeEnd', 'onImperativeStep', 'onStepsEnd', 'onSuccess', 'onError']));
|
|
885
885
|
_defineProperty(TargetData, "lifecycleCoreSet", new Set(['value', 'steps', 'cycles', 'enabledOn', 'loop', 'interval']));
|
|
886
886
|
_defineProperty(TargetData, "lifecycleMethodSet", new Set([].concat(_toConsumableArray(_TargetData.lifecycleCallbackSet), _toConsumableArray(_TargetData.lifecycleCoreSet))));
|
|
887
887
|
_defineProperty(TargetData, "lifecyclePatterns", {
|
package/build/TargetUtil.js
CHANGED
|
@@ -292,13 +292,13 @@ var TargetUtil = exports.TargetUtil = /*#__PURE__*/function () {
|
|
|
292
292
|
if (!targetValue) {
|
|
293
293
|
return;
|
|
294
294
|
}
|
|
295
|
-
var
|
|
295
|
+
var invokerTModel = tmodel.isTargetImperative(key) ? targetValue.originalTModel : targetValue.invokerTModel;
|
|
296
296
|
var invokerTarget = tmodel.isTargetImperative(key) ? targetValue.originalTargetName : targetValue.invokerTarget;
|
|
297
|
-
if (!
|
|
297
|
+
if (!invokerTModel || !invokerTarget) {
|
|
298
298
|
return;
|
|
299
299
|
}
|
|
300
|
-
TargetUtil.cleanupTarget(
|
|
301
|
-
TargetUtil.bubbleInvokerCompletion(
|
|
300
|
+
TargetUtil.cleanupTarget(invokerTModel, invokerTarget);
|
|
301
|
+
TargetUtil.bubbleInvokerCompletion(invokerTModel, invokerTarget, visited, levelUp + 1);
|
|
302
302
|
}
|
|
303
303
|
}, {
|
|
304
304
|
key: "activateTargets",
|