targetj 1.0.214 → 1.0.216
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 +28 -28
- package/build/BaseModel.js +0 -6
- package/build/DomInit.js +24 -9
- package/build/EventListener.js +6 -4
- package/build/TModelManager.js +4 -2
- package/build/TargetData.js +4 -8
- package/dist/targetjs.js +1 -1
- package/dist/targetjs.js.gz +0 -0
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -18,9 +18,11 @@ Traditional frameworks model the UI as a function of state: change state, re-ren
|
|
|
18
18
|
|
|
19
19
|
TargetJS is built for this reality. Instead of managing complex flags, your code structure mirrors these sequences directly.
|
|
20
20
|
|
|
21
|
-
It achieves this through Targets. A Target is a self-contained unit that merges data (fields) and logic (methods) into a single reactive block. Each Target has its own internal state, timing, and lifecycle, acting like a living cell within your app. By simply ordering them in your code, you create complex asynchronous workflows without async/await or .then() chains.
|
|
21
|
+
It achieves this through Targets. A Target is a self-contained unit that merges data (fields) and logic (methods) into a single reactive block. Each Target has its own internal state, timing, and lifecycle, acting like a living cell within your app. By simply ordering them in your code, you create complex asynchronous workflows without async/await or .then() chains.
|
|
22
22
|
|
|
23
|
-
|
|
23
|
+
In addition, animation is built directly into the framework’s logic.
|
|
24
|
+
|
|
25
|
+
By adopting a compact style, TargetJS makes the journey from A to B explicit, with significantly less code than traditional frameworks.
|
|
24
26
|
|
|
25
27
|
## ⚡ Quick Start (30 Seconds)
|
|
26
28
|
|
|
@@ -139,32 +141,30 @@ We handle UI, two animations, a POST request, and a cleanup.
|
|
|
139
141
|
import { App } from "targetj";
|
|
140
142
|
|
|
141
143
|
App({
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
onKey(e) { if (e.key === "Enter") this.activateTarget("onClick"); }
|
|
167
|
-
}
|
|
144
|
+
width: 220, height: 60, lineHeight: 60, textAlign: "center",
|
|
145
|
+
borderRadius: 10, backgroundColor: "#f5f5f5", cursor: "pointer", userSelect: "none",
|
|
146
|
+
role: "button", tabIndex: 0,
|
|
147
|
+
html: "♡ Like",
|
|
148
|
+
onClick() {
|
|
149
|
+
this.setTarget('scale', { value: [1.2, 1], steps: 8, interval: 12 });
|
|
150
|
+
this.setTarget('backgroundColor', { value: [ '#ffe8ec', '#f5f5f5' ], steps: 12, interval: 12 });
|
|
151
|
+
},
|
|
152
|
+
heart$$: {
|
|
153
|
+
html: "♥", color: "crimson", fontSize: 20,
|
|
154
|
+
fly() {
|
|
155
|
+
const cx = this.getCenterX(), cy = this.getCenterY();
|
|
156
|
+
this.setTarget({
|
|
157
|
+
opacity: { value: [0, 1, 1, 0.8, 0.1], steps: 20 },
|
|
158
|
+
scale: { value: [0.8, 1.4, 1.1, 0.9, 0.8], steps: 20 },
|
|
159
|
+
rotate: { value: [0, 12, -8, 6, 0], steps: 20 },
|
|
160
|
+
x: { value: [cx, cx + 22, cx - 16, cx + 10, cx], steps: 30 },
|
|
161
|
+
y: { value: [cy - 8, cy - 70, cy - 90, cy - 120, cy - 150], steps: 30 }
|
|
162
|
+
});
|
|
163
|
+
}
|
|
164
|
+
},
|
|
165
|
+
fetch$$: { method: "POST", id: 123, url: "/api/like" }, // Wait for hearts to finish, THEN fetch
|
|
166
|
+
removeHearts$$() { this.removeChildren(); }, // Wait for fetch to finish, THEN cleanup
|
|
167
|
+
onKey(e) { if (e.key === "Enter") this.activateTarget("onClick"); }
|
|
168
168
|
}).mount("#likeButton");
|
|
169
169
|
```
|
|
170
170
|
|
package/build/BaseModel.js
CHANGED
|
@@ -311,12 +311,6 @@ var BaseModel = exports.BaseModel = /*#__PURE__*/function () {
|
|
|
311
311
|
if (target.active !== false || _TUtil.TUtil.isDefined(target.initialValue)) {
|
|
312
312
|
this.addToStyleTargetList(key);
|
|
313
313
|
}
|
|
314
|
-
if (_TargetData.TargetData.coreTargetMap[key]) {
|
|
315
|
-
this.coreTargetMap || (this.coreTargetMap = new Map());
|
|
316
|
-
if (!this.coreTargetMap.has(key)) {
|
|
317
|
-
this.coreTargetMap.set(key, true);
|
|
318
|
-
}
|
|
319
|
-
}
|
|
320
314
|
if (_TargetParser.TargetParser.isIntervalTarget(target)) {
|
|
321
315
|
target.cycles = 1;
|
|
322
316
|
target.isInterval = true;
|
package/build/DomInit.js
CHANGED
|
@@ -74,18 +74,33 @@ var DomInit = exports.DomInit = /*#__PURE__*/function () {
|
|
|
74
74
|
if ($dom) {
|
|
75
75
|
tmodel.targets.$dom = $dom;
|
|
76
76
|
tmodel.val('$dom', $dom);
|
|
77
|
-
|
|
77
|
+
var tag = $dom.getTagName().toLowerCase();
|
|
78
|
+
var patch = {};
|
|
79
|
+
if (tmodel.val('element') !== tag) {
|
|
80
|
+
patch.element = tag;
|
|
81
|
+
}
|
|
82
|
+
patch.position = $dom.getStyleValue('position') || 'relative';
|
|
83
|
+
patch.domIsland = true;
|
|
84
|
+
if (!_TUtil.TUtil.isDefined(tmodel.targets.reuseDomDefinition)) {
|
|
85
|
+
patch.reuseDomDefinition = true;
|
|
86
|
+
patch.domHolder = true;
|
|
87
|
+
if (!_TUtil.TUtil.isDefined(tmodel.targets.excludeXYCalc)) {
|
|
88
|
+
patch.excludeXYCalc = true;
|
|
89
|
+
}
|
|
90
|
+
if (!_TUtil.TUtil.isDefined(tmodel.targets.x) && !_TUtil.TUtil.isDefined(tmodel.targets.excludeX)) {
|
|
91
|
+
patch.excludeX = true;
|
|
92
|
+
}
|
|
93
|
+
if (!_TUtil.TUtil.isDefined(tmodel.targets.y) && !_TUtil.TUtil.isDefined(tmodel.targets.excludeY)) {
|
|
94
|
+
patch.excludeY = true;
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
tmodel.addTargets(patch);
|
|
78
98
|
var id = $dom.getId();
|
|
79
|
-
if (id) {
|
|
80
|
-
|
|
81
|
-
tmodel.
|
|
82
|
-
tmodel.oid = uniqueId.oid;
|
|
83
|
-
tmodel.oidNum = uniqueId.num;
|
|
99
|
+
if (id && id !== tmodel.oid) {
|
|
100
|
+
$dom.attr('tgjs-oid', tmodel.oid);
|
|
101
|
+
tmodel.domId = id;
|
|
84
102
|
}
|
|
85
|
-
$dom.setSelector("#".concat(tmodel.oid));
|
|
86
|
-
$dom.setId(tmodel.oid);
|
|
87
103
|
$dom.attr('tgjs', 'true');
|
|
88
|
-
tmodel.initTargets();
|
|
89
104
|
}
|
|
90
105
|
}
|
|
91
106
|
}
|
package/build/EventListener.js
CHANGED
|
@@ -534,11 +534,13 @@ var EventListener = exports.EventListener = /*#__PURE__*/function () {
|
|
|
534
534
|
}, {
|
|
535
535
|
key: "getTModelFromEvent",
|
|
536
536
|
value: function getTModelFromEvent(event) {
|
|
537
|
-
var
|
|
538
|
-
var oid
|
|
537
|
+
var el = event.currentTarget || event.target;
|
|
538
|
+
var oid;
|
|
539
|
+
if (el && el.nodeType === 1) {
|
|
540
|
+
oid = el.getAttribute('tgjs-oid') || el.id;
|
|
541
|
+
}
|
|
539
542
|
if (!oid || !_App.tApp.manager.visibleOidMap[oid]) {
|
|
540
|
-
|
|
541
|
-
oid = (_event$target = event.target) === null || _event$target === void 0 ? void 0 : _event$target.id;
|
|
543
|
+
oid = el === null || el === void 0 ? void 0 : el.id;
|
|
542
544
|
if (!oid || !_App.tApp.manager.visibleOidMap[oid]) {
|
|
543
545
|
oid = _$Dom.$Dom.findNearestParentWithId(event.target);
|
|
544
546
|
}
|
package/build/TModelManager.js
CHANGED
|
@@ -445,9 +445,11 @@ var TModelManager = exports.TModelManager = /*#__PURE__*/function () {
|
|
|
445
445
|
_step9;
|
|
446
446
|
try {
|
|
447
447
|
for (_iterator9.s(); !(_step9 = _iterator9.n()).done;) {
|
|
448
|
+
var _tmodel2$domId;
|
|
448
449
|
var _tmodel2 = _step9.value;
|
|
449
|
-
|
|
450
|
-
|
|
450
|
+
var domId = (_tmodel2$domId = _tmodel2.domId) !== null && _tmodel2$domId !== void 0 ? _tmodel2$domId : _tmodel2.oid;
|
|
451
|
+
if (_$Dom.$Dom.query("#".concat(domId))) {
|
|
452
|
+
_tmodel2.$dom = new _$Dom.$Dom("#".concat(domId));
|
|
451
453
|
_tmodel2.$dom.attr('tgjs', 'true');
|
|
452
454
|
_tmodel2.hasDomNow = true;
|
|
453
455
|
_tmodel2.markLayoutDirty('hasDomNow');
|
package/build/TargetData.js
CHANGED
|
@@ -266,16 +266,12 @@ _defineProperty(TargetData, "mustExecuteTargets", {
|
|
|
266
266
|
fetch: true,
|
|
267
267
|
fetchImage: true
|
|
268
268
|
});
|
|
269
|
-
_defineProperty(TargetData, "
|
|
270
|
-
x: true,
|
|
271
|
-
y: true
|
|
272
|
-
});
|
|
273
|
-
_defineProperty(TargetData, "ignoreRerun", _objectSpread(_objectSpread({}, _TargetData.coreTargetMap), {}, {
|
|
269
|
+
_defineProperty(TargetData, "ignoreRerun", {
|
|
274
270
|
isVisible: true
|
|
275
|
-
})
|
|
276
|
-
_defineProperty(TargetData, "ignoreTargetMethodNameMap",
|
|
271
|
+
});
|
|
272
|
+
_defineProperty(TargetData, "ignoreTargetMethodNameMap", {
|
|
277
273
|
isVisible: true
|
|
278
|
-
})
|
|
274
|
+
});
|
|
279
275
|
_defineProperty(TargetData, "cssFunctionMap", {
|
|
280
276
|
skew: {
|
|
281
277
|
x: 0,
|