@orbat-mapper/tactical-draw 0.26.0 → 0.27.0

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/dist/index.d.mts CHANGED
@@ -2307,12 +2307,36 @@ declare class TacticalDraw {
2307
2307
  * This is a pure synchronous query over adapter-cached state: it does not
2308
2308
  * depend on `onPick`/`"click"` dispatch having run first, so it is safe to
2309
2309
  * call from any host click handler regardless of ordering relative to
2310
- * TacticalDraw's own pick/click pipeline.
2310
+ * TacticalDraw's own pick/click pipeline. A press that changes what is under
2311
+ * the pointer (e.g. an Alt+click vertex delete) can leave the pixel empty
2312
+ * for the click that ends it; pair this with {@link consumedPointerCycle}.
2311
2313
  */
2312
2314
  ownsInteractionAt(pixel: PixelCoordinate, options?: {
2313
2315
  tolerance?: number;
2314
2316
  originalEvent?: unknown;
2315
2317
  }): InteractionHit | null;
2318
+ /**
2319
+ * Whether the active edit consumed the current pointer cycle's click — for
2320
+ * hosts composing their own click-away / deselection logic alongside
2321
+ * {@link ownsInteractionAt} (issue #668).
2322
+ *
2323
+ * Some presses change what is under the pointer, for example: Alt+click
2324
+ * (or a tap in `delete` mode) deletes the vertex handle that was pressed,
2325
+ * Alt+click on an option handle moves its grip to the reset position, and a
2326
+ * label or point-symbol drag moves what was pressed. The edit swallows the
2327
+ * click that ends such a press, but
2328
+ * a pixel query made from that click can find nothing there any more. Call
2329
+ * this from the host's own map `click` handler and treat `true` like an
2330
+ * owned hit, e.g. `td.ownsInteractionAt(pixel) || td.consumedPointerCycle()`.
2331
+ *
2332
+ * `true` from the press that consumed the click until the next pointerdown,
2333
+ * so the answer doesn't depend on whether the host's `click` handler runs
2334
+ * before or after TacticalDraw's own. Only meaningful inside a `click`
2335
+ * handler: after a drag that no click follows, it stays `true` until the
2336
+ * next press. `false` while idle, during draws, and once the edit has
2337
+ * settled.
2338
+ */
2339
+ consumedPointerCycle(): boolean;
2316
2340
  private toInteractionHit;
2317
2341
  /**
2318
2342
  * Abort the in-flight draw or edit. The default `"session"` reason matches
package/dist/index.mjs CHANGED
@@ -2151,11 +2151,18 @@ function runEditInteraction(spec) {
2151
2151
  * edit takes two clicks instead of one.
2152
2152
  */
2153
2153
  let suppressClickAway = false;
2154
+ /**
2155
+ * This pointer cycle armed {@link suppressClickAway}. Survives the trailing
2156
+ * `click` (which consumes the suppression) and is cleared only on the next
2157
+ * `pointerdown`, so hosts can ask about the click in any handler order.
2158
+ */
2159
+ let consumedThisCycle = false;
2154
2160
  /** A zero-movement body drag released this pointer cycle — set through `shell.noteBodyClick()`. */
2155
2161
  let bodyClickPending = false;
2156
2162
  const shell = {
2157
2163
  suppressNextClickAway() {
2158
2164
  suppressClickAway = true;
2165
+ consumedThisCycle = true;
2159
2166
  },
2160
2167
  noteBodyClick() {
2161
2168
  bodyClickPending = true;
@@ -2202,7 +2209,7 @@ function runEditInteraction(spec) {
2202
2209
  if (wasBodyClick) return;
2203
2210
  spec.close();
2204
2211
  };
2205
- return runInteraction({
2212
+ const core = runInteraction({
2206
2213
  adapter,
2207
2214
  signal,
2208
2215
  layers,
@@ -2252,6 +2259,7 @@ function runEditInteraction(spec) {
2252
2259
  };
2253
2260
  const onDown = (pixel, info) => {
2254
2261
  suppressClickAway = false;
2262
+ consumedThisCycle = false;
2255
2263
  spec.onDown(pixel, info);
2256
2264
  };
2257
2265
  const unsubDown = driver.onPointerDown(onDown);
@@ -2279,6 +2287,16 @@ function runEditInteraction(spec) {
2279
2287
  spec.attach(controllerContext, driver, shell);
2280
2288
  }
2281
2289
  });
2290
+ return {
2291
+ promise: core.promise,
2292
+ get settled() {
2293
+ return core.settled;
2294
+ },
2295
+ get pointerCycleConsumed() {
2296
+ return consumedThisCycle && !core.settled;
2297
+ },
2298
+ abort: core.abort
2299
+ };
2282
2300
  }
2283
2301
  //#endregion
2284
2302
  //#region src/tactical-draw/active-interaction.ts
@@ -2338,6 +2356,10 @@ var ActiveInteractionTracker = class {
2338
2356
  get session() {
2339
2357
  return this.currentSession;
2340
2358
  }
2359
+ /** Whether the active interaction consumed the current pointer cycle's click. */
2360
+ get pointerCycleConsumed() {
2361
+ return this.handle?.pointerCycleConsumed === true;
2362
+ }
2341
2363
  /** True while an interaction is mid-construction (between `begin` and `set`). */
2342
2364
  get isStarting() {
2343
2365
  return this.starting;
@@ -6462,6 +6484,9 @@ function runEdit(opts) {
6462
6484
  get settled() {
6463
6485
  return core.settled;
6464
6486
  },
6487
+ get pointerCycleConsumed() {
6488
+ return core.pointerCycleConsumed;
6489
+ },
6465
6490
  usesGraphicStack: true,
6466
6491
  measureId: measure.id,
6467
6492
  abort(reason, cause) {
@@ -7885,6 +7910,9 @@ function runGroupTransform(opts) {
7885
7910
  get settled() {
7886
7911
  return core.settled;
7887
7912
  },
7913
+ get pointerCycleConsumed() {
7914
+ return core.pointerCycleConsumed;
7915
+ },
7888
7916
  get graphicIds() {
7889
7917
  return members.map((m) => m.graphic.id);
7890
7918
  },
@@ -8396,6 +8424,9 @@ function runPointSymbolEdit(opts) {
8396
8424
  get settled() {
8397
8425
  return handle.settled;
8398
8426
  },
8427
+ get pointerCycleConsumed() {
8428
+ return handle.pointerCycleConsumed;
8429
+ },
8399
8430
  get usesGraphicStack() {
8400
8431
  return usesGraphicStack;
8401
8432
  },
@@ -8728,6 +8759,9 @@ function runImageEdit(opts) {
8728
8759
  get settled() {
8729
8760
  return handle.settled;
8730
8761
  },
8762
+ get pointerCycleConsumed() {
8763
+ return handle.pointerCycleConsumed;
8764
+ },
8731
8765
  get usesGraphicStack() {
8732
8766
  return usesGraphicStack;
8733
8767
  },
@@ -9105,6 +9139,9 @@ function runMarkerEdit(opts) {
9105
9139
  get settled() {
9106
9140
  return handle.settled;
9107
9141
  },
9142
+ get pointerCycleConsumed() {
9143
+ return handle.pointerCycleConsumed;
9144
+ },
9108
9145
  get usesGraphicStack() {
9109
9146
  return usesGraphicStack;
9110
9147
  },
@@ -10458,7 +10495,9 @@ var TacticalDraw = class {
10458
10495
  * This is a pure synchronous query over adapter-cached state: it does not
10459
10496
  * depend on `onPick`/`"click"` dispatch having run first, so it is safe to
10460
10497
  * call from any host click handler regardless of ordering relative to
10461
- * TacticalDraw's own pick/click pipeline.
10498
+ * TacticalDraw's own pick/click pipeline. A press that changes what is under
10499
+ * the pointer (e.g. an Alt+click vertex delete) can leave the pixel empty
10500
+ * for the click that ends it; pair this with {@link consumedPointerCycle}.
10462
10501
  */
10463
10502
  ownsInteractionAt(pixel, options) {
10464
10503
  this.assertAlive();
@@ -10534,6 +10573,31 @@ var TacticalDraw = class {
10534
10573
  }
10535
10574
  return null;
10536
10575
  }
10576
+ /**
10577
+ * Whether the active edit consumed the current pointer cycle's click — for
10578
+ * hosts composing their own click-away / deselection logic alongside
10579
+ * {@link ownsInteractionAt} (issue #668).
10580
+ *
10581
+ * Some presses change what is under the pointer, for example: Alt+click
10582
+ * (or a tap in `delete` mode) deletes the vertex handle that was pressed,
10583
+ * Alt+click on an option handle moves its grip to the reset position, and a
10584
+ * label or point-symbol drag moves what was pressed. The edit swallows the
10585
+ * click that ends such a press, but
10586
+ * a pixel query made from that click can find nothing there any more. Call
10587
+ * this from the host's own map `click` handler and treat `true` like an
10588
+ * owned hit, e.g. `td.ownsInteractionAt(pixel) || td.consumedPointerCycle()`.
10589
+ *
10590
+ * `true` from the press that consumed the click until the next pointerdown,
10591
+ * so the answer doesn't depend on whether the host's `click` handler runs
10592
+ * before or after TacticalDraw's own. Only meaningful inside a `click`
10593
+ * handler: after a drag that no click follows, it stays `true` until the
10594
+ * next press. `false` while idle, during draws, and once the edit has
10595
+ * settled.
10596
+ */
10597
+ consumedPointerCycle() {
10598
+ this.assertAlive();
10599
+ return this.activeInteraction.pointerCycleConsumed;
10600
+ }
10537
10601
  toInteractionHit(layer, feature) {
10538
10602
  const measureId = tryControlMeasureIdFromFeature(feature);
10539
10603
  return measureId != null ? {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@orbat-mapper/tactical-draw",
3
- "version": "0.26.0",
3
+ "version": "0.27.0",
4
4
  "description": "Engine-agnostic draw/edit core for tactical control measures (MIL-STD-2525 / APP-6). The MapAdapter ABI and bring-your-own-engine entry point for the tactical-draw package family.",
5
5
  "license": "MIT",
6
6
  "author": "Orbat Mapper",