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 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
- By building animation directly into the logic of the framework and adopting a compact style, TargetJS makes the journey from A to B explicit and with significantly less code than traditional frameworks.
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
- likeButton: {
143
- width: 220, height: 60, lineHeight: 60, textAlign: "center",
144
- borderRadius: 10, backgroundColor: "#f5f5f5", cursor: "pointer", userSelect: "none",
145
- role: "button", tabIndex: 0,
146
- html: "♡ Like",
147
- onClick() {
148
- this.setTarget('scale', { value: [1.2, 1], steps: 8, interval: 12 });
149
- this.setTarget('backgroundColor', { value: [ '#ffe8ec', '#f5f5f5' ], steps: 12, interval: 12 });
150
- },
151
- heart$$: {
152
- html: "♥", color: "crimson", fontSize: 20,
153
- fly() {
154
- const cx = this.getCenterX(), cy = this.getCenterY();
155
- this.setTarget({
156
- opacity: { value: [0, 1, 1, 0.8, 0.1], steps: 20 },
157
- scale: { value: [0.8, 1.4, 1.1, 0.9, 0.8], steps: 20 },
158
- rotate: { value: [0, 12, -8, 6, 0], steps: 20 },
159
- x: { value: [cx, cx + 22, cx - 16, cx + 10, cx], steps: 30 },
160
- y: { value: [cy - 8, cy - 70, cy - 90, cy - 120, cy - 150], steps: 30 }
161
- });
162
- }
163
- },
164
- fetch$$: { method: "POST", id: 123, url: "/api/like" }, // Wait for hearts to finish, THEN fetch
165
- removeHearts$$() { this.removeChildren(); }, // Wait for fetch to finish, THEN cleanup
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
 
@@ -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
- delete tmodel.targets.position;
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
- var uniqueId = _App.App.getOid(id);
81
- tmodel.type = id;
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
  }
@@ -534,11 +534,13 @@ var EventListener = exports.EventListener = /*#__PURE__*/function () {
534
534
  }, {
535
535
  key: "getTModelFromEvent",
536
536
  value: function getTModelFromEvent(event) {
537
- var _event$currentTarget;
538
- var oid = (_event$currentTarget = event.currentTarget) === null || _event$currentTarget === void 0 ? void 0 : _event$currentTarget.id;
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
- var _event$target;
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
  }
@@ -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
- if (_$Dom.$Dom.query("#".concat(_tmodel2.oid))) {
450
- _tmodel2.$dom = new _$Dom.$Dom("#".concat(_tmodel2.oid));
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');
@@ -266,16 +266,12 @@ _defineProperty(TargetData, "mustExecuteTargets", {
266
266
  fetch: true,
267
267
  fetchImage: true
268
268
  });
269
- _defineProperty(TargetData, "coreTargetMap", {
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", _objectSpread(_objectSpread({}, _TargetData.coreTargetMap), {}, {
271
+ });
272
+ _defineProperty(TargetData, "ignoreTargetMethodNameMap", {
277
273
  isVisible: true
278
- }));
274
+ });
279
275
  _defineProperty(TargetData, "cssFunctionMap", {
280
276
  skew: {
281
277
  x: 0,