@orbat-mapper/tactical-draw 0.26.0 → 0.28.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
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { $ as PinPresentationCapability, A as PointSymbolConnector, B as isPointSymbol, C as makeFillPatternImage, D as PointSymbolAnchor, E as PointSymbol, F as PointSymbolRect, G as ResolvedEditModifiers, H as DEFAULT_EDIT_MODIFIERS, I as PointSymbolRender, J as PointerEventInfo, K as EditPointerDriver, L as PointSymbolSize, M as PointSymbolOffset, N as PointSymbolOffsetStyle, O as PointSymbolCapability, P as PointSymbolPlacement, Q as PinPresentation, R as PointSymbolStyle, S as isMinePattern, T as OffsetDragModifier, U as EditModifiers, V as resizePointSymbolSize, W as ModifierKey, X as PinFootprint, Y as DEFAULT_PIN_PRESENTATION, Z as PinOverridePatch, _ as HatchPattern, a as LayerId, at as PinRender, b as fillPatternImageDimension, c as MapEvent, ct as pinDistanceScale, d as PickHandler, et as PinPresentationPatch, f as PickOptions, g as HATCH_PATTERNS, h as TextStyleOptions, i as ImageOverlayResource, it as PinPresentationStore, j as PointSymbolGraphicModifiers, k as PointSymbolColors, l as MapEventHandler, lt as pinZoomScale, m as StyleOptions, n as HandleStyle, nt as PinPresentationStatus, o as MapAdapter, ot as combinePinScale, p as PixelCoordinate, q as PointerCallback, r as IconResource, rt as PinPresentationStatusEvent, s as MapCursor, st as isValidPinNumber, t as FeatureGroup, tt as PinPresentationState, u as PickEvent, ut as resolvePinPresentation, v as MINE_PATTERN_TILE_SIZE, w as parseColor, x as fillPatternImageId, y as Rgba, z as clonePointSymbol } from "./map-adapter-
|
|
1
|
+
import { $ as PinPresentationCapability, A as PointSymbolConnector, B as isPointSymbol, C as makeFillPatternImage, D as PointSymbolAnchor, E as PointSymbol, F as PointSymbolRect, G as ResolvedEditModifiers, H as DEFAULT_EDIT_MODIFIERS, I as PointSymbolRender, J as PointerEventInfo, K as EditPointerDriver, L as PointSymbolSize, M as PointSymbolOffset, N as PointSymbolOffsetStyle, O as PointSymbolCapability, P as PointSymbolPlacement, Q as PinPresentation, R as PointSymbolStyle, S as isMinePattern, T as OffsetDragModifier, U as EditModifiers, V as resizePointSymbolSize, W as ModifierKey, X as PinFootprint, Y as DEFAULT_PIN_PRESENTATION, Z as PinOverridePatch, _ as HatchPattern, a as LayerId, at as PinRender, b as fillPatternImageDimension, c as MapEvent, ct as pinDistanceScale, d as PickHandler, et as PinPresentationPatch, f as PickOptions, g as HATCH_PATTERNS, h as TextStyleOptions, i as ImageOverlayResource, it as PinPresentationStore, j as PointSymbolGraphicModifiers, k as PointSymbolColors, l as MapEventHandler, lt as pinZoomScale, m as StyleOptions, n as HandleStyle, nt as PinPresentationStatus, o as MapAdapter, ot as combinePinScale, p as PixelCoordinate, q as PointerCallback, r as IconResource, rt as PinPresentationStatusEvent, s as MapCursor, st as isValidPinNumber, t as FeatureGroup, tt as PinPresentationState, u as PickEvent, ut as resolvePinPresentation, v as MINE_PATTERN_TILE_SIZE, w as parseColor, x as fillPatternImageId, y as Rgba, z as clonePointSymbol } from "./map-adapter-DDQarsRQ.mjs";
|
|
2
2
|
import { AmplifierPlacement, AmplifierPlacements, ControlMeasure, ControlMeasureKind, ControlMeasureRender, ControlMeasureStyle, HighlightAppearance, LabelFit, SymbolColors, TextAmplifiers } from "@orbat-mapper/control-measures";
|
|
3
3
|
import { Feature, Position } from "geojson";
|
|
4
4
|
|
|
@@ -850,15 +850,26 @@ interface EditSession {
|
|
|
850
850
|
*/
|
|
851
851
|
readonly detailHandles: boolean;
|
|
852
852
|
/**
|
|
853
|
-
* The sub-selected part of a graphic whose definition divides it
|
|
854
|
-
* (`ControlMeasureTopology.partOf`), e.g. the index of the Flow
|
|
855
|
-
* selected flow (ADR-0065)
|
|
856
|
-
*
|
|
857
|
-
* a point or midpoint, or clicking the graphic's body,
|
|
858
|
-
* the pointer, and an edit or undo that removes
|
|
859
|
-
* to `0`.
|
|
853
|
+
* The primary sub-selected part of a graphic whose definition divides it
|
|
854
|
+
* into parts (`ControlMeasureTopology.partOf`), e.g. the index of the Flow
|
|
855
|
+
* Arrow's selected flow (ADR-0065): the part most recently added to
|
|
856
|
+
* [[selectedParts]]. Hosts read it to edit the part's own settings. Starts
|
|
857
|
+
* at `0`; pressing a point or midpoint, or clicking the graphic's body,
|
|
858
|
+
* selects the part under the pointer alone, and an edit or undo that removes
|
|
859
|
+
* the selected part falls back to `0`. Dragging a point or midpoint of a part
|
|
860
|
+
* that is already selected keeps the selection; a click on it without a drag
|
|
861
|
+
* selects it alone. `undefined` for graphics without parts.
|
|
860
862
|
*/
|
|
861
863
|
readonly selectedPart: number | undefined;
|
|
864
|
+
/**
|
|
865
|
+
* Every sub-selected part, [[selectedPart]] included, ascending. Reshape
|
|
866
|
+
* mode shows the option grips of each. Never empty while the graphic has
|
|
867
|
+
* parts; empty for graphics without parts. An edit or undo drops parts the
|
|
868
|
+
* graphic no longer has (promoting the primary if it went), and when the
|
|
869
|
+
* part count changes the set collapses to its primary, since parts are
|
|
870
|
+
* indices and the ones after a removed part shift.
|
|
871
|
+
*/
|
|
872
|
+
readonly selectedParts: readonly number[];
|
|
862
873
|
/**
|
|
863
874
|
* Live size anchor for the measure under edit (ADR-0020). `"ground"` bakes a
|
|
864
875
|
* pixel size to meters on commit; `"screen"` keeps it zoom-aware. Initialised
|
|
@@ -893,17 +904,31 @@ interface EditSession {
|
|
|
893
904
|
*/
|
|
894
905
|
setDetailHandles(visible: boolean): void;
|
|
895
906
|
/**
|
|
896
|
-
* Select
|
|
907
|
+
* Select `part` alone (see [[selectedPart]]), or with `extend` toggle it in
|
|
908
|
+
* or out of [[selectedParts]]: a part toggled in becomes primary; toggling
|
|
909
|
+
* the primary out promotes the most recently added remaining part; toggling
|
|
910
|
+
* out the last part is a no-op. View state only: no change event, no
|
|
897
911
|
* history entry. A no-op for a part the working graphic doesn't have, for
|
|
898
912
|
* graphics without parts, and after settlement.
|
|
899
913
|
*/
|
|
900
|
-
selectPart(part: number
|
|
914
|
+
selectPart(part: number, opts?: {
|
|
915
|
+
extend?: boolean;
|
|
916
|
+
}): void;
|
|
917
|
+
/**
|
|
918
|
+
* Replace [[selectedParts]] (e.g. "All flows"), ignoring parts the graphic
|
|
919
|
+
* doesn't have. `primary`, when it is among them, becomes [[selectedPart]];
|
|
920
|
+
* otherwise the last listed part does. View state only, like
|
|
921
|
+
* [[selectPart]]; a no-op without a valid part.
|
|
922
|
+
*/
|
|
923
|
+
selectParts(parts: readonly number[], primary?: number): void;
|
|
901
924
|
/**
|
|
902
|
-
* Subscribe to
|
|
903
|
-
* the
|
|
904
|
-
*
|
|
925
|
+
* Subscribe to part selection changes, from the pointer, [[selectPart]],
|
|
926
|
+
* [[selectParts]] or the reconcile after an edit or undo. Called once per
|
|
927
|
+
* effective change with the primary and the full set; a call that changes
|
|
928
|
+
* neither doesn't notify. Returns an unsubscribe function; registering
|
|
929
|
+
* after settlement is a no-op.
|
|
905
930
|
*/
|
|
906
|
-
onPartSelect(listener: (part: number | undefined) => void): () => void;
|
|
931
|
+
onPartSelect(listener: (part: number | undefined, parts: readonly number[]) => void): () => void;
|
|
907
932
|
/** Atomically replace the live working graphic while preserving id and kind. */
|
|
908
933
|
updateGraphic(updater: (graphic: ControlMeasure) => ControlMeasure): void;
|
|
909
934
|
/** Shallow-merge per-measure generator options into the live working copy. */
|
|
@@ -2307,12 +2332,36 @@ declare class TacticalDraw {
|
|
|
2307
2332
|
* This is a pure synchronous query over adapter-cached state: it does not
|
|
2308
2333
|
* depend on `onPick`/`"click"` dispatch having run first, so it is safe to
|
|
2309
2334
|
* call from any host click handler regardless of ordering relative to
|
|
2310
|
-
* TacticalDraw's own pick/click pipeline.
|
|
2335
|
+
* TacticalDraw's own pick/click pipeline. A press that changes what is under
|
|
2336
|
+
* the pointer (e.g. an Alt+click vertex delete) can leave the pixel empty
|
|
2337
|
+
* for the click that ends it; pair this with {@link consumedPointerCycle}.
|
|
2311
2338
|
*/
|
|
2312
2339
|
ownsInteractionAt(pixel: PixelCoordinate, options?: {
|
|
2313
2340
|
tolerance?: number;
|
|
2314
2341
|
originalEvent?: unknown;
|
|
2315
2342
|
}): InteractionHit | null;
|
|
2343
|
+
/**
|
|
2344
|
+
* Whether the active edit consumed the current pointer cycle's click — for
|
|
2345
|
+
* hosts composing their own click-away / deselection logic alongside
|
|
2346
|
+
* {@link ownsInteractionAt} (issue #668).
|
|
2347
|
+
*
|
|
2348
|
+
* Some presses change what is under the pointer, for example: Alt+click
|
|
2349
|
+
* (or a tap in `delete` mode) deletes the vertex handle that was pressed,
|
|
2350
|
+
* Alt+click on an option handle moves its grip to the reset position, and a
|
|
2351
|
+
* label or point-symbol drag moves what was pressed. The edit swallows the
|
|
2352
|
+
* click that ends such a press, but
|
|
2353
|
+
* a pixel query made from that click can find nothing there any more. Call
|
|
2354
|
+
* this from the host's own map `click` handler and treat `true` like an
|
|
2355
|
+
* owned hit, e.g. `td.ownsInteractionAt(pixel) || td.consumedPointerCycle()`.
|
|
2356
|
+
*
|
|
2357
|
+
* `true` from the press that consumed the click until the next pointerdown,
|
|
2358
|
+
* so the answer doesn't depend on whether the host's `click` handler runs
|
|
2359
|
+
* before or after TacticalDraw's own. Only meaningful inside a `click`
|
|
2360
|
+
* handler: after a drag that no click follows, it stays `true` until the
|
|
2361
|
+
* next press. `false` while idle, during draws, and once the edit has
|
|
2362
|
+
* settled.
|
|
2363
|
+
*/
|
|
2364
|
+
consumedPointerCycle(): boolean;
|
|
2316
2365
|
private toInteractionHit;
|
|
2317
2366
|
/**
|
|
2318
2367
|
* 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
|
-
|
|
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;
|
|
@@ -2723,7 +2745,8 @@ const MODIFIER_KEYS = Object.keys(KEY_PROPS);
|
|
|
2723
2745
|
const DEFAULT_EDIT_MODIFIERS = Object.freeze({
|
|
2724
2746
|
modifierDrag: Object.freeze(["ctrl", "meta"]),
|
|
2725
2747
|
deleteOrReset: "alt",
|
|
2726
|
-
constrain: "shift"
|
|
2748
|
+
constrain: "shift",
|
|
2749
|
+
extendPartSelection: false
|
|
2727
2750
|
});
|
|
2728
2751
|
function checkKey(role, key) {
|
|
2729
2752
|
if (key === false) return false;
|
|
@@ -2732,8 +2755,9 @@ function checkKey(role, key) {
|
|
|
2732
2755
|
}
|
|
2733
2756
|
/**
|
|
2734
2757
|
* Lay `patch` over `base`, validating every key. Throws a `RangeError` for an
|
|
2735
|
-
* unknown key, or when `deleteOrReset` shares a key with `modifierDrag
|
|
2736
|
-
* act on the same vertex press, so
|
|
2758
|
+
* unknown key, or when `deleteOrReset` shares a key with `modifierDrag`, or
|
|
2759
|
+
* `extendPartSelection` with either — they act on the same vertex press, so
|
|
2760
|
+
* one would silently win.
|
|
2737
2761
|
*/
|
|
2738
2762
|
function resolveEditModifiers(base, patch) {
|
|
2739
2763
|
let modifierDrag = base.modifierDrag;
|
|
@@ -2745,13 +2769,23 @@ function resolveEditModifiers(base, patch) {
|
|
|
2745
2769
|
}
|
|
2746
2770
|
const deleteOrReset = patch?.deleteOrReset !== void 0 ? checkKey("deleteOrReset", patch.deleteOrReset) : base.deleteOrReset;
|
|
2747
2771
|
const constrain = patch?.constrain !== void 0 ? checkKey("constrain", patch.constrain) : base.constrain;
|
|
2748
|
-
|
|
2772
|
+
const extendPartSelection = patch?.extendPartSelection !== void 0 ? checkKey("extendPartSelection", patch.extendPartSelection) : base.extendPartSelection;
|
|
2773
|
+
assertNoSharedKey("deleteOrReset", deleteOrReset, "modifierDrag", modifierDrag);
|
|
2774
|
+
assertNoSharedKey("extendPartSelection", extendPartSelection, "modifierDrag", modifierDrag);
|
|
2775
|
+
assertNoSharedKey("extendPartSelection", extendPartSelection, "deleteOrReset", deleteOrReset);
|
|
2749
2776
|
return Object.freeze({
|
|
2750
2777
|
modifierDrag,
|
|
2751
2778
|
deleteOrReset,
|
|
2752
|
-
constrain
|
|
2779
|
+
constrain,
|
|
2780
|
+
extendPartSelection
|
|
2753
2781
|
});
|
|
2754
2782
|
}
|
|
2783
|
+
/** Throw when `role`'s key is also one of `other`'s: both act on the same vertex press. */
|
|
2784
|
+
function assertNoSharedKey(role, key, otherRole, other) {
|
|
2785
|
+
if (!key || other === false) return;
|
|
2786
|
+
if (typeof other === "string" ? other !== key : !other.includes(key)) return;
|
|
2787
|
+
throw new RangeError(`editModifiers: ${role} and ${otherRole} both use "${key}"; they act on the same vertex press, so give them different keys`);
|
|
2788
|
+
}
|
|
2755
2789
|
/** Whether `info` reports any of `keys` held; never when the role is off. */
|
|
2756
2790
|
function modifierHeld(info, keys) {
|
|
2757
2791
|
if (!info || keys === false) return false;
|
|
@@ -4127,30 +4161,74 @@ function samePoints(a, b) {
|
|
|
4127
4161
|
}
|
|
4128
4162
|
function createPartSelection(opts) {
|
|
4129
4163
|
const { topology, isSettled, repaint } = opts;
|
|
4130
|
-
let
|
|
4164
|
+
let order = topology.parts().has(0) ? [0] : [];
|
|
4165
|
+
let partCount = topology.parts().size;
|
|
4166
|
+
let snapshot = freeze(order);
|
|
4131
4167
|
const listeners = createCommitEmitter("EditSession.onPartSelect listener errors");
|
|
4132
|
-
|
|
4133
|
-
|
|
4134
|
-
|
|
4135
|
-
|
|
4168
|
+
const primary = () => order.at(-1);
|
|
4169
|
+
/** Adopt `next` (in addition order); repaint and notify only if the set or primary changed. */
|
|
4170
|
+
function apply(next, repaintAfter) {
|
|
4171
|
+
const sorted = freeze(next);
|
|
4172
|
+
if (next.at(-1) === primary() && sameParts(sorted, snapshot)) return;
|
|
4173
|
+
order = next;
|
|
4174
|
+
snapshot = sorted;
|
|
4136
4175
|
if (repaintAfter) repaint();
|
|
4137
|
-
listeners.emit(
|
|
4176
|
+
listeners.emit({
|
|
4177
|
+
part: primary(),
|
|
4178
|
+
parts: snapshot
|
|
4179
|
+
});
|
|
4180
|
+
}
|
|
4181
|
+
/** The graphic's parts now; also records the count so `reconcile` doesn't collapse a fresh set. */
|
|
4182
|
+
function currentParts() {
|
|
4183
|
+
const parts = topology.parts();
|
|
4184
|
+
partCount = parts.size;
|
|
4185
|
+
return parts;
|
|
4138
4186
|
}
|
|
4139
4187
|
return {
|
|
4140
4188
|
get selected() {
|
|
4141
|
-
return
|
|
4189
|
+
return primary();
|
|
4190
|
+
},
|
|
4191
|
+
get parts() {
|
|
4192
|
+
return snapshot;
|
|
4193
|
+
},
|
|
4194
|
+
select(part, selectOpts) {
|
|
4195
|
+
if (isSettled() || part === void 0 || !currentParts().has(part)) return;
|
|
4196
|
+
if (!selectOpts?.extend) return apply([part], true);
|
|
4197
|
+
if (!order.includes(part)) return apply([...order, part], true);
|
|
4198
|
+
if (order.length > 1) apply(order.filter((p) => p !== part), true);
|
|
4199
|
+
},
|
|
4200
|
+
selectParts(parts, wanted) {
|
|
4201
|
+
if (isSettled()) return;
|
|
4202
|
+
const valid = currentParts();
|
|
4203
|
+
const next = [...new Set(parts.filter((p) => valid.has(p)))];
|
|
4204
|
+
if (next.length === 0) return;
|
|
4205
|
+
if (wanted !== void 0 && next.includes(wanted)) {
|
|
4206
|
+
next.splice(next.indexOf(wanted), 1);
|
|
4207
|
+
next.push(wanted);
|
|
4208
|
+
}
|
|
4209
|
+
apply(next, true);
|
|
4142
4210
|
},
|
|
4143
|
-
select,
|
|
4144
4211
|
reconcile() {
|
|
4145
|
-
if (
|
|
4146
|
-
|
|
4212
|
+
if (isSettled() || order.length === 0) return;
|
|
4213
|
+
const countBefore = partCount;
|
|
4214
|
+
const valid = currentParts();
|
|
4215
|
+
let next = order.filter((p) => valid.has(p));
|
|
4216
|
+
if (valid.size !== countBefore) next = next.slice(-1);
|
|
4217
|
+
if (next.length === 0 && valid.size > 0) next = [valid.has(0) ? 0 : Math.min(...valid)];
|
|
4218
|
+
apply(next, false);
|
|
4147
4219
|
},
|
|
4148
4220
|
onSelect(listener) {
|
|
4149
4221
|
if (isSettled()) return () => {};
|
|
4150
|
-
return listeners.register(listener);
|
|
4222
|
+
return listeners.register(({ part, parts }) => listener(part, parts));
|
|
4151
4223
|
}
|
|
4152
4224
|
};
|
|
4153
4225
|
}
|
|
4226
|
+
function freeze(parts) {
|
|
4227
|
+
return Object.freeze([...parts].sort((a, b) => a - b));
|
|
4228
|
+
}
|
|
4229
|
+
function sameParts(a, b) {
|
|
4230
|
+
return a.length === b.length && a.every((p, i) => p === b[i]);
|
|
4231
|
+
}
|
|
4154
4232
|
/**
|
|
4155
4233
|
* The part of the segment nearest `pixel` (for a click on the graphic's
|
|
4156
4234
|
* body), or `undefined` when no projectable segment carries a part.
|
|
@@ -5127,6 +5205,15 @@ function runEdit(opts) {
|
|
|
5127
5205
|
let nonGeometryDirty = false;
|
|
5128
5206
|
let dragInFlight = false;
|
|
5129
5207
|
/**
|
|
5208
|
+
* A point or midpoint press whose effect on the part selection waits for
|
|
5209
|
+
* the gesture to turn out a click or a drag: one made with the
|
|
5210
|
+
* `extendPartSelection` key held (a click toggles the part), or a plain
|
|
5211
|
+
* press on a part that is already selected (a click selects it alone, a
|
|
5212
|
+
* drag keeps the selection). A drag of a part outside the selection
|
|
5213
|
+
* selects it alone. See `resolvePressAsDrag`.
|
|
5214
|
+
*/
|
|
5215
|
+
let pendingPress = null;
|
|
5216
|
+
/**
|
|
5130
5217
|
* Mutable style snapshot. Initialised from the edit-start input; replaced
|
|
5131
5218
|
* when the façade routes an external style change to us via
|
|
5132
5219
|
* `notifyExternalMeasure`. `EditSession.measure` stays the immutable
|
|
@@ -5338,7 +5425,7 @@ function runEdit(opts) {
|
|
|
5338
5425
|
})));
|
|
5339
5426
|
const optionHandles = getControlMeasureOptionHandles(measure.kind, workingPoints, workingOptions, {
|
|
5340
5427
|
detail: detailHandles,
|
|
5341
|
-
...parts.selected !== void 0 ? { part: parts.
|
|
5428
|
+
...parts.selected !== void 0 ? { part: parts.parts } : {},
|
|
5342
5429
|
...optionHandleContext()
|
|
5343
5430
|
});
|
|
5344
5431
|
for (let index = 0; index < optionHandles.length; index++) {
|
|
@@ -5799,8 +5886,14 @@ function runEdit(opts) {
|
|
|
5799
5886
|
get selectedPart() {
|
|
5800
5887
|
return parts.selected;
|
|
5801
5888
|
},
|
|
5802
|
-
|
|
5803
|
-
parts.
|
|
5889
|
+
get selectedParts() {
|
|
5890
|
+
return parts.parts;
|
|
5891
|
+
},
|
|
5892
|
+
selectPart(part, selectOpts) {
|
|
5893
|
+
parts.select(part, selectOpts);
|
|
5894
|
+
},
|
|
5895
|
+
selectParts(selected, primary) {
|
|
5896
|
+
parts.selectParts(selected, primary);
|
|
5804
5897
|
},
|
|
5805
5898
|
onPartSelect(listener) {
|
|
5806
5899
|
return parts.onSelect(listener);
|
|
@@ -6066,6 +6159,7 @@ function runEdit(opts) {
|
|
|
6066
6159
|
}
|
|
6067
6160
|
const onDriverDown = (pixel, info) => {
|
|
6068
6161
|
if (ctx.settled || dragInFlight) return;
|
|
6162
|
+
pendingPress = null;
|
|
6069
6163
|
const tol = info?.hitTolerance ?? 12;
|
|
6070
6164
|
if (modes.includes("labeldrag") && labels.onDown(pixel, tol)) {
|
|
6071
6165
|
dragInFlight = true;
|
|
@@ -6087,9 +6181,19 @@ function runEdit(opts) {
|
|
|
6087
6181
|
shell.suppressNextClickAway();
|
|
6088
6182
|
return;
|
|
6089
6183
|
}
|
|
6090
|
-
|
|
6091
|
-
|
|
6092
|
-
if (
|
|
6184
|
+
const pressedPart = hit.kind === "vertex" ? topology.partOf(hit.index) : hit.kind === "midpoint" ? hit.segment?.part : void 0;
|
|
6185
|
+
const extend = modifierHeld(info, keys().extendPartSelection);
|
|
6186
|
+
if (pressedPart !== void 0 && (extend || parts.parts.includes(pressedPart))) pendingPress = {
|
|
6187
|
+
part: pressedPart,
|
|
6188
|
+
downPixel: pixel,
|
|
6189
|
+
extend
|
|
6190
|
+
};
|
|
6191
|
+
else parts.select(pressedPart);
|
|
6192
|
+
if (hit.kind === "vertex" && modifierHeld(info, keys().modifierDrag) && startModifierDrag(hit.index, pixel, tol)) {
|
|
6193
|
+
if (pendingPress) parts.select(pendingPress.part);
|
|
6194
|
+
pendingPress = null;
|
|
6195
|
+
return;
|
|
6196
|
+
}
|
|
6093
6197
|
const optionModifier = hit.kind === "option" && modifierHeld(info, keys().modifierDrag);
|
|
6094
6198
|
if (hit.kind === "option" && hit.optionId && deleteOrReset) {
|
|
6095
6199
|
const patch = resetControlMeasureOptionHandle(measure.kind, workingPoints, workingOptions, hit.optionId, optionHandleContext(optionModifier));
|
|
@@ -6259,8 +6363,15 @@ function runEdit(opts) {
|
|
|
6259
6363
|
recomputeDirty();
|
|
6260
6364
|
transient.emit("move", snapshot.points, null);
|
|
6261
6365
|
}
|
|
6366
|
+
/** A pending press turned into a drag: it keeps the selection, or selects an unselected part alone. */
|
|
6367
|
+
function resolvePressAsDrag() {
|
|
6368
|
+
const part = pendingPress.part;
|
|
6369
|
+
pendingPress = null;
|
|
6370
|
+
if (!parts.parts.includes(part)) parts.select(part);
|
|
6371
|
+
}
|
|
6262
6372
|
const onDriverMove = (pixel, info) => {
|
|
6263
6373
|
if (ctx.settled) return;
|
|
6374
|
+
if (pendingPress && !withinClickSlop(pixel, pendingPress.downPixel)) resolvePressAsDrag();
|
|
6264
6375
|
if (labels.dragging) {
|
|
6265
6376
|
const patch = labels.onMove(pixel);
|
|
6266
6377
|
if (patch) {
|
|
@@ -6354,6 +6465,24 @@ function runEdit(opts) {
|
|
|
6354
6465
|
const { fsm, preDragPoints, preDragOptions, controlPointIndex } = activeDrag;
|
|
6355
6466
|
activeDrag = null;
|
|
6356
6467
|
driver.setDragPanEnabled(true);
|
|
6468
|
+
const press = pendingPress;
|
|
6469
|
+
if (press && !withinClickSlop(pixel, press.downPixel)) resolvePressAsDrag();
|
|
6470
|
+
else if (press && !press.extend) {
|
|
6471
|
+
pendingPress = null;
|
|
6472
|
+
parts.select(press.part);
|
|
6473
|
+
} else if (press) {
|
|
6474
|
+
pendingPress = null;
|
|
6475
|
+
deferred.end();
|
|
6476
|
+
transient.emit("end", preDragPoints, controlPointIndex);
|
|
6477
|
+
replaceWorkingPoints(preDragPoints);
|
|
6478
|
+
workingOptions = preDragOptions;
|
|
6479
|
+
renderWorkingGraphic();
|
|
6480
|
+
recomputeDirty();
|
|
6481
|
+
endDragBookkeeping();
|
|
6482
|
+
parts.select(press.part, { extend: true });
|
|
6483
|
+
renderHandlesLayer();
|
|
6484
|
+
return;
|
|
6485
|
+
}
|
|
6357
6486
|
const snapped = snapDrag(pixel, (at) => reshapeTarget(at, info, controlPointIndex));
|
|
6358
6487
|
deferred.finish(releaseDeferred(snapped.pixel, snapped.target), (finalPixel) => {
|
|
6359
6488
|
const next = fsm.end(finalPixel, { constrainAngles: constrainHeld(info) });
|
|
@@ -6427,7 +6556,7 @@ function runEdit(opts) {
|
|
|
6427
6556
|
onMove: onDriverMove,
|
|
6428
6557
|
onUp: onDriverUp,
|
|
6429
6558
|
ownsGraphic: (id) => id === measure.id,
|
|
6430
|
-
onOwnClick: (event) => parts.select(partNearestPixel(event.pixel, topology.segments(), workingPoints, (p) => driver.toPixel(p))),
|
|
6559
|
+
onOwnClick: (event) => parts.select(partNearestPixel(event.pixel, topology.segments(), workingPoints, (p) => driver.toPixel(p)), { extend: eventModifierHeld(event.originalEvent, keys().extendPartSelection) }),
|
|
6431
6560
|
close: () => {
|
|
6432
6561
|
ctx.commit(rebuildRendered);
|
|
6433
6562
|
},
|
|
@@ -6462,6 +6591,9 @@ function runEdit(opts) {
|
|
|
6462
6591
|
get settled() {
|
|
6463
6592
|
return core.settled;
|
|
6464
6593
|
},
|
|
6594
|
+
get pointerCycleConsumed() {
|
|
6595
|
+
return core.pointerCycleConsumed;
|
|
6596
|
+
},
|
|
6465
6597
|
usesGraphicStack: true,
|
|
6466
6598
|
measureId: measure.id,
|
|
6467
6599
|
abort(reason, cause) {
|
|
@@ -7885,6 +8017,9 @@ function runGroupTransform(opts) {
|
|
|
7885
8017
|
get settled() {
|
|
7886
8018
|
return core.settled;
|
|
7887
8019
|
},
|
|
8020
|
+
get pointerCycleConsumed() {
|
|
8021
|
+
return core.pointerCycleConsumed;
|
|
8022
|
+
},
|
|
7888
8023
|
get graphicIds() {
|
|
7889
8024
|
return members.map((m) => m.graphic.id);
|
|
7890
8025
|
},
|
|
@@ -8396,6 +8531,9 @@ function runPointSymbolEdit(opts) {
|
|
|
8396
8531
|
get settled() {
|
|
8397
8532
|
return handle.settled;
|
|
8398
8533
|
},
|
|
8534
|
+
get pointerCycleConsumed() {
|
|
8535
|
+
return handle.pointerCycleConsumed;
|
|
8536
|
+
},
|
|
8399
8537
|
get usesGraphicStack() {
|
|
8400
8538
|
return usesGraphicStack;
|
|
8401
8539
|
},
|
|
@@ -8728,6 +8866,9 @@ function runImageEdit(opts) {
|
|
|
8728
8866
|
get settled() {
|
|
8729
8867
|
return handle.settled;
|
|
8730
8868
|
},
|
|
8869
|
+
get pointerCycleConsumed() {
|
|
8870
|
+
return handle.pointerCycleConsumed;
|
|
8871
|
+
},
|
|
8731
8872
|
get usesGraphicStack() {
|
|
8732
8873
|
return usesGraphicStack;
|
|
8733
8874
|
},
|
|
@@ -9105,6 +9246,9 @@ function runMarkerEdit(opts) {
|
|
|
9105
9246
|
get settled() {
|
|
9106
9247
|
return handle.settled;
|
|
9107
9248
|
},
|
|
9249
|
+
get pointerCycleConsumed() {
|
|
9250
|
+
return handle.pointerCycleConsumed;
|
|
9251
|
+
},
|
|
9108
9252
|
get usesGraphicStack() {
|
|
9109
9253
|
return usesGraphicStack;
|
|
9110
9254
|
},
|
|
@@ -10458,7 +10602,9 @@ var TacticalDraw = class {
|
|
|
10458
10602
|
* This is a pure synchronous query over adapter-cached state: it does not
|
|
10459
10603
|
* depend on `onPick`/`"click"` dispatch having run first, so it is safe to
|
|
10460
10604
|
* call from any host click handler regardless of ordering relative to
|
|
10461
|
-
* TacticalDraw's own pick/click pipeline.
|
|
10605
|
+
* TacticalDraw's own pick/click pipeline. A press that changes what is under
|
|
10606
|
+
* the pointer (e.g. an Alt+click vertex delete) can leave the pixel empty
|
|
10607
|
+
* for the click that ends it; pair this with {@link consumedPointerCycle}.
|
|
10462
10608
|
*/
|
|
10463
10609
|
ownsInteractionAt(pixel, options) {
|
|
10464
10610
|
this.assertAlive();
|
|
@@ -10534,6 +10680,31 @@ var TacticalDraw = class {
|
|
|
10534
10680
|
}
|
|
10535
10681
|
return null;
|
|
10536
10682
|
}
|
|
10683
|
+
/**
|
|
10684
|
+
* Whether the active edit consumed the current pointer cycle's click — for
|
|
10685
|
+
* hosts composing their own click-away / deselection logic alongside
|
|
10686
|
+
* {@link ownsInteractionAt} (issue #668).
|
|
10687
|
+
*
|
|
10688
|
+
* Some presses change what is under the pointer, for example: Alt+click
|
|
10689
|
+
* (or a tap in `delete` mode) deletes the vertex handle that was pressed,
|
|
10690
|
+
* Alt+click on an option handle moves its grip to the reset position, and a
|
|
10691
|
+
* label or point-symbol drag moves what was pressed. The edit swallows the
|
|
10692
|
+
* click that ends such a press, but
|
|
10693
|
+
* a pixel query made from that click can find nothing there any more. Call
|
|
10694
|
+
* this from the host's own map `click` handler and treat `true` like an
|
|
10695
|
+
* owned hit, e.g. `td.ownsInteractionAt(pixel) || td.consumedPointerCycle()`.
|
|
10696
|
+
*
|
|
10697
|
+
* `true` from the press that consumed the click until the next pointerdown,
|
|
10698
|
+
* so the answer doesn't depend on whether the host's `click` handler runs
|
|
10699
|
+
* before or after TacticalDraw's own. Only meaningful inside a `click`
|
|
10700
|
+
* handler: after a drag that no click follows, it stays `true` until the
|
|
10701
|
+
* next press. `false` while idle, during draws, and once the edit has
|
|
10702
|
+
* settled.
|
|
10703
|
+
*/
|
|
10704
|
+
consumedPointerCycle() {
|
|
10705
|
+
this.assertAlive();
|
|
10706
|
+
return this.activeInteraction.pointerCycleConsumed;
|
|
10707
|
+
}
|
|
10537
10708
|
toInteractionHit(layer, feature) {
|
|
10538
10709
|
const measureId = tryControlMeasureIdFromFeature(feature);
|
|
10539
10710
|
return measureId != null ? {
|
|
@@ -244,12 +244,29 @@ interface EditModifiers {
|
|
|
244
244
|
* @default "shift"
|
|
245
245
|
*/
|
|
246
246
|
constrain?: ModifierKey | false;
|
|
247
|
+
/**
|
|
248
|
+
* Click a point, a midpoint or the body of a graphic with parts (e.g. a Flow
|
|
249
|
+
* Arrow's flows) with this key held to toggle that part in or out of the
|
|
250
|
+
* edit session's part selection instead of selecting it alone (see
|
|
251
|
+
* `EditSession.selectedParts`). A drag with the key held is a plain
|
|
252
|
+
* drag, so it may share the `constrain` key (Shift-drag constrains,
|
|
253
|
+
* Shift-click extends). Must not share a key with `modifierDrag` or
|
|
254
|
+
* `deleteOrReset`, which act on the same press. Point and midpoint presses
|
|
255
|
+
* read the key from the edit pointer events; a body click reads it from the
|
|
256
|
+
* engine's click event.
|
|
257
|
+
*
|
|
258
|
+
* Off by default: a host that synthesises the constrain key on every event
|
|
259
|
+
* (to make constraining persistent) would otherwise extend on every click.
|
|
260
|
+
* @default false
|
|
261
|
+
*/
|
|
262
|
+
extendPartSelection?: ModifierKey | false;
|
|
247
263
|
}
|
|
248
264
|
/** {@link EditModifiers} with every role filled in, as `getEditModifiers()` returns it. */
|
|
249
265
|
interface ResolvedEditModifiers {
|
|
250
266
|
modifierDrag: readonly ModifierKey[] | false;
|
|
251
267
|
deleteOrReset: ModifierKey | false;
|
|
252
268
|
constrain: ModifierKey | false;
|
|
269
|
+
extendPartSelection: ModifierKey | false;
|
|
253
270
|
}
|
|
254
271
|
declare const DEFAULT_EDIT_MODIFIERS: ResolvedEditModifiers;
|
|
255
272
|
//#endregion
|
package/dist/testing.d.mts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { a as LayerId, o as MapAdapter, p as PixelCoordinate } from "./map-adapter-
|
|
1
|
+
import { a as LayerId, o as MapAdapter, p as PixelCoordinate } from "./map-adapter-DDQarsRQ.mjs";
|
|
2
2
|
import { Feature } from "geojson";
|
|
3
3
|
|
|
4
4
|
//#region src/testing/feature-group-conformance.d.ts
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@orbat-mapper/tactical-draw",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.28.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",
|
|
@@ -39,7 +39,7 @@
|
|
|
39
39
|
"access": "public"
|
|
40
40
|
},
|
|
41
41
|
"dependencies": {
|
|
42
|
-
"@orbat-mapper/control-measures": "^0.
|
|
42
|
+
"@orbat-mapper/control-measures": "^0.43.0"
|
|
43
43
|
},
|
|
44
44
|
"peerDependencies": {
|
|
45
45
|
"vitest": ">=4.0.0"
|