@oicl/openbridge-webcomponents-full-bundle 2.0.0-next.170 → 2.0.0-next.171
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/bundle/openbridge-webcomponents.bundle.js +870 -441
- package/bundle/openbridge-webcomponents.bundle.js.map +1 -1
- package/custom-elements.json +1110 -383
- package/dist/ar/poi/poi-aton.d.ts +1 -0
- package/dist/ar/poi/poi-aton.d.ts.map +1 -1
- package/dist/ar/poi/poi-aton.js +1 -0
- package/dist/ar/poi/poi-aton.js.map +1 -1
- package/dist/ar/poi/poi-base.d.ts +39 -5
- package/dist/ar/poi/poi-base.d.ts.map +1 -1
- package/dist/ar/poi/poi-base.js +108 -37
- package/dist/ar/poi/poi-base.js.map +1 -1
- package/dist/ar/poi/poi-data.d.ts +1 -0
- package/dist/ar/poi/poi-data.d.ts.map +1 -1
- package/dist/ar/poi/poi-data.js +1 -0
- package/dist/ar/poi/poi-data.js.map +1 -1
- package/dist/ar/poi/poi-vessel.d.ts +1 -0
- package/dist/ar/poi/poi-vessel.d.ts.map +1 -1
- package/dist/ar/poi/poi-vessel.js +1 -0
- package/dist/ar/poi/poi-vessel.js.map +1 -1
- package/dist/ar/poi/poi.d.ts +4 -12
- package/dist/ar/poi/poi.d.ts.map +1 -1
- package/dist/ar/poi/poi.js +6 -72
- package/dist/ar/poi/poi.js.map +1 -1
- package/dist/ar/poi-button/poi-button.d.ts +6 -2
- package/dist/ar/poi-button/poi-button.d.ts.map +1 -1
- package/dist/ar/poi-button/poi-button.js +10 -1
- package/dist/ar/poi-button/poi-button.js.map +1 -1
- package/dist/ar/poi-card/poi-card.d.ts +12 -1
- package/dist/ar/poi-card/poi-card.d.ts.map +1 -1
- package/dist/ar/poi-card/poi-card.js +4 -1
- package/dist/ar/poi-card/poi-card.js.map +1 -1
- package/dist/ar/poi-controller/poi-controller.d.ts +45 -1
- package/dist/ar/poi-controller/poi-controller.d.ts.map +1 -1
- package/dist/ar/poi-controller/poi-controller.js +72 -14
- package/dist/ar/poi-controller/poi-controller.js.map +1 -1
- package/dist/ar/poi-group/poi-group.d.ts +28 -5
- package/dist/ar/poi-group/poi-group.d.ts.map +1 -1
- package/dist/ar/poi-group/poi-group.js +50 -7
- package/dist/ar/poi-group/poi-group.js.map +1 -1
- package/dist/ar/poi-layer/poi-layer.css.js +69 -18
- package/dist/ar/poi-layer/poi-layer.css.js.map +1 -1
- package/dist/ar/poi-layer/poi-layer.d.ts +64 -5
- package/dist/ar/poi-layer/poi-layer.d.ts.map +1 -1
- package/dist/ar/poi-layer/poi-layer.js +173 -39
- package/dist/ar/poi-layer/poi-layer.js.map +1 -1
- package/dist/ar/poi-layer-stack/poi-layer-stack.d.ts +82 -7
- package/dist/ar/poi-layer-stack/poi-layer-stack.d.ts.map +1 -1
- package/dist/ar/poi-layer-stack/poi-layer-stack.js +172 -100
- package/dist/ar/poi-layer-stack/poi-layer-stack.js.map +1 -1
- package/dist/ar/poi-projection/poi-projection.d.ts +88 -0
- package/dist/ar/poi-projection/poi-projection.d.ts.map +1 -0
- package/dist/ar/poi-projection/poi-projection.js +90 -0
- package/dist/ar/poi-projection/poi-projection.js.map +1 -0
- package/docs/MigrationGuide.mdx +61 -5
- package/docs/migration-guide/a11y-labels.md +8 -0
- package/docs/migration-guide/api-automation.md +1 -0
- package/package.json +2 -2
- package/src/ar/_test-utils.ts +18 -6
- package/src/ar/poi/poi-aton.ts +2 -0
- package/src/ar/poi/poi-base.ts +159 -70
- package/src/ar/poi/poi-data.ts +2 -0
- package/src/ar/poi/poi-dom-ownership.spec.ts +393 -0
- package/src/ar/poi/poi-vessel.ts +2 -0
- package/src/ar/poi/poi.ts +12 -113
- package/src/ar/poi-button/poi-button.ts +25 -3
- package/src/ar/poi-card/poi-card.ts +16 -2
- package/src/ar/poi-controller/poi-controller.spec.ts +54 -0
- package/src/ar/poi-controller/poi-controller.stories.ts +76 -24
- package/src/ar/poi-controller/poi-controller.ts +111 -41
- package/src/ar/poi-group/poi-group.stories.ts +18 -5
- package/src/ar/poi-group/poi-group.ts +87 -12
- package/src/ar/poi-layer/poi-layer.css +69 -18
- package/src/ar/poi-layer/poi-layer.stories.ts +30 -16
- package/src/ar/poi-layer/poi-layer.ts +289 -64
- package/src/ar/poi-layer-stack/poi-layer-stack.stories.ts +56 -23
- package/src/ar/poi-layer-stack/poi-layer-stack.ts +342 -247
- package/src/ar/poi-projection/poi-projection.stories.ts +100 -0
- package/src/ar/poi-projection/poi-projection.ts +147 -0
|
@@ -23,6 +23,22 @@ export enum PoiLayerSelectionMode {
|
|
|
23
23
|
Multi = 'multi',
|
|
24
24
|
}
|
|
25
25
|
|
|
26
|
+
/**
|
|
27
|
+
* Tracking record for a selected target. The stack never re-parents targets;
|
|
28
|
+
* it renders selection by projecting the target's button (and, for targets
|
|
29
|
+
* authored inside the selected layer, its pointer) between layers via CSS
|
|
30
|
+
* custom properties.
|
|
31
|
+
*/
|
|
32
|
+
type SelectionRecord = {
|
|
33
|
+
/** The layer that owns the target in the DOM. Never modified by the stack. */
|
|
34
|
+
homeLayer: ObcPoiLayer;
|
|
35
|
+
/**
|
|
36
|
+
* The logical origin layer: equal to `homeLayer` for normal targets;
|
|
37
|
+
* inferred for targets authored directly inside the selected layer.
|
|
38
|
+
*/
|
|
39
|
+
originLayer: ObcPoiLayer;
|
|
40
|
+
};
|
|
41
|
+
|
|
26
42
|
/**
|
|
27
43
|
* `<obc-poi-layer-stack>` coordinates multiple POI layers and manages
|
|
28
44
|
* selection behavior across stacked layers.
|
|
@@ -30,6 +46,36 @@ export enum PoiLayerSelectionMode {
|
|
|
30
46
|
* Use `selection-mode` to control whether targets can be selected across the
|
|
31
47
|
* stack (`none`, `single`, or `multi`).
|
|
32
48
|
*
|
|
49
|
+
* ### Required Setup
|
|
50
|
+
* 1. Place the stack in `obc-poi-controller`'s `slot="stack"`, or manage the
|
|
51
|
+
* stack's height and media geometry yourself.
|
|
52
|
+
* 2. Give exactly one child `obc-poi-layer` the `is-selected` attribute — the
|
|
53
|
+
* stack projects selected targets' buttons into it and resets all
|
|
54
|
+
* selection state if no selected layer exists.
|
|
55
|
+
* 3. Mark the background/default layer with
|
|
56
|
+
* `data-controller-layer="background"` when the stack is used inside
|
|
57
|
+
* `obc-poi-controller`.
|
|
58
|
+
* 4. Set `--obc-poi-layer-min-height` on layers that can start empty, so they
|
|
59
|
+
* do not collapse to 0px height.
|
|
60
|
+
*
|
|
61
|
+
* ### DOM Ownership
|
|
62
|
+
* The stack never moves, creates, or removes consumer-owned DOM. Selection is
|
|
63
|
+
* rendered by projecting the target's button into the selected layer via CSS
|
|
64
|
+
* custom properties (`--obc-poi-button-projection-y` /
|
|
65
|
+
* `--obc-poi-target-projection-y`); the target element stays where the
|
|
66
|
+
* consumer put it. Declarative renderers (React, Vue, Lit) can manage POI
|
|
67
|
+
* children as ordinary framework-owned elements.
|
|
68
|
+
*
|
|
69
|
+
* ### Selection API
|
|
70
|
+
* Selection state is fully reachable without DOM inspection:
|
|
71
|
+
* - `selectedTargets` — the currently selected POI targets.
|
|
72
|
+
* - `selectTarget(target, {selectionId?})` — select programmatically;
|
|
73
|
+
* `selectionId` presets the stack-managed badge id.
|
|
74
|
+
* - `deselectTarget(target)` / `clearSelection()` — deselect one/all.
|
|
75
|
+
* - `selection-change` event — fired on every selection mutation
|
|
76
|
+
* (user click, programmatic call, or bootstrap seeding) with
|
|
77
|
+
* `{selected, added, removed}` in `detail`.
|
|
78
|
+
*
|
|
33
79
|
* ### Slots
|
|
34
80
|
* - Default slot for `obc-poi-layer` elements that participate in the stack.
|
|
35
81
|
*
|
|
@@ -42,6 +88,7 @@ export enum PoiLayerSelectionMode {
|
|
|
42
88
|
* ```
|
|
43
89
|
*
|
|
44
90
|
* @slot - Layers participating in the stack.
|
|
91
|
+
* @fires {CustomEvent<{selected: Poi[]; added: Poi | null; removed: Poi | null}>} selection-change - Fired whenever the selection set changes (user click, programmatic call, or bootstrap seeding). Bubbles and is composed.
|
|
45
92
|
* @experimental
|
|
46
93
|
*/
|
|
47
94
|
@customElement('obc-poi-layer-stack')
|
|
@@ -56,14 +103,14 @@ export class ObcPoiLayerStack extends LitElement {
|
|
|
56
103
|
private handleSlotChange = () => this.schedulePlacement();
|
|
57
104
|
private handleTargetLayoutChange = () => this.schedulePlacement();
|
|
58
105
|
private handleLayerSelectionChanged = () => this.schedulePlacement();
|
|
59
|
-
private selectionMap = new Map<
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
>();
|
|
106
|
+
private selectionMap = new Map<Poi, SelectionRecord>();
|
|
107
|
+
/**
|
|
108
|
+
* Deselected targets that live in one layer but render in another (targets
|
|
109
|
+
* authored inside the selected layer whose logical origin is a different
|
|
110
|
+
* layer). Their projections are refreshed on every placement pass so layer
|
|
111
|
+
* resizes do not leave stale pixel offsets.
|
|
112
|
+
*/
|
|
113
|
+
private displacedTargets = new Map<Poi, SelectionRecord>();
|
|
67
114
|
private selectionCounter = 0;
|
|
68
115
|
private placementRaf = 0;
|
|
69
116
|
private mutationObserver?: MutationObserver;
|
|
@@ -116,6 +163,11 @@ export class ObcPoiLayerStack extends LitElement {
|
|
|
116
163
|
this.requestPoiRender(target);
|
|
117
164
|
});
|
|
118
165
|
this.selectionMap.clear();
|
|
166
|
+
this.displacedTargets.forEach((_, target) => {
|
|
167
|
+
this.clearTargetProjectionStyles(target);
|
|
168
|
+
this.requestPoiRender(target);
|
|
169
|
+
});
|
|
170
|
+
this.displacedTargets.clear();
|
|
119
171
|
this.selectionCounter = 0;
|
|
120
172
|
}
|
|
121
173
|
|
|
@@ -126,33 +178,94 @@ export class ObcPoiLayerStack extends LitElement {
|
|
|
126
178
|
if (target.hasAttribute(ObcPoiLayerStack.STACK_RETURNING_ATTR)) return;
|
|
127
179
|
|
|
128
180
|
this.cleanupSelection();
|
|
129
|
-
const originLayer = this.getTargetLayer(target);
|
|
130
|
-
if (!originLayer) return;
|
|
131
|
-
|
|
132
|
-
const selectedLayer = this.getLayer('selected') ?? this.getLayer('top');
|
|
133
|
-
if (!selectedLayer) return;
|
|
134
|
-
|
|
135
181
|
const existing = this.selectionMap.get(target);
|
|
136
182
|
if (existing) {
|
|
137
183
|
this.resetSelectionForTarget(target, existing);
|
|
138
184
|
return;
|
|
139
185
|
}
|
|
186
|
+
this.performSelection(target);
|
|
187
|
+
}
|
|
188
|
+
|
|
189
|
+
/** Currently selected POI targets. */
|
|
190
|
+
get selectedTargets(): Poi[] {
|
|
191
|
+
this.cleanupSelection();
|
|
192
|
+
return Array.from(this.selectionMap.keys());
|
|
193
|
+
}
|
|
194
|
+
|
|
195
|
+
/**
|
|
196
|
+
* Programmatically select a target, following the same flow as a user
|
|
197
|
+
* click. `options.selectionId` presets the badge id shown in the
|
|
198
|
+
* stack-managed header; without it the id auto-increments. Returns
|
|
199
|
+
* `false` when selection is disabled, the target is mid-transition or
|
|
200
|
+
* already selected, or no layer can host the selection.
|
|
201
|
+
*/
|
|
202
|
+
selectTarget(target: Poi, options?: {selectionId?: string}): boolean {
|
|
203
|
+
if (this.selectionMode === PoiLayerSelectionMode.None) return false;
|
|
204
|
+
if (target.hasAttribute(ObcPoiLayerStack.STACK_RETURNING_ATTR)) {
|
|
205
|
+
return false;
|
|
206
|
+
}
|
|
207
|
+
this.cleanupSelection();
|
|
208
|
+
if (this.selectionMap.has(target)) return false;
|
|
209
|
+
return this.performSelection(target, options?.selectionId);
|
|
210
|
+
}
|
|
211
|
+
|
|
212
|
+
/**
|
|
213
|
+
* Programmatically deselect a target. Returns `false` when it is not
|
|
214
|
+
* selected.
|
|
215
|
+
*/
|
|
216
|
+
deselectTarget(target: Poi): boolean {
|
|
217
|
+
const record = this.selectionMap.get(target);
|
|
218
|
+
if (!record) return false;
|
|
219
|
+
this.resetSelectionForTarget(target, record);
|
|
220
|
+
return true;
|
|
221
|
+
}
|
|
222
|
+
|
|
223
|
+
/** Deselect all targets. */
|
|
224
|
+
clearSelection(): void {
|
|
225
|
+
Array.from(this.selectionMap.entries()).forEach(([target, record]) => {
|
|
226
|
+
this.resetSelectionForTarget(target, record);
|
|
227
|
+
});
|
|
228
|
+
}
|
|
229
|
+
|
|
230
|
+
private performSelection(target: Poi, selectionId?: string): boolean {
|
|
231
|
+
const homeLayer = this.getTargetLayer(target);
|
|
232
|
+
if (!homeLayer) return false;
|
|
233
|
+
|
|
234
|
+
const selectedLayer = this.getLayer('selected') ?? this.getLayer('top');
|
|
235
|
+
if (!selectedLayer) return false;
|
|
140
236
|
|
|
141
237
|
if (this.selectionMode === PoiLayerSelectionMode.Single) {
|
|
142
238
|
this.clearOtherTopSelections(target);
|
|
143
239
|
this.clearSelectionMapExcept(target);
|
|
144
240
|
}
|
|
145
241
|
|
|
146
|
-
const
|
|
147
|
-
|
|
242
|
+
const displaced = this.displacedTargets.get(target);
|
|
243
|
+
this.displacedTargets.delete(target);
|
|
244
|
+
const originLayer =
|
|
245
|
+
displaced?.originLayer ??
|
|
246
|
+
(homeLayer === selectedLayer
|
|
148
247
|
? this.inferBootstrapOriginLayer(target, selectedLayer)
|
|
149
|
-
:
|
|
248
|
+
: homeLayer);
|
|
150
249
|
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
250
|
+
if (selectionId) {
|
|
251
|
+
target.setAttribute('data-stack-selection-id', selectionId);
|
|
252
|
+
}
|
|
253
|
+
const record: SelectionRecord = {homeLayer, originLayer};
|
|
254
|
+
this.selectionMap.set(target, record);
|
|
154
255
|
this.activateTrackedTarget(target, record, selectedLayer);
|
|
155
256
|
this.schedulePlacement();
|
|
257
|
+
this.dispatchSelectionChange(target, null);
|
|
258
|
+
return true;
|
|
259
|
+
}
|
|
260
|
+
|
|
261
|
+
private dispatchSelectionChange(added: Poi | null, removed: Poi | null) {
|
|
262
|
+
this.dispatchEvent(
|
|
263
|
+
new CustomEvent('selection-change', {
|
|
264
|
+
detail: {selected: this.selectedTargets, added, removed},
|
|
265
|
+
bubbles: true,
|
|
266
|
+
composed: true,
|
|
267
|
+
})
|
|
268
|
+
);
|
|
156
269
|
}
|
|
157
270
|
|
|
158
271
|
private getPoiTargetFromEvent(event: Event): Poi | null {
|
|
@@ -195,6 +308,11 @@ export class ObcPoiLayerStack extends LitElement {
|
|
|
195
308
|
this.selectionMap.delete(target);
|
|
196
309
|
}
|
|
197
310
|
});
|
|
311
|
+
this.displacedTargets.forEach((_, target) => {
|
|
312
|
+
if (!target.isConnected) {
|
|
313
|
+
this.displacedTargets.delete(target);
|
|
314
|
+
}
|
|
315
|
+
});
|
|
198
316
|
}
|
|
199
317
|
|
|
200
318
|
private getLayer(
|
|
@@ -224,6 +342,7 @@ export class ObcPoiLayerStack extends LitElement {
|
|
|
224
342
|
const topTargets = this.getLayerTargets(activeLayer);
|
|
225
343
|
topTargets.forEach((other) => {
|
|
226
344
|
if (other === target) return;
|
|
345
|
+
if (this.displacedTargets.has(other)) return;
|
|
227
346
|
const record = this.selectionMap.get(other);
|
|
228
347
|
this.resetSelectionForTarget(other, record);
|
|
229
348
|
});
|
|
@@ -338,44 +457,115 @@ export class ObcPoiLayerStack extends LitElement {
|
|
|
338
457
|
target.refreshProjectionLayout?.(trackDurationMs);
|
|
339
458
|
}
|
|
340
459
|
|
|
341
|
-
private
|
|
342
|
-
const raw = target.style.getPropertyValue(
|
|
460
|
+
private getInlineVarPx(target: Poi, name: string): number {
|
|
461
|
+
const raw = target.style.getPropertyValue(name);
|
|
343
462
|
const parsed = Number.parseFloat(raw);
|
|
344
463
|
return Number.isFinite(parsed) ? parsed : 0;
|
|
345
464
|
}
|
|
346
465
|
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
): number {
|
|
351
|
-
if (!destinationLayer || destinationLayer === originLayer) {
|
|
466
|
+
/** Pixel delta between two layers' bottom edges (`to.bottom - from.bottom`). */
|
|
467
|
+
private layerBottomDelta(from: ObcPoiLayer, to: ObcPoiLayer): number {
|
|
468
|
+
if (from === to) {
|
|
352
469
|
return 0;
|
|
353
470
|
}
|
|
471
|
+
return (
|
|
472
|
+
to.getBoundingClientRect().bottom - from.getBoundingClientRect().bottom
|
|
473
|
+
);
|
|
474
|
+
}
|
|
354
475
|
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
476
|
+
private setProjectionVar(target: Poi, name: string, valuePx: number) {
|
|
477
|
+
if (Math.abs(valuePx) < 0.5) {
|
|
478
|
+
target.style.removeProperty(name);
|
|
479
|
+
} else {
|
|
480
|
+
target.style.setProperty(name, `${valuePx}px`);
|
|
481
|
+
}
|
|
358
482
|
}
|
|
359
483
|
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
484
|
+
/**
|
|
485
|
+
* Render the target at the given projection offsets without touching its
|
|
486
|
+
* DOM position. When `animate` is set and an offset actually changes, the
|
|
487
|
+
* jump is FLIP-animated via the Web Animations API.
|
|
488
|
+
*/
|
|
489
|
+
private async applyTargetProjection(
|
|
490
|
+
target: Poi,
|
|
491
|
+
buttonOffsetPx: number,
|
|
492
|
+
targetOffsetPx: number,
|
|
493
|
+
animate: boolean
|
|
494
|
+
) {
|
|
495
|
+
const currentButton = this.getInlineVarPx(
|
|
496
|
+
target,
|
|
497
|
+
'--obc-poi-button-projection-y'
|
|
498
|
+
);
|
|
499
|
+
const currentTarget = this.getInlineVarPx(
|
|
500
|
+
target,
|
|
501
|
+
'--obc-poi-target-projection-y'
|
|
502
|
+
);
|
|
503
|
+
const changed =
|
|
504
|
+
Math.abs(buttonOffsetPx - currentButton) >= 0.5 ||
|
|
505
|
+
Math.abs(targetOffsetPx - currentTarget) >= 0.5;
|
|
506
|
+
|
|
507
|
+
if (!changed) {
|
|
508
|
+
this.setProjectionVar(
|
|
509
|
+
target,
|
|
510
|
+
'--obc-poi-button-projection-y',
|
|
511
|
+
buttonOffsetPx
|
|
512
|
+
);
|
|
513
|
+
this.setProjectionVar(
|
|
514
|
+
target,
|
|
515
|
+
'--obc-poi-target-projection-y',
|
|
516
|
+
targetOffsetPx
|
|
517
|
+
);
|
|
518
|
+
this.requestPoiRender(target);
|
|
519
|
+
this.refreshTargetProjectionLayout(target);
|
|
520
|
+
return;
|
|
366
521
|
}
|
|
367
522
|
|
|
368
|
-
const
|
|
369
|
-
const
|
|
370
|
-
|
|
523
|
+
const {button, line} = this.getAnimationElements(target);
|
|
524
|
+
const beforeButtonRect = animate
|
|
525
|
+
? (button?.getBoundingClientRect() ?? null)
|
|
526
|
+
: null;
|
|
527
|
+
const beforeLineRect = animate
|
|
528
|
+
? (line?.getBoundingClientRect() ?? null)
|
|
529
|
+
: null;
|
|
530
|
+
|
|
531
|
+
this.setProjectionVar(
|
|
532
|
+
target,
|
|
533
|
+
'--obc-poi-button-projection-y',
|
|
534
|
+
buttonOffsetPx
|
|
535
|
+
);
|
|
536
|
+
this.setProjectionVar(
|
|
537
|
+
target,
|
|
538
|
+
'--obc-poi-target-projection-y',
|
|
539
|
+
targetOffsetPx
|
|
540
|
+
);
|
|
541
|
+
this.requestPoiRender(target);
|
|
542
|
+
this.refreshTargetProjectionLayout(target);
|
|
543
|
+
if (!animate) {
|
|
544
|
+
return;
|
|
545
|
+
}
|
|
546
|
+
await this.waitForPoiRender(target);
|
|
547
|
+
await this.animateLayerJump(target, beforeButtonRect, beforeLineRect);
|
|
548
|
+
}
|
|
549
|
+
|
|
550
|
+
/**
|
|
551
|
+
* The group a target currently belongs to — a light-DOM parent for
|
|
552
|
+
* consumer-managed groups, or the shadow group whose member slot the
|
|
553
|
+
* target is assigned to for layer-created auto groups.
|
|
554
|
+
*/
|
|
555
|
+
private getContainingGroup(target: Poi): ObcPoiGroup | null {
|
|
556
|
+
if (target.parentElement?.tagName.toLowerCase() === 'obc-poi-group') {
|
|
557
|
+
return target.parentElement as ObcPoiGroup;
|
|
558
|
+
}
|
|
559
|
+
const slotParent = target.assignedSlot?.parentElement;
|
|
560
|
+
if (slotParent?.tagName.toLowerCase() === 'obc-poi-group') {
|
|
561
|
+
return slotParent as ObcPoiGroup;
|
|
562
|
+
}
|
|
563
|
+
return null;
|
|
371
564
|
}
|
|
372
565
|
|
|
373
566
|
private detachTargetFromCurrentGroup(target: Poi): ObcPoiLayer | null {
|
|
374
567
|
const currentLayer = this.getTargetLayer(target);
|
|
375
|
-
const sourceGroup =
|
|
376
|
-
target.parentElement?.tagName.toLowerCase() === 'obc-poi-group'
|
|
377
|
-
? (target.parentElement as ObcPoiGroup)
|
|
378
|
-
: null;
|
|
568
|
+
const sourceGroup = this.getContainingGroup(target);
|
|
379
569
|
|
|
380
570
|
if (!sourceGroup) {
|
|
381
571
|
return currentLayer;
|
|
@@ -527,165 +717,64 @@ export class ObcPoiLayerStack extends LitElement {
|
|
|
527
717
|
}
|
|
528
718
|
}
|
|
529
719
|
|
|
530
|
-
private async moveTargetIntoSelectedLayer(
|
|
531
|
-
target: Poi,
|
|
532
|
-
_originLayer: ObcPoiLayer,
|
|
533
|
-
selectedLayer: ObcPoiLayer,
|
|
534
|
-
animate = true
|
|
535
|
-
) {
|
|
536
|
-
// BEFORE: measure button and line positions
|
|
537
|
-
const {button, line} = this.getAnimationElements(target);
|
|
538
|
-
const beforeButtonRect = button?.getBoundingClientRect() ?? null;
|
|
539
|
-
const beforeLineRect = line?.getBoundingClientRect() ?? null;
|
|
540
|
-
|
|
541
|
-
// Move to destination layer
|
|
542
|
-
if (this.getTargetLayer(target) !== selectedLayer) {
|
|
543
|
-
selectedLayer.appendChild(target);
|
|
544
|
-
}
|
|
545
|
-
|
|
546
|
-
// Render at final state (no projection variables needed)
|
|
547
|
-
this.requestPoiRender(target);
|
|
548
|
-
this.refreshTargetProjectionLayout(target);
|
|
549
|
-
await this.waitForPoiRender(target);
|
|
550
|
-
|
|
551
|
-
if (!animate) return;
|
|
552
|
-
|
|
553
|
-
// AFTER: animate from old positions to new
|
|
554
|
-
await this.animateLayerJump(target, beforeButtonRect, beforeLineRect);
|
|
555
|
-
}
|
|
556
|
-
|
|
557
|
-
private async moveTrackedTargetToSelectedLayer(
|
|
558
|
-
target: Poi,
|
|
559
|
-
record: {
|
|
560
|
-
originLayer: ObcPoiLayer;
|
|
561
|
-
previousAnimatePosition: boolean;
|
|
562
|
-
keepInSelectedLayer: boolean;
|
|
563
|
-
},
|
|
564
|
-
selectedLayer: ObcPoiLayer,
|
|
565
|
-
animateProjection: boolean
|
|
566
|
-
) {
|
|
567
|
-
const currentLayer =
|
|
568
|
-
this.detachTargetFromCurrentGroup(target) ??
|
|
569
|
-
this.getTargetLayer(target) ??
|
|
570
|
-
record.originLayer;
|
|
571
|
-
|
|
572
|
-
clearTargetGroupingAttributes(target);
|
|
573
|
-
await this.moveTargetIntoSelectedLayer(
|
|
574
|
-
target,
|
|
575
|
-
record.originLayer,
|
|
576
|
-
selectedLayer,
|
|
577
|
-
animateProjection
|
|
578
|
-
);
|
|
579
|
-
|
|
580
|
-
if (currentLayer !== selectedLayer) {
|
|
581
|
-
currentLayer.requestGroupingUpdate();
|
|
582
|
-
}
|
|
583
|
-
selectedLayer.requestGroupingUpdate();
|
|
584
|
-
}
|
|
585
|
-
|
|
586
|
-
private async syncTargetProjection(
|
|
587
|
-
target: Poi,
|
|
588
|
-
originLayer: ObcPoiLayer,
|
|
589
|
-
selectedLayer: ObcPoiLayer | null,
|
|
590
|
-
animate = true
|
|
591
|
-
) {
|
|
592
|
-
const nextProjectionOffset = this.getLayerProjectionOffset(
|
|
593
|
-
originLayer,
|
|
594
|
-
selectedLayer
|
|
595
|
-
);
|
|
596
|
-
const currentProjectionOffset =
|
|
597
|
-
this.getTargetButtonProjectionOffset(target);
|
|
598
|
-
|
|
599
|
-
if (Math.abs(nextProjectionOffset - currentProjectionOffset) < 0.5) {
|
|
600
|
-
if (Math.abs(nextProjectionOffset) < 0.5) {
|
|
601
|
-
target.style.removeProperty('--obc-poi-button-projection-y');
|
|
602
|
-
} else {
|
|
603
|
-
target.style.setProperty(
|
|
604
|
-
'--obc-poi-button-projection-y',
|
|
605
|
-
`${nextProjectionOffset}px`
|
|
606
|
-
);
|
|
607
|
-
}
|
|
608
|
-
this.requestPoiRender(target);
|
|
609
|
-
this.refreshTargetProjectionLayout(target);
|
|
610
|
-
return;
|
|
611
|
-
}
|
|
612
|
-
|
|
613
|
-
if (Math.abs(nextProjectionOffset) < 0.5) {
|
|
614
|
-
target.style.removeProperty('--obc-poi-button-projection-y');
|
|
615
|
-
} else {
|
|
616
|
-
target.style.setProperty(
|
|
617
|
-
'--obc-poi-button-projection-y',
|
|
618
|
-
`${nextProjectionOffset}px`
|
|
619
|
-
);
|
|
620
|
-
}
|
|
621
|
-
this.requestPoiRender(target);
|
|
622
|
-
if (animate) {
|
|
623
|
-
this.refreshTargetProjectionLayout(
|
|
624
|
-
target,
|
|
625
|
-
ObcPoiLayerStack.STACK_JUMP_DURATION_MS
|
|
626
|
-
);
|
|
627
|
-
await this.waitForPoiRender(target);
|
|
628
|
-
return;
|
|
629
|
-
}
|
|
630
|
-
this.refreshTargetProjectionLayout(target);
|
|
631
|
-
}
|
|
632
|
-
|
|
633
720
|
private async animateTargetReturnToOrigin(
|
|
634
721
|
target: Poi,
|
|
635
|
-
record:
|
|
636
|
-
originLayer: ObcPoiLayer;
|
|
637
|
-
previousAnimatePosition: boolean;
|
|
638
|
-
keepInSelectedLayer: boolean;
|
|
639
|
-
}
|
|
722
|
+
record: SelectionRecord
|
|
640
723
|
) {
|
|
641
724
|
target.setAttribute(ObcPoiLayerStack.STACK_RETURNING_ATTR, 'true');
|
|
642
725
|
|
|
643
726
|
try {
|
|
644
|
-
const
|
|
645
|
-
this.detachTargetFromCurrentGroup(target) ??
|
|
646
|
-
this.getTargetLayer(target);
|
|
727
|
+
const sourceGroupLayer = this.detachTargetFromCurrentGroup(target);
|
|
647
728
|
|
|
648
|
-
// Clear grouping attributes immediately so the target doesn't
|
|
649
|
-
//
|
|
729
|
+
// Clear grouping attributes immediately so the target doesn't render
|
|
730
|
+
// in the origin position with data-grouped (which sets opacity:0).
|
|
650
731
|
clearTargetGroupingAttributes(target);
|
|
651
732
|
|
|
652
|
-
//
|
|
653
|
-
|
|
654
|
-
|
|
655
|
-
const
|
|
656
|
-
|
|
657
|
-
|
|
658
|
-
|
|
659
|
-
|
|
660
|
-
|
|
661
|
-
|
|
662
|
-
|
|
663
|
-
|
|
664
|
-
|
|
665
|
-
this.refreshTargetProjectionLayout(target);
|
|
666
|
-
await this.waitForPoiRender(target);
|
|
733
|
+
// Project the whole target (button and pointer) to its logical origin
|
|
734
|
+
// layer; for normal targets that is its own layer, so both offsets
|
|
735
|
+
// resolve to 0 and the inline variables are removed.
|
|
736
|
+
const originOffset = this.layerBottomDelta(
|
|
737
|
+
record.homeLayer,
|
|
738
|
+
record.originLayer
|
|
739
|
+
);
|
|
740
|
+
await this.applyTargetProjection(
|
|
741
|
+
target,
|
|
742
|
+
originOffset,
|
|
743
|
+
originOffset,
|
|
744
|
+
true
|
|
745
|
+
);
|
|
667
746
|
|
|
668
|
-
// AFTER: animate from old positions to new
|
|
669
|
-
await this.animateLayerJump(target, beforeButtonRect, beforeLineRect);
|
|
670
747
|
this.setSelectedTargetInteractivity(target, false);
|
|
671
748
|
clearTargetGroupingAttributes(target);
|
|
672
749
|
this.clearTargetSelectedId(target);
|
|
673
|
-
|
|
750
|
+
if (record.homeLayer === record.originLayer) {
|
|
751
|
+
this.clearTargetProjectionStyles(target);
|
|
752
|
+
} else {
|
|
753
|
+
// The target stays displaced into its origin layer — keep the
|
|
754
|
+
// projection variables and track it so layer resizes refresh them.
|
|
755
|
+
target.style.removeProperty(
|
|
756
|
+
'--obc-poi-forced-target-transition-duration'
|
|
757
|
+
);
|
|
758
|
+
target.style.removeProperty('--obc-poi-layer-inactive-opacity');
|
|
759
|
+
target.style.removeProperty('z-index');
|
|
760
|
+
this.displacedTargets.set(target, record);
|
|
761
|
+
}
|
|
674
762
|
this.requestPoiRender(target);
|
|
675
|
-
if (
|
|
676
|
-
|
|
763
|
+
if (sourceGroupLayer && sourceGroupLayer !== record.homeLayer) {
|
|
764
|
+
sourceGroupLayer.requestGroupingUpdate();
|
|
677
765
|
}
|
|
678
|
-
record.
|
|
766
|
+
record.homeLayer.requestGroupingUpdate();
|
|
679
767
|
this.schedulePlacement();
|
|
680
768
|
} finally {
|
|
681
769
|
target.removeAttribute(ObcPoiLayerStack.STACK_RETURNING_ATTR);
|
|
770
|
+
target.removeAttribute('data-stack-selected');
|
|
682
771
|
}
|
|
683
772
|
}
|
|
684
773
|
|
|
685
774
|
private setSelectedTargetInteractivity(target: Poi, selected: boolean) {
|
|
686
775
|
const isInAutoGroup =
|
|
687
776
|
target.hasAttribute('data-grouped') ||
|
|
688
|
-
|
|
777
|
+
this.getContainingGroup(target) !== null;
|
|
689
778
|
|
|
690
779
|
target.selected = selected;
|
|
691
780
|
if (selected) {
|
|
@@ -702,63 +791,53 @@ export class ObcPoiLayerStack extends LitElement {
|
|
|
702
791
|
}
|
|
703
792
|
}
|
|
704
793
|
|
|
705
|
-
private trackSelectionTarget(
|
|
706
|
-
target: Poi,
|
|
707
|
-
originLayer: ObcPoiLayer,
|
|
708
|
-
keepInSelectedLayer = true
|
|
709
|
-
) {
|
|
710
|
-
this.selectionMap.set(target, {
|
|
711
|
-
originLayer,
|
|
712
|
-
previousAnimatePosition: target.animatePosition ?? false,
|
|
713
|
-
keepInSelectedLayer,
|
|
714
|
-
});
|
|
715
|
-
target.removeAttribute('data-stack-selected');
|
|
716
|
-
}
|
|
717
|
-
|
|
718
794
|
private activateTrackedTarget(
|
|
719
795
|
target: Poi,
|
|
720
|
-
record:
|
|
721
|
-
originLayer: ObcPoiLayer;
|
|
722
|
-
previousAnimatePosition: boolean;
|
|
723
|
-
keepInSelectedLayer: boolean;
|
|
724
|
-
},
|
|
796
|
+
record: SelectionRecord,
|
|
725
797
|
selectedLayer: ObcPoiLayer,
|
|
726
798
|
animateProjection = true
|
|
727
799
|
) {
|
|
728
|
-
if (record.
|
|
729
|
-
target
|
|
730
|
-
|
|
731
|
-
|
|
732
|
-
|
|
733
|
-
|
|
734
|
-
record,
|
|
735
|
-
selectedLayer,
|
|
736
|
-
animateProjection
|
|
737
|
-
);
|
|
738
|
-
} else {
|
|
739
|
-
const targetProjectionOffset = this.getTargetProjectionOffset(
|
|
740
|
-
record.originLayer,
|
|
741
|
-
selectedLayer
|
|
742
|
-
);
|
|
743
|
-
if (Math.abs(targetProjectionOffset) < 0.5) {
|
|
744
|
-
target.style.removeProperty('--obc-poi-target-projection-y');
|
|
745
|
-
} else {
|
|
746
|
-
target.style.setProperty(
|
|
747
|
-
'--obc-poi-target-projection-y',
|
|
748
|
-
`${targetProjectionOffset}px`
|
|
749
|
-
);
|
|
750
|
-
}
|
|
751
|
-
target.style.removeProperty('--obc-poi-button-projection-y');
|
|
752
|
-
this.requestPoiRender(target);
|
|
753
|
-
this.refreshTargetProjectionLayout(target);
|
|
754
|
-
}
|
|
755
|
-
} else {
|
|
800
|
+
if (record.homeLayer !== selectedLayer) {
|
|
801
|
+
// Cross-layer selection: the target stays a DOM child of its home
|
|
802
|
+
// layer; `data-stack-selected` excludes it from that layer's grouping
|
|
803
|
+
// and its button is projected into the selected layer. The pointer
|
|
804
|
+
// stays anchored at the origin position.
|
|
805
|
+
const sourceGroupLayer = this.detachTargetFromCurrentGroup(target);
|
|
756
806
|
clearTargetGroupingAttributes(target);
|
|
807
|
+
const firstActivation = !target.hasAttribute('data-stack-selected');
|
|
757
808
|
target.setAttribute('data-stack-selected', 'true');
|
|
758
|
-
|
|
809
|
+
const buttonOffset = this.layerBottomDelta(
|
|
810
|
+
record.homeLayer,
|
|
811
|
+
selectedLayer
|
|
812
|
+
);
|
|
813
|
+
const targetOffset = this.layerBottomDelta(
|
|
814
|
+
record.homeLayer,
|
|
815
|
+
record.originLayer
|
|
816
|
+
);
|
|
817
|
+
void this.applyTargetProjection(
|
|
759
818
|
target,
|
|
760
|
-
|
|
819
|
+
buttonOffset,
|
|
820
|
+
targetOffset,
|
|
821
|
+
animateProjection
|
|
822
|
+
);
|
|
823
|
+
if (firstActivation) {
|
|
824
|
+
if (sourceGroupLayer && sourceGroupLayer !== record.homeLayer) {
|
|
825
|
+
sourceGroupLayer.requestGroupingUpdate();
|
|
826
|
+
}
|
|
827
|
+
record.homeLayer.requestGroupingUpdate();
|
|
828
|
+
}
|
|
829
|
+
} else {
|
|
830
|
+
// Target authored inside the selected layer: it remains a normal
|
|
831
|
+
// resident there (grouped and measured as before); only its pointer
|
|
832
|
+
// projects down to the inferred origin layer.
|
|
833
|
+
const targetOffset = this.layerBottomDelta(
|
|
761
834
|
selectedLayer,
|
|
835
|
+
record.originLayer
|
|
836
|
+
);
|
|
837
|
+
void this.applyTargetProjection(
|
|
838
|
+
target,
|
|
839
|
+
0,
|
|
840
|
+
targetOffset,
|
|
762
841
|
animateProjection
|
|
763
842
|
);
|
|
764
843
|
}
|
|
@@ -781,6 +860,9 @@ export class ObcPoiLayerStack extends LitElement {
|
|
|
781
860
|
if (this.selectionMap.has(target)) {
|
|
782
861
|
continue;
|
|
783
862
|
}
|
|
863
|
+
if (this.displacedTargets.has(target)) {
|
|
864
|
+
continue;
|
|
865
|
+
}
|
|
784
866
|
if (
|
|
785
867
|
this.selectionMode === PoiLayerSelectionMode.Single &&
|
|
786
868
|
this.selectionMap.size > 0
|
|
@@ -789,31 +871,21 @@ export class ObcPoiLayerStack extends LitElement {
|
|
|
789
871
|
}
|
|
790
872
|
|
|
791
873
|
const originLayer = this.inferBootstrapOriginLayer(target, selectedLayer);
|
|
792
|
-
this.selectionMap.set(target, {
|
|
793
|
-
originLayer,
|
|
794
|
-
previousAnimatePosition: target.animatePosition ?? false,
|
|
795
|
-
keepInSelectedLayer: true,
|
|
796
|
-
});
|
|
797
|
-
target.removeAttribute('data-stack-selected');
|
|
874
|
+
this.selectionMap.set(target, {homeLayer: selectedLayer, originLayer});
|
|
798
875
|
seededTargets.add(target);
|
|
876
|
+
this.dispatchSelectionChange(target, null);
|
|
799
877
|
}
|
|
800
878
|
return seededTargets;
|
|
801
879
|
}
|
|
802
880
|
|
|
803
|
-
private resetSelectionForTarget(
|
|
804
|
-
target: Poi,
|
|
805
|
-
record?: {
|
|
806
|
-
originLayer: ObcPoiLayer;
|
|
807
|
-
previousAnimatePosition: boolean;
|
|
808
|
-
keepInSelectedLayer: boolean;
|
|
809
|
-
}
|
|
810
|
-
) {
|
|
811
|
-
target.removeAttribute('data-stack-selected');
|
|
881
|
+
private resetSelectionForTarget(target: Poi, record?: SelectionRecord) {
|
|
812
882
|
if (record) {
|
|
813
883
|
this.selectionMap.delete(target);
|
|
814
884
|
void this.animateTargetReturnToOrigin(target, record);
|
|
885
|
+
this.dispatchSelectionChange(null, target);
|
|
815
886
|
return;
|
|
816
887
|
}
|
|
888
|
+
target.removeAttribute('data-stack-selected');
|
|
817
889
|
this.setSelectedTargetInteractivity(target, false);
|
|
818
890
|
clearTargetGroupingAttributes(target);
|
|
819
891
|
this.clearTargetSelectedId(target);
|
|
@@ -895,6 +967,7 @@ export class ObcPoiLayerStack extends LitElement {
|
|
|
895
967
|
this.selectionMap.forEach((record, target) => {
|
|
896
968
|
this.resetSelectionForTarget(target, record);
|
|
897
969
|
});
|
|
970
|
+
this.refreshDisplacedTargets();
|
|
898
971
|
return;
|
|
899
972
|
}
|
|
900
973
|
|
|
@@ -908,12 +981,6 @@ export class ObcPoiLayerStack extends LitElement {
|
|
|
908
981
|
if (target.hasAttribute(ObcPoiLayerStack.STACK_RETURNING_ATTR)) {
|
|
909
982
|
return;
|
|
910
983
|
}
|
|
911
|
-
if (
|
|
912
|
-
!record.keepInSelectedLayer &&
|
|
913
|
-
!target.hasAttribute('data-stack-selected')
|
|
914
|
-
) {
|
|
915
|
-
target.setAttribute('data-stack-selected', 'true');
|
|
916
|
-
}
|
|
917
984
|
this.activateTrackedTarget(
|
|
918
985
|
target,
|
|
919
986
|
record,
|
|
@@ -921,6 +988,34 @@ export class ObcPoiLayerStack extends LitElement {
|
|
|
921
988
|
!seededTargets.has(target)
|
|
922
989
|
);
|
|
923
990
|
});
|
|
991
|
+
this.refreshDisplacedTargets();
|
|
992
|
+
}
|
|
993
|
+
|
|
994
|
+
/**
|
|
995
|
+
* Keep deselected targets that render outside their DOM layer (targets
|
|
996
|
+
* authored in the selected layer whose logical origin is another layer)
|
|
997
|
+
* projected at up-to-date offsets across layer resizes.
|
|
998
|
+
*/
|
|
999
|
+
private refreshDisplacedTargets() {
|
|
1000
|
+
this.displacedTargets.forEach((record, target) => {
|
|
1001
|
+
if (!target.isConnected) {
|
|
1002
|
+
this.displacedTargets.delete(target);
|
|
1003
|
+
return;
|
|
1004
|
+
}
|
|
1005
|
+
if (target.hasAttribute(ObcPoiLayerStack.STACK_RETURNING_ATTR)) {
|
|
1006
|
+
return;
|
|
1007
|
+
}
|
|
1008
|
+
const originOffset = this.layerBottomDelta(
|
|
1009
|
+
record.homeLayer,
|
|
1010
|
+
record.originLayer
|
|
1011
|
+
);
|
|
1012
|
+
void this.applyTargetProjection(
|
|
1013
|
+
target,
|
|
1014
|
+
originOffset,
|
|
1015
|
+
originOffset,
|
|
1016
|
+
false
|
|
1017
|
+
);
|
|
1018
|
+
});
|
|
924
1019
|
}
|
|
925
1020
|
|
|
926
1021
|
override render() {
|